| 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 "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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 bool ExtensionDownloader::AddPendingExtension(const std::string& id, | 214 bool ExtensionDownloader::AddPendingExtension(const std::string& id, |
| 215 const GURL& update_url, | 215 const GURL& update_url, |
| 216 int request_id) { | 216 int request_id) { |
| 217 // Use a zero version to ensure that a pending extension will always | 217 // Use a zero version to ensure that a pending extension will always |
| 218 // be updated, and thus installed (assuming all extensions have | 218 // be updated, and thus installed (assuming all extensions have |
| 219 // non-zero versions). | 219 // non-zero versions). |
| 220 Version version("0.0.0.0"); | 220 Version version("0.0.0.0"); |
| 221 DCHECK(version.IsValid()); | 221 DCHECK(version.IsValid()); |
| 222 | 222 |
| 223 return AddExtensionData(id, version, Extension::TYPE_UNKNOWN, update_url, "", | 223 return AddExtensionData(id, version, Manifest::TYPE_UNKNOWN, update_url, "", |
| 224 request_id); | 224 request_id); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ExtensionDownloader::StartAllPending() { | 227 void ExtensionDownloader::StartAllPending() { |
| 228 ReportStats(); | 228 ReportStats(); |
| 229 url_stats_ = URLStats(); | 229 url_stats_ = URLStats(); |
| 230 | 230 |
| 231 for (FetchMap::iterator it = fetches_preparing_.begin(); | 231 for (FetchMap::iterator it = fetches_preparing_.begin(); |
| 232 it != fetches_preparing_.end(); ++it) { | 232 it != fetches_preparing_.end(); ++it) { |
| 233 std::vector<linked_ptr<ManifestFetchData> >& list = it->second; | 233 std::vector<linked_ptr<ManifestFetchData> >& list = it->second; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 249 new ManifestFetchData(extension_urls::GetWebstoreUpdateUrl(), | 249 new ManifestFetchData(extension_urls::GetWebstoreUpdateUrl(), |
| 250 request_id)); | 250 request_id)); |
| 251 DCHECK(blacklist_fetch->base_url().SchemeIsSecure()); | 251 DCHECK(blacklist_fetch->base_url().SchemeIsSecure()); |
| 252 blacklist_fetch->AddExtension(kBlacklistAppID, version, &ping_data, "", | 252 blacklist_fetch->AddExtension(kBlacklistAppID, version, &ping_data, "", |
| 253 kDefaultInstallSource); | 253 kDefaultInstallSource); |
| 254 StartUpdateCheck(blacklist_fetch.Pass()); | 254 StartUpdateCheck(blacklist_fetch.Pass()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool ExtensionDownloader::AddExtensionData(const std::string& id, | 257 bool ExtensionDownloader::AddExtensionData(const std::string& id, |
| 258 const Version& version, | 258 const Version& version, |
| 259 Extension::Type extension_type, | 259 Manifest::Type extension_type, |
| 260 const GURL& extension_update_url, | 260 const GURL& extension_update_url, |
| 261 const std::string& update_url_data, | 261 const std::string& update_url_data, |
| 262 int request_id) { | 262 int request_id) { |
| 263 GURL update_url(extension_update_url); | 263 GURL update_url(extension_update_url); |
| 264 // Skip extensions with non-empty invalid update URLs. | 264 // Skip extensions with non-empty invalid update URLs. |
| 265 if (!update_url.is_empty() && !update_url.is_valid()) { | 265 if (!update_url.is_empty() && !update_url.is_valid()) { |
| 266 LOG(WARNING) << "Extension " << id << " has invalid update url " | 266 LOG(WARNING) << "Extension " << id << " has invalid update url " |
| 267 << update_url; | 267 << update_url; |
| 268 return false; | 268 return false; |
| 269 } | 269 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 283 url_stats_.google_url_count++; | 283 url_stats_.google_url_count++; |
| 284 } else if (update_url.is_empty()) { | 284 } else if (update_url.is_empty()) { |
| 285 url_stats_.no_url_count++; | 285 url_stats_.no_url_count++; |
| 286 // Fill in default update URL. | 286 // Fill in default update URL. |
| 287 update_url = extension_urls::GetWebstoreUpdateUrl(); | 287 update_url = extension_urls::GetWebstoreUpdateUrl(); |
| 288 } else { | 288 } else { |
| 289 url_stats_.other_url_count++; | 289 url_stats_.other_url_count++; |
| 290 } | 290 } |
| 291 | 291 |
| 292 switch (extension_type) { | 292 switch (extension_type) { |
| 293 case Extension::TYPE_THEME: | 293 case Manifest::TYPE_THEME: |
| 294 ++url_stats_.theme_count; | 294 ++url_stats_.theme_count; |
| 295 break; | 295 break; |
| 296 case Extension::TYPE_EXTENSION: | 296 case Manifest::TYPE_EXTENSION: |
| 297 case Extension::TYPE_USER_SCRIPT: | 297 case Manifest::TYPE_USER_SCRIPT: |
| 298 ++url_stats_.extension_count; | 298 ++url_stats_.extension_count; |
| 299 break; | 299 break; |
| 300 case Extension::TYPE_HOSTED_APP: | 300 case Manifest::TYPE_HOSTED_APP: |
| 301 case Extension::TYPE_LEGACY_PACKAGED_APP: | 301 case Manifest::TYPE_LEGACY_PACKAGED_APP: |
| 302 ++url_stats_.app_count; | 302 ++url_stats_.app_count; |
| 303 break; | 303 break; |
| 304 case Extension::TYPE_PLATFORM_APP: | 304 case Manifest::TYPE_PLATFORM_APP: |
| 305 ++url_stats_.platform_app_count; | 305 ++url_stats_.platform_app_count; |
| 306 break; | 306 break; |
| 307 case Extension::TYPE_UNKNOWN: | 307 case Manifest::TYPE_UNKNOWN: |
| 308 default: | 308 default: |
| 309 ++url_stats_.pending_count; | 309 ++url_stats_.pending_count; |
| 310 break; | 310 break; |
| 311 } | 311 } |
| 312 | 312 |
| 313 std::vector<GURL> update_urls; | 313 std::vector<GURL> update_urls; |
| 314 update_urls.push_back(update_url); | 314 update_urls.push_back(update_url); |
| 315 // If UMA is enabled, also add to ManifestFetchData for the | 315 // If UMA is enabled, also add to ManifestFetchData for the |
| 316 // webstore update URL. | 316 // webstore update URL. |
| 317 if (!extension_urls::IsWebstoreUpdateUrl(update_url) && | 317 if (!extension_urls::IsWebstoreUpdateUrl(update_url) && |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, | 772 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, |
| 773 const std::string& version) { | 773 const std::string& version) { |
| 774 UpdateDetails updateInfo(id, Version(version)); | 774 UpdateDetails updateInfo(id, Version(version)); |
| 775 content::NotificationService::current()->Notify( | 775 content::NotificationService::current()->Notify( |
| 776 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 776 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
| 777 content::NotificationService::AllBrowserContextsAndSources(), | 777 content::NotificationService::AllBrowserContextsAndSources(), |
| 778 content::Details<UpdateDetails>(&updateInfo)); | 778 content::Details<UpdateDetails>(&updateInfo)); |
| 779 } | 779 } |
| 780 | 780 |
| 781 } // namespace extensions | 781 } // namespace extensions |
| OLD | NEW |