1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_
6 #define COMPONENTS_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_
12 #include "base/containers/flat_map.h"
13 #include "base/time/time.h"
14 #include "components/update_client/configurator.h"
15 #include "third_party/abseil-cpp/absl/types/optional.h"
22 namespace update_client {
23 class CommandLineConfigPolicy;
24 class ProtocolHandlerFactory;
25 } // namespace update_client
27 namespace component_updater {
29 // Helper class for the implementations of update_client::Configurator.
30 // Can be used both on iOS and other platforms.
31 class ConfiguratorImpl {
33 ConfiguratorImpl(const update_client::CommandLineConfigPolicy& config_policy,
34 bool require_encryption);
36 ConfiguratorImpl(const ConfiguratorImpl&) = delete;
37 ConfiguratorImpl& operator=(const ConfiguratorImpl&) = delete;
41 // Delay from calling Start() to the first update check.
42 base::TimeDelta InitialDelay() const;
44 // Delay to every subsequent update check. 0 means don't check.
45 base::TimeDelta NextCheckDelay() const;
47 // Minimum delta time before an on-demand check is allowed for the same
49 base::TimeDelta OnDemandDelay() const;
51 // The time delay between applying updates for different components.
52 base::TimeDelta UpdateDelay() const;
54 // The URLs for the update checks. The URLs are tried in order, the first one
55 // that succeeds wins.
56 std::vector<GURL> UpdateUrl() const;
58 // The URLs for pings. Returns an empty vector if and only if pings are
59 // disabled. Similarly, these URLs have a fall back behavior too.
60 std::vector<GURL> PingUrl() const;
62 // Version of the application. Used to compare the component manifests.
63 const base::Version& GetBrowserVersion() const;
65 // Returns the OS's long name like "Windows", "Mac OS X", etc.
66 std::string GetOSLongName() const;
68 // Parameters added to each url request. It can be empty if none are needed.
69 // Returns a map of name-value pairs that match ^[-_a-zA-Z0-9]$ regex.
70 base::flat_map<std::string, std::string> ExtraRequestParams() const;
72 // Provides a hint for the server to control the order in which multiple
73 // download urls are returned.
74 std::string GetDownloadPreference() const;
76 // True means that this client can handle delta updates.
77 bool EnabledDeltas() const;
79 // True is the component updates are enabled.
80 bool EnabledComponentUpdates() const;
82 // True means that the background downloader can be used for downloading
83 // non on-demand components.
84 bool EnabledBackgroundDownloader() const;
86 // True if signing of update checks is enabled.
87 bool EnabledCupSigning() const;
89 // Returns the app GUID with which Chrome is registered with Google Update, or
90 // an empty string if this brand does not integrate with Google Update.
91 std::string GetAppGuid() const;
93 // Returns the class factory to create protocol parser and protocol
94 // serializer object instances.
95 std::unique_ptr<update_client::ProtocolHandlerFactory>
96 GetProtocolHandlerFactory() const;
98 absl::optional<bool> IsMachineExternallyManaged() const;
100 update_client::UpdaterStateProvider GetUpdaterStateProvider() const;
103 base::flat_map<std::string, std::string> extra_info_;
104 const bool background_downloads_enabled_;
105 const bool deltas_enabled_;
106 const bool fast_update_;
107 const bool pings_enabled_;
108 const bool require_encryption_;
109 const GURL url_source_override_;
110 const base::TimeDelta initial_delay_;
113 } // namespace component_updater
115 #endif // COMPONENTS_COMPONENT_UPDATER_CONFIGURATOR_IMPL_H_