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

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

Issue 2506713002: Avoid parsing the webstore base url so much. (Closed)
Patch Set: fix chromeos 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
« no previous file with comments | « chrome/common/extensions/chrome_extensions_client.h ('k') | extensions/common/extension_urls.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9a4a929ae7b1dddc2643342e158c230cbd045d26..8ee8e509dadd5827271782d97c7d6284a96fce25 100644
--- a/chrome/common/extensions/chrome_extensions_client.cc
+++ b/chrome/common/extensions/chrome_extensions_client.cc
@@ -132,6 +132,9 @@ void ChromeExtensionsClient::Initialize() {
// TODO(dmazzoni): remove this once we have an extension API that
// allows any extension to request read-only access to webui pages.
scripting_whitelist_.push_back(extension_misc::kChromeVoxExtensionId);
+
+ webstore_base_url_ = GURL(extension_urls::kChromeWebstoreBaseURL);
+ webstore_update_url_ = GURL(extension_urls::GetDefaultWebstoreUpdateUrl());
}
const PermissionMessageProvider&
@@ -269,16 +272,17 @@ void ChromeExtensionsClient::RecordDidSuppressFatalError() {
NUM_CHANNELS_FOR_HISTOGRAM);
}
-std::string ChromeExtensionsClient::GetWebstoreBaseURL() const {
- std::string gallery_prefix = extension_urls::kChromeWebstoreBaseURL;
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAppsGalleryURL))
- gallery_prefix =
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kAppsGalleryURL);
- if (base::EndsWith(gallery_prefix, "/", base::CompareCase::SENSITIVE))
- gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
- return gallery_prefix;
+const GURL& ChromeExtensionsClient::GetWebstoreBaseURL() const {
+ // Browser tests like to alter the command line at runtime with new update
+ // URLs. Just update the cached value of the base url (to avoid reparsing
+ // it) if the value has changed.
+ base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
+ if (cmdline->HasSwitch(switches::kAppsGalleryURL)) {
+ std::string url = cmdline->GetSwitchValueASCII(switches::kAppsGalleryURL);
+ if (webstore_base_url_.possibly_invalid_spec() != url)
+ webstore_base_url_ = GURL(url);
+ }
+ return webstore_base_url_;
}
const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const {
@@ -289,10 +293,8 @@ const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const {
if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) {
std::string url =
cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL);
- if (webstore_update_url_ != url)
+ if (webstore_update_url_.possibly_invalid_spec() != url)
webstore_update_url_ = GURL(url);
- } else if (webstore_update_url_.is_empty()) {
- webstore_update_url_ = GURL(extension_urls::GetDefaultWebstoreUpdateUrl());
}
return webstore_update_url_;
}
« no previous file with comments | « chrome/common/extensions/chrome_extensions_client.h ('k') | extensions/common/extension_urls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698