| 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 <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "components/update_client/update_client.h" | 14 #include "components/update_client/update_client.h" |
| 15 #include "components/update_client/updater_state.h" | |
| 16 | 15 |
| 17 class GURL; | 16 class GURL; |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 class FilePath; | 19 class FilePath; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace net { | 22 namespace net { |
| 24 class URLFetcher; | 23 class URLFetcher; |
| 25 class URLFetcherDelegate; | 24 class URLFetcherDelegate; |
| 26 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
| 27 } | 26 } |
| 28 | 27 |
| 29 namespace update_client { | 28 namespace update_client { |
| 30 | 29 |
| 31 class Component; | 30 class Component; |
| 32 struct CrxComponent; | 31 struct CrxComponent; |
| 33 | 32 |
| 34 // Defines a name-value pair that represents an installer attribute. | 33 // Defines a name-value pair that represents an installer attribute. |
| 35 // Installer attributes are component-specific metadata, which may be serialized | 34 // Installer attributes are component-specific metadata, which may be serialized |
| 36 // in an update check request. | 35 // in an update check request. |
| 37 using InstallerAttribute = std::pair<std::string, std::string>; | 36 using InstallerAttribute = std::pair<std::string, std::string>; |
| 38 | 37 |
| 39 // An update protocol request starts with a common preamble which includes | |
| 40 // version and platform information for Chrome and the operating system, | |
| 41 // followed by a request body, which is the actual payload of the request. | |
| 42 // For example: | |
| 43 // | |
| 44 // <?xml version="1.0" encoding="UTF-8"?> | |
| 45 // <request protocol="3.0" version="chrome-32.0.1.0" prodversion="32.0.1.0" | |
| 46 // requestid="{7383396D-B4DD-46E1-9104-AAC6B918E792}" | |
| 47 // updaterchannel="canary" arch="x86" nacl_arch="x86-64" | |
| 48 // ADDITIONAL ATTRIBUTES> | |
| 49 // <hw physmemory="16"/> | |
| 50 // <os platform="win" version="6.1" arch="x86"/> | |
| 51 // ... REQUEST BODY ... | |
| 52 // </request> | |
| 53 | |
| 54 // Builds a protocol request string by creating the outer envelope for | |
| 55 // the request and including the request body specified as a parameter. | |
| 56 // If present, the |download_preference| specifies a group policy that | |
| 57 // affects the list of download URLs returned in the update response. | |
| 58 // If specified, |additional_attributes| are appended as attributes of the | |
| 59 // request element. The additional attributes have to be well-formed for | |
| 60 // insertion in the request element. |updater_state_attributes| is an optional | |
| 61 // parameter specifying that an <updater> element is serialized as part of | |
| 62 // the request. | |
| 63 std::string BuildProtocolRequest( | |
| 64 const std::string& prod_id, | |
| 65 const std::string& browser_version, | |
| 66 const std::string& channel, | |
| 67 const std::string& lang, | |
| 68 const std::string& os_long_name, | |
| 69 const std::string& download_preference, | |
| 70 const std::string& request_body, | |
| 71 const std::string& additional_attributes, | |
| 72 const std::unique_ptr<UpdaterState::Attributes>& updater_state_attributes); | |
| 73 | |
| 74 // Sends a protocol request to the the service endpoint specified by |url|. | 38 // Sends a protocol request to the the service endpoint specified by |url|. |
| 75 // The body of the request is provided by |protocol_request| and it is | 39 // The body of the request is provided by |protocol_request| and it is |
| 76 // expected to contain XML data. The caller owns the returned object. | 40 // expected to contain XML data. The caller owns the returned object. |
| 77 std::unique_ptr<net::URLFetcher> SendProtocolRequest( | 41 std::unique_ptr<net::URLFetcher> SendProtocolRequest( |
| 78 const GURL& url, | 42 const GURL& url, |
| 79 const std::string& protocol_request, | 43 const std::string& protocol_request, |
| 80 net::URLFetcherDelegate* url_fetcher_delegate, | 44 net::URLFetcherDelegate* url_fetcher_delegate, |
| 81 net::URLRequestContextGetter* url_request_context_getter); | 45 net::URLRequestContextGetter* url_request_context_getter); |
| 82 | 46 |
| 83 // Returns true if the url request of |fetcher| was succesful. | 47 // Returns true if the url request of |fetcher| was succesful. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Removes the unsecure urls in the |urls| parameter. | 84 // Removes the unsecure urls in the |urls| parameter. |
| 121 void RemoveUnsecureUrls(std::vector<GURL>* urls); | 85 void RemoveUnsecureUrls(std::vector<GURL>* urls); |
| 122 | 86 |
| 123 // Adapter function for the old definitions of CrxInstaller::Install until the | 87 // Adapter function for the old definitions of CrxInstaller::Install until the |
| 124 // component installer code is migrated to use a REsult instead of bool. | 88 // component installer code is migrated to use a REsult instead of bool. |
| 125 CrxInstaller::Result InstallFunctionWrapper(base::Callback<bool()> callback); | 89 CrxInstaller::Result InstallFunctionWrapper(base::Callback<bool()> callback); |
| 126 | 90 |
| 127 } // namespace update_client | 91 } // namespace update_client |
| 128 | 92 |
| 129 #endif // COMPONENTS_UPDATE_CLIENT_UTILS_H_ | 93 #endif // COMPONENTS_UPDATE_CLIENT_UTILS_H_ |
| OLD | NEW |