summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 20:48:39 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 20:48:39 +0000
commit6d53eb2ab02939d98002bbd9513cbf1d4c0e258c (patch)
tree01e3375e3147ad15f86b51ceef49e8805511ac7e /chrome/browser
parentd1f99ac961277eab1ef8d0478d1737fd0b57000d (diff)
downloadchromium_src-6d53eb2ab02939d98002bbd9513cbf1d4c0e258c.zip
chromium_src-6d53eb2ab02939d98002bbd9513cbf1d4c0e258c.tar.gz
chromium_src-6d53eb2ab02939d98002bbd9513cbf1d4c0e258c.tar.bz2
Fix a crash bug in memory_utils.cc caused by assuming that the
RenderViewHost's delegate is a WebContents. Review URL: http://codereview.chromium.org/23025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/memory_details.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h3
-rw-r--r--chrome/browser/tab_contents/tab_util.cc3
-rw-r--r--chrome/browser/tab_contents/web_contents.h1
4 files changed, 8 insertions, 5 deletions
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index e1279fe..927b2eb 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -222,9 +222,9 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
continue;
RenderViewHost* host = static_cast<RenderViewHost*>(widget);
- TabContents* contents =
- static_cast<WebContents*>(host->delegate());
- DCHECK(contents);
+ TabContents* contents = NULL;
+ if (host->delegate())
+ contents = host->delegate()->GetAsWebContents();
if (!contents)
continue;
std::wstring title = contents->GetTitle();
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index b701b21..7cfe6f9 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -151,6 +151,9 @@ class RenderViewHostDelegate {
// Retrieves the profile to be used.
virtual Profile* GetProfile() const = 0;
+ // Return this object cast to a WebContents, if it is one.
+ virtual WebContents* GetAsWebContents() { return NULL; }
+
// The RenderView is being constructed (message sent to the renderer process
// to construct a RenderView). Now is a good time to send other setup events
// to the RenderView. This precedes any other commands to the RenderView.
diff --git a/chrome/browser/tab_contents/tab_util.cc b/chrome/browser/tab_contents/tab_util.cc
index 9943279..3437f1c 100644
--- a/chrome/browser/tab_contents/tab_util.cc
+++ b/chrome/browser/tab_contents/tab_util.cc
@@ -34,6 +34,5 @@ WebContents* tab_util::GetWebContentsByID(int render_process_id,
if (!render_view_host)
return NULL;
- return static_cast<WebContents*>(render_view_host->delegate());
+ return render_view_host->delegate()->GetAsWebContents();
}
-
diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h
index 98150a0..275f6f3 100644
--- a/chrome/browser/tab_contents/web_contents.h
+++ b/chrome/browser/tab_contents/web_contents.h
@@ -246,6 +246,7 @@ class WebContents : public TabContents,
virtual RenderViewHostDelegate::View* GetViewDelegate() const;
virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
virtual Profile* GetProfile() const;
+ virtual WebContents* GetAsWebContents() { return this; }
virtual void RendererReady(RenderViewHost* render_view_host);
virtual void RendererGone(RenderViewHost* render_view_host);
virtual void DidNavigate(RenderViewHost* render_view_host,