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

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

Issue 7743004: Move extension/webstore-related URL getters to the extension_urls namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension_constants.cc
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index cf234d1d8bd1b2d124600a36e9ba5eabcece817d..19b9632768cdbb35bbc5d9903c14afaba105dbef 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -4,9 +4,12 @@
#include "chrome/common/extensions/extension_constants.h"
+#include <vector>
+
#include "base/command_line.h"
#include "base/string_util.h"
#include "chrome/common/chrome_switches.h"
+#include "net/base/escape.h"
namespace extension_manifest_keys {
@@ -408,6 +411,48 @@ const char* kIllegalPlugins =
} // namespace extension_manifest_errors
namespace extension_urls {
+std::string GetWebstoreLaunchURL() {
+ std::string gallery_prefix = kGalleryBrowsePrefix;
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
+ gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kAppsGalleryURL);
+ if (EndsWith(gallery_prefix, "/", true))
+ gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
+ return gallery_prefix;
+}
+
+std::string GetWebstoreItemDetailURLPrefix() {
+ return GetWebstoreLaunchURL() + "/detail/";
+}
+
+const char* kGalleryUpdateHttpUrl =
+ "http://clients2.google.com/service/update2/crx";
+const char* kGalleryUpdateHttpsUrl =
+ "https://clients2.google.com/service/update2/crx";
+
+GURL GetWebstoreUpdateUrl(bool secure) {
+ CommandLine* cmdline = CommandLine::ForCurrentProcess();
+ if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
+ return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL));
+ else
+ return GURL(secure ? kGalleryUpdateHttpsUrl : kGalleryUpdateHttpUrl);
+}
+
+GURL GetWebstoreInstallUrl(const std::string& extension_id,
+ const std::string& locale) {
+ std::vector<std::string> params;
+ params.push_back("id=" + extension_id);
+ params.push_back("lang=" + locale);
+ params.push_back("uc");
+ std::string url_string = extension_urls::GetWebstoreUpdateUrl(true).spec();
+
+ GURL url(url_string + "?response=redirect&x=" +
+ EscapeQueryParamValue(JoinString(params, '&'), true));
+ DCHECK(url.is_valid());
+
+ return url;
+}
+
const char* kGalleryBrowsePrefix = "https://chrome.google.com/webstore";
const char* kMiniGalleryBrowsePrefix = "https://tools.google.com/chrome/";
const char* kMiniGalleryDownloadPrefix = "https://dl-ssl.google.com/chrome/";
@@ -436,18 +481,4 @@ const char* kAccessExtensionPath =
const char* kChromeVoxDirectoryName = "access_chromevox";
#endif
-std::string GetWebstoreLaunchURL() {
- std::string gallery_prefix = extension_urls::kGalleryBrowsePrefix;
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
- gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kAppsGalleryURL);
- if (EndsWith(gallery_prefix, "/", true))
- gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
- return gallery_prefix;
-}
-
-std::string GetWebstoreItemDetailURLPrefix() {
- return GetWebstoreLaunchURL() + "/detail/";
-}
-
}
« no previous file with comments | « chrome/common/extensions/extension_constants.h ('k') | chrome/renderer/extensions/chrome_webstore_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698