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 : #ifndef SYZYGY_KASKO_USER_AGENT_H_
16 : #define SYZYGY_KASKO_USER_AGENT_H_
17 :
18 : #include <stdint.h>
19 : #include "base/macros.h"
20 : #include "base/strings/string16.h"
21 :
22 : namespace kasko {
23 :
24 : // Collects the various properties that go into the Kasko user-agent string and
25 : // formats them.
26 : class UserAgent {
27 : public:
28 : enum Architecture { X86, WOW64, X64, IA64 };
29 :
30 : // Creates a default-initialized instance. This does not query platform
31 : // attributes. The client must do so.
32 : // @param product_name The product name.
33 : // @param product_version The product version.
34 : UserAgent(const base::string16& product_name,
35 : const base::string16& product_version);
36 : ~UserAgent();
37 :
38 : // @returns A string suitable for use as the value of a User-Agent header, and
39 : // incorporating the various properties of this class.
40 : base::string16 AsString();
41 :
42 : // Sets the OS version.
43 : // @param major_version The OS major version number.
44 : // @param minor_version The OS minor version number.
45 E : void set_os_version(int32_t major_version, int32_t minor_version) {
46 E : os_major_version_ = major_version;
47 E : os_minor_version_ = minor_version;
48 E : }
49 :
50 : // Sets the platform architecture.
51 : // @param architecture The platform architecture.
52 E : void set_architecture(Architecture architecture) {
53 E : architecture_ = architecture;
54 E : }
55 :
56 : // Sets the WinHttp library version.
57 : // @winhttp_version The WinHttp library version.
58 E : void set_winhttp_version(const base::string16& winhttp_version) {
59 E : winhttp_version_ = winhttp_version;
60 E : }
61 :
62 : private:
63 : base::string16 product_name_;
64 : base::string16 product_version_;
65 : int32_t os_major_version_;
66 : int32_t os_minor_version_;
67 : Architecture architecture_;
68 : base::string16 winhttp_version_;
69 :
70 : DISALLOW_COPY_AND_ASSIGN(UserAgent);
71 : };
72 :
73 : } // namespace kasko
74 :
75 : #endif // SYZYGY_KASKO_USER_AGENT_H_
|