blob: fd29c79c801619d67076f1b9b4170a7ba3ba935a [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
[email protected]ed6fb982014-07-23 16:56:5212#include "base/memory/ref_counted.h"
13
[email protected]343342252014-06-25 23:25:2614class GURL;
wafflesd2d9a332016-04-09 01:59:5715class PrefService;
[email protected]c1adf5a2011-08-03 22:11:3716
[email protected]2f3b1cc2014-03-17 23:07:1517namespace base {
[email protected]6a8ab1d2014-07-10 22:47:3918class Version;
[email protected]2f3b1cc2014-03-17 23:07:1519}
[email protected]1faf0902013-05-11 00:18:3520
21namespace net {
[email protected]1faf0902013-05-11 00:18:3522class URLRequestContextGetter;
[email protected]055981f2014-01-17 20:22:3223}
[email protected]1faf0902013-05-11 00:18:3524
Jay Civelli29f9b942017-11-08 20:07:2625namespace service_manager {
26class Connector;
27}
28
sorin52ac0882015-01-24 01:15:0029namespace update_client {
[email protected]1faf0902013-05-11 00:18:3530
Minh X. Nguyenbe9d8762017-09-11 20:57:4031class ActivityDataService;
[email protected]e260af72014-08-05 07:52:3932
[email protected]655043812014-06-24 01:50:3633// Controls the component updater behavior.
sorin52ac0882015-01-24 01:15:0034// 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.
sorin9797aba2015-04-17 17:15:0337class Configurator : public base::RefCountedThreadSafe<Configurator> {
[email protected]655043812014-06-24 01:50:3638 public:
[email protected]655043812014-06-24 01:50:3639 // Delay in seconds from calling Start() to the first update check.
[email protected]bb743cc62014-06-24 22:08:2240 virtual int InitialDelay() const = 0;
[email protected]343342252014-06-25 23:25:2641
[email protected]655043812014-06-24 01:50:3642 // Delay in seconds to every subsequent update check. 0 means don't check.
sorin7c717622015-05-26 19:59:0943 virtual int NextCheckDelay() const = 0;
[email protected]343342252014-06-25 23:25:2644
[email protected]655043812014-06-24 01:50:3645 // Minimum delta time in seconds before an on-demand check is allowed
46 // for the same component.
[email protected]bb743cc62014-06-24 22:08:2247 virtual int OnDemandDelay() const = 0;
[email protected]343342252014-06-25 23:25:2648
sorin9797aba2015-04-17 17:15:0349 // The time delay in seconds between applying updates for different
50 // components.
51 virtual int UpdateDelay() const = 0;
52
sorin395c2ac2014-09-16 21:31:0753 // 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]343342252014-06-25 23:25:2656
sorin395c2ac2014-09-16 21:31:0757 // 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]343342252014-06-25 23:25:2660
sorin3a4bb482016-09-19 19:23:1261 // 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]6a8ab1d2014-07-10 22:47:3966 // 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
sorina1fafb7d2016-03-23 17:54:4274 // 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]6a8ab1d2014-07-10 22:47:3980 // 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]09974032014-06-27 07:42:0887 // 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]bb743cc62014-06-24 22:08:2290 virtual std::string ExtraRequestParams() const = 0;
[email protected]343342252014-06-25 23:25:2691
sorin590586c2016-01-26 20:09:4092 // 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]655043812014-06-24 01:50:3698 // The source of contexts for all the url requests.
[email protected]bb743cc62014-06-24 22:08:2299 virtual net::URLRequestContextGetter* RequestContext() const = 0;
[email protected]343342252014-06-25 23:25:26100
Jay Civelli29f9b942017-11-08 20:07:26101 // 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]343342252014-06-25 23:25:26105
[email protected]655043812014-06-24 01:50:36106 // True means that this client can handle delta updates.
sorincb4e5e92016-08-02 21:48:40107 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]343342252014-06-25 23:25:26114
[email protected]655043812014-06-24 01:50:36115 // True means that the background downloader can be used for downloading
116 // non on-demand components.
sorincb4e5e92016-08-02 21:48:40117 virtual bool EnabledBackgroundDownloader() const = 0;
[email protected]ed6fb982014-07-23 16:56:52118
sorin1bc5eff2016-02-17 18:45:17119 // True if signing of update checks is enabled.
sorincb4e5e92016-08-02 21:48:40120 virtual bool EnabledCupSigning() const = 0;
sorin1bc5eff2016-02-17 18:45:17121
wafflesd2d9a332016-04-09 01:59:57122 // 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. Nguyenbe9d8762017-09-11 20:57:40130 // 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
sorin21423682016-10-06 17:51:20140 // Returns true if the Chrome is installed for the current user only, or false
sorin97bd0292016-11-14 19:46:53141 // 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.
sorin21423682016-10-06 17:51:20143 virtual bool IsPerUserInstall() const = 0;
144
Sorin Jianua68e1cc2017-06-21 19:45:28145 // 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
sorin9797aba2015-04-17 17:15:03151 protected:
152 friend class base::RefCountedThreadSafe<Configurator>;
153
154 virtual ~Configurator() {}
[email protected]655043812014-06-24 01:50:36155};
156
sorin52ac0882015-01-24 01:15:00157} // namespace update_client
[email protected]055981f2014-01-17 20:22:32158
sorin52ac0882015-01-24 01:15:00159#endif // COMPONENTS_UPDATE_CLIENT_CONFIGURATOR_H_