OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_UPDATE_CLIENT_UTILS_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_UTILS_H_ |
6 #define COMPONENTS_UPDATE_CLIENT_UTILS_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_UTILS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 | 13 |
13 class GURL; | 14 class GURL; |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class FilePath; | 17 class FilePath; |
17 } | 18 } |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 class URLFetcher; | 21 class URLFetcher; |
21 class URLFetcherDelegate; | 22 class URLFetcherDelegate; |
22 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
23 } | 24 } |
24 | 25 |
25 namespace update_client { | 26 namespace update_client { |
26 | 27 |
27 class Configurator; | 28 class Configurator; |
28 struct CrxComponent; | 29 struct CrxComponent; |
29 struct CrxUpdateItem; | 30 struct CrxUpdateItem; |
30 | 31 |
| 32 // Defines a name-value pair that represents an installer attribute. |
| 33 // Installer attributes are component-specific metadata, which may be serialized |
| 34 // in an update check request. |
| 35 using InstallerAttribute = std::pair<std::string, std::string>; |
| 36 |
31 // An update protocol request starts with a common preamble which includes | 37 // An update protocol request starts with a common preamble which includes |
32 // version and platform information for Chrome and the operating system, | 38 // version and platform information for Chrome and the operating system, |
33 // followed by a request body, which is the actual payload of the request. | 39 // followed by a request body, which is the actual payload of the request. |
34 // For example: | 40 // For example: |
35 // | 41 // |
36 // <?xml version="1.0" encoding="UTF-8"?> | 42 // <?xml version="1.0" encoding="UTF-8"?> |
37 // <request protocol="3.0" version="chrome-32.0.1.0" prodversion="32.0.1.0" | 43 // <request protocol="3.0" version="chrome-32.0.1.0" prodversion="32.0.1.0" |
38 // requestid="{7383396D-B4DD-46E1-9104-AAC6B918E792}" | 44 // requestid="{7383396D-B4DD-46E1-9104-AAC6B918E792}" |
39 // updaterchannel="canary" arch="x86" nacl_arch="x86-64" | 45 // updaterchannel="canary" arch="x86" nacl_arch="x86-64" |
40 // ADDITIONAL ATTRIBUTES> | 46 // ADDITIONAL ATTRIBUTES> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 std::string GetCrxComponentID(const CrxComponent& component); | 98 std::string GetCrxComponentID(const CrxComponent& component); |
93 | 99 |
94 // Returns true if the actual SHA-256 hash of the |filepath| matches the | 100 // Returns true if the actual SHA-256 hash of the |filepath| matches the |
95 // |expected_hash|. | 101 // |expected_hash|. |
96 bool VerifyFileHash256(const base::FilePath& filepath, | 102 bool VerifyFileHash256(const base::FilePath& filepath, |
97 const std::string& expected_hash); | 103 const std::string& expected_hash); |
98 | 104 |
99 // Returns true if the |brand| parameter matches ^[a-zA-Z]{4}?$ . | 105 // Returns true if the |brand| parameter matches ^[a-zA-Z]{4}?$ . |
100 bool IsValidBrand(const std::string& brand); | 106 bool IsValidBrand(const std::string& brand); |
101 | 107 |
102 // Returns true if the |ap| parameter matches ^[-+_=a-zA-Z0-9]{0,256}$ . | 108 // Returns true if the name part of the |attr| parameter matches |
103 bool IsValidAp(const std::string& ap); | 109 // ^[-_a-zA-Z0-9]{1,256}$ and the value part of the |attr| parameter |
| 110 // matches ^[-.,;+_=a-zA-Z0-9]{0,256}$ . |
| 111 bool IsValidInstallerAttribute(const InstallerAttribute& attr); |
104 | 112 |
105 // Removes the unsecure urls in the |urls| parameter. | 113 // Removes the unsecure urls in the |urls| parameter. |
106 void RemoveUnsecureUrls(std::vector<GURL>* urls); | 114 void RemoveUnsecureUrls(std::vector<GURL>* urls); |
107 | 115 |
108 } // namespace update_client | 116 } // namespace update_client |
109 | 117 |
110 #endif // COMPONENTS_UPDATE_CLIENT_UTILS_H_ | 118 #endif // COMPONENTS_UPDATE_CLIENT_UTILS_H_ |
OLD | NEW |