diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 00:57:39 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 00:57:39 +0000 |
commit | 5af15b4961481876c87f5a32e0f50df8e7d060ce (patch) | |
tree | 12a79f7ad5d948f7bfa50a3dc7e05220ced4edac /content | |
parent | db4fd48ab5672dd485f8510a69d495bbb327fc4d (diff) | |
download | chromium_src-5af15b4961481876c87f5a32e0f50df8e7d060ce.zip chromium_src-5af15b4961481876c87f5a32e0f50df8e7d060ce.tar.gz chromium_src-5af15b4961481876c87f5a32e0f50df8e7d060ce.tar.bz2 |
Get chrome:// dev tool urls hooked up in content_shell.
Review URL: https://chromiumcodereview.appspot.com/9950040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/app/content_main_runner.cc | 4 | ||||
-rw-r--r-- | content/browser/resource_context_impl.cc | 4 | ||||
-rw-r--r-- | content/public/app/content_main_delegate.h | 10 | ||||
-rw-r--r-- | content/public/common/content_client.h | 6 | ||||
-rw-r--r-- | content/public/common/url_constants.cc | 29 | ||||
-rw-r--r-- | content/public/common/url_constants.h | 17 | ||||
-rw-r--r-- | content/shell/shell_content_client.cc | 5 | ||||
-rw-r--r-- | content/shell/shell_content_client.h | 6 | ||||
-rw-r--r-- | content/shell/shell_main_delegate.cc | 15 | ||||
-rw-r--r-- | content/test/content_test_suite.cc | 6 | ||||
-rw-r--r-- | content/test/test_content_client.cc | 5 | ||||
-rw-r--r-- | content/test/test_content_client.h | 6 |
12 files changed, 88 insertions, 25 deletions
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index d19499f..7de0a61 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -27,6 +27,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" #include "content/public/common/sandbox_init.h" +#include "content/public/common/url_constants.h" #include "crypto/nss_util.h" #include "ipc/ipc_switches.h" #include "media/base/media.h" @@ -383,6 +384,8 @@ class ContentMainRunnerImpl : public content::ContentMainRunner { int exit_code; if (delegate && delegate->BasicStartupComplete(&exit_code)) return exit_code; + DCHECK(!delegate || content::GetContentClient()) << + "BasicStartupComplete didn't set the content client"; completed_basic_startup_ = true; @@ -444,6 +447,7 @@ class ContentMainRunnerImpl : public content::ContentMainRunner { ui::RegisterPathProvider(); content::RegisterPathProvider(); + content::RegisterContentSchemes(true); CHECK(icu_util::Initialize()); diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc index fa3fa7e..d3f9da6 100644 --- a/content/browser/resource_context_impl.cc +++ b/content/browser/resource_context_impl.cc @@ -123,6 +123,10 @@ class DeveloperProtocolHandler return NULL; } + virtual bool WillHandleProtocol(const std::string& protocol) const { + return protocol == chrome::kChromeUIScheme; + } + private: AppCacheService* appcache_service_; BlobStorageController* blob_storage_controller_; diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h index c7c6bd6..7a59472 100644 --- a/content/public/app/content_main_delegate.h +++ b/content/public/app/content_main_delegate.h @@ -19,11 +19,11 @@ class ContentMainDelegate { public: virtual ~ContentMainDelegate() {} - // Tells the embedder that the absolute basic startup has been done, i.e. it's - // now safe to create singletons and check the command line. Return true if - // the process should exit afterwards, and if so, |exit_code| should be set. - // This is the place for embedder to do the things that must happen at the - // start. Most of its startup code should be in the methods below. + // Tells the embedder that the absolute basic startup has been done, i.e. + // it's now safe to create singletons and check the command line. Return true + // if the process should exit afterwards, and if so, |exit_code| should be + // set. This is the place for embedder to do the things that must happen at + // the start. Most of its startup code should be in the methods below. virtual bool BasicStartupComplete(int* exit_code) = 0; // This is where the embedder puts all of its startup code that needs to run diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h index e43fc6e..1371641 100644 --- a/content/public/common/content_client.h +++ b/content/public/common/content_client.h @@ -94,6 +94,12 @@ class CONTENT_EXPORT ContentClient { virtual void AddNPAPIPlugins( webkit::npapi::PluginList* plugin_list) = 0; + // Gives the embedder a chance to register its own standard and saveable + // url schemes early on in the startup sequence. + virtual void AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* savable_schemes) = 0; + // Returns true if the url has a scheme for WebUI. See also // WebUIControllerFactory::UseWebUIForURL in the browser process. virtual bool HasWebUIScheme(const GURL& url) const = 0; diff --git a/content/public/common/url_constants.cc b/content/public/common/url_constants.cc index 806e9ed..0ee514b 100644 --- a/content/public/common/url_constants.cc +++ b/content/public/common/url_constants.cc @@ -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 @@ const char* kDefaultSavableSchemes[] = { 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 @@ const char** GetSavableSchemes() { 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 @@ void RegisterContentSchemes(const char** additional_savable_schemes) { 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; } diff --git a/content/public/common/url_constants.h b/content/public/common/url_constants.h index dedb3fe..893e511 100644 --- a/content/public/common/url_constants.h +++ b/content/public/common/url_constants.h @@ -66,12 +66,17 @@ extern const char kSwappedOutURL[]; // invoked on any thread. CONTENT_EXPORT const char** GetSavableSchemes(); -// Call near the beginning of startup to register the content layer's internal -// URLs that should be parsed as "standard" with the googleurl library. The -// embedder can pass a 0-terminated list of additional schemes that should be -// savable, or NULL if the standard list is sufficient. -CONTENT_EXPORT void RegisterContentSchemes( - const char** additional_savable_schemes); +// Note: ContentMainRunner calls this method internally as part of main +// initialziation, so this function generally should not be called by +// embedders. It's exported to facilitate test harnesses that do not +// utilize ContentMainRunner and that do not wish to lock the set +// of standard schemes at init time. +// +// Called near the beginning of startup to register URL schemes that should +// be parsed as "standard" with the googleurl library. Optionally, the set +// of standard schemes is locked down. The embedder can add additional +// schemes by overriding the ContentClient::AddAdditionalSchemes method. +CONTENT_EXPORT void RegisterContentSchemes(bool lock_standard_schemes); } // namespace content diff --git a/content/shell/shell_content_client.cc b/content/shell/shell_content_client.cc index 61004fe..64ee8ea 100644 --- a/content/shell/shell_content_client.cc +++ b/content/shell/shell_content_client.cc @@ -27,6 +27,11 @@ void ShellContentClient::AddNPAPIPlugins( webkit::npapi::PluginList* plugin_list) { } +void ShellContentClient::AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* savable_schemes) { +} + bool ShellContentClient::HasWebUIScheme(const GURL& url) const { // There are no WebUI URLs in content_shell. return false; diff --git a/content/shell/shell_content_client.h b/content/shell/shell_content_client.h index a7abbf34..6a740af 100644 --- a/content/shell/shell_content_client.h +++ b/content/shell/shell_content_client.h @@ -6,6 +6,9 @@ #define CONTENT_SHELL_SHELL_CONTENT_CLIENT_H_ #pragma once +#include <string> +#include <vector> + #include "base/compiler_specific.h" #include "content/public/common/content_client.h" @@ -21,6 +24,9 @@ class ShellContentClient : public ContentClient { std::vector<content::PepperPluginInfo>* plugins) OVERRIDE; virtual void AddNPAPIPlugins( webkit::npapi::PluginList* plugin_list) OVERRIDE; + virtual void AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* savable_schemes) OVERRIDE; virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE; virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; diff --git a/content/shell/shell_main_delegate.cc b/content/shell/shell_main_delegate.cc index 031f031..06e2907 100644 --- a/content/shell/shell_main_delegate.cc +++ b/content/shell/shell_main_delegate.cc @@ -8,6 +8,7 @@ #include "base/file_path.h" #include "base/path_service.h" #include "content/public/common/content_switches.h" +#include "content/public/common/url_constants.h" #include "content/shell/shell_browser_main.h" #include "content/shell/shell_content_browser_client.h" #include "content/shell/shell_content_plugin_client.h" @@ -30,6 +31,12 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { #if defined(OS_MACOSX) OverrideFrameworkBundlePath(); #endif + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + std::string process_type = + command_line.GetSwitchValueASCII(switches::kProcessType); + content::SetContentClient(&content_client_); + InitializeShellContentClient(process_type); + return false; } @@ -37,14 +44,6 @@ void ShellMainDelegate::PreSandboxStartup() { #if defined(OS_MACOSX) OverrideChildProcessPath(); #endif // OS_MACOSX - - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - std::string process_type = - command_line.GetSwitchValueASCII(switches::kProcessType); - - content::SetContentClient(&content_client_); - InitializeShellContentClient(process_type); - InitializeResourceBundle(); } diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc index be090fe..4272a9c 100644 --- a/content/test/content_test_suite.cc +++ b/content/test/content_test_suite.cc @@ -10,6 +10,7 @@ #include "content/browser/notification_service_impl.h" #include "content/public/common/content_client.h" #include "content/public/common/content_paths.h" +#include "content/public/common/url_constants.h" #include "content/test/test_content_client.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/ui_base_paths.h" @@ -71,6 +72,11 @@ void ContentTestSuite::Initialize() { base::TestSuite::Initialize(); + TestContentClient client_for_init; + content::SetContentClient(&client_for_init); + content::RegisterContentSchemes(false); + content::SetContentClient(NULL); + content::RegisterPathProvider(); ui::RegisterPathProvider(); diff --git a/content/test/test_content_client.cc b/content/test/test_content_client.cc index c62e662..b59e962 100644 --- a/content/test/test_content_client.cc +++ b/content/test/test_content_client.cc @@ -35,6 +35,11 @@ void TestContentClient::AddNPAPIPlugins( webkit::npapi::PluginList* plugin_list) { } +void TestContentClient::AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* savable_schemes) { +} + bool TestContentClient::HasWebUIScheme(const GURL& url) const { return false; } diff --git a/content/test/test_content_client.h b/content/test/test_content_client.h index d540e4e..24b866a 100644 --- a/content/test/test_content_client.h +++ b/content/test/test_content_client.h @@ -6,6 +6,9 @@ #define CONTENT_TEST_TEST_CONTENT_CLIENT_H_ #pragma once +#include <string> +#include <vector> + #include "base/compiler_specific.h" #include "content/public/common/content_client.h" #include "ui/base/resource/data_pack.h" @@ -22,6 +25,9 @@ class TestContentClient : public content::ContentClient { std::vector<content::PepperPluginInfo>* plugins) OVERRIDE; virtual void AddNPAPIPlugins( webkit::npapi::PluginList* plugin_list) OVERRIDE; + virtual void AddAdditionalSchemes( + std::vector<std::string>* standard_schemes, + std::vector<std::string>* savable_schemes) OVERRIDE; virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE; virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; |