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

Unified Diff: content/common/url_constants.cc

Issue 8159006: Move kExtensionScheme from content to chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 2 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
« no previous file with comments | « content/common/url_constants.h ('k') | content/renderer/render_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/url_constants.cc
diff --git a/content/common/url_constants.cc b/content/common/url_constants.cc
index 065ea079a3efd283824b14497dadeeb34b5a13ce..442b52d7e2fea0514dbbb1c5539ff310348e88de 100644
--- a/content/common/url_constants.cc
+++ b/content/common/url_constants.cc
@@ -4,20 +4,23 @@
#include "content/common/url_constants.h"
-#include <stdio.h>
+#include "base/string_util.h"
+#include "googleurl/src/url_util.h"
-namespace chrome {
-
-const char* kSavableSchemes[] = {
- kHttpScheme,
- kHttpsScheme,
- kFileScheme,
- kFtpScheme,
- kExtensionScheme,
- kChromeDevToolsScheme,
- kChromeUIScheme,
+namespace {
+const char* kDefaultSavableSchemes[] = {
+ chrome::kHttpScheme,
+ chrome::kHttpsScheme,
+ chrome::kFileScheme,
+ chrome::kFtpScheme,
+ chrome::kChromeDevToolsScheme,
+ chrome::kChromeUIScheme,
NULL
};
+char** g_savable_schemes = const_cast<char**>(kDefaultSavableSchemes);
+} // namespace
+
+namespace chrome {
const char kAboutScheme[] = "about";
const char kBlobScheme[] = "blob";
@@ -28,7 +31,6 @@ const char kChromeDevToolsScheme[] = "chrome-devtools";
const char kChromeInternalScheme[] = "chrome-internal";
const char kChromeUIScheme[] = "chrome";
const char kDataScheme[] = "data";
-const char kExtensionScheme[] = "chrome-extension";
const char kFileScheme[] = "file";
const char kFileSystemScheme[] = "filesystem";
const char kFtpScheme[] = "ftp";
@@ -46,4 +48,40 @@ const char kAboutCrashURL[] = "about:crash";
const char kUnreachableWebDataURL[] = "chrome://chromewebdata/";
+const char** GetSavableSchemes() {
+ return const_cast<const char**>(g_savable_schemes);
+}
+
+void RegisterContentSchemes(const char** additional_savable_schemes) {
+ // Don't need "chrome-internal" which was used in old versions of Chrome for
+ // the new tab page.
+ url_util::AddStandardScheme(kChromeDevToolsScheme);
+ url_util::AddStandardScheme(kChromeUIScheme);
+ url_util::AddStandardScheme(kMetadataScheme);
+
+ // Prevent future modification of the standard schemes list. This is to
+ // prevent accidental creation of data races in the program. AddStandardScheme
+ // isn't threadsafe so must be called when GURL isn't used on any other
+ // thread. This is really easy to mess up, so we say that all calls to
+ // AddStandardScheme in Chrome must be inside this function.
+ url_util::LockStandardSchemes();
+
+ // We rely on the above lock to protect this part from being invoked twice.
+ if (additional_savable_schemes) {
+ int schemes = 0;
+ while (additional_savable_schemes[++schemes]);
+ // The array, and the copied schemes won't be freed, but will remain
+ // reachable.
+ g_savable_schemes = new char*[schemes + arraysize(kDefaultSavableSchemes)];
+ memcpy(g_savable_schemes,
+ kDefaultSavableSchemes,
+ arraysize(kDefaultSavableSchemes) * sizeof(char*));
+ for (int i = 0; i < schemes; ++i) {
+ g_savable_schemes[arraysize(kDefaultSavableSchemes) + i - 1] =
+ base::strdup(additional_savable_schemes[i]);
+ }
+ g_savable_schemes[arraysize(kDefaultSavableSchemes) + schemes - 1] = 0;
+ }
+}
+
} // namespace chrome
« no previous file with comments | « content/common/url_constants.h ('k') | content/renderer/render_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698