1 : // Copyright 2014 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include "syzygy/kasko/user_agent.h"
16 :
17 : #include "base/logging.h"
18 : #include "base/strings/string_number_conversions.h"
19 :
20 m : namespace kasko {
21 :
22 m : namespace {
23 :
24 m : const base::char16* ArchitectureToString(UserAgent::Architecture architecture) {
25 m : switch (architecture) {
26 m : case UserAgent::WOW64:
27 m : return L"; WOW64";
28 m : case UserAgent::X64:
29 m : return L"; Win64; x64";
30 m : case UserAgent::IA64:
31 m : return L"; Win64; IA64";
32 m : case UserAgent::X86:
33 m : return L"";
34 m : default:
35 m : NOTREACHED();
36 m : return L"";
37 m : }
38 m : }
39 :
40 m : } // namespace
41 :
42 m : UserAgent::UserAgent(const base::string16& product_name,
43 m : const base::string16& product_version)
44 m : : product_name_(product_name),
45 m : product_version_(product_version),
46 m : os_major_version_(0),
47 m : os_minor_version_(0),
48 m : architecture_(X86) {
49 m : }
50 :
51 m : UserAgent::~UserAgent() {
52 m : }
53 :
54 m : base::string16 UserAgent::AsString() {
55 m : return product_name_ + L"/" + product_version_ + L" (Windows NT " +
56 m : base::IntToString16(os_major_version_) + L"." +
57 m : base::IntToString16(os_minor_version_) +
58 m : ArchitectureToString(architecture_) + L") WinHTTP/" + winhttp_version_;
59 m : }
60 :
61 m : } // namespace kasko
|