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