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

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

Issue 2336843002: Decompose //extensions/browser/BUILD.gn (Closed)
Patch Set: fix moar dependencies. Created 4 years, 3 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 (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 "extensions/browser/updater/extension_downloader.h" 5 #include "extensions/browser/updater/extension_downloader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 // This parses and updates a URL query such that the value of the |authuser| 120 // This parses and updates a URL query such that the value of the |authuser|
121 // query parameter is incremented by 1. If parameter was not present in the URL, 121 // query parameter is incremented by 1. If parameter was not present in the URL,
122 // it will be added with a value of 1. All other query keys and values are 122 // it will be added with a value of 1. All other query keys and values are
123 // preserved as-is. Returns |false| if the user index exceeds a hard-coded 123 // preserved as-is. Returns |false| if the user index exceeds a hard-coded
124 // maximum. 124 // maximum.
125 bool IncrementAuthUserIndex(GURL* url) { 125 bool IncrementAuthUserIndex(GURL* url) {
126 int user_index = 0; 126 int user_index = 0;
127 std::string old_query = url->query(); 127 std::string old_query = url->query();
128 std::vector<std::string> new_query_parts; 128 std::vector<std::string> new_query_parts;
129 url::Component query(0, old_query.length()); 129 url::Component query(0, static_cast<int>(old_query.length()));
130 url::Component key, value; 130 url::Component key, value;
131 while (url::ExtractQueryKeyValue(old_query.c_str(), &query, &key, &value)) { 131 while (url::ExtractQueryKeyValue(old_query.c_str(), &query, &key, &value)) {
132 std::string key_string = old_query.substr(key.begin, key.len); 132 std::string key_string = old_query.substr(key.begin, key.len);
133 std::string value_string = old_query.substr(value.begin, value.len); 133 std::string value_string = old_query.substr(value.begin, value.len);
134 if (key_string == kAuthUserQueryKey) { 134 if (key_string == kAuthUserQueryKey) {
135 base::StringToInt(value_string, &user_index); 135 base::StringToInt(value_string, &user_index);
136 } else { 136 } else {
137 new_query_parts.push_back(base::StringPrintf( 137 new_query_parts.push_back(base::StringPrintf(
138 "%s=%s", key_string.c_str(), value_string.c_str())); 138 "%s=%s", key_string.c_str(), value_string.c_str()));
139 } 139 }
140 } 140 }
141 if (user_index >= kMaxAuthUserValue) 141 if (user_index >= kMaxAuthUserValue)
142 return false; 142 return false;
143 new_query_parts.push_back( 143 new_query_parts.push_back(
144 base::StringPrintf("%s=%d", kAuthUserQueryKey, user_index + 1)); 144 base::StringPrintf("%s=%d", kAuthUserQueryKey, user_index + 1));
145 std::string new_query_string = base::JoinString(new_query_parts, "&"); 145 std::string new_query_string = base::JoinString(new_query_parts, "&");
146 url::Component new_query(0, new_query_string.size()); 146 url::Component new_query(0, static_cast<int>(new_query_string.size()));
147 url::Replacements<char> replacements; 147 url::Replacements<char> replacements;
148 replacements.SetQuery(new_query_string.c_str(), new_query); 148 replacements.SetQuery(new_query_string.c_str(), new_query);
149 *url = url->ReplaceComponents(replacements); 149 *url = url->ReplaceComponents(replacements);
150 return true; 150 return true;
151 } 151 }
152 152
153 } // namespace 153 } // namespace
154 154
155 UpdateDetails::UpdateDetails(const std::string& id, 155 UpdateDetails::UpdateDetails(const std::string& id,
156 const base::Version& version) 156 const base::Version& version)
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 return; 436 return;
437 } 437 }
438 } 438 }
439 439
440 if (manifests_queue_.active_request() && 440 if (manifests_queue_.active_request() &&
441 manifests_queue_.active_request()->full_url() == fetch_data->full_url()) { 441 manifests_queue_.active_request()->full_url() == fetch_data->full_url()) {
442 manifests_queue_.active_request()->Merge(*fetch_data); 442 manifests_queue_.active_request()->Merge(*fetch_data);
443 } else { 443 } else {
444 UMA_HISTOGRAM_COUNTS( 444 UMA_HISTOGRAM_COUNTS(
445 "Extensions.UpdateCheckUrlLength", 445 "Extensions.UpdateCheckUrlLength",
446 fetch_data->full_url().possibly_invalid_spec().length()); 446 static_cast<int>(
447 fetch_data->full_url().possibly_invalid_spec().length()));
447 448
448 manifests_queue_.ScheduleRequest(std::move(fetch_data)); 449 manifests_queue_.ScheduleRequest(std::move(fetch_data));
449 } 450 }
450 } 451 }
451 452
452 void ExtensionDownloader::CreateManifestFetcher() { 453 void ExtensionDownloader::CreateManifestFetcher() {
453 if (VLOG_IS_ON(2)) { 454 if (VLOG_IS_ON(2)) {
454 std::vector<std::string> id_vector( 455 std::vector<std::string> id_vector(
455 manifests_queue_.active_request()->extension_ids().begin(), 456 manifests_queue_.active_request()->extension_ids().begin(),
456 manifests_queue_.active_request()->extension_ids().end()); 457 manifests_queue_.active_request()->extension_ids().end());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } else { 572 } else {
572 // The URL of the blacklist file is returned by the server and we need to 573 // The URL of the blacklist file is returned by the server and we need to
573 // be sure that we continue to be able to reliably detect whether a URL 574 // be sure that we continue to be able to reliably detect whether a URL
574 // references a blacklist file. 575 // references a blacklist file.
575 DCHECK(extension_urls::IsBlacklistUpdateUrl(crx_url)) << crx_url; 576 DCHECK(extension_urls::IsBlacklistUpdateUrl(crx_url)) << crx_url;
576 577
577 // Force https (crbug.com/129587). 578 // Force https (crbug.com/129587).
578 if (!crx_url.SchemeIsCryptographic()) { 579 if (!crx_url.SchemeIsCryptographic()) {
579 url::Replacements<char> replacements; 580 url::Replacements<char> replacements;
580 std::string scheme("https"); 581 std::string scheme("https");
581 replacements.SetScheme(scheme.c_str(), 582 replacements.SetScheme(
582 url::Component(0, scheme.size())); 583 scheme.c_str(), url::Component(0, static_cast<int>(scheme.size())));
583 crx_url = crx_url.ReplaceComponents(replacements); 584 crx_url = crx_url.ReplaceComponents(replacements);
584 } 585 }
585 } 586 }
586 std::unique_ptr<ExtensionFetch> fetch( 587 std::unique_ptr<ExtensionFetch> fetch(
587 new ExtensionFetch(update->extension_id, crx_url, update->package_hash, 588 new ExtensionFetch(update->extension_id, crx_url, update->package_hash,
588 update->version, fetch_data->request_ids())); 589 update->version, fetch_data->request_ids()));
589 FetchUpdatedExtension(std::move(fetch)); 590 FetchUpdatedExtension(std::move(fetch));
590 } 591 }
591 592
592 // If the manifest response included a <daystart> element, we want to save 593 // If the manifest response included a <daystart> element, we want to save
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 !ExtensionsBrowserClient::Get()->IsMinBrowserVersionSupported( 658 !ExtensionsBrowserClient::Get()->IsMinBrowserVersionSupported(
658 update->browser_min_version)) { 659 update->browser_min_version)) {
659 // TODO(asargent) - We may want this to show up in the extensions UI 660 // TODO(asargent) - We may want this to show up in the extensions UI
660 // eventually. (http://crbug.com/12547). 661 // eventually. (http://crbug.com/12547).
661 DLOG(WARNING) << "Updated version of extension " << id 662 DLOG(WARNING) << "Updated version of extension " << id
662 << " available, but requires chrome version " 663 << " available, but requires chrome version "
663 << update->browser_min_version; 664 << update->browser_min_version;
664 continue; 665 continue;
665 } 666 }
666 VLOG(2) << "will try to update " << id; 667 VLOG(2) << "will try to update " << id;
667 result->push_back(i); 668 result->push_back(static_cast<int>(i));
668 } 669 }
669 } 670 }
670 671
671 // Begins (or queues up) download of an updated extension. 672 // Begins (or queues up) download of an updated extension.
672 void ExtensionDownloader::FetchUpdatedExtension( 673 void ExtensionDownloader::FetchUpdatedExtension(
673 std::unique_ptr<ExtensionFetch> fetch_data) { 674 std::unique_ptr<ExtensionFetch> fetch_data) {
674 if (!fetch_data->url.is_valid()) { 675 if (!fetch_data->url.is_valid()) {
675 // TODO(asargent): This can sometimes be invalid. See crbug.com/130881. 676 // TODO(asargent): This can sometimes be invalid. See crbug.com/130881.
676 DLOG(WARNING) << "Invalid URL: '" << fetch_data->url.possibly_invalid_spec() 677 DLOG(WARNING) << "Invalid URL: '" << fetch_data->url.possibly_invalid_spec()
677 << "' for extension " << fetch_data->id; 678 << "' for extension " << fetch_data->id;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 const GURL& update_url, 953 const GURL& update_url,
953 int request_id) { 954 int request_id) {
954 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; 955 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING;
955 if (update_url.DomainIs(ping_enabled_domain_.c_str())) 956 if (update_url.DomainIs(ping_enabled_domain_.c_str()))
956 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; 957 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE;
957 return new ManifestFetchData( 958 return new ManifestFetchData(
958 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); 959 update_url, request_id, brand_code_, manifest_query_params_, ping_mode);
959 } 960 }
960 961
961 } // namespace extensions 962 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698