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

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

Issue 1610833004: Remove Windows XP SHA-256 and ECDSA logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; 52 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads";
53 #endif // defined(OS_WIN) 53 #endif // defined(OS_WIN)
54 54
55 // Returns true if and only if |test| is contained in |vec|. 55 // Returns true if and only if |test| is contained in |vec|.
56 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { 56 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) {
57 if (vec.empty()) 57 if (vec.empty())
58 return 0; 58 return 0;
59 return (std::find(vec.begin(), vec.end(), test) != vec.end()); 59 return (std::find(vec.begin(), vec.end(), test) != vec.end());
60 } 60 }
61 61
62 // Returns true if falling back on an alternate, unsafe, service URL is
63 // allowed. In the fallback case, the security of the component update relies
64 // only on the integrity of the CRX payloads, which is self-validating.
65 // This is allowed only for some of the pre-Windows Vista versions not including
66 // Windows XP SP3. As a side note, pings could be sent to the alternate URL too.
67 bool CanUseAltUrlSource() {
68 #if defined(OS_WIN)
69 return !base::win::MaybeHasSHA256Support();
70 #else
71 return false;
72 #endif // OS_WIN
73 }
74
75 // If there is an element of |vec| of the form |test|=.*, returns the right- 62 // If there is an element of |vec| of the form |test|=.*, returns the right-
76 // hand side of that assignment. Otherwise, returns an empty string. 63 // hand side of that assignment. Otherwise, returns an empty string.
77 // The right-hand side may contain additional '=' characters, allowing for 64 // The right-hand side may contain additional '=' characters, allowing for
78 // further nesting of switch arguments. 65 // further nesting of switch arguments.
79 std::string GetSwitchArgument(const std::vector<std::string>& vec, 66 std::string GetSwitchArgument(const std::vector<std::string>& vec,
80 const char* test) { 67 const char* test) {
81 if (vec.empty()) 68 if (vec.empty())
82 return std::string(); 69 return std::string();
83 for (std::vector<std::string>::const_iterator it = vec.begin(); 70 for (std::vector<std::string>::const_iterator it = vec.begin();
84 it != vec.end(); ++it) { 71 it != vec.end(); ++it) {
85 const std::size_t found = it->find("="); 72 const std::size_t found = it->find("=");
86 if (found != std::string::npos) { 73 if (found != std::string::npos) {
87 if (it->substr(0, found) == test) { 74 if (it->substr(0, found) == test) {
88 return it->substr(found + 1); 75 return it->substr(found + 1);
89 } 76 }
90 } 77 }
91 } 78 }
92 return std::string(); 79 return std::string();
93 } 80 }
94 81
95 } // namespace 82 } // namespace
96 83
97 ConfiguratorImpl::ConfiguratorImpl( 84 ConfiguratorImpl::ConfiguratorImpl(
98 const base::CommandLine* cmdline, 85 const base::CommandLine* cmdline,
99 net::URLRequestContextGetter* url_request_getter) 86 net::URLRequestContextGetter* url_request_getter)
100 : url_request_getter_(url_request_getter), 87 : url_request_getter_(url_request_getter),
101 fast_update_(false), 88 fast_update_(false),
102 pings_enabled_(false), 89 pings_enabled_(false),
103 deltas_enabled_(false), 90 deltas_enabled_(false),
104 background_downloads_enabled_(false), 91 background_downloads_enabled_(false) {
105 fallback_to_alt_source_url_enabled_(false) {
106 // Parse comma-delimited debug flags. 92 // Parse comma-delimited debug flags.
107 std::vector<std::string> switch_values = base::SplitString( 93 std::vector<std::string> switch_values = base::SplitString(
108 cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",", 94 cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",",
109 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 95 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
110 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); 96 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
111 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); 97 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
112 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); 98 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
113 99
114 #if defined(OS_WIN) 100 #if defined(OS_WIN)
115 background_downloads_enabled_ = 101 background_downloads_enabled_ =
116 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads); 102 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads);
117 #else 103 #else
118 background_downloads_enabled_ = false; 104 background_downloads_enabled_ = false;
119 #endif 105 #endif
120 106
121 const std::string switch_url_source = 107 const std::string switch_url_source =
122 GetSwitchArgument(switch_values, kSwitchUrlSource); 108 GetSwitchArgument(switch_values, kSwitchUrlSource);
123 if (!switch_url_source.empty()) { 109 if (!switch_url_source.empty()) {
124 url_source_override_ = GURL(switch_url_source); 110 url_source_override_ = GURL(switch_url_source);
125 DCHECK(url_source_override_.is_valid()); 111 DCHECK(url_source_override_.is_valid());
126 } 112 }
127 113
128 if (HasSwitchValue(switch_values, kSwitchRequestParam)) 114 if (HasSwitchValue(switch_values, kSwitchRequestParam))
129 extra_info_ += "testrequest=\"1\""; 115 extra_info_ += "testrequest=\"1\"";
130
131 fallback_to_alt_source_url_enabled_ = CanUseAltUrlSource();
132 } 116 }
133 117
134 ConfiguratorImpl::~ConfiguratorImpl() {} 118 ConfiguratorImpl::~ConfiguratorImpl() {}
135 119
136 int ConfiguratorImpl::InitialDelay() const { 120 int ConfiguratorImpl::InitialDelay() const {
137 return fast_update_ ? 10 : (6 * kDelayOneMinute); 121 return fast_update_ ? 10 : (6 * kDelayOneMinute);
138 } 122 }
139 123
140 int ConfiguratorImpl::NextCheckDelay() const { 124 int ConfiguratorImpl::NextCheckDelay() const {
141 return fast_update_ ? 60 : (6 * kDelayOneHour); 125 return fast_update_ ? 60 : (6 * kDelayOneHour);
(...skipping 10 matching lines...) Expand all
152 int ConfiguratorImpl::UpdateDelay() const { 136 int ConfiguratorImpl::UpdateDelay() const {
153 return fast_update_ ? 10 : (15 * kDelayOneMinute); 137 return fast_update_ ? 10 : (15 * kDelayOneMinute);
154 } 138 }
155 139
156 std::vector<GURL> ConfiguratorImpl::UpdateUrl() const { 140 std::vector<GURL> ConfiguratorImpl::UpdateUrl() const {
157 std::vector<GURL> urls; 141 std::vector<GURL> urls;
158 if (url_source_override_.is_valid()) { 142 if (url_source_override_.is_valid()) {
159 urls.push_back(GURL(url_source_override_)); 143 urls.push_back(GURL(url_source_override_));
160 } else { 144 } else {
161 urls.push_back(GURL(kUpdaterDefaultUrl)); 145 urls.push_back(GURL(kUpdaterDefaultUrl));
162 if (fallback_to_alt_source_url_enabled_) {
163 urls.push_back(GURL(kUpdaterAltUrl));
164 }
165 } 146 }
166 return urls; 147 return urls;
167 } 148 }
168 149
169 std::vector<GURL> ConfiguratorImpl::PingUrl() const { 150 std::vector<GURL> ConfiguratorImpl::PingUrl() const {
170 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>(); 151 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
171 } 152 }
172 153
173 base::Version ConfiguratorImpl::GetBrowserVersion() const { 154 base::Version ConfiguratorImpl::GetBrowserVersion() const {
174 return base::Version(version_info::GetVersionNumber()); 155 return base::Version(version_info::GetVersionNumber());
(...skipping 12 matching lines...) Expand all
187 } 168 }
188 169
189 bool ConfiguratorImpl::DeltasEnabled() const { 170 bool ConfiguratorImpl::DeltasEnabled() const {
190 return deltas_enabled_; 171 return deltas_enabled_;
191 } 172 }
192 173
193 bool ConfiguratorImpl::UseBackgroundDownloader() const { 174 bool ConfiguratorImpl::UseBackgroundDownloader() const {
194 return background_downloads_enabled_; 175 return background_downloads_enabled_;
195 } 176 }
196 177
197 void ConfiguratorImpl::set_enable_alt_source_url(bool enable_alt_source_url) {
198 fallback_to_alt_source_url_enabled_ = enable_alt_source_url;
199 }
200
201 } // namespace component_updater 178 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698