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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return false; | 143 return false; |
144 } | 144 } |
145 | 145 |
146 // If the extension updates itself from the gallery, ignore any update URL | 146 // If the extension updates itself from the gallery, ignore any update URL |
147 // data. At the moment there is no extra data that an extension can | 147 // data. At the moment there is no extra data that an extension can |
148 // communicate to the the gallery update servers. | 148 // communicate to the the gallery update servers. |
149 std::string update_url_data; | 149 std::string update_url_data; |
150 if (!extension.UpdatesFromGallery()) | 150 if (!extension.UpdatesFromGallery()) |
151 update_url_data = delegate_->GetUpdateUrlData(extension.id()); | 151 update_url_data = delegate_->GetUpdateUrlData(extension.id()); |
152 | 152 |
153 // Make sure we use SSL for store-hosted extensions. | |
154 GURL update_url = extension.update_url(); | |
155 if (extension.UpdatesFromGallery() && !update_url.SchemeIsSecure()) | |
156 update_url = extension_urls::GetWebstoreUpdateUrl(); | |
157 | |
158 return AddExtensionData(extension.id(), *extension.version(), | 153 return AddExtensionData(extension.id(), *extension.version(), |
159 extension.GetType(), update_url, | 154 extension.GetType(), extension.update_url(), |
160 update_url_data); | 155 update_url_data); |
161 } | 156 } |
162 | 157 |
163 bool ExtensionDownloader::AddPendingExtension(const std::string& id, | 158 bool ExtensionDownloader::AddPendingExtension(const std::string& id, |
164 const GURL& update_url) { | 159 const GURL& update_url) { |
165 // Use a zero version to ensure that a pending extension will always | 160 // Use a zero version to ensure that a pending extension will always |
166 // be updated, and thus installed (assuming all extensions have | 161 // be updated, and thus installed (assuming all extensions have |
167 // non-zero versions). | 162 // non-zero versions). |
168 Version version("0.0.0.0"); | 163 Version version("0.0.0.0"); |
169 DCHECK(version.IsValid()); | 164 DCHECK(version.IsValid()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 Extension::Type extension_type, | 199 Extension::Type extension_type, |
205 GURL update_url, | 200 GURL update_url, |
206 const std::string& update_url_data) { | 201 const std::string& update_url_data) { |
207 // Skip extensions with non-empty invalid update URLs. | 202 // Skip extensions with non-empty invalid update URLs. |
208 if (!update_url.is_empty() && !update_url.is_valid()) { | 203 if (!update_url.is_empty() && !update_url.is_valid()) { |
209 LOG(WARNING) << "Extension " << id << " has invalid update url " | 204 LOG(WARNING) << "Extension " << id << " has invalid update url " |
210 << update_url; | 205 << update_url; |
211 return false; | 206 return false; |
212 } | 207 } |
213 | 208 |
214 // Double-check that we're using https for webstore urls. | 209 // Make sure we use SSL for store-hosted extensions. |
215 if (extension_urls::IsWebstoreUpdateUrl(update_url) && | 210 if (extension_urls::IsWebstoreUpdateUrl(update_url) && |
216 !update_url.SchemeIsSecure() && | 211 !update_url.SchemeIsSecure()) |
217 extension_urls::GetWebstoreUpdateUrl().SchemeIsSecure()) { | 212 update_url = extension_urls::GetWebstoreUpdateUrl(); |
218 NOTREACHED() << "Refusing to send non-secure update check for " << id | |
219 << " (" << update_url.spec() << ")"; | |
220 return false; | |
221 } | |
222 | 213 |
223 // Skip extensions with empty IDs. | 214 // Skip extensions with empty IDs. |
224 if (id.empty()) { | 215 if (id.empty()) { |
225 LOG(WARNING) << "Found extension with empty ID"; | 216 LOG(WARNING) << "Found extension with empty ID"; |
226 return false; | 217 return false; |
227 } | 218 } |
228 | 219 |
229 if (update_url.DomainIs("google.com")) { | 220 if (update_url.DomainIs("google.com")) { |
230 url_stats_.google_url_count++; | 221 url_stats_.google_url_count++; |
231 } else if (update_url.is_empty()) { | 222 } else if (update_url.is_empty()) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 656 } |
666 | 657 |
667 void ExtensionDownloader::NotifyUpdateFound(const std::string& id) { | 658 void ExtensionDownloader::NotifyUpdateFound(const std::string& id) { |
668 content::NotificationService::current()->Notify( | 659 content::NotificationService::current()->Notify( |
669 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 660 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
670 content::NotificationService::AllBrowserContextsAndSources(), | 661 content::NotificationService::AllBrowserContextsAndSources(), |
671 content::Details<const std::string>(&id)); | 662 content::Details<const std::string>(&id)); |
672 } | 663 } |
673 | 664 |
674 } // namespace extensions | 665 } // namespace extensions |
OLD | NEW |