Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/extensions/updater/extension_downloader.cc

Issue 10444063: Fix for sync case in code forcing extension updates to use https (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698