| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/component_updater/configurator_impl.h" | 5 #include "components/component_updater/configurator_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/feature_list.h" |
| 12 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/version.h" | 15 #include "base/version.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "components/component_updater/component_updater_switches.h" | 17 #include "components/component_updater/component_updater_switches.h" |
| 17 #include "components/component_updater/component_updater_url_constants.h" | 18 #include "components/component_updater/component_updater_url_constants.h" |
| 18 #include "components/update_client/utils.h" | 19 #include "components/update_client/utils.h" |
| 19 #include "components/version_info/version_info.h" | 20 #include "components/version_info/version_info.h" |
| 20 | 21 |
| 21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 const char kSwitchUrlSource[] = "url-source"; | 48 const char kSwitchUrlSource[] = "url-source"; |
| 48 | 49 |
| 49 // Disables differential updates. | 50 // Disables differential updates. |
| 50 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; | 51 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; |
| 51 | 52 |
| 52 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 53 // Disables background downloads. | 54 // Disables background downloads. |
| 54 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; | 55 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; |
| 55 #endif // defined(OS_WIN) | 56 #endif // defined(OS_WIN) |
| 56 | 57 |
| 58 const base::Feature kAlternateComponentUrls{"AlternateComponentUrls", |
| 59 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 60 |
| 57 // Returns true if and only if |test| is contained in |vec|. | 61 // Returns true if and only if |test| is contained in |vec|. |
| 58 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { | 62 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { |
| 59 if (vec.empty()) | 63 if (vec.empty()) |
| 60 return 0; | 64 return 0; |
| 61 return (std::find(vec.begin(), vec.end(), test) != vec.end()); | 65 return (std::find(vec.begin(), vec.end(), test) != vec.end()); |
| 62 } | 66 } |
| 63 | 67 |
| 64 // If there is an element of |vec| of the form |test|=.*, returns the right- | 68 // If there is an element of |vec| of the form |test|=.*, returns the right- |
| 65 // hand side of that assignment. Otherwise, returns an empty string. | 69 // hand side of that assignment. Otherwise, returns an empty string. |
| 66 // The right-hand side may contain additional '=' characters, allowing for | 70 // The right-hand side may contain additional '=' characters, allowing for |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return fast_update_ ? 10 : (15 * kDelayOneMinute); | 145 return fast_update_ ? 10 : (15 * kDelayOneMinute); |
| 142 } | 146 } |
| 143 | 147 |
| 144 std::vector<GURL> ConfiguratorImpl::UpdateUrl() const { | 148 std::vector<GURL> ConfiguratorImpl::UpdateUrl() const { |
| 145 std::vector<GURL> urls; | 149 std::vector<GURL> urls; |
| 146 if (url_source_override_.is_valid()) { | 150 if (url_source_override_.is_valid()) { |
| 147 urls.push_back(GURL(url_source_override_)); | 151 urls.push_back(GURL(url_source_override_)); |
| 148 return urls; | 152 return urls; |
| 149 } | 153 } |
| 150 | 154 |
| 151 urls.push_back(GURL(kUpdaterDefaultUrl)); | 155 if (base::FeatureList::IsEnabled(kAlternateComponentUrls)) { |
| 152 urls.push_back(GURL(kUpdaterFallbackUrl)); | 156 urls.push_back(GURL(kUpdaterDefaultUrlAlt)); |
| 157 urls.push_back(GURL(kUpdaterFallbackUrlAlt)); |
| 158 } else { |
| 159 urls.push_back(GURL(kUpdaterDefaultUrl)); |
| 160 urls.push_back(GURL(kUpdaterFallbackUrl)); |
| 161 } |
| 162 |
| 153 if (require_encryption_) | 163 if (require_encryption_) |
| 154 update_client::RemoveUnsecureUrls(&urls); | 164 update_client::RemoveUnsecureUrls(&urls); |
| 155 | 165 |
| 156 return urls; | 166 return urls; |
| 157 } | 167 } |
| 158 | 168 |
| 159 std::vector<GURL> ConfiguratorImpl::PingUrl() const { | 169 std::vector<GURL> ConfiguratorImpl::PingUrl() const { |
| 160 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>(); | 170 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>(); |
| 161 } | 171 } |
| 162 | 172 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 190 | 200 |
| 191 bool ConfiguratorImpl::EnabledBackgroundDownloader() const { | 201 bool ConfiguratorImpl::EnabledBackgroundDownloader() const { |
| 192 return background_downloads_enabled_; | 202 return background_downloads_enabled_; |
| 193 } | 203 } |
| 194 | 204 |
| 195 bool ConfiguratorImpl::EnabledCupSigning() const { | 205 bool ConfiguratorImpl::EnabledCupSigning() const { |
| 196 return true; | 206 return true; |
| 197 } | 207 } |
| 198 | 208 |
| 199 } // namespace component_updater | 209 } // namespace component_updater |
| OLD | NEW |