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

Unified Diff: chrome/common/extensions/chrome_extensions_client.cc

Issue 2493053002: [extensions] Stop parsing webstore urls so much (Closed)
Patch Set: still need to check cmd line every time :( Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/chrome_extensions_client.cc
diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc
index b999102c9fe82780c133755f5158d9a46ab26588..ae3e5c05ee1e9a6f6dd5b7db58f75d84856da9b3 100644
--- a/chrome/common/extensions/chrome_extensions_client.cc
+++ b/chrome/common/extensions/chrome_extensions_client.cc
@@ -281,12 +281,20 @@ std::string ChromeExtensionsClient::GetWebstoreBaseURL() const {
return gallery_prefix;
}
-std::string ChromeExtensionsClient::GetWebstoreUpdateURL() const {
+const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const {
+ // Browser tests like to alter the command line at runtime with new update
Devlin 2016/11/11 23:11:30 :(
+ // URLs. Just update the cached value of the update url (to avoid reparsing
+ // it) if the value has changed.
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
- return cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL);
- else
- return extension_urls::GetDefaultWebstoreUpdateUrl().spec();
+ if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) {
+ std::string url =
+ cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL);
+ if (webstore_update_url_ != url)
+ webstore_update_url_ = GURL(url);
+ } else if (webstore_update_url_.is_empty()) {
+ webstore_update_url_ = GURL(extension_urls::GetDefaultWebstoreUpdateUrl());
+ }
+ return webstore_update_url_;
}
bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const {

Powered by Google App Engine
This is Rietveld 408576698