diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 04:12:18 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 04:12:18 +0000 |
commit | 0f2f4b60511540e292e085ba5e1985be6bf93908 (patch) | |
tree | 6d6bb042fe78bb23c4eca3cf4a4222a3dab38e74 /chrome/browser/views/hung_renderer_view.cc | |
parent | aaeb9dc745d49afa66c1b613daa5a3123f309955 (diff) | |
download | chromium_src-0f2f4b60511540e292e085ba5e1985be6bf93908.zip chromium_src-0f2f4b60511540e292e085ba5e1985be6bf93908.tar.gz chromium_src-0f2f4b60511540e292e085ba5e1985be6bf93908.tar.bz2 |
Window Delegate Improvements:
- Windows now must have a Delegate. Just construct the default WindowDelegate
if
you don't want to have to write one in testing.
- Windows now obtain their contents view by asking the delegate via
WindowDelegate::GetContentsView.
- Contents views no longer need to manually store a pointer to the Window that
contains them, WindowDelegate does this automatically via its window()
accessor.
Reviewer notes:
- review window_delegate.h first, then
- window.h/cc
- custom frame window.h/cc
- constrained_window_impl.h/cc
- then everything else (just updating all call sites)
B=1280060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/hung_renderer_view.cc')
-rw-r--r-- | chrome/browser/views/hung_renderer_view.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index 645c6df..2434118 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -140,8 +140,6 @@ class HungRendererWarningView : public ChromeViews::View, void ShowForWebContents(WebContents* contents); void EndForWebContents(WebContents* contents); - void set_window(ChromeViews::Window* window) { window_ = window; } - // ChromeViews::WindowDelegate overrides: virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); @@ -150,7 +148,8 @@ class HungRendererWarningView : public ChromeViews::View, ChromeViews::DialogDelegate::DialogButton button) const; virtual ChromeViews::View* GetExtraView(); virtual bool Accept(bool window_closing); - + virtual ChromeViews::View* GetContentsView(); + // ChromeViews::NativeButton::Listener overrides: virtual void ButtonPressed(ChromeViews::NativeButton* sender); @@ -193,9 +192,6 @@ class HungRendererWarningView : public ChromeViews::View, }; ButtonContainer* kill_button_container_; - // The Window that contains this view. - ChromeViews::Window* window_; - // The model that provides the contents of the table that shows a list of // pages affected by the hang. scoped_ptr<HungPagesTableModel> hung_pages_table_model_; @@ -233,7 +229,6 @@ HungRendererWarningView::HungRendererWarningView() hung_pages_table_(NULL), kill_button_(NULL), kill_button_container_(NULL), - window_(NULL), contents_(NULL), initialized_(false) { InitClass(); @@ -244,7 +239,7 @@ HungRendererWarningView::~HungRendererWarningView() { } void HungRendererWarningView::ShowForWebContents(WebContents* contents) { - DCHECK(contents && window_); + DCHECK(contents && window()); contents_ = contents; // Don't show the warning unless the foreground window is the frame, or this @@ -253,13 +248,13 @@ void HungRendererWarningView::ShowForWebContents(WebContents* contents) { HWND frame_hwnd = GetAncestor(contents->GetContainerHWND(), GA_ROOT); HWND foreground_window = GetForegroundWindow(); if (foreground_window != frame_hwnd && - foreground_window != window_->GetHWND()) { + foreground_window != window()->GetHWND()) { return; } - if (!window_->IsActive()) { + if (!window()->IsActive()) { gfx::Rect bounds = GetDisplayBounds(contents); - window_->SetBounds(bounds, frame_hwnd); + window()->SetBounds(bounds, frame_hwnd); // We only do this if the window isn't active (i.e. hasn't been shown yet, // or is currently shown but deactivated for another WebContents). This is @@ -268,14 +263,14 @@ void HungRendererWarningView::ShowForWebContents(WebContents* contents) { // the list of hung pages for a potentially unrelated renderer while this // one is showing. hung_pages_table_model_->InitForWebContents(contents); - window_->Show(); + window()->Show(); } } void HungRendererWarningView::EndForWebContents(WebContents* contents) { DCHECK(contents); if (contents_ && contents_->process() == contents->process()) { - window_->Close(); + window()->Close(); // Since we're closing, we no longer need this WebContents. contents_ = NULL; } @@ -326,6 +321,13 @@ bool HungRendererWarningView::Accept(bool window_closing) { return true; } +ChromeViews::View* HungRendererWarningView::GetContentsView() { + return this; +} + +/////////////////////////////////////////////////////////////////////////////// +// HungRendererWarningView, ChromeViews::NativeButton::Listener implementation: + void HungRendererWarningView::ButtonPressed( ChromeViews::NativeButton* sender) { if (sender == kill_button_) { @@ -401,7 +403,7 @@ void HungRendererWarningView::CreateKillButtonView() { kill_button_->SetListener(this); kill_button_container_ = new ButtonContainer; - + using ChromeViews::GridLayout; using ChromeViews::ColumnSet; @@ -426,7 +428,7 @@ gfx::Rect HungRendererWarningView::GetDisplayBounds( GetWindowRect(contents_hwnd, &contents_bounds); CRect window_bounds; - window_->GetBounds(&window_bounds, true); + window()->GetBounds(&window_bounds, true); int window_x = contents_bounds.left + (contents_bounds.Width() - window_bounds.Width()) / 2; @@ -453,9 +455,7 @@ HungRendererWarningView* HungRendererWarning::instance_ = NULL; static HungRendererWarningView* CreateHungRendererWarningView() { HungRendererWarningView* cv = new HungRendererWarningView; - ChromeViews::Window* window = - ChromeViews::Window::CreateChromeWindow(NULL, gfx::Rect(), cv, cv); - cv->set_window(window); + ChromeViews::Window::CreateChromeWindow(NULL, gfx::Rect(), cv); return cv; } |