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 : namespace kasko {
21 :
22 : namespace {
23 :
24 E : const base::char16* ArchitectureToString(UserAgent::Architecture architecture) {
25 E : switch (architecture) {
26 : case UserAgent::WOW64:
27 E : return L"; WOW64";
28 : case UserAgent::X64:
29 i : return L"; Win64; x64";
30 : case UserAgent::IA64:
31 i : return L"; Win64; IA64";
32 : case UserAgent::X86:
33 i : return L"";
34 : default:
35 i : NOTREACHED();
36 i : return L"";
37 : }
38 E : }
39 :
40 : } // namespace
41 :
42 : UserAgent::UserAgent(const base::string16& product_name,
43 : const base::string16& product_version)
44 : : product_name_(product_name),
45 : product_version_(product_version),
46 : os_major_version_(0),
47 : os_minor_version_(0),
48 E : architecture_(X86) {
49 E : }
50 :
51 E : UserAgent::~UserAgent() {
52 E : }
53 :
54 E : base::string16 UserAgent::AsString() {
55 : return product_name_ + L"/" + product_version_ + L" (Windows NT " +
56 : base::IntToString16(os_major_version_) + L"." +
57 : base::IntToString16(os_minor_version_) +
58 E : ArchitectureToString(architecture_) + L") WinHTTP/" + winhttp_version_;
59 E : }
60 :
61 : } // namespace kasko
|