Commit 9502c644 authored by thestig's avatar thestig Committed by Commit bot

Cleanup: Remove Dispatcher and UserScript classes from builds where extensions are disabled.

BUG=402728

Review URL: https://codereview.chromium.org/559103003

Cr-Commit-Position: refs/heads/master@{#294713}
parent c9e38a27
......@@ -148,10 +148,12 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
content::RenderFrame* render_frame,
const std::string& mime_type) OVERRIDE;
#if defined(ENABLE_EXTENSIONS)
// Takes ownership.
void SetExtensionDispatcherForTest(
extensions::Dispatcher* extension_dispatcher);
extensions::Dispatcher* GetExtensionDispatcherForTest();
#endif
#if defined(ENABLE_SPELLCHECK)
// Sets a new |spellcheck|. Used for testing only.
......@@ -165,8 +167,10 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
const blink::WebPluginParams& params,
const ChromeViewHostMsg_GetPluginInfo_Output& output);
#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
static bool IsExtensionOrSharedModuleWhitelisted(
const GURL& url, const std::set<std::string>& whitelist);
#endif
static bool WasWebRequestUsedBySomeExtensions();
......@@ -175,6 +179,7 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
ShouldSuppressErrorPage);
#if defined(ENABLE_EXTENSIONS)
// Gets extension by the given origin, regardless of whether the extension
// is active in the current process.
const extensions::Extension* GetExtensionByOrigin(
......@@ -187,6 +192,7 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
const extensions::ExtensionSet& extensions,
bool is_extension_url,
bool is_initial_navigation);
#endif
static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
const content::WebPluginInfo& plugin);
......@@ -201,10 +207,16 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_;
// TODO(thestig): Extract into a separate file if possible. Cleanup
// ENABLE_EXTENSIONS ifdefs in the .cc file as well.
#if defined(ENABLE_EXTENSIONS)
scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_;
scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
permissions_policy_delegate_;
#endif
scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_;
scoped_ptr<RendererNetPredictor> net_predictor_;
scoped_ptr<password_manager::CredentialManagerClient>
......
......@@ -25,8 +25,12 @@ ExtensionFrameHelper::~ExtensionFrameHelper() {
void ExtensionFrameHelper::WillReleaseScriptContext(
v8::Handle<v8::Context> context,
int world_id) {
// TODO(thestig): Remove scaffolding once this file no longer builds with
// extensions disabled.
#if defined(ENABLE_EXTENSIONS)
extension_dispatcher_->WillReleaseScriptContext(
render_frame()->GetWebFrame(), context, world_id);
#endif
}
bool ExtensionFrameHelper::OnMessageReceived(const IPC::Message& message) {
......
......@@ -46,11 +46,15 @@ bool RendererPermissionsPolicyDelegate::CanExecuteScriptOnPage(
return false;
}
// TODO(thestig): Remove scaffolding once this file no longer builds with
// extensions disabled.
#if defined(ENABLE_EXTENSIONS)
if (dispatcher_->IsExtensionActive(extensions::kWebStoreAppId)) {
if (error)
*error = errors::kCannotScriptGallery;
return false;
}
#endif
return true;
}
......
......@@ -89,8 +89,12 @@ int32_t PepperUMAHost::OnResourceMessageReceived(
}
bool PepperUMAHost::IsPluginWhitelisted() {
#if defined(ENABLE_EXTENSIONS)
return ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted(
document_url_, allowed_origins_);
#else
return false;
#endif
}
bool PepperUMAHost::IsHistogramAllowed(const std::string& histogram) {
......
......@@ -9,7 +9,6 @@
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h"
#include "chrome/renderer/spellchecker/spellcheck.h"
#include "chrome/test/base/chrome_unit_test_suite.h"
#include "components/autofill/content/renderer/autofill_agent.h"
......@@ -19,10 +18,6 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/renderer/render_view.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/extension.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/event_bindings.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
......@@ -31,6 +26,17 @@
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#if defined(ENABLE_EXTENSIONS)
#include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/extension.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/event_bindings.h"
#endif
using autofill::AutofillAgent;
using autofill::PasswordAutofillAgent;
using autofill::PasswordGenerationAgent;
using blink::WebFrame;
using blink::WebInputEvent;
using blink::WebMouseEvent;
......@@ -38,9 +44,6 @@ using blink::WebScriptController;
using blink::WebScriptSource;
using blink::WebString;
using blink::WebURLRequest;
using autofill::AutofillAgent;
using autofill::PasswordAutofillAgent;
using autofill::PasswordGenerationAgent;
ChromeRenderViewTest::ChromeRenderViewTest()
: password_autofill_(NULL),
......@@ -71,9 +74,11 @@ void ChromeRenderViewTest::SetUp() {
}
void ChromeRenderViewTest::TearDown() {
#if defined(ENABLE_EXTENSIONS)
ChromeContentRendererClient* client =
static_cast<ChromeContentRendererClient*>(content_renderer_client_.get());
client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown();
#endif
#if defined(LEAK_SANITIZER)
// Do this before shutting down V8 in RenderViewTest::TearDown().
......@@ -94,11 +99,13 @@ content::ContentBrowserClient*
content::ContentRendererClient*
ChromeRenderViewTest::CreateContentRendererClient() {
ChromeContentRendererClient* client = new ChromeContentRendererClient();
#if defined(ENABLE_EXTENSIONS)
extension_dispatcher_delegate_.reset(
new ChromeExtensionsDispatcherDelegate());
ChromeContentRendererClient* client = new ChromeContentRendererClient();
client->SetExtensionDispatcherForTest(
new extensions::Dispatcher(extension_dispatcher_delegate_.get()));
#endif
#if defined(ENABLE_SPELLCHECK)
client->SetSpellcheck(new SpellCheck());
#endif
......
......@@ -35,7 +35,9 @@ class ChromeRenderViewTest : public content::RenderViewTest {
virtual content::ContentRendererClient*
CreateContentRendererClient() OVERRIDE;
#if defined(ENABLE_EXTENSIONS)
scoped_ptr<extensions::DispatcherDelegate> extension_dispatcher_delegate_;
#endif
autofill::TestPasswordAutofillAgent* password_autofill_;
autofill::TestPasswordGenerationAgent* password_generation_;
......
......@@ -896,8 +896,16 @@
'sources!': [
'renderer/api_definitions_natives.cc',
'renderer/context_menus_custom_bindings.cc',
'renderer/dispatcher.cc',
'renderer/dispatcher.h',
'renderer/render_view_observer_natives.cc',
'renderer/send_request_natives.cc',
'renderer/user_script_injector.cc',
'renderer/user_script_injector.h',
'renderer/user_script_set.cc',
'renderer/user_script_set.h',
'renderer/user_script_set_manager.cc',
'renderer/user_script_set_manager.h',
],
}],
]
......
......@@ -163,8 +163,16 @@ source_set("renderer") {
sources -= [
"api_definitions_natives.cc",
"context_menus_custom_bindings.cc",
"dispatcher.cc",
"dispatcher.h",
"render_view_observer_natives.cc",
"send_request_natives.cc",
"user_script_injector.cc",
"user_script_injector.h",
"user_script_set.cc",
"user_script_set.h",
"user_script_set_manager.cc",
"user_script_set_manager.h",
]
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment