Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/extensions/chrome_extensions_client.h" | 5 #include "chrome/common/extensions/chrome_extensions_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 274 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 275 switches::kAppsGalleryURL)) | 275 switches::kAppsGalleryURL)) |
| 276 gallery_prefix = | 276 gallery_prefix = |
| 277 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 277 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 278 switches::kAppsGalleryURL); | 278 switches::kAppsGalleryURL); |
| 279 if (base::EndsWith(gallery_prefix, "/", base::CompareCase::SENSITIVE)) | 279 if (base::EndsWith(gallery_prefix, "/", base::CompareCase::SENSITIVE)) |
| 280 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); | 280 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); |
| 281 return gallery_prefix; | 281 return gallery_prefix; |
| 282 } | 282 } |
| 283 | 283 |
| 284 std::string ChromeExtensionsClient::GetWebstoreUpdateURL() const { | 284 const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const { |
| 285 // Browser tests like to alter the command line at runtime with new update | |
|
Devlin
2016/11/11 23:11:30
:(
| |
| 286 // URLs. Just update the cached value of the update url (to avoid reparsing | |
| 287 // it) if the value has changed. | |
| 285 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 288 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 286 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) | 289 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) { |
| 287 return cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL); | 290 std::string url = |
| 288 else | 291 cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL); |
| 289 return extension_urls::GetDefaultWebstoreUpdateUrl().spec(); | 292 if (webstore_update_url_ != url) |
| 293 webstore_update_url_ = GURL(url); | |
| 294 } else if (webstore_update_url_.is_empty()) { | |
| 295 webstore_update_url_ = GURL(extension_urls::GetDefaultWebstoreUpdateUrl()); | |
| 296 } | |
| 297 return webstore_update_url_; | |
| 290 } | 298 } |
| 291 | 299 |
| 292 bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { | 300 bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { |
| 293 // The extension blacklist URL is returned from the update service and | 301 // The extension blacklist URL is returned from the update service and |
| 294 // therefore not determined by Chromium. If the location of the blacklist file | 302 // therefore not determined by Chromium. If the location of the blacklist file |
| 295 // ever changes, we need to update this function. A DCHECK in the | 303 // ever changes, we need to update this function. A DCHECK in the |
| 296 // ExtensionUpdater ensures that we notice a change. This is the full URL | 304 // ExtensionUpdater ensures that we notice a change. This is the full URL |
| 297 // of a blacklist: | 305 // of a blacklist: |
| 298 // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt | 306 // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt |
| 299 return base::StartsWith(url.spec(), kExtensionBlocklistUrlPrefix, | 307 return base::StartsWith(url.spec(), kExtensionBlocklistUrlPrefix, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 const { | 342 const { |
| 335 return GetCurrentChannel() == version_info::Channel::UNKNOWN; | 343 return GetCurrentChannel() == version_info::Channel::UNKNOWN; |
| 336 } | 344 } |
| 337 | 345 |
| 338 // static | 346 // static |
| 339 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 347 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
| 340 return g_client.Pointer(); | 348 return g_client.Pointer(); |
| 341 } | 349 } |
| 342 | 350 |
| 343 } // namespace extensions | 351 } // namespace extensions |
| OLD | NEW |