Commit 746d3052 authored by jam@chromium.org's avatar jam@chromium.org

Remove a bunch of RenderViewHostDelegate usage in chrome. I added a...

Remove a bunch of RenderViewHostDelegate usage in chrome. I added a WebContents::FromRenderViewHost which can be used instead of RenderViewHost::GetDelegate()->GetAsWebContents().

BUG=98716
Review URL: https://chromiumcodereview.appspot.com/10416026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138254 0039d316-1c4b-4281-b951-d872f2087c98
parent 1751ffe9
...@@ -27,7 +27,7 @@ class BookmarkManagerExtensionEventRouter ...@@ -27,7 +27,7 @@ class BookmarkManagerExtensionEventRouter
TabContentsWrapper* tab); TabContentsWrapper* tab);
virtual ~BookmarkManagerExtensionEventRouter(); virtual ~BookmarkManagerExtensionEventRouter();
// RenderViewHostDelegate::BookmarkDrag interface // BookmarkTabHelper::BookmarkDrag interface
virtual void OnDragEnter(const BookmarkNodeData& data) OVERRIDE; virtual void OnDragEnter(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDragOver(const BookmarkNodeData& data) OVERRIDE; virtual void OnDragOver(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDragLeave(const BookmarkNodeData& data) OVERRIDE; virtual void OnDragLeave(const BookmarkNodeData& data) OVERRIDE;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "net/test/test_server.h" #include "net/test/test_server.h"
...@@ -123,10 +122,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) { ...@@ -123,10 +122,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) {
.AppendASCII("1.0.0.0"))); .AppendASCII("1.0.0.0")));
ExtensionProcessManager* manager = ExtensionProcessManager* manager =
browser()->profile()->GetExtensionProcessManager(); browser()->profile()->GetExtensionProcessManager();
ExtensionHost* host = FindHostWithPath(manager, "/backgroundpage.html", 1); ExtensionHost* host = FindHostWithPath(manager, "/backgroundpage.html", 1);
webkit_glue::WebPreferences prefs = webkit_glue::WebPreferences prefs =
host->render_view_host()->GetDelegate()->GetWebkitPrefs(); host->render_view_host()->GetWebkitPreferences();
ASSERT_TRUE(prefs.experimental_webgl_enabled); ASSERT_TRUE(prefs.experimental_webgl_enabled);
ASSERT_TRUE(prefs.accelerated_compositing_enabled); ASSERT_TRUE(prefs.accelerated_compositing_enabled);
ASSERT_TRUE(prefs.accelerated_2d_canvas_enabled); ASSERT_TRUE(prefs.accelerated_2d_canvas_enabled);
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
...@@ -120,9 +119,9 @@ ListValue* GetTabsForProcess(int process_id) { ...@@ -120,9 +119,9 @@ ListValue* GetTabsForProcess(int process_id) {
content::RenderViewHost* host = content::RenderViewHost::From( content::RenderViewHost* host = content::RenderViewHost::From(
const_cast<content::RenderWidgetHost*>(widget)); const_cast<content::RenderWidgetHost*>(widget));
content::RenderViewHostDelegate* host_delegate = host->GetDelegate(); content::WebContents* contents =
content::WebContents* contents = host_delegate->GetAsWebContents(); content::WebContents::FromRenderViewHost(host);
if (contents != NULL) { if (contents) {
tab_id = ExtensionTabUtil::GetTabId(contents); tab_id = ExtensionTabUtil::GetTabId(contents);
if (tab_id != -1) if (tab_id != -1)
tabs_list->Append(Value::CreateIntegerValue(tab_id)); tabs_list->Append(Value::CreateIntegerValue(tab_id));
......
...@@ -249,12 +249,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { ...@@ -249,12 +249,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
GURL url = host_delegate->GetURL(); GURL url = host_delegate->GetURL();
content::ViewType type = host_delegate->GetRenderViewType(); content::ViewType type = host_delegate->GetRenderViewType();
if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) {
// TODO(erikkay) the type for devtools doesn't actually appear to process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME;
// be set.
if (type == content::VIEW_TYPE_DEV_TOOLS_UI)
process.renderer_type = ProcessMemoryInformation::RENDERER_DEVTOOLS;
else
process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME;
} else if (extension_process_map->Contains( } else if (extension_process_map->Contains(
host->GetProcess()->GetID())) { host->GetProcess()->GetID())) {
// For our purposes, don't count processes containing only hosted apps // For our purposes, don't count processes containing only hosted apps
......
...@@ -31,7 +31,6 @@ class ProcessMetrics; ...@@ -31,7 +31,6 @@ class ProcessMetrics;
namespace content { namespace content {
class RenderViewHost; class RenderViewHost;
class RenderViewHostDelegate;
class SessionStorageNamespace; class SessionStorageNamespace;
class WebContents; class WebContents;
} }
......
...@@ -359,13 +359,12 @@ void CloudPrintFlowHandler::Observe( ...@@ -359,13 +359,12 @@ void CloudPrintFlowHandler::Observe(
url.path() == dialog_url.path() && url.path() == dialog_url.path() &&
url.scheme() == dialog_url.scheme()) { url.scheme() == dialog_url.scheme()) {
RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost();
if (rvh && rvh->GetDelegate()) { if (rvh) {
webkit_glue::WebPreferences webkit_prefs = webkit_glue::WebPreferences webkit_prefs = rvh->GetWebkitPreferences();
rvh->GetDelegate()->GetWebkitPrefs();
webkit_prefs.allow_scripts_to_close_windows = true; webkit_prefs.allow_scripts_to_close_windows = true;
rvh->UpdateWebkitPreferences(webkit_prefs); rvh->UpdateWebkitPreferences(webkit_prefs);
} else { } else {
DCHECK(false); NOTREACHED();
} }
} }
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h" #include "content/public/browser/web_contents.h"
using content::RenderViewHost; using content::RenderViewHost;
using content::RenderWidgetHost; using content::RenderWidgetHost;
using content::WebContents;
namespace { namespace {
...@@ -47,9 +48,8 @@ RenderViewHost* FindFirstDevToolsHost() { ...@@ -47,9 +48,8 @@ RenderViewHost* FindFirstDevToolsHost() {
continue; continue;
RenderViewHost* host = RenderViewHost* host =
RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
WebContents* contents = WebContents::FromRenderViewHost(host);
content::RenderViewHostDelegate* host_delegate = host->GetDelegate(); GURL url = contents->GetURL();
GURL url = host_delegate->GetURL();
if (url.SchemeIs(chrome::kChromeDevToolsScheme)) if (url.SchemeIs(chrome::kChromeDevToolsScheme))
return host; return host;
} }
......
...@@ -131,15 +131,6 @@ WebContents* LoginHandler::GetWebContentsForLogin() const { ...@@ -131,15 +131,6 @@ WebContents* LoginHandler::GetWebContentsForLogin() const {
tab_contents_id_); tab_contents_id_);
} }
RenderViewHostDelegate* LoginHandler::GetRenderViewHostDelegate() const {
RenderViewHost* rvh = RenderViewHost::FromID(render_process_host_id_,
tab_contents_id_);
if (!rvh)
return NULL;
return rvh->GetDelegate();
}
void LoginHandler::SetAuth(const string16& username, void LoginHandler::SetAuth(const string16& username,
const string16& password) { const string16& password) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......
...@@ -57,9 +57,6 @@ class LoginHandler : public content::ResourceDispatcherHostLoginDelegate, ...@@ -57,9 +57,6 @@ class LoginHandler : public content::ResourceDispatcherHostLoginDelegate,
// Returns the WebContents that needs authentication. // Returns the WebContents that needs authentication.
content::WebContents* GetWebContentsForLogin() const; content::WebContents* GetWebContentsForLogin() const;
// Returns the RenderViewHostDelegate for the page that needs authentication.
content::RenderViewHostDelegate* GetRenderViewHostDelegate() const;
// Resend the request with authentication credentials. // Resend the request with authentication credentials.
// This function can be called from either thread. // This function can be called from either thread.
void SetAuth(const string16& username, const string16& password); void SetAuth(const string16& username, const string16& password);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "grit/locale_settings.h" #include "grit/locale_settings.h"
#include "grit/platform_locale_settings.h" #include "grit/platform_locale_settings.h"
...@@ -529,10 +528,8 @@ void PrefsTabHelper::Observe(int type, ...@@ -529,10 +528,8 @@ void PrefsTabHelper::Observe(int type,
} }
void PrefsTabHelper::UpdateWebPreferences() { void PrefsTabHelper::UpdateWebPreferences() {
content::RenderViewHostDelegate* rvhd =
web_contents_->GetRenderViewHost()->GetDelegate();
web_contents_->GetRenderViewHost()->UpdateWebkitPreferences( web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(
rvhd->GetWebkitPrefs()); web_contents_->GetRenderViewHost()->GetWebkitPreferences());
} }
void PrefsTabHelper::UpdateRendererPreferences() { void PrefsTabHelper::UpdateRendererPreferences() {
......
...@@ -116,8 +116,7 @@ bool HasClientHost(RenderViewHost* rvh) { ...@@ -116,8 +116,7 @@ bool HasClientHost(RenderViewHost* rvh) {
} }
DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) { DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) {
RenderViewHostDelegate* rvh_delegate = rvh->GetDelegate(); WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
WebContents* web_contents = rvh_delegate->GetAsWebContents();
std::string title; std::string title;
std::string target_type = is_tab ? kPageTargetType : ""; std::string target_type = is_tab ? kPageTargetType : "";
GURL favicon_url; GURL favicon_url;
...@@ -143,7 +142,7 @@ DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) { ...@@ -143,7 +142,7 @@ DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) {
return BuildTargetDescriptor(target_type, return BuildTargetDescriptor(target_type,
HasClientHost(rvh), HasClientHost(rvh),
rvh_delegate->GetURL(), web_contents->GetURL(),
title, title,
favicon_url, favicon_url,
rvh->GetProcess()->GetID(), rvh->GetProcess()->GetID(),
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
...@@ -348,9 +347,8 @@ void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) { ...@@ -348,9 +347,8 @@ void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) {
void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) { void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) {
content::RenderViewHost* rvh = content::RenderViewHost* rvh =
web_ui()->GetWebContents()->GetRenderViewHost(); web_ui()->GetWebContents()->GetRenderViewHost();
if (rvh && rvh->GetDelegate()) { if (rvh) {
webkit_glue::WebPreferences webkit_prefs = webkit_glue::WebPreferences webkit_prefs = rvh->GetWebkitPreferences();
rvh->GetDelegate()->GetWebkitPrefs();
webkit_prefs.allow_scripts_to_close_windows = true; webkit_prefs.allow_scripts_to_close_windows = true;
rvh->UpdateWebkitPreferences(webkit_prefs); rvh->UpdateWebkitPreferences(webkit_prefs);
} else { } else {
......
...@@ -1598,6 +1598,10 @@ void RenderViewHostImpl::ExitFullscreen() { ...@@ -1598,6 +1598,10 @@ void RenderViewHostImpl::ExitFullscreen() {
WasResized(); WasResized();
} }
webkit_glue::WebPreferences RenderViewHostImpl::GetWebkitPreferences() {
return delegate_->GetWebkitPrefs();
}
void RenderViewHostImpl::UpdateWebkitPreferences( void RenderViewHostImpl::UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) { const webkit_glue::WebPreferences& prefs) {
Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs));
......
...@@ -226,6 +226,7 @@ class CONTENT_EXPORT RenderViewHostImpl ...@@ -226,6 +226,7 @@ class CONTENT_EXPORT RenderViewHostImpl
virtual void Zoom(PageZoom zoom) OVERRIDE; virtual void Zoom(PageZoom zoom) OVERRIDE;
virtual void SyncRendererPrefs() OVERRIDE; virtual void SyncRendererPrefs() OVERRIDE;
virtual void ToggleSpeechInput() OVERRIDE; virtual void ToggleSpeechInput() OVERRIDE;
virtual webkit_glue::WebPreferences GetWebkitPreferences() OVERRIDE;
virtual void UpdateWebkitPreferences( virtual void UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) OVERRIDE; const webkit_glue::WebPreferences& prefs) OVERRIDE;
......
...@@ -250,6 +250,11 @@ WebContents* WebContents::Create( ...@@ -250,6 +250,11 @@ WebContents* WebContents::Create(
NULL, NULL,
static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace)); static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace));
} }
WebContents* WebContents::FromRenderViewHost(RenderViewHost* rvh) {
return rvh->GetDelegate()->GetAsWebContents();
}
} }
// WebContentsImpl ------------------------------------------------------------- // WebContentsImpl -------------------------------------------------------------
......
...@@ -251,6 +251,9 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost { ...@@ -251,6 +251,9 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
virtual void ToggleSpeechInput() = 0; virtual void ToggleSpeechInput() = 0;
// Returns the current WebKit preferences.
virtual webkit_glue::WebPreferences GetWebkitPreferences() = 0;
// Passes a list of Webkit preferences to the renderer. // Passes a list of Webkit preferences to the renderer.
virtual void UpdateWebkitPreferences( virtual void UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) = 0; const webkit_glue::WebPreferences& prefs) = 0;
......
...@@ -65,6 +65,10 @@ class WebContents : public PageNavigator { ...@@ -65,6 +65,10 @@ class WebContents : public PageNavigator {
const WebContents* base_web_contents, const WebContents* base_web_contents,
SessionStorageNamespace* session_storage_namespace); SessionStorageNamespace* session_storage_namespace);
// Returns a WebContents that wraps the RenderViewHost, or NULL if the
// render view host's delegate isn't a WebContents.
CONTENT_EXPORT static WebContents* FromRenderViewHost(RenderViewHost* rvh);
virtual ~WebContents() {} virtual ~WebContents() {}
// Intrinsic tab state ------------------------------------------------------- // Intrinsic tab state -------------------------------------------------------
......
...@@ -16,7 +16,6 @@ namespace content { ...@@ -16,7 +16,6 @@ namespace content {
enum ViewTypeValues { enum ViewTypeValues {
VIEW_TYPE_INVALID, VIEW_TYPE_INVALID,
VIEW_TYPE_INTERSTITIAL_PAGE, VIEW_TYPE_INTERSTITIAL_PAGE,
VIEW_TYPE_DEV_TOOLS_UI,
VIEW_TYPE_CONTENT_END VIEW_TYPE_CONTENT_END
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment