| 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" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/scoped_handle.h" | 15 #include "base/memory/scoped_handle.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/platform_file.h" | 17 #include "base/platform_file.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 20 #include "base/time.h" | 20 #include "base/time.h" |
| 21 #include "base/version.h" | 21 #include "base/version.h" |
| 22 #include "chrome/browser/extensions/updater/request_queue_impl.h" | 22 #include "chrome/browser/extensions/updater/request_queue_impl.h" |
| 23 #include "chrome/browser/extensions/updater/safe_manifest_parser.h" | 23 #include "chrome/browser/extensions/updater/safe_manifest_parser.h" |
| 24 #include "chrome/browser/metrics/metrics_service.h" | 24 #include "chrome/browser/metrics/metrics_service.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/chrome_version_info.h" | 27 #include "chrome/common/chrome_version_info.h" |
| 28 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
| 29 #include "chrome/common/extensions/manifest_url_info.h" |
| 29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
| 31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 32 #include "net/base/backoff_entry.h" | 33 #include "net/base/backoff_entry.h" |
| 33 #include "net/base/load_flags.h" | 34 #include "net/base/load_flags.h" |
| 34 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
| 35 #include "net/url_request/url_fetcher.h" | 36 #include "net/url_request/url_fetcher.h" |
| 36 #include "net/url_request/url_request_status.h" | 37 #include "net/url_request/url_request_status.h" |
| 37 | 38 |
| 38 using base::Time; | 39 using base::Time; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 DCHECK(request_context_); | 187 DCHECK(request_context_); |
| 187 } | 188 } |
| 188 | 189 |
| 189 ExtensionDownloader::~ExtensionDownloader() {} | 190 ExtensionDownloader::~ExtensionDownloader() {} |
| 190 | 191 |
| 191 bool ExtensionDownloader::AddExtension(const Extension& extension, | 192 bool ExtensionDownloader::AddExtension(const Extension& extension, |
| 192 int request_id) { | 193 int request_id) { |
| 193 // Skip extensions with empty update URLs converted from user | 194 // Skip extensions with empty update URLs converted from user |
| 194 // scripts. | 195 // scripts. |
| 195 if (extension.converted_from_user_script() && | 196 if (extension.converted_from_user_script() && |
| 196 extension.update_url().is_empty()) { | 197 ManifestURLInfo::GetUpdateURL(&extension).is_empty()) { |
| 197 return false; | 198 return false; |
| 198 } | 199 } |
| 199 | 200 |
| 200 // If the extension updates itself from the gallery, ignore any update URL | 201 // If the extension updates itself from the gallery, ignore any update URL |
| 201 // data. At the moment there is no extra data that an extension can | 202 // data. At the moment there is no extra data that an extension can |
| 202 // communicate to the the gallery update servers. | 203 // communicate to the the gallery update servers. |
| 203 std::string update_url_data; | 204 std::string update_url_data; |
| 204 if (!extension.UpdatesFromGallery()) | 205 if (!extension.UpdatesFromGallery()) |
| 205 update_url_data = delegate_->GetUpdateUrlData(extension.id()); | 206 update_url_data = delegate_->GetUpdateUrlData(extension.id()); |
| 206 | 207 |
| 207 return AddExtensionData(extension.id(), *extension.version(), | 208 return AddExtensionData(extension.id(), *extension.version(), |
| 208 extension.GetType(), extension.update_url(), | 209 extension.GetType(), |
| 210 ManifestURLInfo::GetUpdateURL(&extension), |
| 209 update_url_data, request_id); | 211 update_url_data, request_id); |
| 210 } | 212 } |
| 211 | 213 |
| 212 bool ExtensionDownloader::AddPendingExtension(const std::string& id, | 214 bool ExtensionDownloader::AddPendingExtension(const std::string& id, |
| 213 const GURL& update_url, | 215 const GURL& update_url, |
| 214 int request_id) { | 216 int request_id) { |
| 215 // 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 |
| 216 // be updated, and thus installed (assuming all extensions have | 218 // be updated, and thus installed (assuming all extensions have |
| 217 // non-zero versions). | 219 // non-zero versions). |
| 218 Version version("0.0.0.0"); | 220 Version version("0.0.0.0"); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, | 772 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, |
| 771 const std::string& version) { | 773 const std::string& version) { |
| 772 UpdateDetails updateInfo(id, Version(version)); | 774 UpdateDetails updateInfo(id, Version(version)); |
| 773 content::NotificationService::current()->Notify( | 775 content::NotificationService::current()->Notify( |
| 774 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 776 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
| 775 content::NotificationService::AllBrowserContextsAndSources(), | 777 content::NotificationService::AllBrowserContextsAndSources(), |
| 776 content::Details<UpdateDetails>(&updateInfo)); | 778 content::Details<UpdateDetails>(&updateInfo)); |
| 777 } | 779 } |
| 778 | 780 |
| 779 } // namespace extensions | 781 } // namespace extensions |
| OLD | NEW |