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

Side by Side Diff: chrome/browser/extensions/updater/extension_downloader.cc

Issue 476073002: Revert of Factor Chrome details out of update manifest fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/updater/extension_downloader.h" 5 #include "chrome/browser/extensions/updater/extension_downloader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 : OAuth2TokenService::Consumer(kTokenServiceConsumerId), 180 : OAuth2TokenService::Consumer(kTokenServiceConsumerId),
181 delegate_(delegate), 181 delegate_(delegate),
182 request_context_(request_context), 182 request_context_(request_context),
183 weak_ptr_factory_(this), 183 weak_ptr_factory_(this),
184 manifests_queue_(&kDefaultBackoffPolicy, 184 manifests_queue_(&kDefaultBackoffPolicy,
185 base::Bind(&ExtensionDownloader::CreateManifestFetcher, 185 base::Bind(&ExtensionDownloader::CreateManifestFetcher,
186 base::Unretained(this))), 186 base::Unretained(this))),
187 extensions_queue_(&kDefaultBackoffPolicy, 187 extensions_queue_(&kDefaultBackoffPolicy,
188 base::Bind(&ExtensionDownloader::CreateExtensionFetcher, 188 base::Bind(&ExtensionDownloader::CreateExtensionFetcher,
189 base::Unretained(this))), 189 base::Unretained(this))),
190 extension_cache_(NULL), 190 extension_cache_(NULL) {
191 enable_extra_update_metrics_(false) {
192 DCHECK(delegate_); 191 DCHECK(delegate_);
193 DCHECK(request_context_); 192 DCHECK(request_context_);
194 } 193 }
195 194
196 ExtensionDownloader::~ExtensionDownloader() {} 195 ExtensionDownloader::~ExtensionDownloader() {}
197 196
198 bool ExtensionDownloader::AddExtension(const Extension& extension, 197 bool ExtensionDownloader::AddExtension(const Extension& extension,
199 int request_id) { 198 int request_id) {
200 // Skip extensions with empty update URLs converted from user 199 // Skip extensions with empty update URLs converted from user
201 // scripts. 200 // scripts.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 fetches_preparing_.clear(); 258 fetches_preparing_.clear();
260 } 259 }
261 260
262 void ExtensionDownloader::StartBlacklistUpdate( 261 void ExtensionDownloader::StartBlacklistUpdate(
263 const std::string& version, 262 const std::string& version,
264 const ManifestFetchData::PingData& ping_data, 263 const ManifestFetchData::PingData& ping_data,
265 int request_id) { 264 int request_id) {
266 // Note: it is very important that we use the https version of the update 265 // Note: it is very important that we use the https version of the update
267 // url here to avoid DNS hijacking of the blacklist, which is not validated 266 // url here to avoid DNS hijacking of the blacklist, which is not validated
268 // by a public key signature like .crx files are. 267 // by a public key signature like .crx files are.
269 scoped_ptr<ManifestFetchData> blacklist_fetch(CreateManifestFetchData( 268 scoped_ptr<ManifestFetchData> blacklist_fetch(
270 extension_urls::GetWebstoreUpdateUrl(), request_id)); 269 new ManifestFetchData(extension_urls::GetWebstoreUpdateUrl(),
270 request_id));
271 DCHECK(blacklist_fetch->base_url().SchemeIsSecure()); 271 DCHECK(blacklist_fetch->base_url().SchemeIsSecure());
272 blacklist_fetch->AddExtension(kBlacklistAppID, 272 blacklist_fetch->AddExtension(kBlacklistAppID,
273 version, 273 version,
274 &ping_data, 274 &ping_data,
275 std::string(), 275 std::string(),
276 kDefaultInstallSource); 276 kDefaultInstallSource);
277 StartUpdateCheck(blacklist_fetch.Pass()); 277 StartUpdateCheck(blacklist_fetch.Pass());
278 } 278 }
279 279
280 void ExtensionDownloader::SetWebstoreIdentityProvider( 280 void ExtensionDownloader::SetWebstoreIdentityProvider(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 ++url_stats_.platform_app_count; 333 ++url_stats_.platform_app_count;
334 break; 334 break;
335 case Manifest::TYPE_UNKNOWN: 335 case Manifest::TYPE_UNKNOWN:
336 default: 336 default:
337 ++url_stats_.pending_count; 337 ++url_stats_.pending_count;
338 break; 338 break;
339 } 339 }
340 340
341 std::vector<GURL> update_urls; 341 std::vector<GURL> update_urls;
342 update_urls.push_back(update_url); 342 update_urls.push_back(update_url);
343 // If metrics are enabled, also add to ManifestFetchData for the 343 // If UMA is enabled, also add to ManifestFetchData for the
344 // webstore update URL. 344 // webstore update URL.
345 if (!extension_urls::IsWebstoreUpdateUrl(update_url) && 345 if (!extension_urls::IsWebstoreUpdateUrl(update_url) &&
346 enable_extra_update_metrics_) { 346 ChromeMetricsServiceAccessor::IsMetricsReportingEnabled()) {
347 update_urls.push_back(extension_urls::GetWebstoreUpdateUrl()); 347 update_urls.push_back(extension_urls::GetWebstoreUpdateUrl());
348 } 348 }
349 349
350 for (size_t i = 0; i < update_urls.size(); ++i) { 350 for (size_t i = 0; i < update_urls.size(); ++i) {
351 DCHECK(!update_urls[i].is_empty()); 351 DCHECK(!update_urls[i].is_empty());
352 DCHECK(update_urls[i].is_valid()); 352 DCHECK(update_urls[i].is_valid());
353 353
354 std::string install_source = i == 0 ? 354 std::string install_source = i == 0 ?
355 kDefaultInstallSource : kNotFromWebstoreInstallSource; 355 kDefaultInstallSource : kNotFromWebstoreInstallSource;
356 356
(...skipping 13 matching lines...) Expand all
370 if (existing_fetch->AddExtension(id, version.GetString(), 370 if (existing_fetch->AddExtension(id, version.GetString(),
371 optional_ping_data, update_url_data, 371 optional_ping_data, update_url_data,
372 install_source)) { 372 install_source)) {
373 added = true; 373 added = true;
374 } 374 }
375 } 375 }
376 if (!added) { 376 if (!added) {
377 // Otherwise add a new element to the list, if the list doesn't exist or 377 // Otherwise add a new element to the list, if the list doesn't exist or
378 // if its last element is already full. 378 // if its last element is already full.
379 linked_ptr<ManifestFetchData> fetch( 379 linked_ptr<ManifestFetchData> fetch(
380 CreateManifestFetchData(update_urls[i], request_id)); 380 new ManifestFetchData(update_urls[i], request_id));
381 fetches_preparing_[std::make_pair(request_id, update_urls[i])]. 381 fetches_preparing_[std::make_pair(request_id, update_urls[i])].
382 push_back(fetch); 382 push_back(fetch);
383 added = fetch->AddExtension(id, version.GetString(), 383 added = fetch->AddExtension(id, version.GetString(),
384 optional_ping_data, 384 optional_ping_data,
385 update_url_data, 385 update_url_data,
386 install_source); 386 install_source);
387 DCHECK(added); 387 DCHECK(added);
388 } 388 }
389 } 389 }
390 390
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 921 }
922 922
923 void ExtensionDownloader::OnGetTokenFailure( 923 void ExtensionDownloader::OnGetTokenFailure(
924 const OAuth2TokenService::Request* request, 924 const OAuth2TokenService::Request* request,
925 const GoogleServiceAuthError& error) { 925 const GoogleServiceAuthError& error) {
926 // If we fail to get an access token, kick the pending fetch and let it fall 926 // If we fail to get an access token, kick the pending fetch and let it fall
927 // back on cookies. 927 // back on cookies.
928 extension_fetcher_->Start(); 928 extension_fetcher_->Start();
929 } 929 }
930 930
931 ManifestFetchData* ExtensionDownloader::CreateManifestFetchData(
932 const GURL& update_url,
933 int request_id) {
934 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING;
935 if (update_url.DomainIs(ping_enabled_domain_.c_str())) {
936 if (enable_extra_update_metrics_) {
937 ping_mode = ManifestFetchData::PING_WITH_METRICS;
938 } else {
939 ping_mode = ManifestFetchData::PING;
940 }
941 }
942 return new ManifestFetchData(
943 update_url, request_id, brand_code_, manifest_query_params_, ping_mode);
944 }
945
946 } // namespace extensions 931 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698