summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/DEPS1
-rw-r--r--chrome/app/chrome_main.cc31
-rw-r--r--chrome/browser/visitedlink/visitedlink_unittest.cc10
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/chrome_dll.gypi1
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/chrome_content_client.cc4
-rw-r--r--chrome/common/chrome_content_client.h1
-rw-r--r--chrome/common/chrome_content_gpu_client.cc15
-rw-r--r--chrome/common/chrome_content_gpu_client.h20
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc206
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h34
-rw-r--r--chrome/renderer/extensions/chrome_app_bindings.cc43
-rw-r--r--chrome/renderer/extensions/chrome_app_bindings.h4
-rw-r--r--chrome/renderer/extensions/event_bindings.cc7
-rw-r--r--chrome/renderer/extensions/event_bindings.h4
-rw-r--r--chrome/renderer/extensions/extension_dispatcher.cc17
-rw-r--r--chrome/renderer/extensions/extension_dispatcher.h7
-rw-r--r--chrome/renderer/extensions/extension_helper.cc13
-rw-r--r--chrome/renderer/extensions/extension_helper.h6
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc27
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.h3
-rw-r--r--chrome/renderer/extensions/user_script_idle_scheduler.cc13
-rw-r--r--chrome/renderer/extensions/user_script_idle_scheduler.h6
-rw-r--r--chrome/renderer/render_thread.cc182
-rw-r--r--chrome/renderer/render_thread.h47
-rw-r--r--chrome/renderer/render_thread_unittest.cc63
-rw-r--r--chrome/renderer/safe_browsing/phishing_classifier_delegate.cc12
-rw-r--r--chrome/renderer/safe_browsing/phishing_classifier_delegate.h9
-rw-r--r--chrome/renderer/safe_browsing/render_view_fake_resources_test.cc1
-rw-r--r--chrome/renderer/safe_browsing/render_view_fake_resources_test.h2
-rw-r--r--chrome/renderer/spellchecker/spellcheck.cc60
-rw-r--r--chrome/renderer/spellchecker/spellcheck.h27
-rw-r--r--chrome/renderer/spellchecker/spellcheck_provider.cc19
-rw-r--r--chrome/renderer/spellchecker/spellcheck_provider.h7
-rw-r--r--chrome/renderer/spellchecker/spellcheck_unittest.cc6
-rw-r--r--chrome/renderer/visitedlink_slave.cc40
-rw-r--r--chrome/renderer/visitedlink_slave.h16
-rw-r--r--chrome/test/render_view_test.cc4
-rw-r--r--content/common/content_client.cc2
-rw-r--r--content/common/content_client.h9
-rw-r--r--content/common/gpu/content_gpu_client.h24
-rw-r--r--content/content_common.gypi1
-rw-r--r--content/gpu/gpu_child_thread.cc4
-rw-r--r--content/renderer/DEPS1
-rw-r--r--content/renderer/content_renderer_client.cc14
-rw-r--r--content/renderer/content_renderer_client.h11
-rw-r--r--content/renderer/render_view.cc22
-rw-r--r--content/renderer/render_view.h4
-rw-r--r--content/renderer/renderer_webkitclient_impl.cc5
-rw-r--r--webkit/glue/context_menu.cc8
51 files changed, 505 insertions, 571 deletions
diff --git a/chrome/app/DEPS b/chrome/app/DEPS
index 95afdc9..3f22131 100644
--- a/chrome/app/DEPS
+++ b/chrome/app/DEPS
@@ -2,6 +2,7 @@ include_rules = [
"+breakpad",
"+chrome/browser",
"+chrome/installer",
+ "+chrome/renderer", # For ChromeContentRendererClient
"+grit", # For generated headers
"+policy", # For generated headers and source
"+sandbox",
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index 0f9d663..bf2e210 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/platform_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_content_client.h"
-#include "chrome/common/chrome_content_gpu_client.h"
#include "chrome/common/chrome_content_plugin_client.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_paths.h"
@@ -35,6 +34,7 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/profiling.h"
#include "chrome/common/url_constants.h"
+#include "chrome/renderer/chrome_content_renderer_client.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/common/content_client.h"
#include "content/common/content_paths.h"
@@ -217,9 +217,21 @@ void EnableHeapProfiler(const CommandLine& command_line) {
#endif
}
-void InitializeChromeContentGpuClient() {
- static chrome::ChromeContentGpuClient chrome_content_gpu_client;
- content::GetContentClient()->set_gpu(&chrome_content_gpu_client);
+void InitializeChromeContentRendererClient() {
+#if !defined(NACL_WIN64) // We don't build the renderer code on win nacl64.
+ static chrome::ChromeContentRendererClient chrome_content_renderer_client;
+ content::GetContentClient()->set_renderer(&chrome_content_renderer_client);
+#endif
+}
+
+void InitializeChromeContentClient(const std::string& process_type) {
+ if (process_type == switches::kPluginProcess) {
+ static chrome::ChromeContentPluginClient chrome_content_plugin_client;
+ content::GetContentClient()->set_plugin(&chrome_content_plugin_client);
+ } else if (process_type == switches::kRendererProcess ||
+ process_type == switches::kExtensionProcess) {
+ InitializeChromeContentRendererClient();
+ }
}
void CommonSubprocessInit(const std::string& process_type) {
@@ -243,12 +255,7 @@ void CommonSubprocessInit(const std::string& process_type) {
setlocale(LC_NUMERIC, "C");
#endif
- if (process_type == switches::kPluginProcess) {
- static chrome::ChromeContentPluginClient chrome_content_plugin_client;
- content::GetContentClient()->set_plugin(&chrome_content_plugin_client);
- } else if (process_type == switches::kGpuProcess) {
- InitializeChromeContentGpuClient();
- }
+ InitializeChromeContentClient(process_type);
}
// Returns true if this subprocess type needs the ResourceBundle initialized
@@ -432,6 +439,8 @@ int RunZygote(const MainFunctionParams& main_function_params) {
InitCrashReporter();
#endif
+ InitializeChromeContentClient(process_type);
+
for (size_t i = 0; i < arraysize(kMainFunctions); ++i) {
if (process_type == kMainFunctions[i].name)
return kMainFunctions[i].function(main_params);
@@ -699,7 +708,7 @@ int ChromeMain(int argc, char** argv) {
InitWebCoreSystemInterface();
#endif
- InitializeChromeContentGpuClient();
+ InitializeChromeContentRendererClient();
}
#endif // GOOGLE_CHROME_BUILD
diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc
index dd7aa83..88acc78 100644
--- a/chrome/browser/visitedlink/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink/visitedlink_unittest.cc
@@ -51,7 +51,7 @@ class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener {
i < g_slaves.size(); i++) {
base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
- g_slaves[i]->Init(new_handle);
+ g_slaves[i]->OnUpdateVisitedLinks(new_handle);
}
}
}
@@ -134,8 +134,7 @@ class VisitedLinkTest : public testing::Test {
base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
master_->shared_memory()->ShareToProcess(
base::GetCurrentProcessHandle(), &new_handle);
- bool success = slave.Init(new_handle);
- ASSERT_TRUE(success);
+ slave.OnUpdateVisitedLinks(new_handle);
g_slaves.push_back(&slave);
bool found;
@@ -276,7 +275,7 @@ TEST_F(VisitedLinkTest, DeleteAll) {
base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
master_->shared_memory()->ShareToProcess(
base::GetCurrentProcessHandle(), &new_handle);
- ASSERT_TRUE(slave.Init(new_handle));
+ slave.OnUpdateVisitedLinks(new_handle);
g_slaves.push_back(&slave);
// Add the test URLs.
@@ -325,8 +324,7 @@ TEST_F(VisitedLinkTest, Resizing) {
base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
master_->shared_memory()->ShareToProcess(
base::GetCurrentProcessHandle(), &new_handle);
- bool success = slave.Init(new_handle);
- ASSERT_TRUE(success);
+ slave.OnUpdateVisitedLinks(new_handle);
g_slaves.push_back(&slave);
int32 used_count = master_->GetUsedCount();
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index c0649f3..bd02135 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -140,8 +140,6 @@
'common/badge_util.h',
'common/chrome_content_client.cc',
'common/chrome_content_client.h',
- 'common/chrome_content_gpu_client.cc',
- 'common/chrome_content_gpu_client.h',
'common/chrome_content_plugin_client.cc',
'common/chrome_content_plugin_client.h',
'common/common_glue.cc',
diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi
index ecd297e..e8a7fa1 100644
--- a/chrome/chrome_dll.gypi
+++ b/chrome/chrome_dll.gypi
@@ -597,7 +597,6 @@
# and get rid of the common_constants.gypi which was added as a hack
# to avoid making common compile on 64 bit on Windows.
'../chrome/common/chrome_content_client.cc',
- '../chrome/common/chrome_content_gpu_client.cc',
'../chrome/common/chrome_content_plugin_client.cc',
'../content/common/child_process.cc',
'../content/common/child_thread.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 7200e13..981d3a8 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1825,7 +1825,6 @@
'renderer/net/predictor_queue_unittest.cc',
'renderer/net/renderer_predictor_unittest.cc',
'renderer/render_process_unittest.cc',
- 'renderer/render_thread_unittest.cc',
'renderer/renderer_about_handler_unittest.cc',
'renderer/renderer_main_unittest.cc',
'renderer/safe_browsing/features_unittest.cc',
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index 96795f6..01d2bcd8 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -12,4 +12,8 @@ void ChromeContentClient::SetActiveURL(const GURL& url) {
child_process_logging::SetActiveURL(url);
}
+void ChromeContentClient::SetGpuInfo(const GPUInfo& gpu_info) {
+ child_process_logging::SetGpuInfo(gpu_info);
+}
+
} // namespace chrome
diff --git a/chrome/common/chrome_content_client.h b/chrome/common/chrome_content_client.h
index e0f5a2a..a04da22 100644
--- a/chrome/common/chrome_content_client.h
+++ b/chrome/common/chrome_content_client.h
@@ -13,6 +13,7 @@ namespace chrome {
class ChromeContentClient : public content::ContentClient {
public:
virtual void SetActiveURL(const GURL& url);
+ virtual void SetGpuInfo(const GPUInfo& gpu_info);
};
} // namespace chrome
diff --git a/chrome/common/chrome_content_gpu_client.cc b/chrome/common/chrome_content_gpu_client.cc
deleted file mode 100644
index 15263aa..0000000
--- a/chrome/common/chrome_content_gpu_client.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/chrome_content_gpu_client.h"
-
-#include "chrome/common/child_process_logging.h"
-
-namespace chrome {
-
-void ChromeContentGpuClient::SetGpuInfo(const GPUInfo& gpu_info) {
- child_process_logging::SetGpuInfo(gpu_info);
-}
-
-} // namespace chrome
diff --git a/chrome/common/chrome_content_gpu_client.h b/chrome/common/chrome_content_gpu_client.h
deleted file mode 100644
index 53b3cdf..0000000
--- a/chrome/common/chrome_content_gpu_client.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_CHROME_CONTENT_GPU_CLIENT_H_
-#define CHROME_COMMON_CHROME_CONTENT_GPU_CLIENT_H_
-#pragma once
-
-#include "content/common/gpu/content_gpu_client.h"
-
-namespace chrome {
-
-class ChromeContentGpuClient : public content::ContentGpuClient {
- public:
- virtual void SetGpuInfo(const GPUInfo& gpu_info);
-};
-
-} // namespace chrome
-
-#endif // CHROME_COMMON_CHROME_CONTENT_GPU_CLIENT_H_
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 8fc30c7..0e3204d 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -9,9 +9,11 @@
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "base/values.h"
+#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/extension_localization_peer.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/render_messages.h"
@@ -23,6 +25,7 @@
#include "chrome/renderer/blocked_plugin.h"
#include "chrome/renderer/chrome_render_observer.h"
#include "chrome/renderer/devtools_agent.h"
+#include "chrome/renderer/devtools_agent_filter.h"
#include "chrome/renderer/extensions/bindings_utils.h"
#include "chrome/renderer/extensions/event_bindings.h"
#include "chrome/renderer/extensions/extension_dispatcher.h"
@@ -30,19 +33,29 @@
#include "chrome/renderer/extensions/extension_process_bindings.h"
#include "chrome/renderer/extensions/extension_resource_request_policy.h"
#include "chrome/renderer/extensions/renderer_extension_bindings.h"
+#include "chrome/renderer/external_extension.h"
#include "chrome/renderer/localized_error.h"
#include "chrome/renderer/page_click_tracker.h"
#include "chrome/renderer/print_web_view_helper.h"
+#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/safe_browsing/malware_dom_details.h"
#include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
+#include "chrome/renderer/search_extension.h"
#include "chrome/renderer/searchbox.h"
+#include "chrome/renderer/searchbox_extension.h"
+#include "chrome/renderer/security_filter_peer.h"
+#include "chrome/renderer/spellchecker/spellcheck.h"
+#include "chrome/renderer/spellchecker/spellcheck_provider.h"
#include "chrome/renderer/translate_helper.h"
+#include "chrome/renderer/visitedlink_slave.h"
+#include "content/common/resource_dispatcher.h"
#include "content/common/view_messages.h"
#include "content/renderer/render_view.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/renderer_resources.h"
#include "net/base/net_errors.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
@@ -53,9 +66,14 @@
#include "webkit/plugins/npapi/plugin_list.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+#if defined(OS_MACOSX)
+#include "chrome/app/breakpad_mac.h"
+#endif
+
using autofill::AutofillAgent;
using autofill::FormManager;
using autofill::PasswordAutofillManager;
+using WebKit::WebCache;
using WebKit::WebFrame;
using WebKit::WebPlugin;
using WebKit::WebPluginParams;
@@ -67,26 +85,92 @@ using WebKit::WebVector;
namespace {
-// Returns true if the frame is navigating to an URL either into or out of an
-// extension app's extent.
-// TODO(creis): Temporary workaround for crbug.com/65953: Only return true if
-// we would enter an extension app's extent from a non-app, or if we leave an
-// extension with no web extent. We avoid swapping processes to exit a hosted
-// app with a web extent for now, since we do not yet restore context (such
-// as window.opener) if the window navigates back.
-static bool CrossesExtensionExtents(WebFrame* frame, const GURL& new_url) {
- const ExtensionSet* extensions = ExtensionDispatcher::Get()->extensions();
- // If the URL is still empty, this is a window.open navigation. Check the
- // opener's URL.
- GURL old_url(frame->url());
- if (old_url.is_empty() && frame->opener())
- old_url = frame->opener()->url();
+static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
+
+#if defined(OS_POSIX)
+class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
+ void OnChannelError() {
+ // On POSIX, at least, one can install an unload handler which loops
+ // forever and leave behind a renderer process which eats 100% CPU forever.
+ //
+ // This is because the terminate signals (ViewMsg_ShouldClose and the error
+ // from the IPC channel) are routed to the main message loop but never
+ // processed (because that message loop is stuck in V8).
+ //
+ // One could make the browser SIGKILL the renderers, but that leaves open a
+ // large window where a browser failure (or a user, manually terminating
+ // the browser because "it's stuck") will leave behind a process eating all
+ // the CPU.
+ //
+ // So, we install a filter on the channel so that we can process this event
+ // here and kill the process.
+
+#if defined(OS_MACOSX)
+ // TODO(viettrungluu): crbug.com/28547: The following is needed, as a
+ // stopgap, to avoid leaking due to not releasing Breakpad properly.
+ // TODO(viettrungluu): Investigate why this is being called.
+ if (IsCrashReporterEnabled()) {
+ VLOG(1) << "Cleaning up Breakpad.";
+ DestructCrashReporter();
+ } else {
+ VLOG(1) << "Breakpad not enabled; no clean-up needed.";
+ }
+#endif // OS_MACOSX
- bool old_url_is_hosted_app = extensions->GetByURL(old_url) &&
- !extensions->GetByURL(old_url)->web_extent().is_empty();
- return !extensions->InSameExtent(old_url, new_url) &&
- !old_url_is_hosted_app;
-}
+ _exit(0);
+ }
+};
+#endif
+
+class RenderResourceObserver : public ResourceDispatcher::Observer {
+ public:
+ RenderResourceObserver()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ }
+
+ virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete(
+ webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ ResourceType::Type resource_type,
+ const net::URLRequestStatus& status) {
+ // Update the browser about our cache.
+ // Rate limit informing the host of our cache stats.
+ if (method_factory_.empty()) {
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &RenderResourceObserver::InformHostOfCacheStats),
+ kCacheStatsDelayMS);
+ }
+
+ if (status.status() != net::URLRequestStatus::CANCELED ||
+ status.os_error() == net::ERR_ABORTED) {
+ return NULL;
+ }
+
+ // Resource canceled with a specific error are filtered.
+ return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest(
+ resource_type, current_peer, status.os_error());
+ }
+
+ virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse(
+ webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ const std::string& mime_type,
+ const GURL& url) {
+ return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer(
+ current_peer, RenderThread::current(), mime_type, url);
+ }
+
+ private:
+ void InformHostOfCacheStats() {
+ WebCache::UsageStats stats;
+ WebCache::getUsageStats(&stats);
+ RenderThread::current()->Send(new ViewHostMsg_UpdatedCacheStats(stats));
+ }
+
+ ScopedRunnableMethodFactory<RenderResourceObserver> method_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderResourceObserver);
+};
static void AppendParams(const std::vector<string16>& additional_names,
const std::vector<string16>& additional_values,
@@ -119,6 +203,39 @@ static void AppendParams(const std::vector<string16>& additional_names,
namespace chrome {
+ChromeContentRendererClient::ChromeContentRendererClient() {
+}
+
+ChromeContentRendererClient::~ChromeContentRendererClient() {
+}
+
+void ChromeContentRendererClient::RenderThreadStarted() {
+ extension_dispatcher_.reset(new ExtensionDispatcher());
+ spellcheck_.reset(new SpellCheck());
+ visited_link_slave_.reset(new VisitedLinkSlave());
+ phishing_classifier_.reset(new safe_browsing::PhishingClassifierFilter);
+
+ RenderThread* thread = RenderThread::current();
+ thread->AddFilter(new DevToolsAgentFilter());
+#if defined(OS_POSIX)
+ thread->AddFilter(new SuicideOnChannelErrorFilter());
+#endif
+
+ thread->AddObserver(extension_dispatcher_.get());
+ thread->AddObserver(phishing_classifier_.get());
+ thread->AddObserver(spellcheck_.get());
+ thread->AddObserver(visited_link_slave_.get());
+
+ thread->RegisterExtension(extensions_v8::ExternalExtension::Get());
+ thread->RegisterExtension(extensions_v8::SearchBoxExtension::Get());
+ v8::Extension* search_extension = extensions_v8::SearchExtension::Get();
+ // search_extension is null if not enabled.
+ if (search_extension)
+ thread->RegisterExtension(search_extension);
+
+ thread->resource_dispatcher()->set_observer(new RenderResourceObserver());
+}
+
void ChromeContentRendererClient::RenderViewCreated(RenderView* render_view) {
safe_browsing::PhishingClassifierDelegate* phishing_classifier = NULL;
#ifndef OS_CHROMEOS
@@ -130,9 +247,10 @@ void ChromeContentRendererClient::RenderViewCreated(RenderView* render_view) {
#endif
new DevToolsAgent(render_view);
- new ExtensionHelper(render_view);
+ new ExtensionHelper(render_view, extension_dispatcher_.get());
new PrintWebViewHelper(render_view);
new SearchBox(render_view);
+ new SpellCheckProvider(render_view, spellcheck_.get());
new safe_browsing::MalwareDOMDetails(render_view);
PasswordAutofillManager* password_autofill_manager =
@@ -156,6 +274,10 @@ void ChromeContentRendererClient::RenderViewCreated(RenderView* render_view) {
}
}
+void ChromeContentRendererClient::SetNumberOfViews(int number_of_views) {
+ child_process_logging::SetNumberOfViews(number_of_views);
+}
+
SkBitmap* ChromeContentRendererClient::GetSadPluginBitmap() {
return ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SAD_PLUGIN);
}
@@ -316,7 +438,7 @@ std::string ChromeContentRendererClient::GetNavigationErrorHtml(
int resource_id;
DictionaryValue error_strings;
if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme))
- extension = ExtensionDispatcher::Get()->extensions()->GetByURL(failed_url);
+ extension = extension_dispatcher_->extensions()->GetByURL(failed_url);
if (extension) {
LocalizedError::GetAppErrorStrings(error, failed_url, extension,
&error_strings);
@@ -349,13 +471,13 @@ std::string ChromeContentRendererClient::GetNavigationErrorHtml(
}
bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
- return !ExtensionDispatcher::Get()->is_extension_process();
+ return !extension_dispatcher_->is_extension_process();
}
bool ChromeContentRendererClient::AllowPopup(const GURL& creator) {
// Extensions and apps always allowed to create unrequested popups. The second
// check is necessary to include content scripts.
- return ExtensionDispatcher::Get()->extensions()->GetByURL(creator) ||
+ return extension_dispatcher_->extensions()->GetByURL(creator) ||
bindings_utils::GetInfoForCurrentContext();
}
@@ -381,7 +503,7 @@ bool ChromeContentRendererClient::ShouldFork(WebFrame* frame,
if (is_content_initiated) {
const Extension* extension =
- ExtensionDispatcher::Get()->extensions()->GetByURL(url);
+ extension_dispatcher_->extensions()->GetByURL(url);
if (extension && extension->is_app()) {
UMA_HISTOGRAM_ENUMERATION(
extension_misc::kAppLaunchHistogram,
@@ -401,7 +523,7 @@ bool ChromeContentRendererClient::WillSendRequest(WebKit::WebFrame* frame,
// the request and cause an error.
if (url.SchemeIs(chrome::kExtensionScheme) &&
!ExtensionResourceRequestPolicy::CanRequestResource(
- url, GURL(frame->url()), ExtensionDispatcher::Get()->extensions())) {
+ url, GURL(frame->url()), extension_dispatcher_->extensions())) {
*new_url = GURL("chrome-extension://invalid/");
return true;
}
@@ -410,7 +532,8 @@ bool ChromeContentRendererClient::WillSendRequest(WebKit::WebFrame* frame,
}
void ChromeContentRendererClient::DidCreateScriptContext(WebFrame* frame) {
- EventBindings::HandleContextCreated(frame, false);
+ EventBindings::HandleContextCreated(
+ frame, false, extension_dispatcher_.get());
}
void ChromeContentRendererClient::DidDestroyScriptContext(WebFrame* frame) {
@@ -419,7 +542,36 @@ void ChromeContentRendererClient::DidDestroyScriptContext(WebFrame* frame) {
void ChromeContentRendererClient::DidCreateIsolatedScriptContext(
WebFrame* frame) {
- EventBindings::HandleContextCreated(frame, true);
+ EventBindings::HandleContextCreated(frame, true, extension_dispatcher_.get());
+}
+
+unsigned long long ChromeContentRendererClient::VisitedLinkHash(
+ const char* canonical_url, size_t length) {
+ return visited_link_slave_->ComputeURLFingerprint(canonical_url, length);
+}
+
+bool ChromeContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
+ return visited_link_slave_->IsVisited(link_hash);
+}
+
+void ChromeContentRendererClient::SetExtensionDispatcher(
+ ExtensionDispatcher* extension_dispatcher) {
+ extension_dispatcher_.reset(extension_dispatcher);
+}
+
+bool ChromeContentRendererClient::CrossesExtensionExtents(WebFrame* frame,
+ const GURL& new_url) {
+ const ExtensionSet* extensions = extension_dispatcher_->extensions();
+ // If the URL is still empty, this is a window.open navigation. Check the
+ // opener's URL.
+ GURL old_url(frame->url());
+ if (old_url.is_empty() && frame->opener())
+ old_url = frame->opener()->url();
+
+ bool old_url_is_hosted_app = extensions->GetByURL(old_url) &&
+ !extensions->GetByURL(old_url)->web_extent().is_empty();
+ return !extensions->InSameExtent(old_url, new_url) &&
+ !old_url_is_hosted_app;
}
} // namespace chrome
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index ce6bd04..e56204b 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -6,8 +6,17 @@
#define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
#pragma once
+#include "base/memory/scoped_ptr.h"
#include "content/renderer/content_renderer_client.h"
+class ExtensionDispatcher;
+class SpellCheck;
+class VisitedLinkSlave;
+
+namespace safe_browsing {
+class PhishingClassifierFilter;
+}
+
namespace webkit {
namespace npapi {
class PluginGroup;
@@ -18,7 +27,12 @@ namespace chrome {
class ChromeContentRendererClient : public content::ContentRendererClient {
public:
+ ChromeContentRendererClient();
+ ~ChromeContentRendererClient();
+
+ virtual void RenderThreadStarted();
virtual void RenderViewCreated(RenderView* render_view);
+ virtual void SetNumberOfViews(int number_of_views);
virtual SkBitmap* GetSadPluginBitmap();
virtual std::string GetDefaultEncoding();
virtual WebKit::WebPlugin* CreatePlugin(
@@ -40,6 +54,12 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
virtual void DidCreateScriptContext(WebKit::WebFrame* frame);
virtual void DidDestroyScriptContext(WebKit::WebFrame* frame);
virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* frame);
+ virtual unsigned long long VisitedLinkHash(const char* canonical_url,
+ size_t length);
+ virtual bool IsLinkVisited(unsigned long long link_hash);
+
+ // For testing.
+ void SetExtensionDispatcher(ExtensionDispatcher* extension_dispatcher);
private:
WebKit::WebPlugin* CreatePluginPlaceholder(
@@ -51,6 +71,20 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
int message_id,
bool is_blocked_for_prerendering,
bool allow_loading);
+
+ // Returns true if the frame is navigating to an URL either into or out of an
+ // extension app's extent.
+ // TODO(creis): Temporary workaround for crbug.com/65953: Only return true if
+ // we would enter an extension app's extent from a non-app, or if we leave an
+ // extension with no web extent. We avoid swapping processes to exit a hosted
+ // app with a web extent for now, since we do not yet restore context (such
+ // as window.opener) if the window navigates back.
+ bool CrossesExtensionExtents(WebKit::WebFrame* frame, const GURL& new_url);
+
+ scoped_ptr<ExtensionDispatcher> extension_dispatcher_;
+ scoped_ptr<SpellCheck> spellcheck_;
+ scoped_ptr<VisitedLinkSlave> visited_link_slave_;
+ scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
};
} // namespace chrome
diff --git a/chrome/renderer/extensions/chrome_app_bindings.cc b/chrome/renderer/extensions/chrome_app_bindings.cc
index f5cdd38..ef072346 100644
--- a/chrome/renderer/extensions/chrome_app_bindings.cc
+++ b/chrome/renderer/extensions/chrome_app_bindings.cc
@@ -21,19 +21,25 @@ static const char* const kAppExtensionName = "v8/ChromeApp";
class ChromeAppExtensionWrapper : public v8::Extension {
public:
- ChromeAppExtensionWrapper() :
- v8::Extension(kAppExtensionName,
- "var chrome;"
- "if (!chrome)"
- " chrome = {};"
- "if (!chrome.app) {"
- " chrome.app = new function() {"
- " native function GetIsInstalled();"
- " native function Install();"
- " this.__defineGetter__('isInstalled', GetIsInstalled);"
- " this.install = Install;"
- " };"
- "}") {}
+ explicit ChromeAppExtensionWrapper(ExtensionDispatcher* extension_dispatcher)
+ : v8::Extension(kAppExtensionName,
+ "var chrome;"
+ "if (!chrome)"
+ " chrome = {};"
+ "if (!chrome.app) {"
+ " chrome.app = new function() {"
+ " native function GetIsInstalled();"
+ " native function Install();"
+ " this.__defineGetter__('isInstalled', GetIsInstalled);"
+ " this.install = Install;"
+ " };"
+ "}") {
+ extension_dispatcher_ = extension_dispatcher;
+ }
+
+ ~ChromeAppExtensionWrapper() {
+ extension_dispatcher_ = NULL;
+ }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name) {
@@ -58,7 +64,7 @@ class ChromeAppExtensionWrapper : public v8::Extension {
return v8::Boolean::New(false);
bool has_web_extent =
- ExtensionDispatcher::Get()->extensions()->GetByURL(url) != NULL;
+ extension_dispatcher_->extensions()->GetByURL(url) != NULL;
return v8::Boolean::New(has_web_extent);
}
@@ -73,10 +79,15 @@ class ChromeAppExtensionWrapper : public v8::Extension {
return v8::Undefined();
}
+
+ static ExtensionDispatcher* extension_dispatcher_;
};
-v8::Extension* ChromeAppExtension::Get() {
- return new ChromeAppExtensionWrapper();
+ExtensionDispatcher* ChromeAppExtensionWrapper::extension_dispatcher_;
+
+v8::Extension* ChromeAppExtension::Get(
+ ExtensionDispatcher* extension_dispatcher) {
+ return new ChromeAppExtensionWrapper(extension_dispatcher);
}
} // namespace extensions_v8
diff --git a/chrome/renderer/extensions/chrome_app_bindings.h b/chrome/renderer/extensions/chrome_app_bindings.h
index 1292eb2..8e7da1b 100644
--- a/chrome/renderer/extensions/chrome_app_bindings.h
+++ b/chrome/renderer/extensions/chrome_app_bindings.h
@@ -12,6 +12,8 @@
#define CHROME_RENDERER_EXTENSIONS_CHROME_APP_BINDINGS_H_
#pragma once
+class ExtensionDispatcher;
+
namespace v8 {
class Extension;
}
@@ -20,7 +22,7 @@ namespace extensions_v8 {
class ChromeAppExtension {
public:
- static v8::Extension* Get();
+ static v8::Extension* Get(ExtensionDispatcher* extension_dispatcher);
};
} // namespace extensions_v8
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index 0e41f64..f5408d6 100644
--- a/chrome/renderer/extensions/event_bindings.cc
+++ b/chrome/renderer/extensions/event_bindings.cc
@@ -249,7 +249,10 @@ static void ContextWeakReferenceCallback(v8::Persistent<v8::Value> context,
NOTREACHED();
}
-void EventBindings::HandleContextCreated(WebFrame* frame, bool content_script) {
+void EventBindings::HandleContextCreated(
+ WebFrame* frame,
+ bool content_script,
+ ExtensionDispatcher* extension_dispatcher) {
if (!bindings_registered)
return;
@@ -266,7 +269,7 @@ void EventBindings::HandleContextCreated(WebFrame* frame, bool content_script) {
if (!ds)
ds = frame->dataSource();
GURL url = ds->request().url();
- const ExtensionSet* extensions = ExtensionDispatcher::Get()->extensions();
+ const ExtensionSet* extensions = extension_dispatcher->extensions();
std::string extension_id = extensions->GetIdByURL(url);
if (!extensions->ExtensionBindingsAllowed(url) &&
diff --git a/chrome/renderer/extensions/event_bindings.h b/chrome/renderer/extensions/event_bindings.h
index 95b049e..893e3a6 100644
--- a/chrome/renderer/extensions/event_bindings.h
+++ b/chrome/renderer/extensions/event_bindings.h
@@ -10,6 +10,7 @@
#include "v8/include/v8.h"
+class ExtensionDispatcher;
class GURL;
class RenderThreadBase;
class RenderView;
@@ -32,7 +33,8 @@ class EventBindings {
// Handle a script context coming / going away.
static void HandleContextCreated(WebKit::WebFrame* frame,
- bool content_script);
+ bool content_script,
+ ExtensionDispatcher* extension_dispatcher);
static void HandleContextDestroyed(WebKit::WebFrame* frame);
// Calls the given function in each registered context which is listening for
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc
index d3bdf60..fe30498 100644
--- a/chrome/renderer/extensions/extension_dispatcher.cc
+++ b/chrome/renderer/extensions/extension_dispatcher.cc
@@ -22,19 +22,11 @@
namespace {
static const double kInitialExtensionIdleHandlerDelayS = 5.0 /* seconds */;
static const int64 kMaxExtensionIdleHandlerDelayS = 5*60 /* seconds */;
-static ExtensionDispatcher* g_extension_dispatcher;
}
using WebKit::WebFrame;
-ExtensionDispatcher* ExtensionDispatcher::Get() {
- return g_extension_dispatcher;
-}
-
ExtensionDispatcher::ExtensionDispatcher() {
- DCHECK(!g_extension_dispatcher);
- g_extension_dispatcher = this;
-
std::string type_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
is_extension_process_ = type_str == switches::kExtensionProcess ||
@@ -49,7 +41,6 @@ ExtensionDispatcher::ExtensionDispatcher() {
}
ExtensionDispatcher::~ExtensionDispatcher() {
- g_extension_dispatcher = NULL;
}
bool ExtensionDispatcher::OnControlMessageReceived(
@@ -72,10 +63,6 @@ bool ExtensionDispatcher::OnControlMessageReceived(
return handled;
}
-void ExtensionDispatcher::OnRenderProcessShutdown() {
- delete this;
-}
-
void ExtensionDispatcher::WebKitInitialized() {
// For extensions, we want to ensure we call the IdleHandler every so often,
// even if the extension keeps up activity.
@@ -85,10 +72,10 @@ void ExtensionDispatcher::WebKitInitialized() {
RenderThread::current(), &RenderThread::IdleHandler);
}
- RegisterExtension(extensions_v8::ChromeAppExtension::Get(), false);
+ RegisterExtension(extensions_v8::ChromeAppExtension::Get(this), false);
// Add v8 extensions related to chrome extensions.
- RegisterExtension(ExtensionProcessBindings::Get(), true);
+ RegisterExtension(ExtensionProcessBindings::Get(this), true);
RegisterExtension(BaseJsV8Extension::Get(), true);
RegisterExtension(JsonSchemaJsV8Extension::Get(), true);
RegisterExtension(EventBindings::Get(), true);
diff --git a/chrome/renderer/extensions/extension_dispatcher.h b/chrome/renderer/extensions/extension_dispatcher.h
index 3526a47..8b46396 100644
--- a/chrome/renderer/extensions/extension_dispatcher.h
+++ b/chrome/renderer/extensions/extension_dispatcher.h
@@ -31,13 +31,9 @@ class Extension;
}
// Dispatches extension control messages sent to the renderer and stores
-// renderer extension related state. Object will delete itself when the
-// renderer shuts down.
+// renderer extension related state.
class ExtensionDispatcher : public RenderProcessObserver {
public:
- // Returns the ExtensionDispatcher for this process.
- static ExtensionDispatcher* Get();
-
ExtensionDispatcher();
virtual ~ExtensionDispatcher();
@@ -50,7 +46,6 @@ class ExtensionDispatcher : public RenderProcessObserver {
// RenderProcessObserver implementation:
virtual bool OnControlMessageReceived(const IPC::Message& message);
- virtual void OnRenderProcessShutdown();
virtual void WebKitInitialized();
virtual bool AllowScriptExtension(const std::string& v8_extension_name,
const GURL& url,
diff --git a/chrome/renderer/extensions/extension_helper.cc b/chrome/renderer/extensions/extension_helper.cc
index 5dbc62c..4e3a9ef 100644
--- a/chrome/renderer/extensions/extension_helper.cc
+++ b/chrome/renderer/extensions/extension_helper.cc
@@ -28,8 +28,10 @@ typedef std::map<WebFrame*, UserScriptIdleScheduler*> SchedulerMap;
static base::LazyInstance<SchedulerMap> g_schedulers(base::LINKER_INITIALIZED);
}
-ExtensionHelper::ExtensionHelper(RenderView* render_view)
- : RenderViewObserver(render_view) {
+ExtensionHelper::ExtensionHelper(RenderView* render_view,
+ ExtensionDispatcher* extension_dispatcher)
+ : RenderViewObserver(render_view),
+ extension_dispatcher_(extension_dispatcher) {
}
ExtensionHelper::~ExtensionHelper() {
@@ -47,7 +49,7 @@ bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) {
}
void ExtensionHelper::DidFinishDocumentLoad(WebFrame* frame) {
- ExtensionDispatcher::Get()->user_script_slave()->InjectScripts(
+ extension_dispatcher_->user_script_slave()->InjectScripts(
frame, UserScript::DOCUMENT_END);
SchedulerMap::iterator i = g_schedulers.Get().find(frame);
@@ -62,7 +64,7 @@ void ExtensionHelper::DidFinishLoad(WebKit::WebFrame* frame) {
}
void ExtensionHelper::DidCreateDocumentElement(WebFrame* frame) {
- ExtensionDispatcher::Get()->user_script_slave()->InjectScripts(
+ extension_dispatcher_->user_script_slave()->InjectScripts(
frame, UserScript::DOCUMENT_START);
}
@@ -89,7 +91,8 @@ void ExtensionHelper::DidCreateDataSource(WebFrame* frame, WebDataSource* ds) {
if (g_schedulers.Get().count(frame))
return;
- g_schedulers.Get()[frame] = new UserScriptIdleScheduler(frame);
+ g_schedulers.Get()[frame] = new UserScriptIdleScheduler(
+ frame, extension_dispatcher_);
}
void ExtensionHelper::OnExtensionResponse(int request_id,
diff --git a/chrome/renderer/extensions/extension_helper.h b/chrome/renderer/extensions/extension_helper.h
index e508581..a51e1e7 100644
--- a/chrome/renderer/extensions/extension_helper.h
+++ b/chrome/renderer/extensions/extension_helper.h
@@ -10,6 +10,7 @@
#include "content/renderer/render_view_observer.h"
+class ExtensionDispatcher;
class GURL;
class ListValue;
struct ExtensionMsg_ExecuteCode_Params;
@@ -17,7 +18,8 @@ struct ExtensionMsg_ExecuteCode_Params;
// Filters extension related messages sent to RenderViews.
class ExtensionHelper : public RenderViewObserver {
public:
- explicit ExtensionHelper(RenderView* render_view);
+ ExtensionHelper(RenderView* render_view,
+ ExtensionDispatcher* extension_dispatcher);
virtual ~ExtensionHelper();
private:
@@ -40,6 +42,8 @@ class ExtensionHelper : public RenderViewObserver {
const GURL& event_url);
void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params);
+ ExtensionDispatcher* extension_dispatcher_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionHelper);
};
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 09bfa1a..4254832 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -183,9 +183,17 @@ class ExtensionViewAccumulator : public RenderViewVisitor {
class ExtensionImpl : public ExtensionBase {
public:
- ExtensionImpl() : ExtensionBase(
- kExtensionName, GetStringResource(IDR_EXTENSION_PROCESS_BINDINGS_JS),
- arraysize(kExtensionDeps), kExtensionDeps) {}
+ explicit ExtensionImpl(ExtensionDispatcher* extension_dispatcher)
+ : ExtensionBase(kExtensionName,
+ GetStringResource(IDR_EXTENSION_PROCESS_BINDINGS_JS),
+ arraysize(kExtensionDeps),
+ kExtensionDeps) {
+ extension_dispatcher_ = extension_dispatcher;
+ }
+
+ ~ExtensionImpl() {
+ extension_dispatcher_ = NULL;
+ }
static void SetFunctionNames(const std::vector<std::string>& names) {
std::set<std::string>* name_set = GetFunctionNameSet();
@@ -203,7 +211,7 @@ class ExtensionImpl : public ExtensionBase {
return std::string(); // this can happen as a tab is closing.
GURL url = renderview->webview()->mainFrame()->url();
- const ExtensionSet* extensions = ExtensionDispatcher::Get()->extensions();
+ const ExtensionSet* extensions = extension_dispatcher_->extensions();
if (!extensions->ExtensionBindingsAllowed(url))
return std::string();
@@ -518,7 +526,7 @@ class ExtensionImpl : public ExtensionBase {
static v8::Handle<v8::Value> IsExtensionProcess(const v8::Arguments& args) {
bool retval = false;
if (EventBindings::GetRenderThread())
- retval = ExtensionDispatcher::Get()->is_extension_process();
+ retval = extension_dispatcher_->is_extension_process();
return v8::Boolean::New(retval);
}
@@ -528,12 +536,17 @@ class ExtensionImpl : public ExtensionBase {
retval = EventBindings::GetRenderThread()->IsIncognitoProcess();
return v8::Boolean::New(retval);
}
+
+ static ExtensionDispatcher* extension_dispatcher_;
};
+ExtensionDispatcher* ExtensionImpl::extension_dispatcher_;
+
} // namespace
-v8::Extension* ExtensionProcessBindings::Get() {
- static v8::Extension* extension = new ExtensionImpl();
+v8::Extension* ExtensionProcessBindings::Get(
+ ExtensionDispatcher* extension_dispatcher) {
+ static v8::Extension* extension = new ExtensionImpl(extension_dispatcher);
return extension;
}
diff --git a/chrome/renderer/extensions/extension_process_bindings.h b/chrome/renderer/extensions/extension_process_bindings.h
index 4aa4140..d187453 100644
--- a/chrome/renderer/extensions/extension_process_bindings.h
+++ b/chrome/renderer/extensions/extension_process_bindings.h
@@ -15,6 +15,7 @@
#include "chrome/common/view_types.h"
#include "v8/include/v8.h"
+class ExtensionDispatcher;
class GURL;
class URLPattern;
@@ -25,7 +26,7 @@ class WebView;
class ExtensionProcessBindings {
public:
static void SetFunctionNames(const std::vector<std::string>& names);
- static v8::Extension* Get();
+ static v8::Extension* Get(ExtensionDispatcher* extension_dispatcher);
// Gets the set of extensions running in this process.
static void GetActiveExtensions(std::set<std::string>* extension_ids);
diff --git a/chrome/renderer/extensions/user_script_idle_scheduler.cc b/chrome/renderer/extensions/user_script_idle_scheduler.cc
index cc6f142..98cce4a 100644
--- a/chrome/renderer/extensions/user_script_idle_scheduler.cc
+++ b/chrome/renderer/extensions/user_script_idle_scheduler.cc
@@ -26,10 +26,12 @@ using WebKit::WebFrame;
using WebKit::WebString;
using WebKit::WebView;
-UserScriptIdleScheduler::UserScriptIdleScheduler(WebFrame* frame)
+UserScriptIdleScheduler::UserScriptIdleScheduler(
+ WebFrame* frame, ExtensionDispatcher* extension_dispatcher)
: ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
frame_(frame),
- has_run_(false) {
+ has_run_(false),
+ extension_dispatcher_(extension_dispatcher) {
}
UserScriptIdleScheduler::~UserScriptIdleScheduler() {
@@ -78,7 +80,7 @@ void UserScriptIdleScheduler::MaybeRun() {
// http://code.google.com/p/chromium/issues/detail?id=29644
has_run_ = true;
- ExtensionDispatcher::Get()->user_script_slave()->InjectScripts(
+ extension_dispatcher_->user_script_slave()->InjectScripts(
frame_, UserScript::DOCUMENT_IDLE);
while (!pending_code_execution_queue_.empty()) {
@@ -91,9 +93,8 @@ void UserScriptIdleScheduler::MaybeRun() {
void UserScriptIdleScheduler::ExecuteCodeImpl(
const ExtensionMsg_ExecuteCode_Params& params) {
- const Extension* extension =
- ExtensionDispatcher::Get()->extensions()->GetByID(
- params.extension_id);
+ const Extension* extension = extension_dispatcher_->extensions()->GetByID(
+ params.extension_id);
RenderView* render_view = RenderView::FromWebView(frame_->view());
// Since extension info is sent separately from user script info, they can
diff --git a/chrome/renderer/extensions/user_script_idle_scheduler.h b/chrome/renderer/extensions/user_script_idle_scheduler.h
index 2944237..62258c6 100644
--- a/chrome/renderer/extensions/user_script_idle_scheduler.h
+++ b/chrome/renderer/extensions/user_script_idle_scheduler.h
@@ -12,6 +12,7 @@
#include "base/memory/linked_ptr.h"
#include "base/task.h"
+class ExtensionDispatcher;
class RenderView;
struct ExtensionMsg_ExecuteCode_Params;
@@ -37,7 +38,8 @@ class WebFrame;
// ExtensionDispatcher, which contains the mapping from WebFrame to us.
class UserScriptIdleScheduler {
public:
- explicit UserScriptIdleScheduler(WebKit::WebFrame* frame);
+ UserScriptIdleScheduler(WebKit::WebFrame* frame,
+ ExtensionDispatcher* extension_dispatcher);
~UserScriptIdleScheduler();
void ExecuteCode(const ExtensionMsg_ExecuteCode_Params& params);
@@ -69,6 +71,8 @@ class UserScriptIdleScheduler {
// This is only used if we're for the main frame.
std::queue<linked_ptr<ExtensionMsg_ExecuteCode_Params> >
pending_code_execution_queue_;
+
+ ExtensionDispatcher* extension_dispatcher_;
};
#endif // CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_IDLE_SCHEDULER_H_
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index b6981af..528ada6 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -22,26 +22,14 @@
#include "base/threading/thread_local.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension_localization_peer.h"
#include "chrome/common/render_messages.h"
-#include "chrome/common/safebrowsing_messages.h"
-#include "chrome/common/spellcheck_messages.h"
#include "chrome/common/url_constants.h"
#include "chrome/renderer/automation/dom_automation_v8_extension.h"
-#include "chrome/renderer/devtools_agent_filter.h"
-#include "chrome/renderer/extensions/extension_dispatcher.h"
-#include "chrome/renderer/external_extension.h"
#include "chrome/renderer/loadtimes_extension_bindings.h"
#include "chrome/renderer/net/renderer_net_predictor.h"
#include "chrome/renderer/render_process_impl.h"
#include "chrome/renderer/renderer_histogram_snapshots.h"
-#include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
-#include "chrome/renderer/search_extension.h"
-#include "chrome/renderer/searchbox_extension.h"
-#include "chrome/renderer/security_filter_peer.h"
-#include "chrome/renderer/spellchecker/spellcheck.h"
#include "content/common/appcache/appcache_dispatcher.h"
#include "content/common/database_messages.h"
#include "content/common/db_message_filter.h"
@@ -49,7 +37,6 @@
#include "content/common/gpu_messages.h"
#include "content/common/plugin_messages.h"
#include "content/common/renderer_preferences.h"
-#include "content/common/resource_dispatcher.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
#include "content/common/web_database_observer_impl.h"
@@ -103,10 +90,6 @@
#include <objbase.h>
#endif
-#if defined(OS_MACOSX)
-#include "chrome/app/breakpad_mac.h"
-#endif
-
#if defined(OS_POSIX)
#include "ipc/ipc_channel_posix.h"
#endif
@@ -123,7 +106,6 @@ using WebKit::WebStorageEventDispatcher;
using WebKit::WebView;
namespace {
-static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */;
// Keep the global RenderThread in a TLS slot so it is impossible to access
@@ -131,41 +113,6 @@ static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */;
static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls(
base::LINKER_INITIALIZED);
-#if defined(OS_POSIX)
-class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
- void OnChannelError() {
- // On POSIX, at least, one can install an unload handler which loops
- // forever and leave behind a renderer process which eats 100% CPU forever.
- //
- // This is because the terminate signals (ViewMsg_ShouldClose and the error
- // from the IPC channel) are routed to the main message loop but never
- // processed (because that message loop is stuck in V8).
- //
- // One could make the browser SIGKILL the renderers, but that leaves open a
- // large window where a browser failure (or a user, manually terminating
- // the browser because "it's stuck") will leave behind a process eating all
- // the CPU.
- //
- // So, we install a filter on the channel so that we can process this event
- // here and kill the process.
-
-#if defined(OS_MACOSX)
- // TODO(viettrungluu): crbug.com/28547: The following is needed, as a
- // stopgap, to avoid leaking due to not releasing Breakpad properly.
- // TODO(viettrungluu): Investigate why this is being called.
- if (IsCrashReporterEnabled()) {
- VLOG(1) << "Cleaning up Breakpad.";
- DestructCrashReporter();
- } else {
- VLOG(1) << "Breakpad not enabled; no clean-up needed.";
- }
-#endif // OS_MACOSX
-
- _exit(0);
- }
-};
-#endif
-
class RenderViewContentSettingsSetter : public RenderViewVisitor {
public:
RenderViewContentSettingsSetter(const GURL& url,
@@ -214,40 +161,6 @@ class RenderViewZoomer : public RenderViewVisitor {
DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
};
-class RenderResourceObserver : public ResourceDispatcher::Observer {
- public:
- RenderResourceObserver() {
- }
-
- virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete(
- webkit_glue::ResourceLoaderBridge::Peer* current_peer,
- ResourceType::Type resource_type,
- const net::URLRequestStatus& status) {
- // Update the browser about our cache.
- RenderThread::current()->InformHostOfCacheStatsLater();
-
- if (status.status() != net::URLRequestStatus::CANCELED ||
- status.os_error() == net::ERR_ABORTED) {
- return NULL;
- }
-
- // Resource canceled with a specific error are filtered.
- return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest(
- resource_type, current_peer, status.os_error());
- }
-
- virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse(
- webkit_glue::ResourceLoaderBridge::Peer* current_peer,
- const std::string& mime_type,
- const GURL& url) {
- return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer(
- current_peer, RenderThread::current(), mime_type, url);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderResourceObserver);
-};
-
} // namespace
// When we run plugins in process, we actually run them on the render thread,
@@ -264,8 +177,6 @@ RenderThread::RenderThread(const std::string& channel_name)
void RenderThread::Init() {
TRACE_EVENT_BEGIN("RenderThread::Init", 0, "");
- content::GetContentClient()->set_renderer(&renderer_client_);
-
#if defined(OS_MACOSX)
// On Mac, the select popups are rendered by the browser.
WebKit::WebView::setUseExternalPopupMenus(true);
@@ -284,23 +195,15 @@ void RenderThread::Init() {
suspend_webkit_shared_timer_ = true;
notify_webkit_of_modal_loop_ = true;
plugin_refresh_allowed_ = true;
- cache_stats_task_pending_ = false;
widget_count_ = 0;
hidden_widget_count_ = 0;
idle_notification_delay_in_s_ = kInitialIdleHandlerDelayS;
task_factory_.reset(new ScopedRunnableMethodFactory<RenderThread>(this));
- resource_dispatcher()->set_observer(new RenderResourceObserver());
-
- visited_link_slave_.reset(new VisitedLinkSlave());
renderer_net_predictor_.reset(new RendererNetPredictor());
histogram_snapshots_.reset(new RendererHistogramSnapshots());
appcache_dispatcher_.reset(new AppCacheDispatcher(this));
indexed_db_dispatcher_.reset(new IndexedDBDispatcher());
- spellchecker_.reset(new SpellCheck());
-
- devtools_agent_filter_ = new DevToolsAgentFilter();
- AddFilter(devtools_agent_filter_.get());
db_message_filter_ = new DBMessageFilter();
AddFilter(db_message_filter_.get());
@@ -308,12 +211,7 @@ void RenderThread::Init() {
cookie_message_filter_ = new CookieMessageFilter();
AddFilter(cookie_message_filter_.get());
-#if defined(OS_POSIX)
- suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter;
- AddFilter(suicide_on_channel_error_filter_.get());
-#endif
-
- AddObserver(new ExtensionDispatcher());
+ content::GetContentClient()->renderer()->RenderThreadStarted();
TRACE_EVENT_END("RenderThread::Init", 0, "");
}
@@ -329,7 +227,6 @@ RenderThread::~RenderThread() {
// Shutdown in reverse of the initialization order.
RemoveFilter(db_message_filter_.get());
db_message_filter_ = NULL;
- RemoveFilter(devtools_agent_filter_.get());
// Shutdown the file thread if it's running.
if (file_thread_.get())
@@ -469,13 +366,11 @@ bool RenderThread::Send(IPC::Message* msg) {
void RenderThread::AddRoute(int32 routing_id,
IPC::Channel::Listener* listener) {
widget_count_++;
- child_process_logging::SetNumberOfViews(widget_count_);
return ChildThread::AddRoute(routing_id, listener);
}
void RenderThread::RemoveRoute(int32 routing_id) {
widget_count_--;
- child_process_logging::SetNumberOfViews(widget_count_);
return ChildThread::RemoveRoute(routing_id);
}
@@ -539,21 +434,6 @@ void RenderThread::SendHistograms(int sequence_number) {
return histogram_snapshots_->SendHistograms(sequence_number);
}
-void RenderThread::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
- DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle";
- visited_link_slave_->Init(table);
-}
-
-void RenderThread::OnAddVisitedLinks(
- const VisitedLinkSlave::Fingerprints& fingerprints) {
- for (size_t i = 0; i < fingerprints.size(); ++i)
- WebView::updateVisitedLinkState(fingerprints[i]);
-}
-
-void RenderThread::OnResetVisitedLinks() {
- WebView::resetVisitedLinkState();
-}
-
void RenderThread::OnSetContentSettingsForCurrentURL(
const GURL& url,
const ContentSettings& content_settings) {
@@ -592,9 +472,6 @@ bool RenderThread::OnControlMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderThread, msg)
- IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks)
- IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks)
- IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks)
IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentURL,
OnSetContentSettingsForCurrentURL)
IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL,
@@ -616,12 +493,7 @@ bool RenderThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent)
- IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInitSpellChecker)
- IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnSpellCheckWordAdded)
- IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect,
- OnSpellCheckEnableAutoSpellCorrect)
IPC_MESSAGE_HANDLER(GpuMsg_GpuChannelEstablished, OnGpuChannelEstablished)
- IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -711,26 +583,6 @@ void RenderThread::OnGetV8HeapStats() {
heap_stats.used_heap_size()));
}
-void RenderThread::InformHostOfCacheStats() {
- EnsureWebKitInitialized();
- WebCache::UsageStats stats;
- WebCache::getUsageStats(&stats);
- Send(new ViewHostMsg_UpdatedCacheStats(stats));
- cache_stats_task_pending_ = false;
-}
-
-void RenderThread::InformHostOfCacheStatsLater() {
- // Rate limit informing the host of our cache stats.
- if (cache_stats_task_pending_)
- return;
-
- cache_stats_task_pending_ = true;
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- task_factory_->NewRunnableMethod(
- &RenderThread::InformHostOfCacheStats),
- kCacheStatsDelayMS);
-}
-
void RenderThread::CloseCurrentConnections() {
Send(new ViewHostMsg_CloseCurrentConnections());
}
@@ -839,12 +691,6 @@ void RenderThread::EnsureWebKitInitialized() {
WebSecurityPolicy::registerURLSchemeAsSecure(extension_scheme);
RegisterExtension(extensions_v8::LoadTimesExtension::Get());
- RegisterExtension(extensions_v8::ExternalExtension::Get());
- RegisterExtension(extensions_v8::SearchBoxExtension::Get());
- v8::Extension* search_extension = extensions_v8::SearchExtension::Get();
- // search_extension is null if not enabled.
- if (search_extension)
- RegisterExtension(search_extension);
if (command_line.HasSwitch(switches::kEnableBenchmarking))
RegisterExtension(extensions_v8::BenchmarkingExtension::Get());
@@ -949,8 +795,6 @@ void RenderThread::ScheduleIdleHandler(double initial_delay_s) {
}
void RenderThread::OnPurgeMemory() {
- spellchecker_.reset(new SpellCheck());
-
EnsureWebKitInitialized();
// Clear the object cache (as much as possible; some live objects cannot be
@@ -992,24 +836,6 @@ void RenderThread::OnPurgePluginListCache(bool reload_pages) {
plugin_refresh_allowed_ = true;
}
-void RenderThread::OnInitSpellChecker(
- IPC::PlatformFileForTransit bdict_file,
- const std::vector<std::string>& custom_words,
- const std::string& language,
- bool auto_spell_correct) {
- spellchecker_->Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file),
- custom_words, language);
- spellchecker_->EnableAutoSpellCorrect(auto_spell_correct);
-}
-
-void RenderThread::OnSpellCheckWordAdded(const std::string& word) {
- spellchecker_->WordAdded(word);
-}
-
-void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) {
- spellchecker_->EnableAutoSpellCorrect(enable);
-}
-
void RenderThread::OnSetIsIncognitoProcess(bool is_incognito_process) {
is_incognito_process_ = is_incognito_process;
}
@@ -1019,7 +845,7 @@ void RenderThread::OnGpuChannelEstablished(
base::ProcessHandle renderer_process_for_gpu,
const GPUInfo& gpu_info) {
gpu_channel_->set_gpu_info(gpu_info);
- child_process_logging::SetGpuInfo(gpu_info);
+ content::GetContentClient()->SetGpuInfo(gpu_info);
if (!channel_handle.name.empty() && renderer_process_for_gpu != 0) {
// Connect to the GPU process if a channel name was received.
@@ -1030,10 +856,6 @@ void RenderThread::OnGpuChannelEstablished(
}
}
-void RenderThread::OnSetPhishingModel(IPC::PlatformFileForTransit model_file) {
- safe_browsing::PhishingClassifierDelegate::SetPhishingModel(model_file);
-}
-
scoped_refptr<base::MessageLoopProxy>
RenderThread::GetFileThreadMessageLoopProxy() {
DCHECK(message_loop() == MessageLoop::current());
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index c214684..ffca2dc 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -15,19 +15,15 @@
#include "base/time.h"
#include "base/timer.h"
#include "build/build_config.h"
-#include "chrome/renderer/chrome_content_renderer_client.h"
-#include "chrome/renderer/visitedlink_slave.h"
#include "content/common/child_thread.h"
#include "content/common/css_colors.h"
#include "content/common/gpu_process_launch_causes.h"
#include "ipc/ipc_channel_proxy.h"
-#include "ipc/ipc_platform_file.h"
#include "ui/gfx/native_widget_types.h"
class AppCacheDispatcher;
class CookieMessageFilter;
class DBMessageFilter;
-class DevToolsAgentFilter;
class FilePath;
class GpuChannelHost;
class IndexedDBDispatcher;
@@ -36,7 +32,6 @@ class RendererHistogramSnapshots;
class RenderProcessObserver;
class RendererNetPredictor;
class RendererWebKitClientImpl;
-class SpellCheck;
class SkBitmap;
class WebDatabaseObserverImpl;
@@ -167,10 +162,6 @@ class RenderThread : public RenderThreadBase,
void DoNotSuspendWebKitSharedTimer();
void DoNotNotifyWebKitOfModalLoop();
- VisitedLinkSlave* visited_link_slave() const {
- return visited_link_slave_.get();
- }
-
AppCacheDispatcher* appcache_dispatcher() const {
return appcache_dispatcher_.get();
}
@@ -179,10 +170,6 @@ class RenderThread : public RenderThreadBase,
return indexed_db_dispatcher_.get();
}
- SpellCheck* spellchecker() const {
- return spellchecker_.get();
- }
-
bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; }
double idle_notification_delay_in_s() const {
@@ -198,10 +185,6 @@ class RenderThread : public RenderThreadBase,
// Send all the Histogram data to browser.
void SendHistograms(int sequence_number);
- // Invokes InformHostOfCacheStats after a short delay. Used to move this
- // bookkeeping operation off the critical latency path.
- void InformHostOfCacheStatsLater();
-
// Sends a message to the browser to close all connections.
void CloseCurrentConnections();
@@ -269,9 +252,6 @@ class RenderThread : public RenderThreadBase,
void Init();
- void OnUpdateVisitedLinks(base::SharedMemoryHandle table);
- void OnAddVisitedLinks(const VisitedLinkSlave::Fingerprints& fingerprints);
- void OnResetVisitedLinks();
void OnSetZoomLevelForCurrentURL(const GURL& url, double zoom_level);
void OnSetContentSettingsForCurrentURL(
const GURL& url, const ContentSettings& content_settings);
@@ -297,40 +277,23 @@ class RenderThread : public RenderThreadBase,
void OnPurgeMemory();
void OnPurgePluginListCache(bool reload_pages);
- void OnInitSpellChecker(IPC::PlatformFileForTransit bdict_file,
- const std::vector<std::string>& custom_words,
- const std::string& language,
- bool auto_spell_correct);
- void OnSpellCheckWordAdded(const std::string& word);
- void OnSpellCheckEnableAutoSpellCorrect(bool enable);
-
void OnGpuChannelEstablished(const IPC::ChannelHandle& channel_handle,
base::ProcessHandle renderer_process_for_gpu,
const GPUInfo& gpu_info);
- void OnSetPhishingModel(IPC::PlatformFileForTransit model_file);
-
void OnGetAccessibilityTree();
- // Gather usage statistics from the in-memory cache and inform our host.
- // These functions should be call periodically so that the host can make
- // decisions about how to allocation resources using current information.
- void InformHostOfCacheStats();
-
// We initialize WebKit as late as possible.
void EnsureWebKitInitialized();
// These objects live solely on the render thread.
scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > task_factory_;
- scoped_ptr<VisitedLinkSlave> visited_link_slave_;
scoped_ptr<RendererNetPredictor> renderer_net_predictor_;
scoped_ptr<AppCacheDispatcher> appcache_dispatcher_;
scoped_ptr<IndexedDBDispatcher> indexed_db_dispatcher_;
- scoped_refptr<DevToolsAgentFilter> devtools_agent_filter_;
scoped_ptr<RendererHistogramSnapshots> histogram_snapshots_;
scoped_ptr<RendererWebKitClientImpl> webkit_client_;
scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_;
- scoped_ptr<SpellCheck> spellchecker_;
// Used on the renderer and IPC threads.
scoped_refptr<DBMessageFilter> db_message_filter_;
@@ -339,17 +302,9 @@ class RenderThread : public RenderThreadBase,
// Used on multiple script execution context threads.
scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
-#if defined(OS_POSIX)
- scoped_refptr<IPC::ChannelProxy::MessageFilter>
- suicide_on_channel_error_filter_;
-#endif
-
// If true, then a GetPlugins call is allowed to rescan the disk.
bool plugin_refresh_allowed_;
- // Is there a pending task for doing CacheStats.
- bool cache_stats_task_pending_;
-
// The count of RenderWidgets running through this thread.
int widget_count_;
@@ -377,8 +332,6 @@ class RenderThread : public RenderThreadBase,
// Map of registered v8 extensions. The key is the extension name.
std::set<std::string> v8_extensions_;
- chrome::ChromeContentRendererClient renderer_client_;
-
ObserverList<RenderProcessObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(RenderThread);
diff --git a/chrome/renderer/render_thread_unittest.cc b/chrome/renderer/render_thread_unittest.cc
deleted file mode 100644
index 6430798..0000000
--- a/chrome/renderer/render_thread_unittest.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/render_messages.h"
-#include "chrome/renderer/mock_render_process.h"
-#include "chrome/renderer/render_thread.h"
-#include "ipc/ipc_sync_channel.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-const char kThreadName[] = "render_thread_unittest";
-
-class RenderThreadTest : public testing::Test {
- public:
- virtual void SetUp() {
- // Need a MODE_SERVER to make MODE_CLIENTs (like a RenderThread) happy.
- channel_ = new IPC::Channel(kThreadName, IPC::Channel::MODE_SERVER, NULL);
- mock_process_.reset(new MockRenderProcess);
- mock_process_->set_main_thread(new RenderThread(kThreadName));
- }
-
- virtual void TearDown() {
- message_loop_.RunAllPending();
- mock_process_.reset();
- // Need to fully destruct IPC::SyncChannel before the message loop goes
- // away.
- message_loop_.RunAllPending();
- // Delete the server channel after the RenderThread so that
- // IPC::SyncChannel's OnChannelError doesn't fire on the context and attempt
- // to use the listener thread which is now gone.
- delete channel_;
- }
-
- protected:
- MessageLoop message_loop_;
- scoped_ptr<MockRenderProcess> mock_process_;
- IPC::Channel *channel_;
-};
-
-TEST_F(RenderThreadTest, TestGlobal) {
- ASSERT_TRUE(RenderThread::current());
-}
-
-TEST_F(RenderThreadTest, TestVisitedMsg) {
-#if defined(OS_WIN)
- IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(NULL);
-#elif defined(OS_POSIX)
- IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(
- base::SharedMemoryHandle(0, false));
-#endif
- ASSERT_TRUE(msg);
- // Message goes nowhere, but this confirms Init() has happened.
- // Unusually (?), RenderThread() Start()s itself in it's constructor.
- mock_process_->main_thread()->Send(msg);
-
- // No need to delete msg; per Message::Send() documentation, "The
- // implementor takes ownership of the given Message regardless of
- // whether or not this method succeeds."
-}
-
-} // namespace
diff --git a/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc b/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc
index 9789920e..358507a 100644
--- a/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc
+++ b/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc
@@ -71,7 +71,17 @@ class ScorerCallback {
scoped_ptr<base::ScopedCallbackFactory<ScorerCallback> > callback_factory_;
};
-void PhishingClassifierDelegate::SetPhishingModel(
+bool PhishingClassifierFilter::OnControlMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PhishingClassifierFilter, message)
+ IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PhishingClassifierFilter::OnSetPhishingModel(
IPC::PlatformFileForTransit model_file) {
safe_browsing::Scorer::CreateFromFile(
IPC::PlatformFileForTransitToPlatformFile(model_file),
diff --git a/chrome/renderer/safe_browsing/phishing_classifier_delegate.h b/chrome/renderer/safe_browsing/phishing_classifier_delegate.h
index 3e3a09e..a07cc8b 100644
--- a/chrome/renderer/safe_browsing/phishing_classifier_delegate.h
+++ b/chrome/renderer/safe_browsing/phishing_classifier_delegate.h
@@ -11,6 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "content/renderer/render_view_observer.h"
+#include "content/renderer/render_process_observer.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_platform_file.h"
@@ -18,10 +19,14 @@ namespace safe_browsing {
class PhishingClassifier;
class Scorer;
-class PhishingClassifierDelegate : public RenderViewObserver {
+class PhishingClassifierFilter : public RenderProcessObserver {
public:
- static void SetPhishingModel(IPC::PlatformFileForTransit model_file);
+ virtual bool OnControlMessageReceived(const IPC::Message& message);
+ void OnSetPhishingModel(IPC::PlatformFileForTransit model_file);
+};
+class PhishingClassifierDelegate : public RenderViewObserver {
+ public:
// The RenderView owns us. This object takes ownership of the classifier.
// Note that if classifier is null, a default instance of PhishingClassifier
// will be used.
diff --git a/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc b/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc
index 2abaa59..6b890f7 100644
--- a/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc
+++ b/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc
@@ -60,6 +60,7 @@ void RenderViewFakeResourcesTest::SetUp() {
// but we use a real RenderThread so that we can use the ResourceDispatcher
// to fetch network resources. These are then served canned content
// in OnRequestResource().
+ content::GetContentClient()->set_renderer(&chrome_content_renderer_client_);
sandbox_init_wrapper_.reset(new SandboxInitWrapper);
command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM));
params_.reset(new MainFunctionParams(*command_line_,
diff --git a/chrome/renderer/safe_browsing/render_view_fake_resources_test.h b/chrome/renderer/safe_browsing/render_view_fake_resources_test.h
index 0e01fda..4f44a514 100644
--- a/chrome/renderer/safe_browsing/render_view_fake_resources_test.h
+++ b/chrome/renderer/safe_browsing/render_view_fake_resources_test.h
@@ -47,6 +47,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "chrome/renderer/chrome_content_renderer_client.h"
#include "content/renderer/render_view_visitor.h"
#include "ipc/ipc_channel.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -119,6 +120,7 @@ class RenderViewFakeResourcesTest : public ::testing::Test,
static const int32 kViewId; // arbitrary id for our testing view
MessageLoopForIO message_loop_;
+ chrome::ChromeContentRendererClient chrome_content_renderer_client_;
// channel that the renderer uses to talk to the browser.
// For this test, we will handle the browser end of the channel.
scoped_ptr<IPC::Channel> channel_;
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc
index 0ed18ce..ca14cbb 100644
--- a/chrome/renderer/spellchecker/spellcheck.cc
+++ b/chrome/renderer/spellchecker/spellcheck.cc
@@ -8,6 +8,7 @@
#include "base/metrics/histogram.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "chrome/common/render_messages.h"
#include "chrome/common/spellcheck_common.h"
#include "chrome/common/spellcheck_messages.h"
#include "chrome/renderer/render_thread.h"
@@ -26,6 +27,49 @@ SpellCheck::SpellCheck()
SpellCheck::~SpellCheck() {
}
+bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(SpellCheck, message)
+ IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit)
+ IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnWordAdded)
+ IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect,
+ OnEnableAutoSpellCorrect)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ if (message.type() == ViewMsg_PurgeMemory::ID) {
+ delete this;
+ new SpellCheck();
+ }
+
+ return handled;
+}
+
+void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file,
+ const std::vector<std::string>& custom_words,
+ const std::string& language,
+ bool auto_spell_correct) {
+ Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file),
+ custom_words, language);
+ auto_spell_correct_turned_on_ = auto_spell_correct;
+}
+
+void SpellCheck::OnWordAdded(const std::string& word) {
+ if (is_using_platform_spelling_engine_)
+ return;
+
+ if (!hunspell_.get()) {
+ // Save it for later---add it when hunspell is initialized.
+ custom_words_.push_back(word);
+ } else {
+ AddWordToHunspell(word);
+ }
+}
+
+void SpellCheck::OnEnableAutoSpellCorrect(bool enable) {
+ auto_spell_correct_turned_on_ = enable;
+}
+
void SpellCheck::Init(base::PlatformFile file,
const std::vector<std::string>& custom_words,
const std::string& language) {
@@ -147,22 +191,6 @@ string16 SpellCheck::GetAutoCorrectionWord(const string16& word, int tag) {
return autocorrect_word;
}
-void SpellCheck::EnableAutoSpellCorrect(bool turn_on) {
- auto_spell_correct_turned_on_ = turn_on;
-}
-
-void SpellCheck::WordAdded(const std::string& word) {
- if (is_using_platform_spelling_engine_)
- return;
-
- if (!hunspell_.get()) {
- // Save it for later---add it when hunspell is initialized.
- custom_words_.push_back(word);
- } else {
- AddWordToHunspell(word);
- }
-}
-
void SpellCheck::InitializeHunspell() {
if (hunspell_.get())
return;
diff --git a/chrome/renderer/spellchecker/spellcheck.h b/chrome/renderer/spellchecker/spellcheck.h
index 29980b5..0af6ef8 100644
--- a/chrome/renderer/spellchecker/spellcheck.h
+++ b/chrome/renderer/spellchecker/spellcheck.h
@@ -9,11 +9,14 @@
#include <string>
#include <vector>
+#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/platform_file.h"
#include "base/string16.h"
#include "base/time.h"
#include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
+#include "content/renderer/render_process_observer.h"
+#include "ipc/ipc_platform_file.h"
#include "unicode/uscript.h"
class Hunspell;
@@ -24,10 +27,9 @@ class MemoryMappedFile;
// TODO(morrita): Needs reorg with SpellCheckProvider.
// See http://crbug.com/73699.
-class SpellCheck {
+class SpellCheck : public RenderProcessObserver {
public:
SpellCheck();
-
~SpellCheck();
void Init(base::PlatformFile file,
@@ -59,14 +61,6 @@ class SpellCheck {
// behind its command line flag.
string16 GetAutoCorrectionWord(const string16& word, int tag);
- // Turn auto spell correct support ON or OFF.
- // |turn_on| = true means turn ON; false means turn OFF.
- void EnableAutoSpellCorrect(bool turn_on);
-
- // Add a word to the custom list. This may be called before or after
- // |hunspell_| has been initialized.
- void WordAdded(const std::string& word);
-
// Returns true if the spellchecker delegate checking to a system-provided
// checker on the browser process.
bool is_using_platform_spelling_engine() const {
@@ -74,6 +68,19 @@ class SpellCheck {
}
private:
+ FRIEND_TEST(SpellCheckTest, GetAutoCorrectionWord_EN_US);
+
+ // RenderProcessObserver implementation:
+ virtual bool OnControlMessageReceived(const IPC::Message& message);
+
+ // Message handlers.
+ void OnInit(IPC::PlatformFileForTransit bdict_file,
+ const std::vector<std::string>& custom_words,
+ const std::string& language,
+ bool auto_spell_correct);
+ void OnWordAdded(const std::string& word);
+ void OnEnableAutoSpellCorrect(bool enable);
+
// Initializes the Hunspell dictionary, or does nothing if |hunspell_| is
// non-null. This blocks.
void InitializeHunspell();
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc
index e0b262f..bb6edc9 100644
--- a/chrome/renderer/spellchecker/spellcheck_provider.cc
+++ b/chrome/renderer/spellchecker/spellcheck_provider.cc
@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/spellcheck_messages.h"
-#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/spellchecker/spellcheck.h"
#include "content/renderer/render_view.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
@@ -31,6 +30,8 @@ SpellCheckProvider::SpellCheckProvider(RenderView* render_view,
document_tag_(0),
spelling_panel_visible_(false),
spellcheck_(spellcheck) {
+ if (render_view) // NULL in unit tests.
+ render_view->webview()->setSpellCheckClient(this);
}
SpellCheckProvider::~SpellCheckProvider() {
@@ -85,11 +86,10 @@ void SpellCheckProvider::spellCheck(
EnsureDocumentTag();
string16 word(text);
- RenderThread* thread = RenderThread::current();
// Will be NULL during unit tests.
- if (thread) {
+ if (spellcheck_) {
std::vector<string16> suggestions;
- thread->spellchecker()->SpellCheckWord(
+ spellcheck_->SpellCheckWord(
word.c_str(), word.size(), document_tag_,
&offset, &length, optional_suggestions ? & suggestions : NULL);
if (optional_suggestions)
@@ -97,12 +97,6 @@ void SpellCheckProvider::spellCheck(
}
}
-void SpellCheckProvider::spellCheck(const WebString& text,
- int& offset,
- int& length) {
- spellCheck(text, offset, length, NULL);
-}
-
void SpellCheckProvider::requestCheckingOfText(
const WebString& text,
WebTextCheckingCompletion* completion) {
@@ -113,10 +107,9 @@ WebString SpellCheckProvider::autoCorrectWord(const WebString& word) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) {
EnsureDocumentTag();
- RenderThread* thread = RenderThread::current();
// Will be NULL during unit tests.
- if (thread)
- return thread->spellchecker()->GetAutoCorrectionWord(word, document_tag_);
+ if (spellcheck_)
+ return spellcheck_->GetAutoCorrectionWord(word, document_tag_);
}
return string16();
}
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.h b/chrome/renderer/spellchecker/spellcheck_provider.h
index 0713d01..1e1f5a9 100644
--- a/chrome/renderer/spellchecker/spellcheck_provider.h
+++ b/chrome/renderer/spellchecker/spellcheck_provider.h
@@ -12,9 +12,6 @@
#include "content/renderer/render_view_observer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h"
-// TODO(jam): remove me once WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS is rolled
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
-
class RenderView;
class SpellCheck;
@@ -62,10 +59,6 @@ class SpellCheckProvider : public RenderViewObserver,
int& offset,
int& length,
WebKit::WebVector<WebKit::WebString>* optional_suggestions);
- // TODO(jam): remove me once WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS is rolled
- virtual void spellCheck(const WebKit::WebString& text,
- int& offset,
- int& length);
virtual void requestCheckingOfText(
const WebKit::WebString& text,
WebKit::WebTextCheckingCompletion* completion);
diff --git a/chrome/renderer/spellchecker/spellcheck_unittest.cc b/chrome/renderer/spellchecker/spellcheck_unittest.cc
index 75c24f2..9b31383 100644
--- a/chrome/renderer/spellchecker/spellcheck_unittest.cc
+++ b/chrome/renderer/spellchecker/spellcheck_unittest.cc
@@ -27,6 +27,8 @@ FilePath GetHunspellDirectory() {
return hunspell_directory;
}
+} // namespace
+
class SpellCheckTest : public testing::Test {
public:
SpellCheckTest() {
@@ -690,7 +692,7 @@ TEST_F(SpellCheckTest, GetAutoCorrectionWord_EN_US) {
{"noen", ""},
{"what", ""},
};
- spell_check()->EnableAutoSpellCorrect(true);
+ spell_check()->OnEnableAutoSpellCorrect(true);
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
string16 misspelled_word(UTF8ToUTF16(kTestCases[i].input));
@@ -703,5 +705,3 @@ TEST_F(SpellCheckTest, GetAutoCorrectionWord_EN_US) {
EXPECT_EQ(expected_autocorrect_word, autocorrect_word);
}
}
-
-} // namespace
diff --git a/chrome/renderer/visitedlink_slave.cc b/chrome/renderer/visitedlink_slave.cc
index a2e9434..9f301d9 100644
--- a/chrome/renderer/visitedlink_slave.cc
+++ b/chrome/renderer/visitedlink_slave.cc
@@ -6,30 +6,47 @@
#include "base/logging.h"
#include "base/shared_memory.h"
+#include "chrome/common/render_messages.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+
+using WebKit::WebView;
VisitedLinkSlave::VisitedLinkSlave() : shared_memory_(NULL) {
}
+
VisitedLinkSlave::~VisitedLinkSlave() {
FreeTable();
}
+bool VisitedLinkSlave::OnControlMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(VisitedLinkSlave, message)
+ IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks)
+ IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks)
+ IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
// This function's job is to initialize the table with the given
-// shared memory handle. This memory is mappend into the process.
-bool VisitedLinkSlave::Init(base::SharedMemoryHandle shared_memory) {
+// shared memory handle. This memory is mapped into the process.
+void VisitedLinkSlave::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
+ DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle";
// since this function may be called again to change the table, we may need
// to free old objects
FreeTable();
DCHECK(shared_memory_ == NULL && hash_table_ == NULL);
// create the shared memory object
- shared_memory_ = new base::SharedMemory(shared_memory, true);
+ shared_memory_ = new base::SharedMemory(table, true);
if (!shared_memory_)
- return false;
+ return;
// map the header into our process so we can see how long the rest is,
// and set the salt
if (!shared_memory_->Map(sizeof(SharedHeader)))
- return false;
+ return;
SharedHeader* header =
static_cast<SharedHeader*>(shared_memory_->memory());
DCHECK(header);
@@ -41,7 +58,7 @@ bool VisitedLinkSlave::Init(base::SharedMemoryHandle shared_memory) {
if (!shared_memory_->Map(sizeof(SharedHeader) +
table_len * sizeof(Fingerprint))) {
shared_memory_->Close();
- return false;
+ return;
}
// commit the data
@@ -49,7 +66,16 @@ bool VisitedLinkSlave::Init(base::SharedMemoryHandle shared_memory) {
hash_table_ = reinterpret_cast<Fingerprint*>(
static_cast<char*>(shared_memory_->memory()) + sizeof(SharedHeader));
table_length_ = table_len;
- return true;
+}
+
+void VisitedLinkSlave::OnAddVisitedLinks(
+ const VisitedLinkSlave::Fingerprints& fingerprints) {
+ for (size_t i = 0; i < fingerprints.size(); ++i)
+ WebView::updateVisitedLinkState(fingerprints[i]);
+}
+
+void VisitedLinkSlave::OnResetVisitedLinks() {
+ WebView::resetVisitedLinkState();
}
void VisitedLinkSlave::FreeTable() {
diff --git a/chrome/renderer/visitedlink_slave.h b/chrome/renderer/visitedlink_slave.h
index 60e14a8..d437126 100644
--- a/chrome/renderer/visitedlink_slave.h
+++ b/chrome/renderer/visitedlink_slave.h
@@ -8,21 +8,23 @@
#include "base/shared_memory.h"
#include "chrome/common/visitedlink_common.h"
+#include "content/renderer/render_process_observer.h"
// Reads the link coloring database provided by the master. There can be any
// number of slaves reading the same database.
-class VisitedLinkSlave : public VisitedLinkCommon
-{
+class VisitedLinkSlave : public VisitedLinkCommon,
+ public RenderProcessObserver {
public:
VisitedLinkSlave();
virtual ~VisitedLinkSlave();
- // Called to initialize this object, nothing will work until this is called.
- // It can also be called again at any time to update the table that we're
- // using. The handle should be the handle generated by the VisitedLinkMaster.
- // Returns true on success.
- bool Init(base::SharedMemoryHandle shared_memory);
+ // RenderProcessObserver implementation.
+ virtual bool OnControlMessageReceived(const IPC::Message& message);
+ // Message handlers.
+ void OnUpdateVisitedLinks(base::SharedMemoryHandle table);
+ void OnAddVisitedLinks(const VisitedLinkSlave::Fingerprints& fingerprints);
+ void OnResetVisitedLinks();
private:
void FreeTable();
diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc
index 8c3854b..41a6daf 100644
--- a/chrome/test/render_view_test.cc
+++ b/chrome/test/render_view_test.cc
@@ -96,6 +96,7 @@ void RenderViewTest::LoadHTML(const char* html) {
void RenderViewTest::SetUp() {
content::GetContentClient()->set_renderer(&chrome_content_renderer_client_);
extension_dispatcher_ = new ExtensionDispatcher();
+ chrome_content_renderer_client_.SetExtensionDispatcher(extension_dispatcher_);
sandbox_init_wrapper_.reset(new SandboxInitWrapper());
command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM));
params_.reset(new MainFunctionParams(*command_line_, *sandbox_init_wrapper_,
@@ -111,7 +112,8 @@ void RenderViewTest::SetUp() {
WebScriptController::registerExtension(JsonSchemaJsV8Extension::Get());
WebScriptController::registerExtension(EventBindings::Get());
WebScriptController::registerExtension(ExtensionApiTestV8Extension::Get());
- WebScriptController::registerExtension(ExtensionProcessBindings::Get());
+ WebScriptController::registerExtension(ExtensionProcessBindings::Get(
+ extension_dispatcher_));
WebScriptController::registerExtension(RendererExtensionBindings::Get());
EventBindings::SetRenderThread(&render_thread_);
diff --git a/content/common/content_client.cc b/content/common/content_client.cc
index 79fe8cc..53758bb 100644
--- a/content/common/content_client.cc
+++ b/content/common/content_client.cc
@@ -17,7 +17,7 @@ ContentClient* GetContentClient() {
}
ContentClient::ContentClient() :
- browser_(NULL), gpu_(NULL), plugin_(NULL), renderer_(NULL) {
+ browser_(NULL), plugin_(NULL), renderer_(NULL) {
}
ContentClient::~ContentClient() {
diff --git a/content/common/content_client.h b/content/common/content_client.h
index 8836a44..9b7da6f 100644
--- a/content/common/content_client.h
+++ b/content/common/content_client.h
@@ -9,12 +9,12 @@
#include "base/basictypes.h"
class GURL;
+struct GPUInfo;
namespace content {
class ContentBrowserClient;
class ContentClient;
-class ContentGpuClient;
class ContentPluginClient;
class ContentRendererClient;
@@ -31,8 +31,6 @@ class ContentClient {
ContentBrowserClient* browser() { return browser_; }
void set_browser(ContentBrowserClient* c) { browser_ = c; }
- ContentGpuClient* gpu() { return gpu_; }
- void set_gpu(ContentGpuClient* g) { gpu_ = g; }
ContentPluginClient* plugin() { return plugin_; }
void set_plugin(ContentPluginClient* r) { plugin_ = r; }
ContentRendererClient* renderer() { return renderer_; }
@@ -42,11 +40,12 @@ class ContentClient {
// clear the URL.
virtual void SetActiveURL(const GURL& url) {}
+ // Sets the data on the current gpu.
+ virtual void SetGpuInfo(const GPUInfo& gpu_info) {}
+
private:
// The embedder API for participating in browser logic.
ContentBrowserClient* browser_;
- // The embedder API for participating in gpu logic.
- ContentGpuClient* gpu_;
// The embedder API for participating in plugin logic.
ContentPluginClient* plugin_;
// The embedder API for participating in renderer logic.
diff --git a/content/common/gpu/content_gpu_client.h b/content/common/gpu/content_gpu_client.h
deleted file mode 100644
index 3df4de2..0000000
--- a/content/common/gpu/content_gpu_client.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_GPU_CONTENT_GPU_CLIENT_H_
-#define CONTENT_COMMON_GPU_CONTENT_GPU_CLIENT_H_
-#pragma once
-
-#include "content/common/content_client.h"
-
-struct GPUInfo;
-
-namespace content {
-
-// Embedder API for participating in plugin logic.
-class ContentGpuClient {
- public:
- // Sets the data on the gpu to send along with crash reports.
- virtual void SetGpuInfo(const GPUInfo& gpu_info) {}
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_CONTENT_GPU_CLIENT_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 1047715..de8e378 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -94,7 +94,6 @@
'common/geolocation_messages.h',
'common/geoposition.cc',
'common/geoposition.h',
- 'common/gpu/content_gpu_client.h',
'common/gpu/gpu_channel.cc',
'common/gpu/gpu_channel.h',
'common/gpu/gpu_channel_manager.cc',
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index f0a8aad..af52c53 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -13,7 +13,7 @@
#include "build/build_config.h"
#include "chrome/common/chrome_switches.h"
#include "content/common/child_process.h"
-#include "content/common/gpu/content_gpu_client.h"
+#include "content/common/content_client.h"
#include "content/common/gpu_messages.h"
#include "content/gpu/gpu_info_collector.h"
#include "content/gpu/gpu_watchdog_thread.h"
@@ -125,7 +125,7 @@ void GpuChildThread::OnInitialize() {
}
gpu_info_collector::CollectGraphicsInfo(&gpu_info_);
- content::GetContentClient()->gpu()->SetGpuInfo(gpu_info_);
+ content::GetContentClient()->SetGpuInfo(gpu_info_);
LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete";
// Record initialization only after collecting the GPU info because that can
diff --git a/content/renderer/DEPS b/content/renderer/DEPS
index bda91c8..9758979 100644
--- a/content/renderer/DEPS
+++ b/content/renderer/DEPS
@@ -4,6 +4,7 @@ include_rules = [
"-chrome/renderer/autofill",
"-chrome/renderer/extensions",
"-chrome/renderer/safe_browsing",
+ "-chrome/renderer/spellchecker",
"+content/plugin", # For shared npruntime proxying code.
"+v8/include",
diff --git a/content/renderer/content_renderer_client.cc b/content/renderer/content_renderer_client.cc
index a4bdd28..87dd711 100644
--- a/content/renderer/content_renderer_client.cc
+++ b/content/renderer/content_renderer_client.cc
@@ -9,10 +9,15 @@
using WebKit::WebFrame;
namespace content {
+void ContentRendererClient::RenderThreadStarted() {
+}
void ContentRendererClient::RenderViewCreated(RenderView* render_view) {
}
+void ContentRendererClient::SetNumberOfViews(int number_of_views) {
+}
+
SkBitmap* ContentRendererClient::GetSadPluginBitmap() {
return NULL;
}
@@ -63,4 +68,13 @@ void ContentRendererClient::DidDestroyScriptContext(WebFrame* frame) {
void ContentRendererClient::DidCreateIsolatedScriptContext(WebFrame* frame) {
}
+unsigned long long ContentRendererClient::VisitedLinkHash(
+ const char* canonical_url, size_t length) {
+ return 0;
+}
+
+bool ContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
+ return false;
+}
+
} // namespace content
diff --git a/content/renderer/content_renderer_client.h b/content/renderer/content_renderer_client.h
index ea15759..1dc9450 100644
--- a/content/renderer/content_renderer_client.h
+++ b/content/renderer/content_renderer_client.h
@@ -28,9 +28,15 @@ namespace content {
// Embedder API for participating in renderer logic.
class ContentRendererClient {
public:
+ // Notifies us that the RenderThread has been created.
+ virtual void RenderThreadStarted();
+
// Notifies that a new RenderView has been created.
virtual void RenderViewCreated(RenderView* render_view);
+ // Sets a number of views/tabs opened in this process.
+ virtual void SetNumberOfViews(int number_of_views);
+
// Returns the bitmap to show when a plugin crashed, or NULL for none.
virtual SkBitmap* GetSadPluginBitmap();
@@ -72,6 +78,11 @@ class ContentRendererClient {
virtual void DidCreateScriptContext(WebKit::WebFrame* frame);
virtual void DidDestroyScriptContext(WebKit::WebFrame* frame);
virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* frame);
+
+ // See WebKit::WebKitClient.
+ virtual unsigned long long VisitedLinkHash(const char* canonical_url,
+ size_t length);
+ virtual bool IsLinkVisited(unsigned long long link_hash);
};
} // namespace content
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 4ea0bcc..74ef462 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -42,8 +42,6 @@
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/searchbox.h"
-#include "chrome/renderer/spellchecker/spellcheck.h"
-#include "chrome/renderer/spellchecker/spellcheck_provider.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "content/common/appcache/appcache_dispatcher.h"
#include "content/common/clipboard_messages.h"
@@ -442,7 +440,6 @@ RenderView::RenderView(RenderThreadBase* render_thread,
geolocation_dispatcher_(NULL),
speech_input_dispatcher_(NULL),
device_orientation_dispatcher_(NULL),
- spellcheck_provider_(NULL),
accessibility_ack_pending_(false),
p2p_socket_dispatcher_(NULL),
pending_app_icon_requests_(0),
@@ -501,11 +498,6 @@ RenderView::RenderView(RenderThreadBase* render_thread,
audio_message_filter_ = new AudioMessageFilter(routing_id_);
render_thread_->AddFilter(audio_message_filter_);
- RenderThread* current_thread = RenderThread::current();
- SpellCheck* spellcheck = current_thread ? current_thread->spellchecker() : 0;
- spellcheck_provider_ = new SpellCheckProvider(this, spellcheck);
- webview()->setSpellCheckClient(spellcheck_provider_);
-
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableP2PApi)) {
p2p_socket_dispatcher_ = new P2PSocketDispatcher(this);
@@ -1945,20 +1937,6 @@ bool RenderView::runModalBeforeUnloadDialog(
void RenderView::showContextMenu(
WebFrame* frame, const WebContextMenuData& data) {
ContextMenuParams params = ContextMenuParams(data);
-#if !defined(WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS)
- if (!params.misspelled_word.empty() && RenderThread::current()) {
- int misspelled_offset, misspelled_length;
- bool spelled_right = RenderThread::current()->spellchecker()->
- SpellCheckWord(
- params.misspelled_word.c_str(), params.misspelled_word.size(),
- spellcheck_provider_->document_tag(),
- &misspelled_offset, &misspelled_length,
- &params.dictionary_suggestions);
- if (spelled_right)
- params.misspelled_word.clear();
- }
-#endif
-
// Serializing a GURL longer than content::kMaxURLChars will fail, so don't do
// it. We replace it with an empty GURL so the appropriate items are disabled
// in the context menu.
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index efe2323..f1c983e 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -72,7 +72,6 @@ class RenderViewVisitor;
class RenderWidgetFullscreenPepper;
class SkBitmap;
class SpeechInputDispatcher;
-class SpellCheckProvider;
class WebPluginDelegatePepper;
class WebPluginDelegateProxy;
class WebUIBindings;
@@ -1215,9 +1214,6 @@ class RenderView : public RenderWidget,
// Device orientation dispatcher attached to this view; lazily initialized.
DeviceOrientationDispatcher* device_orientation_dispatcher_;
- // spellcheck provider which is registered as a view observer.
- SpellCheckProvider* spellcheck_provider_;
-
scoped_refptr<AudioMessageFilter> audio_message_filter_;
// Handles accessibility requests into the renderer side, as well as
diff --git a/content/renderer/renderer_webkitclient_impl.cc b/content/renderer/renderer_webkitclient_impl.cc
index 92ec578f..6ae54fc 100644
--- a/content/renderer/renderer_webkitclient_impl.cc
+++ b/content/renderer/renderer_webkitclient_impl.cc
@@ -23,6 +23,7 @@
#include "content/common/webblobregistry_impl.h"
#include "content/common/webmessageportchannel_impl.h"
#include "content/plugin/npobject_util.h"
+#include "content/renderer/content_renderer_client.h"
#include "content/renderer/render_view.h"
#include "content/renderer/renderer_webaudiodevice_impl.h"
#include "content/renderer/renderer_webidbfactory_impl.h"
@@ -201,12 +202,12 @@ bool RendererWebKitClientImpl::SendSyncMessageFromAnyThread(
unsigned long long RendererWebKitClientImpl::visitedLinkHash(
const char* canonical_url,
size_t length) {
- return RenderThread::current()->visited_link_slave()->ComputeURLFingerprint(
+ return content::GetContentClient()->renderer()->VisitedLinkHash(
canonical_url, length);
}
bool RendererWebKitClientImpl::isLinkVisited(unsigned long long link_hash) {
- return RenderThread::current()->visited_link_slave()->IsVisited(link_hash);
+ return content::GetContentClient()->renderer()->IsLinkVisited(link_hash);
}
WebKit::WebMessagePortChannel*
diff --git a/webkit/glue/context_menu.cc b/webkit/glue/context_menu.cc
index 0d68c03..317130e 100644
--- a/webkit/glue/context_menu.cc
+++ b/webkit/glue/context_menu.cc
@@ -5,9 +5,6 @@
#include "webkit/glue/context_menu.h"
#include "webkit/glue/glue_serialize.h"
-// TODO(jam): remove me once WebKit is merged.
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h"
-
namespace webkit_glue {
const int32 CustomContextMenuContext::kCurrentRenderWidget = kint32max;
@@ -46,11 +43,6 @@ ContextMenuParams::ContextMenuParams(const WebKit::WebContextMenuData& data)
edit_flags(data.editFlags),
security_info(data.securityInfo),
frame_charset(data.frameEncoding.utf8()) {
-#if defined(WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS)
- for (size_t i = 0; i < data.dictionarySuggestions.size(); ++i)
- dictionary_suggestions.push_back(data.dictionarySuggestions[i]);
-#endif
-
custom_context.is_pepper_menu = false;
for (size_t i = 0; i < data.customItems.size(); ++i)
custom_items.push_back(WebMenuItem(data.customItems[i]));