[email protected] | de0fdca2 | 2014-08-19 05:26:09 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | c1adf5a | 2011-08-03 22:11:37 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 5 | #ifndef COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_ |
| 6 | #define COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_ |
[email protected] | c1adf5a | 2011-08-03 22:11:37 | [diff] [blame] | 7 | |
dcheng | d0fc6aa9 | 2016-04-22 18:03:12 | [diff] [blame] | 8 | #include <memory> |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 9 | #include <string> |
sorin | 395c2ac | 2014-09-16 21:31:07 | [diff] [blame] | 10 | #include <vector> |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 11 | |
Sorin Jianu | c303bf4 | 2018-09-07 16:19:33 | [diff] [blame] | 12 | #include "base/containers/flat_map.h" |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
Antonio Gomes | b616250 | 2018-06-28 20:21:55 | [diff] [blame] | 14 | #include "services/network/public/cpp/shared_url_loader_factory.h" |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 15 | |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 16 | class GURL; |
waffles | d2d9a33 | 2016-04-09 01:59:57 | [diff] [blame] | 17 | class PrefService; |
[email protected] | c1adf5a | 2011-08-03 22:11:37 | [diff] [blame] | 18 | |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 19 | namespace base { |
[email protected] | 6a8ab1d | 2014-07-10 22:47:39 | [diff] [blame] | 20 | class Version; |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 21 | } |
[email protected] | 1faf090 | 2013-05-11 00:18:35 | [diff] [blame] | 22 | |
Jay Civelli | 29f9b94 | 2017-11-08 20:07:26 | [diff] [blame] | 23 | namespace service_manager { |
| 24 | class Connector; |
| 25 | } |
| 26 | |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 27 | namespace update_client { |
[email protected] | 1faf090 | 2013-05-11 00:18:35 | [diff] [blame] | 28 | |
Minh X. Nguyen | be9d876 | 2017-09-11 20:57:40 | [diff] [blame] | 29 | class ActivityDataService; |
Sorin Jianu | 47a4dd8c | 2018-10-19 16:34:54 | [diff] [blame] | 30 | class ProtocolHandlerFactory; |
[email protected] | e260af7 | 2014-08-05 07:52:39 | [diff] [blame] | 31 | |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 32 | // Controls the component updater behavior. |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 33 | // TODO(sorin): this class will be split soon in two. One class controls |
| 34 | // the behavior of the update client, and the other class controls the |
| 35 | // behavior of the component updater. |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 36 | class Configurator : public base::RefCountedThreadSafe<Configurator> { |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 37 | public: |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 38 | // Delay in seconds from calling Start() to the first update check. |
[email protected] | bb743cc6 | 2014-06-24 22:08:22 | [diff] [blame] | 39 | virtual int InitialDelay() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 40 | |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 41 | // Delay in seconds to every subsequent update check. 0 means don't check. |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame] | 42 | virtual int NextCheckDelay() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 43 | |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 44 | // Minimum delta time in seconds before an on-demand check is allowed |
| 45 | // for the same component. |
[email protected] | bb743cc6 | 2014-06-24 22:08:22 | [diff] [blame] | 46 | virtual int OnDemandDelay() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 47 | |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 48 | // The time delay in seconds between applying updates for different |
| 49 | // components. |
| 50 | virtual int UpdateDelay() const = 0; |
| 51 | |
sorin | 395c2ac | 2014-09-16 21:31:07 | [diff] [blame] | 52 | // The URLs for the update checks. The URLs are tried in order, the first one |
| 53 | // that succeeds wins. |
| 54 | virtual std::vector<GURL> UpdateUrl() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 55 | |
sorin | 395c2ac | 2014-09-16 21:31:07 | [diff] [blame] | 56 | // The URLs for pings. Returns an empty vector if and only if pings are |
| 57 | // disabled. Similarly, these URLs have a fall back behavior too. |
| 58 | virtual std::vector<GURL> PingUrl() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 59 | |
sorin | 3a4bb48 | 2016-09-19 19:23:12 | [diff] [blame] | 60 | // The ProdId is used as a prefix in some of the version strings which appear |
| 61 | // in the protocol requests. Possible values include "chrome", "chromecrx", |
| 62 | // "chromiumcrx", and "unknown". |
| 63 | virtual std::string GetProdId() const = 0; |
| 64 | |
[email protected] | 6a8ab1d | 2014-07-10 22:47:39 | [diff] [blame] | 65 | // Version of the application. Used to compare the component manifests. |
| 66 | virtual base::Version GetBrowserVersion() const = 0; |
| 67 | |
| 68 | // Returns the value we use for the "updaterchannel=" and "prodchannel=" |
| 69 | // parameters. Possible return values include: "canary", "dev", "beta", and |
| 70 | // "stable". |
| 71 | virtual std::string GetChannel() const = 0; |
| 72 | |
sorin | a1fafb7d | 2016-03-23 17:54:42 | [diff] [blame] | 73 | // Returns the brand code or distribution tag that has been assigned to |
| 74 | // a partner. A brand code is a 4-character string used to identify |
| 75 | // installations that took place as a result of partner deals or website |
| 76 | // promotions. |
| 77 | virtual std::string GetBrand() const = 0; |
| 78 | |
[email protected] | 6a8ab1d | 2014-07-10 22:47:39 | [diff] [blame] | 79 | // Returns the language for the present locale. Possible return values are |
| 80 | // standard tags for languages, such as "en", "en-US", "de", "fr", "af", etc. |
| 81 | virtual std::string GetLang() const = 0; |
| 82 | |
| 83 | // Returns the OS's long name like "Windows", "Mac OS X", etc. |
| 84 | virtual std::string GetOSLongName() const = 0; |
| 85 | |
[email protected] | 0997403 | 2014-06-27 07:42:08 | [diff] [blame] | 86 | // Parameters added to each url request. It can be empty if none are needed. |
Sorin Jianu | c303bf4 | 2018-09-07 16:19:33 | [diff] [blame] | 87 | // Returns a map of name-value pairs that match ^[-_a-zA-Z0-9]$ regex. |
| 88 | virtual base::flat_map<std::string, std::string> ExtraRequestParams() |
| 89 | const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 90 | |
sorin | 590586c | 2016-01-26 20:09:40 | [diff] [blame] | 91 | // Provides a hint for the server to control the order in which multiple |
| 92 | // download urls are returned. The hint may or may not be honored in the |
| 93 | // response returned by the server. |
| 94 | // Returns an empty string if no policy is in effect. |
| 95 | virtual std::string GetDownloadPreference() const = 0; |
| 96 | |
Antonio Gomes | b616250 | 2018-06-28 20:21:55 | [diff] [blame] | 97 | virtual scoped_refptr<network::SharedURLLoaderFactory> URLLoaderFactory() |
| 98 | const = 0; |
| 99 | |
Jay Civelli | 29f9b94 | 2017-11-08 20:07:26 | [diff] [blame] | 100 | // Returns a new connector to the service manager. That connector is not bound |
| 101 | // to any thread yet. |
| 102 | virtual std::unique_ptr<service_manager::Connector> |
| 103 | CreateServiceManagerConnector() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 104 | |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 105 | // True means that this client can handle delta updates. |
sorin | cb4e5e9 | 2016-08-02 21:48:40 | [diff] [blame] | 106 | virtual bool EnabledDeltas() const = 0; |
| 107 | |
| 108 | // True if component updates are enabled. Updates for all components are |
| 109 | // enabled by default. This method allows enabling or disabling |
| 110 | // updates for certain components such as the plugins. Updates for some |
| 111 | // components are always enabled and can't be disabled programatically. |
| 112 | virtual bool EnabledComponentUpdates() const = 0; |
[email protected] | 34334225 | 2014-06-25 23:25:26 | [diff] [blame] | 113 | |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 114 | // True means that the background downloader can be used for downloading |
| 115 | // non on-demand components. |
sorin | cb4e5e9 | 2016-08-02 21:48:40 | [diff] [blame] | 116 | virtual bool EnabledBackgroundDownloader() const = 0; |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 117 | |
sorin | 1bc5eff | 2016-02-17 18:45:17 | [diff] [blame] | 118 | // True if signing of update checks is enabled. |
sorin | cb4e5e9 | 2016-08-02 21:48:40 | [diff] [blame] | 119 | virtual bool EnabledCupSigning() const = 0; |
sorin | 1bc5eff | 2016-02-17 18:45:17 | [diff] [blame] | 120 | |
waffles | d2d9a33 | 2016-04-09 01:59:57 | [diff] [blame] | 121 | // Returns a PrefService that the update_client can use to store persistent |
| 122 | // update information. The PrefService must outlive the entire update_client, |
| 123 | // and be safe to access from the thread the update_client is constructed |
| 124 | // on. |
| 125 | // Returning null is safe and will disable any functionality that requires |
| 126 | // persistent storage. |
| 127 | virtual PrefService* GetPrefService() const = 0; |
| 128 | |
Minh X. Nguyen | be9d876 | 2017-09-11 20:57:40 | [diff] [blame] | 129 | // Returns an ActivityDataService that the update_client can use to access |
| 130 | // to update information (namely active bit, last active/rollcall days) |
| 131 | // normally stored in the user extension profile. |
| 132 | // Similar to PrefService, ActivityDataService must outlive the entire |
| 133 | // update_client, and be safe to access from the thread the update_client |
| 134 | // is constructed on. |
| 135 | // Returning null is safe and will disable any functionality that requires |
| 136 | // accessing to the information provided by ActivityDataService. |
| 137 | virtual ActivityDataService* GetActivityDataService() const = 0; |
| 138 | |
sorin | 2142368 | 2016-10-06 17:51:20 | [diff] [blame] | 139 | // Returns true if the Chrome is installed for the current user only, or false |
sorin | 97bd029 | 2016-11-14 19:46:53 | [diff] [blame] | 140 | // if Chrome is installed for all users on the machine. This function must be |
| 141 | // called only from a blocking pool thread, as it may access the file system. |
sorin | 2142368 | 2016-10-06 17:51:20 | [diff] [blame] | 142 | virtual bool IsPerUserInstall() const = 0; |
| 143 | |
Sorin Jianu | a68e1cc | 2017-06-21 19:45:28 | [diff] [blame] | 144 | // Returns the key hash corresponding to a CRX trusted by ActionRun. The |
| 145 | // CRX payloads are signed with this key, and their integrity is verified |
| 146 | // during the unpacking by the action runner. This is a dependency injection |
| 147 | // feature to support testing. |
| 148 | virtual std::vector<uint8_t> GetRunActionKeyHash() const = 0; |
| 149 | |
Sorin Jianu | dbbd2c2c | 2018-06-11 18:16:27 | [diff] [blame] | 150 | // Returns the app GUID with which Chrome is registered with Google Update, or |
| 151 | // an empty string if this brand does not integrate with Google Update. |
| 152 | virtual std::string GetAppGuid() const = 0; |
| 153 | |
Sorin Jianu | 47a4dd8c | 2018-10-19 16:34:54 | [diff] [blame] | 154 | // Returns the class factory to create protocol parser and protocol |
| 155 | // serializer object instances. |
| 156 | virtual std::unique_ptr<ProtocolHandlerFactory> GetProtocolHandlerFactory() |
| 157 | const = 0; |
| 158 | |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 159 | protected: |
| 160 | friend class base::RefCountedThreadSafe<Configurator>; |
| 161 | |
| 162 | virtual ~Configurator() {} |
[email protected] | 65504381 | 2014-06-24 01:50:36 | [diff] [blame] | 163 | }; |
| 164 | |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 165 | } // namespace update_client |
[email protected] | 055981f | 2014-01-17 20:22:32 | [diff] [blame] | 166 | |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 167 | #endif // COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_ |