OLD | NEW |
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 <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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 void ExtensionDownloader::StartBlacklistUpdate( | 273 void ExtensionDownloader::StartBlacklistUpdate( |
274 const std::string& version, | 274 const std::string& version, |
275 const ManifestFetchData::PingData& ping_data, | 275 const ManifestFetchData::PingData& ping_data, |
276 int request_id) { | 276 int request_id) { |
277 // Note: it is very important that we use the https version of the update | 277 // Note: it is very important that we use the https version of the update |
278 // url here to avoid DNS hijacking of the blacklist, which is not validated | 278 // url here to avoid DNS hijacking of the blacklist, which is not validated |
279 // by a public key signature like .crx files are. | 279 // by a public key signature like .crx files are. |
280 scoped_ptr<ManifestFetchData> blacklist_fetch(CreateManifestFetchData( | 280 scoped_ptr<ManifestFetchData> blacklist_fetch(CreateManifestFetchData( |
281 extension_urls::GetWebstoreUpdateUrl(), request_id)); | 281 extension_urls::GetWebstoreUpdateUrl(), request_id)); |
282 DCHECK(blacklist_fetch->base_url().SchemeIsSecure()); | 282 DCHECK(blacklist_fetch->base_url().SchemeIsCryptographic()); |
283 blacklist_fetch->AddExtension(kBlacklistAppID, | 283 blacklist_fetch->AddExtension(kBlacklistAppID, |
284 version, | 284 version, |
285 &ping_data, | 285 &ping_data, |
286 std::string(), | 286 std::string(), |
287 kDefaultInstallSource, | 287 kDefaultInstallSource, |
288 false); | 288 false); |
289 StartUpdateCheck(blacklist_fetch.Pass()); | 289 StartUpdateCheck(blacklist_fetch.Pass()); |
290 } | 290 } |
291 | 291 |
292 void ExtensionDownloader::SetWebstoreIdentityProvider( | 292 void ExtensionDownloader::SetWebstoreIdentityProvider( |
(...skipping 13 matching lines...) Expand all Loading... |
306 GURL update_url(extension_update_url); | 306 GURL update_url(extension_update_url); |
307 // Skip extensions with non-empty invalid update URLs. | 307 // Skip extensions with non-empty invalid update URLs. |
308 if (!update_url.is_empty() && !update_url.is_valid()) { | 308 if (!update_url.is_empty() && !update_url.is_valid()) { |
309 LOG(WARNING) << "Extension " << id << " has invalid update url " | 309 LOG(WARNING) << "Extension " << id << " has invalid update url " |
310 << update_url; | 310 << update_url; |
311 return false; | 311 return false; |
312 } | 312 } |
313 | 313 |
314 // Make sure we use SSL for store-hosted extensions. | 314 // Make sure we use SSL for store-hosted extensions. |
315 if (extension_urls::IsWebstoreUpdateUrl(update_url) && | 315 if (extension_urls::IsWebstoreUpdateUrl(update_url) && |
316 !update_url.SchemeIsSecure()) | 316 !update_url.SchemeIsCryptographic()) |
317 update_url = extension_urls::GetWebstoreUpdateUrl(); | 317 update_url = extension_urls::GetWebstoreUpdateUrl(); |
318 | 318 |
319 // Skip extensions with empty IDs. | 319 // Skip extensions with empty IDs. |
320 if (id.empty()) { | 320 if (id.empty()) { |
321 LOG(WARNING) << "Found extension with empty ID"; | 321 LOG(WARNING) << "Found extension with empty ID"; |
322 return false; | 322 return false; |
323 } | 323 } |
324 | 324 |
325 if (update_url.DomainIs(kGoogleDotCom)) { | 325 if (update_url.DomainIs(kGoogleDotCom)) { |
326 url_stats_.google_url_count++; | 326 url_stats_.google_url_count++; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 GURL crx_url = update->crx_url; | 584 GURL crx_url = update->crx_url; |
585 if (id != kBlacklistAppID) { | 585 if (id != kBlacklistAppID) { |
586 NotifyUpdateFound(update->extension_id, update->version); | 586 NotifyUpdateFound(update->extension_id, update->version); |
587 } else { | 587 } else { |
588 // The URL of the blacklist file is returned by the server and we need to | 588 // The URL of the blacklist file is returned by the server and we need to |
589 // be sure that we continue to be able to reliably detect whether a URL | 589 // be sure that we continue to be able to reliably detect whether a URL |
590 // references a blacklist file. | 590 // references a blacklist file. |
591 DCHECK(extension_urls::IsBlacklistUpdateUrl(crx_url)) << crx_url; | 591 DCHECK(extension_urls::IsBlacklistUpdateUrl(crx_url)) << crx_url; |
592 | 592 |
593 // Force https (crbug.com/129587). | 593 // Force https (crbug.com/129587). |
594 if (!crx_url.SchemeIsSecure()) { | 594 if (!crx_url.SchemeIsCryptographic()) { |
595 url::Replacements<char> replacements; | 595 url::Replacements<char> replacements; |
596 std::string scheme("https"); | 596 std::string scheme("https"); |
597 replacements.SetScheme(scheme.c_str(), | 597 replacements.SetScheme(scheme.c_str(), |
598 url::Component(0, scheme.size())); | 598 url::Component(0, scheme.size())); |
599 crx_url = crx_url.ReplaceComponents(replacements); | 599 crx_url = crx_url.ReplaceComponents(replacements); |
600 } | 600 } |
601 } | 601 } |
602 scoped_ptr<ExtensionFetch> fetch( | 602 scoped_ptr<ExtensionFetch> fetch( |
603 new ExtensionFetch(update->extension_id, crx_url, update->package_hash, | 603 new ExtensionFetch(update->extension_id, crx_url, update->package_hash, |
604 update->version, fetch_data->request_ids())); | 604 update->version, fetch_data->request_ids())); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 } | 761 } |
762 | 762 |
763 void ExtensionDownloader::CreateExtensionFetcher() { | 763 void ExtensionDownloader::CreateExtensionFetcher() { |
764 const ExtensionFetch* fetch = extensions_queue_.active_request(); | 764 const ExtensionFetch* fetch = extensions_queue_.active_request(); |
765 extension_fetcher_.reset(net::URLFetcher::Create( | 765 extension_fetcher_.reset(net::URLFetcher::Create( |
766 kExtensionFetcherId, fetch->url, net::URLFetcher::GET, this)); | 766 kExtensionFetcherId, fetch->url, net::URLFetcher::GET, this)); |
767 extension_fetcher_->SetRequestContext(request_context_.get()); | 767 extension_fetcher_->SetRequestContext(request_context_.get()); |
768 extension_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); | 768 extension_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); |
769 | 769 |
770 int load_flags = net::LOAD_DISABLE_CACHE; | 770 int load_flags = net::LOAD_DISABLE_CACHE; |
771 bool is_secure = fetch->url.SchemeIsSecure(); | 771 bool is_secure = fetch->url.SchemeIsCryptographic(); |
772 if (fetch->credentials != ExtensionFetch::CREDENTIALS_COOKIES || !is_secure) { | 772 if (fetch->credentials != ExtensionFetch::CREDENTIALS_COOKIES || !is_secure) { |
773 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES; | 773 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES; |
774 } | 774 } |
775 extension_fetcher_->SetLoadFlags(load_flags); | 775 extension_fetcher_->SetLoadFlags(load_flags); |
776 | 776 |
777 // Download CRX files to a temp file. The blacklist is small and will be | 777 // Download CRX files to a temp file. The blacklist is small and will be |
778 // processed in memory, so it is fetched into a string. | 778 // processed in memory, so it is fetched into a string. |
779 if (fetch->id != kBlacklistAppID) { | 779 if (fetch->id != kBlacklistAppID) { |
780 extension_fetcher_->SaveResponseToTemporaryFile( | 780 extension_fetcher_->SaveResponseToTemporaryFile( |
781 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 781 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 const GURL& update_url, | 970 const GURL& update_url, |
971 int request_id) { | 971 int request_id) { |
972 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; | 972 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; |
973 if (update_url.DomainIs(ping_enabled_domain_.c_str())) | 973 if (update_url.DomainIs(ping_enabled_domain_.c_str())) |
974 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; | 974 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; |
975 return new ManifestFetchData( | 975 return new ManifestFetchData( |
976 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); | 976 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); |
977 } | 977 } |
978 | 978 |
979 } // namespace extensions | 979 } // namespace extensions |
OLD | NEW |