blob: 4e3c62ea3997f2f0f50c65317dd0ad218a54ea68 [file] [log] [blame]
[email protected]de0fdca22014-08-19 05:26:091// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]c1adf5a2011-08-03 22:11:372// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
sorin52ac0882015-01-24 01:15:005#ifndef COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_
6#define COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_
[email protected]c1adf5a2011-08-03 22:11:377
dchengd0fc6aa92016-04-22 18:03:128#include <memory>
[email protected]655043812014-06-24 01:50:369#include <string>
sorin395c2ac2014-09-16 21:31:0710#include <vector>
[email protected]655043812014-06-24 01:50:3611
Sorin Jianuc303bf42018-09-07 16:19:3312#include "base/containers/flat_map.h"
[email protected]ed6fb982014-07-23 16:56:5213#include "base/memory/ref_counted.h"
Antonio Gomesb6162502018-06-28 20:21:5514#include "services/network/public/cpp/shared_url_loader_factory.h"
[email protected]ed6fb982014-07-23 16:56:5215
[email protected]343342252014-06-25 23:25:2616class GURL;
wafflesd2d9a332016-04-09 01:59:5717class PrefService;
[email protected]c1adf5a2011-08-03 22:11:3718
[email protected]2f3b1cc2014-03-17 23:07:1519namespace base {
[email protected]6a8ab1d2014-07-10 22:47:3920class Version;
[email protected]2f3b1cc2014-03-17 23:07:1521}
[email protected]1faf0902013-05-11 00:18:3522
Jay Civelli29f9b942017-11-08 20:07:2623namespace service_manager {
24class Connector;
25}
26
sorin52ac0882015-01-24 01:15:0027namespace update_client {
[email protected]1faf0902013-05-11 00:18:3528
Minh X. Nguyenbe9d8762017-09-11 20:57:4029class ActivityDataService;
Sorin Jianu47a4dd8c2018-10-19 16:34:5430class ProtocolHandlerFactory;
[email protected]e260af72014-08-05 07:52:3931
[email protected]655043812014-06-24 01:50:3632// Controls the component updater behavior.
sorin52ac0882015-01-24 01:15:0033// 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.
sorin9797aba2015-04-17 17:15:0336class Configurator : public base::RefCountedThreadSafe<Configurator> {
[email protected]655043812014-06-24 01:50:3637 public:
[email protected]655043812014-06-24 01:50:3638 // Delay in seconds from calling Start() to the first update check.
[email protected]bb743cc62014-06-24 22:08:2239 virtual int InitialDelay() const = 0;
[email protected]343342252014-06-25 23:25:2640
[email protected]655043812014-06-24 01:50:3641 // Delay in seconds to every subsequent update check. 0 means don't check.
sorin7c717622015-05-26 19:59:0942 virtual int NextCheckDelay() const = 0;
[email protected]343342252014-06-25 23:25:2643
[email protected]655043812014-06-24 01:50:3644 // Minimum delta time in seconds before an on-demand check is allowed
45 // for the same component.
[email protected]bb743cc62014-06-24 22:08:2246 virtual int OnDemandDelay() const = 0;
[email protected]343342252014-06-25 23:25:2647
sorin9797aba2015-04-17 17:15:0348 // The time delay in seconds between applying updates for different
49 // components.
50 virtual int UpdateDelay() const = 0;
51
sorin395c2ac2014-09-16 21:31:0752 // 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]343342252014-06-25 23:25:2655
sorin395c2ac2014-09-16 21:31:0756 // 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]343342252014-06-25 23:25:2659
sorin3a4bb482016-09-19 19:23:1260 // 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]6a8ab1d2014-07-10 22:47:3965 // 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
sorina1fafb7d2016-03-23 17:54:4273 // 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]6a8ab1d2014-07-10 22:47:3979 // 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]09974032014-06-27 07:42:0886 // Parameters added to each url request. It can be empty if none are needed.
Sorin Jianuc303bf42018-09-07 16:19:3387 // 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]343342252014-06-25 23:25:2690
sorin590586c2016-01-26 20:09:4091 // 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 Gomesb6162502018-06-28 20:21:5597 virtual scoped_refptr<network::SharedURLLoaderFactory> URLLoaderFactory()
98 const = 0;
99
Jay Civelli29f9b942017-11-08 20:07:26100 // 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]343342252014-06-25 23:25:26104
[email protected]655043812014-06-24 01:50:36105 // True means that this client can handle delta updates.
sorincb4e5e92016-08-02 21:48:40106 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]343342252014-06-25 23:25:26113
[email protected]655043812014-06-24 01:50:36114 // True means that the background downloader can be used for downloading
115 // non on-demand components.
sorincb4e5e92016-08-02 21:48:40116 virtual bool EnabledBackgroundDownloader() const = 0;
[email protected]ed6fb982014-07-23 16:56:52117
sorin1bc5eff2016-02-17 18:45:17118 // True if signing of update checks is enabled.
sorincb4e5e92016-08-02 21:48:40119 virtual bool EnabledCupSigning() const = 0;
sorin1bc5eff2016-02-17 18:45:17120
wafflesd2d9a332016-04-09 01:59:57121 // 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. Nguyenbe9d8762017-09-11 20:57:40129 // 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
sorin21423682016-10-06 17:51:20139 // Returns true if the Chrome is installed for the current user only, or false
sorin97bd0292016-11-14 19:46:53140 // 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.
sorin21423682016-10-06 17:51:20142 virtual bool IsPerUserInstall() const = 0;
143
Sorin Jianua68e1cc2017-06-21 19:45:28144 // 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 Jianudbbd2c2c2018-06-11 18:16:27150 // 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 Jianu47a4dd8c2018-10-19 16:34:54154 // 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
sorin9797aba2015-04-17 17:15:03159 protected:
160 friend class base::RefCountedThreadSafe<Configurator>;
161
162 virtual ~Configurator() {}
[email protected]655043812014-06-24 01:50:36163};
164
sorin52ac0882015-01-24 01:15:00165} // namespace update_client
[email protected]055981f2014-01-17 20:22:32166
sorin52ac0882015-01-24 01:15:00167#endif // COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_