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
TabContentsWrapper* tab);
virtual ~BookmarkManagerExtensionEventRouter();
// RenderViewHostDelegate::BookmarkDrag interface
// BookmarkTabHelper::BookmarkDrag interface
virtual void OnDragEnter(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDragOver(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDragLeave(const BookmarkNodeData& data) OVERRIDE;
......
......@@ -26,7 +26,6 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.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 "net/base/net_util.h"
#include "net/test/test_server.h"
......@@ -126,7 +125,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) {
browser()->profile()->GetExtensionProcessManager();
ExtensionHost* host = FindHostWithPath(manager, "/backgroundpage.html", 1);
webkit_glue::WebPreferences prefs =
host->render_view_host()->GetDelegate()->GetWebkitPrefs();
host->render_view_host()->GetWebkitPreferences();
ASSERT_TRUE(prefs.experimental_webgl_enabled);
ASSERT_TRUE(prefs.accelerated_compositing_enabled);
ASSERT_TRUE(prefs.accelerated_2d_canvas_enabled);
......
......@@ -30,7 +30,6 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_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/web_contents.h"
#include "content/public/common/result_codes.h"
......@@ -120,9 +119,9 @@ ListValue* GetTabsForProcess(int process_id) {
content::RenderViewHost* host = content::RenderViewHost::From(
const_cast<content::RenderWidgetHost*>(widget));
content::RenderViewHostDelegate* host_delegate = host->GetDelegate();
content::WebContents* contents = host_delegate->GetAsWebContents();
if (contents != NULL) {
content::WebContents* contents =
content::WebContents::FromRenderViewHost(host);
if (contents) {
tab_id = ExtensionTabUtil::GetTabId(contents);
if (tab_id != -1)
tabs_list->Append(Value::CreateIntegerValue(tab_id));
......
......@@ -249,11 +249,6 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
GURL url = host_delegate->GetURL();
content::ViewType type = host_delegate->GetRenderViewType();
if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) {
// TODO(erikkay) the type for devtools doesn't actually appear to
// 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(
host->GetProcess()->GetID())) {
......
......@@ -31,7 +31,6 @@ class ProcessMetrics;
namespace content {
class RenderViewHost;
class RenderViewHostDelegate;
class SessionStorageNamespace;
class WebContents;
}
......
......@@ -359,13 +359,12 @@ void CloudPrintFlowHandler::Observe(
url.path() == dialog_url.path() &&
url.scheme() == dialog_url.scheme()) {
RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost();
if (rvh && rvh->GetDelegate()) {
webkit_glue::WebPreferences webkit_prefs =
rvh->GetDelegate()->GetWebkitPrefs();
if (rvh) {
webkit_glue::WebPreferences webkit_prefs = rvh->GetWebkitPreferences();
webkit_prefs.allow_scripts_to_close_windows = true;
rvh->UpdateWebkitPreferences(webkit_prefs);
} else {
DCHECK(false);
NOTREACHED();
}
}
......
......@@ -11,10 +11,11 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_process_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::RenderWidgetHost;
using content::WebContents;
namespace {
......@@ -47,9 +48,8 @@ RenderViewHost* FindFirstDevToolsHost() {
continue;
RenderViewHost* host =
RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
content::RenderViewHostDelegate* host_delegate = host->GetDelegate();
GURL url = host_delegate->GetURL();
WebContents* contents = WebContents::FromRenderViewHost(host);
GURL url = contents->GetURL();
if (url.SchemeIs(chrome::kChromeDevToolsScheme))
return host;
}
......
......@@ -131,15 +131,6 @@ WebContents* LoginHandler::GetWebContentsForLogin() const {
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,
const string16& password) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......
......@@ -57,9 +57,6 @@ class LoginHandler : public content::ResourceDispatcherHostLoginDelegate,
// Returns the WebContents that needs authentication.
content::WebContents* GetWebContentsForLogin() const;
// Returns the RenderViewHostDelegate for the page that needs authentication.
content::RenderViewHostDelegate* GetRenderViewHostDelegate() const;
// Resend the request with authentication credentials.
// This function can be called from either thread.
void SetAuth(const string16& username, const string16& password);
......
......@@ -19,7 +19,6 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.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 "grit/locale_settings.h"
#include "grit/platform_locale_settings.h"
......@@ -529,10 +528,8 @@ void PrefsTabHelper::Observe(int type,
}
void PrefsTabHelper::UpdateWebPreferences() {
content::RenderViewHostDelegate* rvhd =
web_contents_->GetRenderViewHost()->GetDelegate();
web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(
rvhd->GetWebkitPrefs());
web_contents_->GetRenderViewHost()->GetWebkitPreferences());
}
void PrefsTabHelper::UpdateRendererPreferences() {
......
......@@ -116,8 +116,7 @@ bool HasClientHost(RenderViewHost* rvh) {
}
DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) {
RenderViewHostDelegate* rvh_delegate = rvh->GetDelegate();
WebContents* web_contents = rvh_delegate->GetAsWebContents();
WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
std::string title;
std::string target_type = is_tab ? kPageTargetType : "";
GURL favicon_url;
......@@ -143,7 +142,7 @@ DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) {
return BuildTargetDescriptor(target_type,
HasClientHost(rvh),
rvh_delegate->GetURL(),
web_contents->GetURL(),
title,
favicon_url,
rvh->GetProcess()->GetID(),
......
......@@ -18,7 +18,6 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.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_ui.h"
#include "third_party/skia/include/core/SkBitmap.h"
......@@ -348,9 +347,8 @@ void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) {
void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) {
content::RenderViewHost* rvh =
web_ui()->GetWebContents()->GetRenderViewHost();
if (rvh && rvh->GetDelegate()) {
webkit_glue::WebPreferences webkit_prefs =
rvh->GetDelegate()->GetWebkitPrefs();
if (rvh) {
webkit_glue::WebPreferences webkit_prefs = rvh->GetWebkitPreferences();
webkit_prefs.allow_scripts_to_close_windows = true;
rvh->UpdateWebkitPreferences(webkit_prefs);
} else {
......
......@@ -1598,6 +1598,10 @@ void RenderViewHostImpl::ExitFullscreen() {
WasResized();
}
webkit_glue::WebPreferences RenderViewHostImpl::GetWebkitPreferences() {
return delegate_->GetWebkitPrefs();
}
void RenderViewHostImpl::UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) {
Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs));
......
......@@ -226,6 +226,7 @@ class CONTENT_EXPORT RenderViewHostImpl
virtual void Zoom(PageZoom zoom) OVERRIDE;
virtual void SyncRendererPrefs() OVERRIDE;
virtual void ToggleSpeechInput() OVERRIDE;
virtual webkit_glue::WebPreferences GetWebkitPreferences() OVERRIDE;
virtual void UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) OVERRIDE;
......
......@@ -250,6 +250,11 @@ WebContents* WebContents::Create(
NULL,
static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace));
}
WebContents* WebContents::FromRenderViewHost(RenderViewHost* rvh) {
return rvh->GetDelegate()->GetAsWebContents();
}
}
// WebContentsImpl -------------------------------------------------------------
......
......@@ -251,6 +251,9 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
virtual void ToggleSpeechInput() = 0;
// Returns the current WebKit preferences.
virtual webkit_glue::WebPreferences GetWebkitPreferences() = 0;
// Passes a list of Webkit preferences to the renderer.
virtual void UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) = 0;
......
......@@ -65,6 +65,10 @@ class WebContents : public PageNavigator {
const WebContents* base_web_contents,
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() {}
// Intrinsic tab state -------------------------------------------------------
......
......@@ -16,7 +16,6 @@ namespace content {
enum ViewTypeValues {
VIEW_TYPE_INVALID,
VIEW_TYPE_INTERSTITIAL_PAGE,
VIEW_TYPE_DEV_TOOLS_UI,
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