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