summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 17:53:26 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 17:53:26 +0000
commit8897c38c5cf3f8e9fe30e736fac30bce3a96844c (patch)
tree1cf3e9d2f06ccf9e5fdd388b56329e77cc3f8a4b
parenta2f7f16c5f4ed45c3b5412499fa42ec964ed2791 (diff)
downloadchromium_src-8897c38c5cf3f8e9fe30e736fac30bce3a96844c.zip
chromium_src-8897c38c5cf3f8e9fe30e736fac30bce3a96844c.tar.gz
chromium_src-8897c38c5cf3f8e9fe30e736fac30bce3a96844c.tar.bz2
Refactor view from methods to show hung renderer dialog.
This moves the methods into a header that all platforms can use and keeps the windows implementation in hung_renderer_view.cc. Review URL: http://codereview.chromium.org/109039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15424 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.vcproj4
-rw-r--r--chrome/browser/hung_renderer_dialog.h21
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc13
-rw-r--r--chrome/browser/views/browser_views.vcproj4
-rw-r--r--chrome/browser/views/hung_renderer_view.cc97
-rw-r--r--chrome/browser/views/hung_renderer_view.h31
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc9
-rw-r--r--chrome/common/temp_scaffolding_stubs.h6
9 files changed, 92 insertions, 95 deletions
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj
index e8cc6c2..ad51e70 100644
--- a/chrome/browser/browser.vcproj
+++ b/chrome/browser/browser.vcproj
@@ -2599,6 +2599,10 @@
>
</File>
<File
+ RelativePath=".\hung_renderer_dialog.h"
+ >
+ </File>
+ <File
RelativePath=".\modal_html_dialog_delegate.cc"
>
</File>
diff --git a/chrome/browser/hung_renderer_dialog.h b/chrome/browser/hung_renderer_dialog.h
new file mode 100644
index 0000000..e5c3b82
--- /dev/null
+++ b/chrome/browser/hung_renderer_dialog.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 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_BROWSER_HUNG_RENDERER_DIALOG_H_
+#define CHROME_BROWSER_HUNG_RENDERER_DIALOG_H_
+
+#include "base/basictypes.h"
+
+class TabContents;
+
+class HungRendererDialog {
+ public:
+ static void ShowForTabContents(TabContents* contents);
+ static void HideForTabContents(TabContents* contents);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HungRendererDialog);
+};
+
+#endif // CHROME_BROWSER_HUNG_RENDERER_DIALOG_H_
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 995447d..743e1bd 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/gears_integration.h"
#include "chrome/browser/google_util.h"
+#include "chrome/browser/hung_renderer_dialog.h"
#include "chrome/browser/jsmessage_box_handler.h"
#include "chrome/browser/load_from_memory_cache_details.h"
#include "chrome/browser/load_notification_details.h"
@@ -43,6 +44,7 @@
#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
+#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
@@ -54,12 +56,9 @@
#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/views/blocked_popup_container.h"
#include "chrome/browser/views/download_started_animation.h"
-#include "chrome/browser/views/hung_renderer_view.h" // TODO(brettw) delete me.
#include "chrome/views/controls/scrollbar/native_scroll_bar.h"
#endif
-#include "grit/generated_resources.h"
-
// Cross-Site Navigations
//
// If a TabContents is told to navigate to a different web site (as determined
@@ -296,7 +295,7 @@ TabContents::~TabContents() {
view_->OnContentsDestroy();
NotifyDisconnected();
- HungRendererWarning::HideForTabContents(AsWC(this));
+ HungRendererDialog::HideForTabContents(AsWC(this));
if (pending_install_.callback_functor)
pending_install_.callback_functor->Cancel();
@@ -1663,7 +1662,7 @@ void TabContents::RenderViewGone(RenderViewHost* rvh) {
view_->Invalidate();
// Hide any visible hung renderer warning for this web contents' process.
- HungRendererWarning::HideForTabContents(AsWC(this));
+ HungRendererDialog::HideForTabContents(AsWC(this));
}
void TabContents::DidNavigate(RenderViewHost* rvh,
@@ -2257,11 +2256,11 @@ void TabContents::RendererUnresponsive(RenderViewHost* rvh,
}
if (render_view_host() && render_view_host()->IsRenderViewLive())
- HungRendererWarning::ShowForTabContents(AsWC(this));
+ HungRendererDialog::ShowForTabContents(AsWC(this));
}
void TabContents::RendererResponsive(RenderViewHost* render_view_host) {
- HungRendererWarning::HideForTabContents(AsWC(this));
+ HungRendererDialog::HideForTabContents(AsWC(this));
}
void TabContents::LoadStateChanged(const GURL& url,
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 25026a2..1fc5c21 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -630,10 +630,6 @@
>
</File>
<File
- RelativePath=".\hung_renderer_view.h"
- >
- </File>
- <File
RelativePath=".\hwnd_html_view.cc"
>
</File>
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index ebe2e93..593b312 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/views/hung_renderer_view.h"
+#include "chrome/browser/hung_renderer_dialog.h"
#include "app/gfx/chrome_canvas.h"
#include "app/resource_bundle.h"
@@ -26,6 +26,13 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
+class HungRendererDialogView;
+
+namespace {
+// We only support showing one of these at a time per app.
+HungRendererDialogView* g_instance = NULL;
+}
+
///////////////////////////////////////////////////////////////////////////////
// HungPagesTableModel
@@ -108,14 +115,14 @@ void HungPagesTableModel::GetGroupRangeForItem(int item,
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView
+// HungRendererDialogView
-class HungRendererWarningView : public views::View,
- public views::DialogDelegate,
- public views::ButtonListener {
+class HungRendererDialogView : public views::View,
+ public views::DialogDelegate,
+ public views::ButtonListener {
public:
- HungRendererWarningView();
- ~HungRendererWarningView();
+ HungRendererDialogView();
+ ~HungRendererDialogView();
void ShowForTabContents(TabContents* contents);
void EndForTabContents(TabContents* contents);
@@ -182,11 +189,11 @@ class HungRendererWarningView : public views::View,
// An amusing icon image.
static SkBitmap* frozen_icon_;
- DISALLOW_EVIL_CONSTRUCTORS(HungRendererWarningView);
+ DISALLOW_EVIL_CONSTRUCTORS(HungRendererDialogView);
};
// static
-SkBitmap* HungRendererWarningView::frozen_icon_ = NULL;
+SkBitmap* HungRendererDialogView::frozen_icon_ = NULL;
// The distance in pixels from the top of the relevant contents to place the
// warning window.
@@ -197,9 +204,9 @@ static const int kTableViewWidth = 300;
static const int kTableViewHeight = 100;
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView, public:
+// HungRendererDialogView, public:
-HungRendererWarningView::HungRendererWarningView()
+HungRendererDialogView::HungRendererDialogView()
: frozen_icon_view_(NULL),
info_label_(NULL),
hung_pages_table_(NULL),
@@ -210,11 +217,11 @@ HungRendererWarningView::HungRendererWarningView()
InitClass();
}
-HungRendererWarningView::~HungRendererWarningView() {
+HungRendererDialogView::~HungRendererDialogView() {
hung_pages_table_->SetModel(NULL);
}
-void HungRendererWarningView::ShowForTabContents(TabContents* contents) {
+void HungRendererDialogView::ShowForTabContents(TabContents* contents) {
DCHECK(contents && window());
contents_ = contents;
@@ -243,7 +250,7 @@ void HungRendererWarningView::ShowForTabContents(TabContents* contents) {
}
}
-void HungRendererWarningView::EndForTabContents(TabContents* contents) {
+void HungRendererDialogView::EndForTabContents(TabContents* contents) {
DCHECK(contents);
if (contents_ && contents_->process() == contents->process()) {
window()->Close();
@@ -253,18 +260,18 @@ void HungRendererWarningView::EndForTabContents(TabContents* contents) {
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView, views::DialogDelegate implementation:
+// HungRendererDialogView, views::DialogDelegate implementation:
-std::wstring HungRendererWarningView::GetWindowTitle() const {
+std::wstring HungRendererDialogView::GetWindowTitle() const {
return l10n_util::GetString(IDS_PRODUCT_NAME);
}
-void HungRendererWarningView::WindowClosing() {
+void HungRendererDialogView::WindowClosing() {
// We are going to be deleted soon, so make sure our instance is destroyed.
- HungRendererWarning::instance_ = NULL;
+ g_instance = NULL;
}
-int HungRendererWarningView::GetDialogButtons() const {
+int HungRendererDialogView::GetDialogButtons() const {
// We specifically don't want a CANCEL button here because that code path is
// also called when the window is closed by the user clicking the X button in
// the window's titlebar, and also if we call Window::Close. Rather, we want
@@ -274,18 +281,18 @@ int HungRendererWarningView::GetDialogButtons() const {
return MessageBoxFlags::DIALOGBUTTON_OK;
}
-std::wstring HungRendererWarningView::GetDialogButtonLabel(
+std::wstring HungRendererDialogView::GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const {
if (button == MessageBoxFlags::DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_BROWSER_HANGMONITOR_RENDERER_WAIT);
return std::wstring();
}
-views::View* HungRendererWarningView::GetExtraView() {
+views::View* HungRendererDialogView::GetExtraView() {
return kill_button_container_;
}
-bool HungRendererWarningView::Accept(bool window_closing) {
+bool HungRendererDialogView::Accept(bool window_closing) {
// Don't do anything if we're being called only because the dialog is being
// destroyed and we don't supply a Cancel function...
if (window_closing)
@@ -297,14 +304,14 @@ bool HungRendererWarningView::Accept(bool window_closing) {
return true;
}
-views::View* HungRendererWarningView::GetContentsView() {
+views::View* HungRendererDialogView::GetContentsView() {
return this;
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView, views::ButtonListener implementation:
+// HungRendererDialogView, views::ButtonListener implementation:
-void HungRendererWarningView::ButtonPressed(views::Button* sender) {
+void HungRendererDialogView::ButtonPressed(views::Button* sender) {
if (sender == kill_button_) {
// Kill the process.
HANDLE process = contents_->process()->process().handle();
@@ -313,19 +320,19 @@ void HungRendererWarningView::ButtonPressed(views::Button* sender) {
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView, views::View overrides:
+// HungRendererDialogView, views::View overrides:
-void HungRendererWarningView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
+void HungRendererDialogView::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
if (!initialized_ && is_add && child == this && GetWidget())
Init();
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView, private:
+// HungRendererDialogView, private:
-void HungRendererWarningView::Init() {
+void HungRendererDialogView::Init() {
frozen_icon_view_ = new views::ImageView;
frozen_icon_view_->SetImage(frozen_icon_);
@@ -372,7 +379,7 @@ void HungRendererWarningView::Init() {
initialized_ = true;
}
-void HungRendererWarningView::CreateKillButtonView() {
+void HungRendererDialogView::CreateKillButtonView() {
kill_button_ = new views::NativeButton(
this, l10n_util::GetString(IDS_BROWSER_HANGMONITOR_RENDERER_END));
@@ -395,7 +402,7 @@ void HungRendererWarningView::CreateKillButtonView() {
layout->AddView(kill_button_);
}
-gfx::Rect HungRendererWarningView::GetDisplayBounds(
+gfx::Rect HungRendererDialogView::GetDisplayBounds(
TabContents* contents) {
HWND contents_hwnd = contents->GetNativeView();
CRect contents_bounds;
@@ -411,7 +418,7 @@ gfx::Rect HungRendererWarningView::GetDisplayBounds(
}
// static
-void HungRendererWarningView::InitClass() {
+void HungRendererDialogView::InitClass() {
static bool initialized = false;
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -421,28 +428,26 @@ void HungRendererWarningView::InitClass() {
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarning
+// HungRendererDialog
-// static
-HungRendererWarningView* HungRendererWarning::instance_ = NULL;
-static HungRendererWarningView* CreateHungRendererWarningView() {
- HungRendererWarningView* cv = new HungRendererWarningView;
+static HungRendererDialogView* CreateHungRendererDialogView() {
+ HungRendererDialogView* cv = new HungRendererDialogView;
views::Window::CreateChromeWindow(NULL, gfx::Rect(), cv);
return cv;
}
// static
-void HungRendererWarning::ShowForTabContents(TabContents* contents) {
+void HungRendererDialog::ShowForTabContents(TabContents* contents) {
if (!logging::DialogsAreSuppressed()) {
- if (!instance_)
- instance_ = CreateHungRendererWarningView();
- instance_->ShowForTabContents(contents);
+ if (!g_instance)
+ g_instance = CreateHungRendererDialogView();
+ g_instance->ShowForTabContents(contents);
}
}
// static
-void HungRendererWarning::HideForTabContents(TabContents* contents) {
- if (!logging::DialogsAreSuppressed() && instance_)
- instance_->EndForTabContents(contents);
+void HungRendererDialog::HideForTabContents(TabContents* contents) {
+ if (!logging::DialogsAreSuppressed() && g_instance)
+ g_instance->EndForTabContents(contents);
}
diff --git a/chrome/browser/views/hung_renderer_view.h b/chrome/browser/views/hung_renderer_view.h
deleted file mode 100644
index def210e..0000000
--- a/chrome/browser/views/hung_renderer_view.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2006-2008 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_BROWSER_VIEWS_HUNG_RENDERER_VIEW_H__
-#define CHROME_BROWSER_VIEWS_HUNG_RENDERER_VIEW_H__
-
-#include "base/basictypes.h"
-
-class HungRendererWarningView;
-namespace views {
-class Window;
-}
-class TabContents;
-
-class HungRendererWarning {
- public:
- static void ShowForTabContents(TabContents* contents);
- static void HideForTabContents(TabContents* contents);
-
- private:
- friend HungRendererWarningView;
-
- // We only support showing one of these at a time per app.
- static HungRendererWarningView* instance_;
-
- DISALLOW_EVIL_CONSTRUCTORS(HungRendererWarning);
-};
-
-
-#endif // CHROME_BROWSER_VIEWS_HUNG_RENDERER_VIEW_H__
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index b472122..212c0b0 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -949,6 +949,7 @@
'browser/history/visit_tracker.h',
'browser/history/visitsegment_database.cc',
'browser/history/visitsegment_database.h',
+ 'browser/hung_renderer_dialog.h',
'browser/icon_loader.cc',
'browser/icon_loader.h',
'browser/icon_manager.cc',
@@ -1336,7 +1337,6 @@
'browser/views/html_dialog_view.cc',
'browser/views/html_dialog_view.h',
'browser/views/hung_renderer_view.cc',
- 'browser/views/hung_renderer_view.h',
'browser/views/hwnd_html_view.cc',
'browser/views/hwnd_html_view.h',
'browser/views/importer_lock_view.cc',
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index 8cfcccd..1eee578 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/download/download_request_dialog_delegate.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/first_run.h"
+#include "chrome/browser/hung_renderer_dialog.h"
#include "chrome/browser/memory_details.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/shell_integration.h"
@@ -301,3 +302,11 @@ void TaskManager::AddResource(Resource* resource) {
void TaskManager::RemoveResource(Resource* resource) {
NOTIMPLEMENTED();
}
+
+void HungRendererDialog::HideForTabContents(TabContents*) {
+ NOTIMPLEMENTED();
+}
+
+void HungRendererDialog::ShowForTabContents(TabContents*) {
+ NOTIMPLEMENTED();
+}
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 4050f4e..0dcf436 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -392,12 +392,6 @@ class WebApp : public base::RefCountedThreadSafe<WebApp> {
}
};
-class HungRendererWarning {
- public:
- static void HideForTabContents(TabContents*) { NOTIMPLEMENTED(); }
- static void ShowForTabContents(TabContents*) { NOTIMPLEMENTED(); }
-};
-
class ModalHtmlDialogDelegate : public HtmlDialogUIDelegate {
public:
ModalHtmlDialogDelegate(const GURL&, int, int, const std::string&,