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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 std::string new_query_string = base::JoinString(new_query_parts, "&"); | 139 std::string new_query_string = base::JoinString(new_query_parts, "&"); |
140 url::Component new_query(0, new_query_string.size()); | 140 url::Component new_query(0, new_query_string.size()); |
141 url::Replacements<char> replacements; | 141 url::Replacements<char> replacements; |
142 replacements.SetQuery(new_query_string.c_str(), new_query); | 142 replacements.SetQuery(new_query_string.c_str(), new_query); |
143 *url = url->ReplaceComponents(replacements); | 143 *url = url->ReplaceComponents(replacements); |
144 return true; | 144 return true; |
145 } | 145 } |
146 | 146 |
147 } // namespace | 147 } // namespace |
148 | 148 |
149 UpdateDetails::UpdateDetails(const std::string& id, const Version& version) | 149 UpdateDetails::UpdateDetails(const std::string& id, |
150 : id(id), version(version) { | 150 const base::Version& version) |
151 } | 151 : id(id), version(version) {} |
152 | 152 |
153 UpdateDetails::~UpdateDetails() { | 153 UpdateDetails::~UpdateDetails() { |
154 } | 154 } |
155 | 155 |
156 ExtensionDownloader::ExtensionFetch::ExtensionFetch() | 156 ExtensionDownloader::ExtensionFetch::ExtensionFetch() |
157 : url(), credentials(CREDENTIALS_NONE) { | 157 : url(), credentials(CREDENTIALS_NONE) { |
158 } | 158 } |
159 | 159 |
160 ExtensionDownloader::ExtensionFetch::ExtensionFetch( | 160 ExtensionDownloader::ExtensionFetch::ExtensionFetch( |
161 const std::string& id, | 161 const std::string& id, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 force_update, | 225 force_update, |
226 install_source); | 226 install_source); |
227 } | 227 } |
228 | 228 |
229 bool ExtensionDownloader::AddPendingExtension(const std::string& id, | 229 bool ExtensionDownloader::AddPendingExtension(const std::string& id, |
230 const GURL& update_url, | 230 const GURL& update_url, |
231 int request_id) { | 231 int request_id) { |
232 // Use a zero version to ensure that a pending extension will always | 232 // Use a zero version to ensure that a pending extension will always |
233 // be updated, and thus installed (assuming all extensions have | 233 // be updated, and thus installed (assuming all extensions have |
234 // non-zero versions). | 234 // non-zero versions). |
235 Version version("0.0.0.0"); | 235 base::Version version("0.0.0.0"); |
236 DCHECK(version.IsValid()); | 236 DCHECK(version.IsValid()); |
237 | 237 |
238 return AddExtensionData(id, | 238 return AddExtensionData(id, |
239 version, | 239 version, |
240 Manifest::TYPE_UNKNOWN, | 240 Manifest::TYPE_UNKNOWN, |
241 update_url, | 241 update_url, |
242 std::string(), | 242 std::string(), |
243 request_id, | 243 request_id, |
244 false, | 244 false, |
245 std::string()); | 245 std::string()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 StartUpdateCheck(blacklist_fetch.Pass()); | 289 StartUpdateCheck(blacklist_fetch.Pass()); |
290 } | 290 } |
291 | 291 |
292 void ExtensionDownloader::SetWebstoreIdentityProvider( | 292 void ExtensionDownloader::SetWebstoreIdentityProvider( |
293 scoped_ptr<IdentityProvider> identity_provider) { | 293 scoped_ptr<IdentityProvider> identity_provider) { |
294 identity_provider_.swap(identity_provider); | 294 identity_provider_.swap(identity_provider); |
295 } | 295 } |
296 | 296 |
297 bool ExtensionDownloader::AddExtensionData( | 297 bool ExtensionDownloader::AddExtensionData( |
298 const std::string& id, | 298 const std::string& id, |
299 const Version& version, | 299 const base::Version& version, |
300 Manifest::Type extension_type, | 300 Manifest::Type extension_type, |
301 const GURL& extension_update_url, | 301 const GURL& extension_update_url, |
302 const std::string& update_url_data, | 302 const std::string& update_url_data, |
303 int request_id, | 303 int request_id, |
304 bool force_update, | 304 bool force_update, |
305 const std::string& install_source_override) { | 305 const std::string& install_source_override) { |
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 DLOG(WARNING) << "Extension " << id << " has invalid update url " | 309 DLOG(WARNING) << "Extension " << id << " has invalid update url " |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 std::string version; | 654 std::string version; |
655 if (!delegate_->GetExtensionExistingVersion(id, &version)) { | 655 if (!delegate_->GetExtensionExistingVersion(id, &version)) { |
656 VLOG(2) << id << " is not installed"; | 656 VLOG(2) << id << " is not installed"; |
657 continue; | 657 continue; |
658 } | 658 } |
659 | 659 |
660 VLOG(2) << id << " is at '" << version << "'"; | 660 VLOG(2) << id << " is at '" << version << "'"; |
661 | 661 |
662 // We should skip the version check if update was forced. | 662 // We should skip the version check if update was forced. |
663 if (!fetch_data.DidForceUpdate(id)) { | 663 if (!fetch_data.DidForceUpdate(id)) { |
664 Version existing_version(version); | 664 base::Version existing_version(version); |
665 Version update_version(update->version); | 665 base::Version update_version(update->version); |
666 if (!update_version.IsValid() || | 666 if (!update_version.IsValid() || |
667 update_version.CompareTo(existing_version) <= 0) { | 667 update_version.CompareTo(existing_version) <= 0) { |
668 continue; | 668 continue; |
669 } | 669 } |
670 } | 670 } |
671 } | 671 } |
672 | 672 |
673 // If the update specifies a browser minimum version, do we qualify? | 673 // If the update specifies a browser minimum version, do we qualify? |
674 if (update->browser_min_version.length() > 0 && | 674 if (update->browser_min_version.length() > 0 && |
675 !ExtensionsBrowserClient::Get()->IsMinBrowserVersionSupported( | 675 !ExtensionsBrowserClient::Get()->IsMinBrowserVersionSupported( |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 it != extension_ids.end(); | 871 it != extension_ids.end(); |
872 ++it) { | 872 ++it) { |
873 const ExtensionDownloaderDelegate::PingResult& ping = ping_results_[*it]; | 873 const ExtensionDownloaderDelegate::PingResult& ping = ping_results_[*it]; |
874 delegate_->OnExtensionDownloadFailed(*it, error, ping, request_ids); | 874 delegate_->OnExtensionDownloadFailed(*it, error, ping, request_ids); |
875 ping_results_.erase(*it); | 875 ping_results_.erase(*it); |
876 } | 876 } |
877 } | 877 } |
878 | 878 |
879 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, | 879 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, |
880 const std::string& version) { | 880 const std::string& version) { |
881 UpdateDetails updateInfo(id, Version(version)); | 881 UpdateDetails updateInfo(id, base::Version(version)); |
882 content::NotificationService::current()->Notify( | 882 content::NotificationService::current()->Notify( |
883 extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 883 extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
884 content::NotificationService::AllBrowserContextsAndSources(), | 884 content::NotificationService::AllBrowserContextsAndSources(), |
885 content::Details<UpdateDetails>(&updateInfo)); | 885 content::Details<UpdateDetails>(&updateInfo)); |
886 } | 886 } |
887 | 887 |
888 bool ExtensionDownloader::IterateFetchCredentialsAfterFailure( | 888 bool ExtensionDownloader::IterateFetchCredentialsAfterFailure( |
889 ExtensionFetch* fetch, | 889 ExtensionFetch* fetch, |
890 const net::URLRequestStatus& status, | 890 const net::URLRequestStatus& status, |
891 int response_code) { | 891 int response_code) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 const GURL& update_url, | 968 const GURL& update_url, |
969 int request_id) { | 969 int request_id) { |
970 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; | 970 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; |
971 if (update_url.DomainIs(ping_enabled_domain_.c_str())) | 971 if (update_url.DomainIs(ping_enabled_domain_.c_str())) |
972 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; | 972 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; |
973 return new ManifestFetchData( | 973 return new ManifestFetchData( |
974 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); | 974 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); |
975 } | 975 } |
976 | 976 |
977 } // namespace extensions | 977 } // namespace extensions |
OLD | NEW |