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

Unified Diff: content/public/common/url_constants.cc

Issue 9950040: Get chrome:// dev tool urls hooked up in content_shell. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/public/common/url_constants.h ('k') | content/shell/shell_content_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/url_constants.cc
===================================================================
--- content/public/common/url_constants.cc (revision 133033)
+++ content/public/common/url_constants.cc (working copy)
@@ -4,7 +4,10 @@
#include "content/public/common/url_constants.h"
+#include <algorithm>
+
#include "base/string_util.h"
+#include "content/public/common/content_client.h"
#include "googleurl/src/url_util.h"
namespace {
@@ -19,6 +22,11 @@
NULL
};
char** g_savable_schemes = const_cast<char**>(kDefaultSavableSchemes);
+
+void AddStandardSchemeHelper(const std::string& scheme) {
+ url_util::AddStandardScheme(scheme.c_str());
+}
+
} // namespace
namespace chrome {
@@ -76,24 +84,33 @@
return const_cast<const char**>(g_savable_schemes);
}
-void RegisterContentSchemes(const char** additional_savable_schemes) {
+void RegisterContentSchemes(bool lock_standard_schemes) {
+ std::vector<std::string> additional_standard_schemes;
+ std::vector<std::string> additional_savable_schemes;
+ GetContentClient()->AddAdditionalSchemes(
+ &additional_standard_schemes,
+ &additional_savable_schemes);
+
// Don't need "chrome-internal" which was used in old versions of Chrome for
// the new tab page.
url_util::AddStandardScheme(chrome::kChromeDevToolsScheme);
url_util::AddStandardScheme(chrome::kChromeUIScheme);
url_util::AddStandardScheme(chrome::kMetadataScheme);
+ std::for_each(additional_standard_schemes.begin(),
+ additional_standard_schemes.end(),
+ AddStandardSchemeHelper);
// 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();
+ if (lock_standard_schemes)
+ 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]);
+ if (!additional_savable_schemes.empty()) {
+ int schemes = static_cast<int>(additional_savable_schemes.size());
// The array, and the copied schemes won't be freed, but will remain
// reachable.
g_savable_schemes = new char*[schemes + arraysize(kDefaultSavableSchemes)];
@@ -102,7 +119,7 @@
arraysize(kDefaultSavableSchemes) * sizeof(char*));
for (int i = 0; i < schemes; ++i) {
g_savable_schemes[arraysize(kDefaultSavableSchemes) + i - 1] =
- base::strdup(additional_savable_schemes[i]);
+ base::strdup(additional_savable_schemes[i].c_str());
}
g_savable_schemes[arraysize(kDefaultSavableSchemes) + schemes - 1] = 0;
}
« no previous file with comments | « content/public/common/url_constants.h ('k') | content/shell/shell_content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698