Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: components/component_updater/configurator_impl.cc

Issue 1740333002: Allow fallback from https to http for component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "components/component_updater/component_updater_switches.h" 16 #include "components/component_updater/component_updater_switches.h"
17 #include "components/component_updater/component_updater_url_constants.h" 17 #include "components/component_updater/component_updater_url_constants.h"
18 #include "components/update_client/configurator.h" 18 #include "components/update_client/utils.h"
19 #include "components/version_info/version_info.h" 19 #include "components/version_info/version_info.h"
20 20
21 #if defined(OS_WIN) 21 #if defined(OS_WIN)
22 #include "base/win/win_util.h" 22 #include "base/win/win_util.h"
23 #endif // OS_WIN 23 #endif // OS_WIN
24 24
25 namespace component_updater { 25 namespace component_updater {
26 26
27 namespace { 27 namespace {
28 // Default time constants. 28 // Default time constants.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 } 76 }
77 } 77 }
78 return std::string(); 78 return std::string();
79 } 79 }
80 80
81 } // namespace 81 } // namespace
82 82
83 ConfiguratorImpl::ConfiguratorImpl( 83 ConfiguratorImpl::ConfiguratorImpl(
84 const base::CommandLine* cmdline, 84 const base::CommandLine* cmdline,
85 net::URLRequestContextGetter* url_request_getter) 85 net::URLRequestContextGetter* url_request_getter,
86 bool require_encryption)
86 : url_request_getter_(url_request_getter), 87 : url_request_getter_(url_request_getter),
87 fast_update_(false), 88 fast_update_(false),
88 pings_enabled_(false), 89 pings_enabled_(false),
89 deltas_enabled_(false), 90 deltas_enabled_(false),
90 background_downloads_enabled_(false) { 91 background_downloads_enabled_(false),
92 require_encryption_(require_encryption) {
91 // Parse comma-delimited debug flags. 93 // Parse comma-delimited debug flags.
92 std::vector<std::string> switch_values = base::SplitString( 94 std::vector<std::string> switch_values = base::SplitString(
93 cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",", 95 cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",",
94 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 96 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
95 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); 97 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
96 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); 98 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
97 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); 99 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
98 100
99 #if defined(OS_WIN) 101 #if defined(OS_WIN)
100 background_downloads_enabled_ = 102 background_downloads_enabled_ =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 135 }
134 136
135 int ConfiguratorImpl::UpdateDelay() const { 137 int ConfiguratorImpl::UpdateDelay() const {
136 return fast_update_ ? 10 : (15 * kDelayOneMinute); 138 return fast_update_ ? 10 : (15 * kDelayOneMinute);
137 } 139 }
138 140
139 std::vector<GURL> ConfiguratorImpl::UpdateUrl() const { 141 std::vector<GURL> ConfiguratorImpl::UpdateUrl() const {
140 std::vector<GURL> urls; 142 std::vector<GURL> urls;
141 if (url_source_override_.is_valid()) { 143 if (url_source_override_.is_valid()) {
142 urls.push_back(GURL(url_source_override_)); 144 urls.push_back(GURL(url_source_override_));
143 } else { 145 return urls;
144 urls.push_back(GURL(kUpdaterDefaultUrl));
145 } 146 }
147
148 urls.push_back(GURL(kUpdaterDefaultUrl));
149 urls.push_back(GURL(kUpdaterFallbackUrl));
150 if (require_encryption_)
151 update_client::RemoveUnsecureUrls(&urls);
152
146 return urls; 153 return urls;
147 } 154 }
148 155
149 std::vector<GURL> ConfiguratorImpl::PingUrl() const { 156 std::vector<GURL> ConfiguratorImpl::PingUrl() const {
150 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>(); 157 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
151 } 158 }
152 159
153 base::Version ConfiguratorImpl::GetBrowserVersion() const { 160 base::Version ConfiguratorImpl::GetBrowserVersion() const {
154 return base::Version(version_info::GetVersionNumber()); 161 return base::Version(version_info::GetVersionNumber());
155 } 162 }
(...skipping 20 matching lines...) Expand all
176 183
177 bool ConfiguratorImpl::UseBackgroundDownloader() const { 184 bool ConfiguratorImpl::UseBackgroundDownloader() const {
178 return background_downloads_enabled_; 185 return background_downloads_enabled_;
179 } 186 }
180 187
181 bool ConfiguratorImpl::UseCupSigning() const { 188 bool ConfiguratorImpl::UseCupSigning() const {
182 return true; 189 return true;
183 } 190 }
184 191
185 } // namespace component_updater 192 } // namespace component_updater
OLDNEW
« no previous file with comments | « components/component_updater/configurator_impl.h ('k') | components/component_updater/default_component_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698