summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-07 22:03:10 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-07 22:03:10 +0000
commit94098fe02a8c5950df6453ccca7621a2d2a6816f (patch)
tree202c8855a76a7e11bb88fb46fe409a3c4d0888cd
parent172f155f817cc56e1ca36bee6aeeca7f8f95bb64 (diff)
downloadchromium_src-94098fe02a8c5950df6453ccca7621a2d2a6816f.zip
chromium_src-94098fe02a8c5950df6453ccca7621a2d2a6816f.tar.gz
chromium_src-94098fe02a8c5950df6453ccca7621a2d2a6816f.tar.bz2
Move WindowDelegate and NonClientView creation and management to Window.
This makes WindowGtk/WindowWin a little uglier for now, will improve with consolidation of more functions into Window. BUG=72040 TEST=none Review URL: http://codereview.chromium.org/6621033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77194 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/accessibility/browser_views_accessibility_browsertest.cc10
-rw-r--r--chrome/browser/chromeos/frame/browser_frame_chromeos.cc2
-rw-r--r--chrome/browser/chromeos/frame/browser_view.cc2
-rw-r--r--chrome/browser/chromeos/frame/bubble_frame_view.cc10
-rw-r--r--chrome/browser/chromeos/frame/bubble_window.cc4
-rw-r--r--chrome/browser/chromeos/login/login_html_dialog.cc2
-rw-r--r--chrome/browser/chromeos/native_dialog_window.cc2
-rw-r--r--chrome/browser/ui/input_window_dialog_win.cc2
-rw-r--r--chrome/browser/ui/touch/tabs/touch_tab_strip.cc2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc3
-rw-r--r--chrome/browser/ui/views/constrained_window_win.cc20
-rw-r--r--chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc10
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_gtk.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.cc12
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.cc8
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc28
-rw-r--r--chrome/browser/ui/views/select_file_dialog.cc2
-rw-r--r--chrome/browser/ui/views/tabs/tab.cc2
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.cc2
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc6
-rw-r--r--views/focus/focus_manager_unittest.cc2
-rw-r--r--views/view_unittest.cc2
-rw-r--r--views/window/client_view.cc1
-rw-r--r--views/window/custom_frame_view.cc26
-rw-r--r--views/window/dialog_client_view.cc11
-rw-r--r--views/window/dialog_delegate.cc5
-rw-r--r--views/window/native_frame_view.cc6
-rw-r--r--views/window/native_window_delegate.h7
-rw-r--r--views/window/non_client_view.cc3
-rw-r--r--views/window/window.cc33
-rw-r--r--views/window/window.h54
-rw-r--r--views/window/window_delegate.h3
-rw-r--r--views/window/window_gtk.cc61
-rw-r--r--views/window/window_gtk.h3
-rw-r--r--views/window/window_win.cc141
-rw-r--r--views/window/window_win.h12
37 files changed, 252 insertions, 253 deletions
diff --git a/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc b/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc
index 40c60cb5d..9460d04 100644
--- a/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc
+++ b/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc
@@ -141,7 +141,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
// info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestNonClientViewAccObj) {
views::View* non_client_view =
- GetBrowserView()->GetWindow()->GetNonClientView();
+ GetBrowserView()->GetWindow()->non_client_view();
TestViewAccessibilityObject(non_client_view,
UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)),
@@ -248,18 +248,18 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
TestAboutChromeViewAccObj) {
// Firstly, test that the WindowDelegate got updated.
- views::Window* aboutChromeWindow =
+ views::Window* about_chrome_window =
GetBrowserView()->DoShowAboutChromeDialog();
EXPECT_STREQ(
- aboutChromeWindow->GetDelegate()->GetWindowTitle().c_str(),
+ about_chrome_window->window_delegate()->GetWindowTitle().c_str(),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_TITLE)).c_str());
- EXPECT_EQ(aboutChromeWindow->GetDelegate()->accessible_role(),
+ EXPECT_EQ(about_chrome_window->window_delegate()->accessible_role(),
AccessibilityTypes::ROLE_DIALOG);
// Also test the accessibility object directly.
IAccessible* acc_obj = NULL;
HRESULT hr =
- ::AccessibleObjectFromWindow(aboutChromeWindow->GetNativeWindow(),
+ ::AccessibleObjectFromWindow(about_chrome_window->GetNativeWindow(),
OBJID_CLIENT,
IID_IAccessible,
reinterpret_cast<void**>(&acc_obj));
diff --git a/chrome/browser/chromeos/frame/browser_frame_chromeos.cc b/chrome/browser/chromeos/frame/browser_frame_chromeos.cc
index 74d1cc8..b32d5fb 100644
--- a/chrome/browser/chromeos/frame/browser_frame_chromeos.cc
+++ b/chrome/browser/chromeos/frame/browser_frame_chromeos.cc
@@ -38,7 +38,7 @@ void BrowserFrameChromeos::InitBrowserFrame() {
if (!browser_view()->IsBrowserTypePopup()) {
// On chromeos we want windows to always render as active.
- GetNonClientView()->DisableInactiveRendering(true);
+ non_client_view()->DisableInactiveRendering(true);
}
}
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc
index 26d8dea..8a0b678 100644
--- a/chrome/browser/chromeos/frame/browser_view.cc
+++ b/chrome/browser/chromeos/frame/browser_view.cc
@@ -234,7 +234,7 @@ void BrowserView::Init() {
// a NonClientFrameView even though visually a TabStrip is over a
// NonClientFrameView.
BrowserFrameGtk* gtk_frame = static_cast<BrowserFrameGtk*>(frame());
- gtk_frame->GetNonClientView()->SetContextMenuController(this);
+ gtk_frame->non_client_view()->SetContextMenuController(this);
// Listen to wrench menu opens.
toolbar()->AddMenuListener(this);
diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc
index 29d2b32..d49d001 100644
--- a/chrome/browser/chromeos/frame/bubble_frame_view.cc
+++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc
@@ -48,8 +48,8 @@ BubbleFrameView::BubbleFrameView(views::Window* frame,
throbber_(NULL) {
set_border(new BubbleBorder(BubbleBorder::NONE));
- if (frame_->GetDelegate()->ShouldShowWindowTitle()) {
- title_ = new views::Label(frame_->GetDelegate()->GetWindowTitle());
+ if (frame_->window_delegate()->ShouldShowWindowTitle()) {
+ title_ = new views::Label(frame_->window_delegate()->GetWindowTitle());
title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
title_->SetFont(title_->font().DeriveFont(kFontSizeCorrectionDelta,
gfx::Font::BOLD));
@@ -88,7 +88,7 @@ void BubbleFrameView::StopThrobber() {
DCHECK(throbber_ != NULL);
throbber_->Stop();
if (title_)
- title_->SetText(frame_->GetDelegate()->GetWindowTitle());
+ title_->SetText(frame_->window_delegate()->GetWindowTitle());
}
gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
@@ -150,9 +150,9 @@ gfx::Insets BubbleFrameView::GetInsets() const {
}
gfx::Size BubbleFrameView::GetPreferredSize() {
- gfx::Size pref = frame_->GetClientView()->GetPreferredSize();
+ gfx::Size pref = frame_->client_view()->GetPreferredSize();
gfx::Rect bounds(0, 0, pref.width(), pref.height());
- return frame_->GetNonClientView()->GetWindowBoundsForClientBounds(
+ return frame_->non_client_view()->GetWindowBoundsForClientBounds(
bounds).size();
}
diff --git a/chrome/browser/chromeos/frame/bubble_window.cc b/chrome/browser/chromeos/frame/bubble_window.cc
index cb5937c..592b70c 100644
--- a/chrome/browser/chromeos/frame/bubble_window.cc
+++ b/chrome/browser/chromeos/frame/bubble_window.cc
@@ -55,7 +55,7 @@ void BubbleWindow::InitWindow(GtkWindow* parent, const gfx::Rect& bounds) {
void BubbleWindow::TrimMargins(int margin_left, int margin_right,
int margin_top, int margin_bottom,
int border_radius) {
- gfx::Size size = GetNonClientView()->GetPreferredSize();
+ gfx::Size size = non_client_view()->GetPreferredSize();
const int w = size.width() - margin_left - margin_right;
const int h = size.height() - margin_top - margin_bottom;
GdkRectangle rect0 = {0, border_radius, w, h - 2 * border_radius};
@@ -111,7 +111,7 @@ views::Window* BubbleWindow::Create(
Style style,
views::WindowDelegate* window_delegate) {
BubbleWindow* window = new BubbleWindow(window_delegate);
- window->GetNonClientView()->SetFrameView(new BubbleFrameView(window, style));
+ window->non_client_view()->SetFrameView(new BubbleFrameView(window, style));
window->InitWindow(parent, bounds);
if (style == STYLE_XSHAPE) {
diff --git a/chrome/browser/chromeos/login/login_html_dialog.cc b/chrome/browser/chromeos/login/login_html_dialog.cc
index ba3e72d..8c51034 100644
--- a/chrome/browser/chromeos/login/login_html_dialog.cc
+++ b/chrome/browser/chromeos/login/login_html_dialog.cc
@@ -74,7 +74,7 @@ void LoginHtmlDialog::Show() {
BubbleWindow::STYLE_XBAR | BubbleWindow::STYLE_THROBBER),
html_view);
bubble_frame_view_ = static_cast<BubbleFrameView*>(
- bubble_window->GetNonClientView()->frame_view());
+ bubble_window->non_client_view()->frame_view());
} else {
views::Window::CreateChromeWindow(parent_window_, gfx::Rect(), html_view);
}
diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc
index 0b325a2..7960580 100644
--- a/chrome/browser/chromeos/native_dialog_window.cc
+++ b/chrome/browser/chromeos/native_dialog_window.cc
@@ -143,7 +143,7 @@ void NativeDialogHost::OnCheckResize(GtkWidget* widget) {
CheckSize();
SizeToPreferredSize();
- gfx::Size window_size = window()->GetNonClientView()->GetPreferredSize();
+ gfx::Size window_size = window()->non_client_view()->GetPreferredSize();
gfx::Rect window_bounds = window()->GetBounds();
window_bounds.set_width(window_size.width());
window_bounds.set_height(window_size.height());
diff --git a/chrome/browser/ui/input_window_dialog_win.cc b/chrome/browser/ui/input_window_dialog_win.cc
index 1f6aeed..268fa7b 100644
--- a/chrome/browser/ui/input_window_dialog_win.cc
+++ b/chrome/browser/ui/input_window_dialog_win.cc
@@ -207,7 +207,7 @@ WinInputWindowDialog::WinInputWindowDialog(HWND parent,
delegate_(delegate) {
window_ = views::Window::CreateChromeWindow(parent, gfx::Rect(),
new ContentView(this));
- window_->GetClientView()->AsDialogClientView()->UpdateDialogButtons();
+ window_->client_view()->AsDialogClientView()->UpdateDialogButtons();
}
WinInputWindowDialog::~WinInputWindowDialog() {
diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc
index a907f22..0cec7be 100644
--- a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc
+++ b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc
@@ -163,7 +163,7 @@ void TouchTabStrip::PaintChildren(gfx::Canvas* canvas) {
}
}
- if (GetWindow()->GetNonClientView()->UseNativeFrame()) {
+ if (GetWindow()->non_client_view()->UseNativeFrame()) {
// Make sure unselected tabs are somewhat transparent.
SkPaint paint;
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
index cd6fea2..75aea90 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -90,8 +90,9 @@ void BookmarkBubbleView::Show(views::Window* parent,
return;
bubble_ = new BookmarkBubbleView(delegate, profile, url, newly_bookmarked);
+ // TODO(beng): Pass |parent| after V2 is complete.
InfoBubble* info_bubble = InfoBubble::Show(
- parent->GetClientView()->GetWidget(), bounds, BubbleBorder::TOP_RIGHT,
+ parent->client_view()->GetWidget(), bounds, BubbleBorder::TOP_RIGHT,
bubble_, bubble_);
// |bubble_| can be set to NULL in InfoBubbleClosing when we close the bubble
// asynchronously. However, that can happen during the Show call above if the
diff --git a/chrome/browser/ui/views/constrained_window_win.cc b/chrome/browser/ui/views/constrained_window_win.cc
index 2f3f932..641d542 100644
--- a/chrome/browser/ui/views/constrained_window_win.cc
+++ b/chrome/browser/ui/views/constrained_window_win.cc
@@ -308,7 +308,7 @@ int ConstrainedWindowFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- int frame_component = container_->GetClientView()->NonClientHitTest(point);
+ int frame_component = container_->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. (We check the ClientView first to be
// consistent with OpaqueBrowserFrameView; it's not really necessary here.)
@@ -326,7 +326,7 @@ int ConstrainedWindowFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, kFrameBorderThickness,
NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
- container_->GetDelegate()->CanResize());
+ container_->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -566,15 +566,15 @@ views::NonClientFrameView* ConstrainedWindowWin::CreateFrameViewForWindow() {
void ConstrainedWindowWin::FocusConstrainedWindow() {
if ((!owner_->delegate() ||
owner_->delegate()->ShouldFocusConstrainedWindow()) &&
- GetDelegate() && GetDelegate()->GetInitiallyFocusedView()) {
- GetDelegate()->GetInitiallyFocusedView()->RequestFocus();
+ window_delegate() && window_delegate()->GetInitiallyFocusedView()) {
+ window_delegate()->GetInitiallyFocusedView()->RequestFocus();
}
}
void ConstrainedWindowWin::ShowConstrainedWindow() {
// We marked the view as hidden during construction. Mark it as
// visible now so FocusManager will let us receive focus.
- GetNonClientView()->SetVisible(true);
+ non_client_view()->SetVisible(true);
if (owner_->delegate())
owner_->delegate()->WillShowConstrainedWindow(owner_);
ActivateConstrainedWindow();
@@ -593,8 +593,8 @@ void ConstrainedWindowWin::CloseConstrainedWindow() {
}
std::wstring ConstrainedWindowWin::GetWindowTitle() const {
- if (GetDelegate())
- return GetDelegate()->GetWindowTitle();
+ if (window_delegate())
+ return window_delegate()->GetWindowTitle();
// TODO(pkasting): Shouldn't this be using a localized string, or else calling
// NOTREACHED()?
@@ -613,7 +613,7 @@ ConstrainedWindowWin::ConstrainedWindowWin(
views::WindowDelegate* window_delegate)
: WindowWin(window_delegate),
owner_(owner) {
- GetNonClientView()->SetFrameView(CreateFrameViewForWindow());
+ non_client_view()->SetFrameView(CreateFrameViewForWindow());
set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION |
WS_THICKFRAME | WS_SYSMENU);
@@ -621,7 +621,7 @@ ConstrainedWindowWin::ConstrainedWindowWin(
// Views default to visible. Since we are creating a window that is
// not visible (no WS_VISIBLE), mark our View as hidden so that
// FocusManager can deal with it properly.
- GetNonClientView()->SetVisible(false);
+ non_client_view()->SetVisible(false);
WindowWin::Init(owner_->GetNativeView(), gfx::Rect());
}
@@ -667,7 +667,7 @@ void ConstrainedWindowWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
// If the window was moved or sized, tell the owner.
if (!(window_pos->flags & SWP_NOMOVE) || !(window_pos->flags & SWP_NOSIZE))
owner_->DidMoveOrResize(this);
- SetMsgHandled(FALSE);
+ WindowWin::OnWindowPosChanged(window_pos);
}
diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
index 1cd4116..40fa89d 100644
--- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
@@ -147,7 +147,7 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
+ frame_->GetWindow()->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. (We check the ClientView first to be
// consistent with OpaqueBrowserFrameView; it's not really necessary here.)
@@ -171,7 +171,7 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point,
NonClientBorderThickness(), NonClientBorderThickness(),
kResizeAreaCornerSize, kResizeAreaCornerSize,
- frame_->GetWindow()->GetDelegate()->CanResize());
+ frame_->GetWindow()->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -251,7 +251,7 @@ bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap AppPanelBrowserFrameView::GetFavIconForTabIconView() {
- return frame_->GetWindow()->GetDelegate()->GetWindowIcon();
+ return frame_->GetWindow()->window_delegate()->GetWindowIcon();
}
///////////////////////////////////////////////////////////////////////////////
@@ -396,13 +396,13 @@ void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = titlebar_bottom->height() - kClientEdgeThickness;
canvas->TileImageInt(*titlebar_bottom, 0,
- frame_->GetWindow()->GetClientView()->y() - edge_height,
+ frame_->GetWindow()->client_view()->y() - edge_height,
width(), edge_height);
}
void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WindowDelegate* d = frame_->GetWindow()->GetDelegate();
+ views::WindowDelegate* d = frame_->GetWindow()->window_delegate();
canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(),
SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(),
title_bounds_.width(), title_bounds_.height());
diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.cc b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
index ef8b1d4..6c8da688 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
@@ -49,7 +49,7 @@ void BrowserFrameGtk::InitBrowserFrame() {
browser_frame_view_ =
browser::CreateBrowserNonClientFrameView(this, browser_view_);
- GetNonClientView()->SetFrameView(browser_frame_view_);
+ non_client_view()->SetFrameView(browser_frame_view_);
WindowGtk::InitWindow(NULL, gfx::Rect());
// Don't focus anything on creation, selecting a tab will set the focus.
}
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc
index 9638f10..54b6e41 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_win.cc
@@ -56,7 +56,7 @@ BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile)
frame_initialized_(false),
profile_(profile) {
browser_view_->set_frame(this);
- GetNonClientView()->SetFrameView(CreateFrameViewForWindow());
+ non_client_view()->SetFrameView(CreateFrameViewForWindow());
// Don't focus anything on creation, selecting a tab will set the focus.
set_focus_on_creation(false);
}
@@ -139,7 +139,7 @@ void BrowserFrameWin::TabStripDisplayModeChanged() {
gfx::Insets BrowserFrameWin::GetClientAreaInsets() const {
// Use the default client insets for an opaque frame or a glass popup/app
// frame.
- if (!GetNonClientView()->UseNativeFrame() ||
+ if (!non_client_view()->UseNativeFrame() ||
!browser_view_->IsBrowserTypeNormal()) {
return WindowWin::GetClientAreaInsets();
}
@@ -200,7 +200,7 @@ LRESULT BrowserFrameWin::OnNCActivate(BOOL active) {
LRESULT BrowserFrameWin::OnNCHitTest(const CPoint& pt) {
// Only do DWM hit-testing when we are using the native frame.
- if (GetNonClientView()->UseNativeFrame()) {
+ if (non_client_view()->UseNativeFrame()) {
LRESULT result;
if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
MAKELPARAM(pt.x, pt.y), &result)) {
@@ -224,8 +224,8 @@ void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
// SWP_SHOWWINDOW, however callers typically are careful about not specifying
// this flag unless necessary to avoid flicker.
if (window_pos->flags & SWP_SHOWWINDOW) {
- GetNonClientView()->Layout();
- GetNonClientView()->SchedulePaint();
+ non_client_view()->Layout();
+ non_client_view()->SchedulePaint();
}
}
@@ -283,7 +283,7 @@ views::RootView* BrowserFrameWin::CreateRootView() {
void BrowserFrameWin::UpdateDWMFrame() {
// Nothing to do yet, or we're not showing a DWM frame.
- if (!GetClientView() || !AlwaysUseNativeFrame())
+ if (!client_view() || !AlwaysUseNativeFrame())
return;
MARGINS margins = { 0 };
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 894a4a5..96605d8 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1660,7 +1660,7 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
bounds->height() + toolbar_->GetPreferredSize().height());
}
- gfx::Rect window_rect = frame_->GetWindow()->GetNonClientView()->
+ gfx::Rect window_rect = frame_->GetWindow()->non_client_view()->
GetWindowBoundsForClientBounds(*bounds);
window_rect.set_origin(bounds->origin());
@@ -2573,7 +2573,7 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
BrowserView* view = new BrowserView(browser);
BrowserFrame::Create(view, browser->profile());
- view->GetWindow()->GetNonClientView()->SetAccessibleName(
+ view->GetWindow()->non_client_view()->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
return view;
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
index c52ba7c..98dc9e7 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -66,7 +66,7 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
browser_view_(browser_view),
throbber_running_(false),
throbber_frame_(0) {
- if (frame_->GetWindow()->GetDelegate()->ShouldShowWindowIcon())
+ if (frame_->GetWindow()->window_delegate()->ShouldShowWindowIcon())
InitThrobberIcons();
}
@@ -167,7 +167,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
+ frame_->GetWindow()->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. We still have to check the tabstrip
// first so that clicks in a tab don't get treated as sysmenu clicks.
@@ -184,7 +184,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, frame_border_thickness,
nonclient_border_thickness, frame_border_thickness,
kResizeAreaCornerSize - frame_border_thickness,
- frame_->GetWindow()->GetDelegate()->CanResize());
+ frame_->GetWindow()->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -368,7 +368,7 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
// of how tall the toolbar itself is.
int client_area_top = browser_view_->UseVerticalTabs() ?
client_area_bounds.y() :
- (frame_->GetWindow()->GetClientView()->y() +
+ (frame_->GetWindow()->client_view()->y() +
browser_view_->GetToolbarBounds().y() +
tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height());
int client_area_bottom =
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index 3bdbd2c..8501d29 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -238,7 +238,7 @@ gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight(false, false) + border_thickness);
- views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
int min_titlebar_width = (2 * FrameBorderThickness(false)) +
kIconLeftSpacing +
(delegate && delegate->ShouldShowWindowIcon() ?
@@ -283,7 +283,7 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
+ frame_->GetWindow()->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. We still have to check the tabstrip
// first so that clicks in a tab don't get treated as sysmenu clicks.
@@ -313,8 +313,8 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
minimize_button_->GetMirroredBounds().Contains(point))
return HTMINBUTTON;
- views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate();
- if (delegate == NULL) {
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return HTCAPTION;
}
@@ -384,7 +384,7 @@ bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
bool vertical_tabs = browser_view_->UseVerticalTabs();
gfx::Rect tabstrip_bounds = browser_view_->tabstrip()->bounds();
gfx::Point tabstrip_origin(tabstrip_bounds.origin());
- View::ConvertPointToView(frame_->GetWindow()->GetClientView(),
+ View::ConvertPointToView(frame_->GetWindow()->client_view(),
this, &tabstrip_origin);
tabstrip_bounds.set_origin(tabstrip_origin);
if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) ||
@@ -432,8 +432,8 @@ bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() {
- views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate();
- if (delegate == NULL) {
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return SkBitmap();
}
@@ -465,7 +465,7 @@ int OpaqueBrowserFrameView::NonClientTopBorderHeight(
bool restored,
bool ignore_vertical_tabs) const {
views::Window* window = frame_->GetWindow();
- views::WindowDelegate* delegate = window->GetDelegate();
+ views::WindowDelegate* delegate = window->window_delegate();
// |delegate| may be NULL if called from callback of InputMethodChanged while
// a window is being destroyed.
// See more discussion at http://crosbug.com/8958
@@ -509,7 +509,7 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
int size = IconSize();
int frame_thickness = FrameBorderThickness(false);
int y;
- views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
if (delegate && (delegate->ShouldShowWindowIcon() ||
delegate->ShouldShowWindowTitle())) {
// Our frame border has a different "3D look" than Windows'. Theirs has a
@@ -698,14 +698,14 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = top_center->height() - kClientEdgeThickness;
canvas->TileImageInt(*top_center, 0,
- window->GetClientView()->y() - edge_height, width(), edge_height);
+ window->client_view()->y() - edge_height, width(), edge_height);
}
}
void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate();
- if (delegate == NULL) {
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ if (!delegate) {
LOG(WARNING) << "delegate is NULL";
return;
}
@@ -856,7 +856,7 @@ void OpaqueBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
ui::ThemeProvider* tp = GetThemeProvider();
- int client_area_top = frame_->GetWindow()->GetClientView()->y();
+ int client_area_top = frame_->GetWindow()->client_view()->y();
int image_top = client_area_top;
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
@@ -1019,7 +1019,7 @@ void OpaqueBrowserFrameView::LayoutTitleBar() {
// The window title is based on the calculated icon position, even when there
// is no icon.
gfx::Rect icon_bounds(IconBounds());
- views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
if (delegate && delegate->ShouldShowWindowIcon())
window_icon_->SetBoundsRect(icon_bounds);
diff --git a/chrome/browser/ui/views/select_file_dialog.cc b/chrome/browser/ui/views/select_file_dialog.cc
index 0aa3970..92652d2 100644
--- a/chrome/browser/ui/views/select_file_dialog.cc
+++ b/chrome/browser/ui/views/select_file_dialog.cc
@@ -491,6 +491,6 @@ void SelectFileDialogImpl::FileBrowseDelegateHandler::HandleSetDialogTitle(
DCHECK(containing_view);
containing_view->GetWindow()->UpdateWindowTitle();
- containing_view->GetWindow()->GetNonClientView()->SchedulePaint();
+ containing_view->GetWindow()->non_client_view()->SchedulePaint();
}
}
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index e6cf2f0..341e742 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -445,7 +445,7 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) {
int tab_id;
if (GetWidget() &&
- GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) {
+ GetWidget()->GetWindow()->non_client_view()->UseNativeFrame()) {
tab_id = IDR_THEME_TAB_BACKGROUND_V;
} else {
tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO :
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 059c7e5..43bb125 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -282,7 +282,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
}
}
- if (GetWindow()->GetNonClientView()->UseNativeFrame()) {
+ if (GetWindow()->non_client_view()->UseNativeFrame()) {
// Make sure unselected tabs are somewhat transparent.
SkPaint paint;
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index 1eb475a..5e4ba94 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -483,7 +483,7 @@ gfx::Size ToolbarView::GetPreferredSize() {
}
int vertical_spacing = PopupTopSpacing() +
- (GetWindow()->GetNonClientView()->UseNativeFrame() ?
+ (GetWindow()->non_client_view()->UseNativeFrame() ?
kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass);
return gfx::Size(0, location_bar_->GetPreferredSize().height() +
vertical_spacing);
@@ -596,7 +596,7 @@ void ToolbarView::OnPaint(gfx::Canvas* canvas) {
// For glass, we need to draw a black line below the location bar to separate
// it from the content area. For non-glass, the NonClientView draws the
// toolbar background below the location bar for us.
- if (GetWindow()->GetNonClientView()->UseNativeFrame())
+ if (GetWindow()->non_client_view()->UseNativeFrame())
canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1);
}
@@ -668,7 +668,7 @@ bool ToolbarView::ShouldShowIncompatibilityWarning() {
}
int ToolbarView::PopupTopSpacing() const {
- return GetWindow()->GetNonClientView()->UseNativeFrame() ?
+ return GetWindow()->non_client_view()->UseNativeFrame() ?
0 : kPopupTopSpacingNonGlass;
}
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index bcf2b94..240d941 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -1677,7 +1677,7 @@ class FocusManagerDtorTest : public FocusManagerTest {
dtor_tracker_(dtor_tracker) {
tracked_focus_manager_ = new FocusManagerDtorTracked(this,
dtor_tracker_);
- GetNonClientView()->SetFrameView(CreateFrameViewForWindow());
+ non_client_view()->SetFrameView(CreateFrameViewForWindow());
InitWindow(NULL, gfx::Rect(0, 0, 100, 100));
ReplaceFocusManager(tracked_focus_manager_);
}
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 16109f7..3eaa9e0 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -1270,7 +1270,7 @@ class DefaultButtonTest : public ViewTest {
focus_manager_ = test_dialog_->contents_->GetFocusManager();
ASSERT_TRUE(focus_manager_ != NULL);
client_view_ =
- static_cast<views::DialogClientView*>(window->GetClientView());
+ static_cast<views::DialogClientView*>(window->client_view());
ok_button_ = client_view_->ok_button();
cancel_button_ = client_view_->cancel_button();
}
diff --git a/views/window/client_view.cc b/views/window/client_view.cc
index 9fb3e70..5d964de 100644
--- a/views/window/client_view.cc
+++ b/views/window/client_view.cc
@@ -33,7 +33,6 @@ bool ClientView::CanClose() {
}
void ClientView::WindowClosing() {
- window_->GetDelegate()->WindowClosing();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index cd687b7..c71a917 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -113,11 +113,10 @@ CustomFrameView::CustomFrameView(Window* frame)
rb.GetBitmapNamed(IDR_MINIMIZE_P));
AddChildView(minimize_button_);
- views::WindowDelegate* d = frame_->GetDelegate();
- should_show_minmax_buttons_ = d->CanMaximize();
- should_show_client_edge_ = d->ShouldShowClientEdge();
+ should_show_minmax_buttons_ = frame_->window_delegate()->CanMaximize();
+ should_show_client_edge_ = frame_->window_delegate()->ShouldShowClientEdge();
- if (d->ShouldShowWindowIcon()) {
+ if (frame_->window_delegate()->ShouldShowWindowIcon()) {
window_icon_ = new ImageButton(this);
AddChildView(window_icon_);
}
@@ -148,7 +147,7 @@ int CustomFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- int frame_component = frame_->GetClientView()->NonClientHitTest(point);
+ int frame_component = frame_->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. (We check the ClientView first to be
// consistent with OpaqueBrowserFrameView; it's not really necessary here.)
@@ -178,7 +177,7 @@ int CustomFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, FrameBorderThickness(),
NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
- frame_->GetDelegate()->CanResize());
+ frame_->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -223,9 +222,9 @@ void CustomFrameView::Layout() {
}
gfx::Size CustomFrameView::GetPreferredSize() {
- gfx::Size pref = frame_->GetClientView()->GetPreferredSize();
+ gfx::Size pref = frame_->client_view()->GetPreferredSize();
gfx::Rect bounds(0, 0, pref.width(), pref.height());
- return frame_->GetNonClientView()->GetWindowBoundsForClientBounds(
+ return frame_->non_client_view()->GetWindowBoundsForClientBounds(
bounds).size();
}
@@ -397,11 +396,11 @@ void CustomFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
int edge_height = titlebar_bottom->height() -
ShouldShowClientEdge() ? kClientEdgeThickness : 0;
canvas->TileImageInt(*titlebar_bottom, 0,
- frame_->GetClientView()->y() - edge_height, width(), edge_height);
+ frame_->client_view()->y() - edge_height, width(), edge_height);
}
void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) {
- WindowDelegate* d = frame_->GetDelegate();
+ WindowDelegate* d = frame_->window_delegate();
// It seems like in some conditions we can be asked to paint after the window
// that contains us is WM_DESTROYed. At this point, our delegate is NULL. The
@@ -416,7 +415,7 @@ void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) {
}
void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
- gfx::Rect client_area_bounds = frame_->GetClientView()->bounds();
+ gfx::Rect client_area_bounds = frame_->client_view()->bounds();
int client_area_top = client_area_bounds.y();
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -534,12 +533,11 @@ void CustomFrameView::LayoutTitleBar() {
// The window title is based on the calculated icon position, even when there
// is no icon.
gfx::Rect icon_bounds(IconBounds());
- views::WindowDelegate* d = frame_->GetDelegate();
- if (d->ShouldShowWindowIcon())
+ if (frame_->window_delegate()->ShouldShowWindowIcon())
window_icon_->SetBoundsRect(icon_bounds);
// Size the title.
- int title_x = d->ShouldShowWindowIcon() ?
+ int title_x = frame_->window_delegate()->ShouldShowWindowIcon() ?
icon_bounds.right() + kIconTitleSpacing : icon_bounds.x();
int title_height = title_font_->GetHeight();
// We bias the title position so that when the difference between the icon and
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index cdf684c..81e8685 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -79,7 +79,7 @@ class DialogButton : public NativeButton {
// Overridden to forward to the delegate.
virtual bool AcceleratorPressed(const Accelerator& accelerator) {
- if (!owner_->GetDelegate()->AsDialogDelegate()->
+ if (!owner_->window_delegate()->AsDialogDelegate()->
AreAcceleratorsEnabled(type_)) {
return false;
}
@@ -288,7 +288,6 @@ void DialogClientView::WindowClosing() {
if (saved_focus_manager_)
saved_focus_manager_->RemoveFocusChangeListener(this);
}
- ClientView::WindowClosing();
}
int DialogClientView::NonClientHitTest(const gfx::Point& point) {
@@ -425,8 +424,8 @@ void DialogClientView::ButtonPressed(
// DialogClientView, private:
void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) {
- if (window()->GetDelegate()->CanResize() ||
- window()->GetDelegate()->CanMaximize()) {
+ if (window()->window_delegate()->CanResize() ||
+ window()->window_delegate()->CanMaximize()) {
#if defined(OS_WIN)
HDC dc = canvas->BeginPlatformPaint();
SIZE gripper_size = { 0, 0 };
@@ -537,9 +536,7 @@ void DialogClientView::CreateExtraView() {
}
DialogDelegate* DialogClientView::GetDialogDelegate() const {
- DialogDelegate* dd = window()->GetDelegate()->AsDialogDelegate();
- DCHECK(dd);
- return dd;
+ return window()->window_delegate()->AsDialogDelegate();
}
void DialogClientView::Close() {
diff --git a/views/window/dialog_delegate.cc b/views/window/dialog_delegate.cc
index 43bdce3..84feb9b 100644
--- a/views/window/dialog_delegate.cc
+++ b/views/window/dialog_delegate.cc
@@ -95,10 +95,7 @@ ClientView* DialogDelegate::CreateClientView(Window* window) {
}
DialogClientView* DialogDelegate::GetDialogClientView() const {
- ClientView* client_view = window()->GetClientView();
- DialogClientView* dialog_client_view = client_view->AsDialogClientView();
- DCHECK(dialog_client_view);
- return dialog_client_view;
+ return window()->client_view()->AsDialogClientView();
}
AccessibilityTypes::Role DialogDelegate::accessible_role() const {
diff --git a/views/window/native_frame_view.cc b/views/window/native_frame_view.cc
index 5b0d34e..bcef23a 100644
--- a/views/window/native_frame_view.cc
+++ b/views/window/native_frame_view.cc
@@ -35,7 +35,7 @@ gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds(
}
int NativeFrameView::NonClientHitTest(const gfx::Point& point) {
- return frame_->GetClientView()->NonClientHitTest(point);
+ return frame_->client_view()->NonClientHitTest(point);
}
void NativeFrameView::GetWindowMask(const gfx::Size& size,
@@ -52,9 +52,9 @@ void NativeFrameView::ResetWindowControls() {
}
gfx::Size NativeFrameView::GetPreferredSize() {
- gfx::Size pref = frame_->GetClientView()->GetPreferredSize();
+ gfx::Size pref = frame_->client_view()->GetPreferredSize();
gfx::Rect bounds(0, 0, pref.width(), pref.height());
- return frame_->GetNonClientView()->GetWindowBoundsForClientBounds(
+ return frame_->non_client_view()->GetWindowBoundsForClientBounds(
bounds).size();
}
diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h
index 229d588..4668de4 100644
--- a/views/window/native_window_delegate.h
+++ b/views/window/native_window_delegate.h
@@ -18,6 +18,13 @@ namespace internal {
class NativeWindowDelegate {
public:
virtual ~NativeWindowDelegate() {}
+
+ // Called just before the native window is destroyed. This is the delegate's
+ // last chance to do anything with the native window handle.
+ virtual void OnWindowDestroying() = 0;
+
+ // Called just after the native window is destroyed.
+ virtual void OnWindowDestroyed() = 0;
};
} // namespace internal
diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc
index e882105..f297c45 100644
--- a/views/window/non_client_view.cc
+++ b/views/window/non_client_view.cc
@@ -6,6 +6,7 @@
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
+#include "views/window/client_view.h"
#include "views/window/window.h"
#if !defined(OS_WIN)
@@ -192,7 +193,7 @@ bool NonClientFrameView::AlwaysUseNativeFrame() const {
bool NonClientFrameView::HitTest(const gfx::Point& l) const {
// For the default case, we assume the non-client frame view never overlaps
// the client view.
- return !GetWindow()->GetClientView()->bounds().Contains(l);
+ return !GetWindow()->client_view()->bounds().Contains(l);
}
void NonClientFrameView::OnBoundsChanged() {
diff --git a/views/window/window.cc b/views/window/window.cc
index 3a14335..5531cff 100644
--- a/views/window/window.cc
+++ b/views/window/window.cc
@@ -11,13 +11,21 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "views/widget/widget.h"
+#include "views/window/window_delegate.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// Window, public:
-Window::Window() : native_window_(NULL) {
+Window::Window(WindowDelegate* window_delegate)
+ : native_window_(NULL),
+ window_delegate_(window_delegate),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ non_client_view_(new NonClientView(this))) {
+ DCHECK(window_delegate_);
+ DCHECK(!window_delegate_->window_);
+ window_delegate_->window_ = this;
}
Window::~Window() {
@@ -151,27 +159,28 @@ NonClientFrameView* Window::CreateFrameViewForWindow() {
void Window::UpdateFrameAfterFrameChange() {
}
-WindowDelegate* Window::GetDelegate() const {
+gfx::NativeWindow Window::GetNativeWindow() const {
return NULL;
}
-NonClientView* Window::GetNonClientView() const {
- return NULL;
+bool Window::ShouldUseNativeFrame() const {
+ return false;
}
-ClientView* Window::GetClientView() const {
- return NULL;
+void Window::FrameTypeChanged() {
}
-gfx::NativeWindow Window::GetNativeWindow() const {
- return NULL;
-}
+////////////////////////////////////////////////////////////////////////////////
+// Window, internal::NativeWindowDelegate implementation:
-bool Window::ShouldUseNativeFrame() const {
- return false;
+void Window::OnWindowDestroying() {
+ non_client_view_->WindowClosing();
+ window_delegate_->WindowClosing();
}
-void Window::FrameTypeChanged() {
+void Window::OnWindowDestroyed() {
+ window_delegate_->DeleteDelegate();
+ window_delegate_ = NULL;
}
} // namespace views
diff --git a/views/window/window.h b/views/window/window.h
index df5a28c..7bc9406 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -7,7 +7,9 @@
#pragma once
#include "ui/gfx/native_widget_types.h"
+#include "views/window/client_view.h"
#include "views/window/native_window_delegate.h"
+#include "views/window/non_client_view.h"
namespace gfx {
class Font;
@@ -17,10 +19,8 @@ class Size;
namespace views {
-class ClientView;
class NativeWindow;
class NonClientFrameView;
-class NonClientView;
class Widget;
class WindowDelegate;
@@ -40,7 +40,7 @@ class WindowDelegate;
//
class Window : public internal::NativeWindowDelegate {
public:
- Window();
+ explicit Window(WindowDelegate* window_delegate);
virtual ~Window();
// Creates an instance of an object implementing this interface.
@@ -177,15 +177,6 @@ class Window : public internal::NativeWindowDelegate {
// Updates the frame after an event caused it to be changed.
virtual void UpdateFrameAfterFrameChange();
- // Retrieves the Window's delegate.
- virtual WindowDelegate* GetDelegate() const;
-
- // Retrieves the Window's non-client view.
- virtual NonClientView* GetNonClientView() const;
-
- // Retrieves the Window's client view.
- virtual ClientView* GetClientView() const;
-
// Retrieves the Window's native window handle.
virtual gfx::NativeWindow GetNativeWindow() const;
@@ -195,6 +186,30 @@ class Window : public internal::NativeWindowDelegate {
// Tell the window that something caused the frame type to change.
virtual void FrameTypeChanged();
+ WindowDelegate* window_delegate() {
+ return const_cast<WindowDelegate*>(
+ const_cast<const Window*>(this)->window_delegate());
+ }
+ const WindowDelegate* window_delegate() const {
+ return window_delegate_;
+ }
+
+ NonClientView* non_client_view() {
+ return const_cast<NonClientView*>(
+ const_cast<const Window*>(this)->non_client_view());
+ }
+ const NonClientView* non_client_view() const {
+ return non_client_view_;
+ }
+
+ ClientView* client_view() {
+ return const_cast<ClientView*>(
+ const_cast<const Window*>(this)->client_view());
+ }
+ const ClientView* client_view() const {
+ return non_client_view()->client_view();
+ }
+
protected:
// TODO(beng): Temporarily provided as a way to associate the subclass'
// implementation of NativeWidget with this.
@@ -202,9 +217,24 @@ class Window : public internal::NativeWindowDelegate {
native_window_ = native_window;
}
+ // Overridden from NativeWindowDelegate:
+ virtual void OnWindowDestroying();
+ virtual void OnWindowDestroyed();
+
private:
+ Window();
+
NativeWindow* native_window_;
+ // Our window delegate (see InitWindow() method for documentation).
+ WindowDelegate* window_delegate_;
+
+ // The View that provides the non-client area of the window (title bar,
+ // window controls, sizing borders etc). To use an implementation other than
+ // the default, this class must be sub-classed and this value set to the
+ // desired implementation before calling |InitWindow()|.
+ NonClientView* non_client_view_;
+
DISALLOW_COPY_AND_ASSIGN(Window);
};
diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h
index 9b02387..fd7b1d1 100644
--- a/views/window/window_delegate.h
+++ b/views/window/window_delegate.h
@@ -122,8 +122,7 @@ class WindowDelegate {
Window* window() const { return window_; }
private:
- friend class WindowGtk;
- friend class WindowWin;
+ friend class Window;
// The Window this delegate is bound to. Weak reference.
Window* window_;
};
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 08c19ed..06feab3 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -87,7 +87,7 @@ Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
const gfx::Rect& bounds,
WindowDelegate* window_delegate) {
WindowGtk* window = new WindowGtk(window_delegate);
- window->GetNonClientView()->SetFrameView(window->CreateFrameViewForWindow());
+ window->non_client_view()->SetFrameView(window->CreateFrameViewForWindow());
window->InitWindow(parent, bounds);
return window;
}
@@ -149,7 +149,7 @@ void WindowGtk::Close() {
return;
}
- if (non_client_view_->CanClose()) {
+ if (GetWindow()->non_client_view()->CanClose()) {
WidgetGtk::Close();
window_closed_ = true;
}
@@ -213,11 +213,11 @@ void WindowGtk::UpdateWindowTitle() {
// If the non-client view is rendering its own title, it'll need to relayout
// now.
- non_client_view_->Layout();
+ GetWindow()->non_client_view()->Layout();
// Update the native frame's text. We do this regardless of whether or not
// the native frame is being used, since this also updates the taskbar, etc.
- std::wstring window_title = window_delegate_->GetWindowTitle();
+ std::wstring window_title = GetWindow()->window_delegate()->GetWindowTitle();
base::i18n::AdjustStringForLocaleDirection(&window_title);
gtk_window_set_title(GetNativeWindow(), WideToUTF8(window_title).c_str());
@@ -244,18 +244,6 @@ void WindowGtk::UpdateFrameAfterFrameChange() {
NOTIMPLEMENTED();
}
-WindowDelegate* WindowGtk::GetDelegate() const {
- return window_delegate_;
-}
-
-NonClientView* WindowGtk::GetNonClientView() const {
- return non_client_view_;
-}
-
-ClientView* WindowGtk::GetClientView() const {
- return non_client_view_->client_view();
-}
-
gfx::NativeWindow WindowGtk::GetNativeWindow() const {
return GTK_WINDOW(GetNativeView());
}
@@ -286,7 +274,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
GetContainedWidgetEventCoordinates(event, &x, &y);
int hittest_code =
- non_client_view_->NonClientHitTest(gfx::Point(x, y));
+ GetWindow()->non_client_view()->NonClientHitTest(gfx::Point(x, y));
switch (hittest_code) {
case HTCAPTION: {
MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, event->x, event->y,
@@ -345,7 +333,7 @@ gboolean WindowGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) {
// Update the cursor for the screen edge.
int hittest_code =
- non_client_view_->NonClientHitTest(gfx::Point(x, y));
+ GetWindow()->non_client_view()->NonClientHitTest(gfx::Point(x, y));
if (hittest_code != HTCLIENT) {
GdkCursorType cursor_type = HitTestCodeToGdkCursorType(hittest_code);
gdk_window_set_cursor(widget->window, gfx::GetCursor(cursor_type));
@@ -359,9 +347,9 @@ void WindowGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
// The Window's NonClientView may provide a custom shape for the Window.
gfx::Path window_mask;
- non_client_view_->GetWindowMask(gfx::Size(allocation->width,
- allocation->height),
- &window_mask);
+ GetWindow()->non_client_view()->GetWindowMask(gfx::Size(allocation->width,
+ allocation->height),
+ &window_mask);
GdkRegion* mask_region = window_mask.CreateNativeRegion();
gdk_window_shape_combine_region(GetNativeView()->window, mask_region, 0, 0);
if (mask_region)
@@ -385,7 +373,7 @@ gboolean WindowGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) {
}
void WindowGtk::SetInitialFocus() {
- View* v = window_delegate_->GetInitiallyFocusedView();
+ View* v = GetWindow()->window_delegate()->GetInitiallyFocusedView();
if (v) {
v->RequestFocus();
}
@@ -396,16 +384,13 @@ void WindowGtk::SetInitialFocus() {
WindowGtk::WindowGtk(WindowDelegate* window_delegate)
: WidgetGtk(TYPE_WINDOW),
+ Window(window_delegate),
ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
is_modal_(false),
- window_delegate_(window_delegate),
- non_client_view_(new NonClientView(this)),
window_state_(GDK_WINDOW_STATE_WITHDRAWN),
window_closed_(false) {
set_native_window(this);
is_window_ = true;
- DCHECK(!window_delegate_->window_);
- window_delegate_->window_ = this;
}
void WindowGtk::InitWindow(GtkWindow* parent, const gfx::Rect& bounds) {
@@ -415,7 +400,7 @@ void WindowGtk::InitWindow(GtkWindow* parent, const gfx::Rect& bounds) {
// We call this after initializing our members since our implementations of
// assorted WidgetWin functions may be called during initialization.
- is_modal_ = window_delegate_->IsModal();
+ is_modal_ = GetWindow()->window_delegate()->IsModal();
if (is_modal_)
gtk_window_set_modal(GetNativeWindow(), true);
@@ -426,8 +411,9 @@ void WindowGtk::InitWindow(GtkWindow* parent, const gfx::Rect& bounds) {
// Create the ClientView, add it to the NonClientView and add the
// NonClientView to the RootView. This will cause everything to be parented.
- non_client_view_->set_client_view(window_delegate_->CreateClientView(this));
- WidgetGtk::SetContentsView(non_client_view_);
+ GetWindow()->non_client_view()->set_client_view(
+ GetWindow()->window_delegate()->CreateClientView(this));
+ WidgetGtk::SetContentsView(GetWindow()->non_client_view());
UpdateWindowTitle();
SetInitialBounds(parent, bounds);
@@ -461,19 +447,19 @@ gboolean WindowGtk::CallWindowStateEvent(GtkWidget* widget,
void WindowGtk::SaveWindowPosition() {
// The delegate may have gone away on us.
- if (!window_delegate_)
+ if (!GetWindow()->window_delegate())
return;
bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
- window_delegate_->SaveWindowPlacement(GetBounds(), maximized);
+ GetWindow()->window_delegate()->SaveWindowPlacement(GetBounds(), maximized);
}
void WindowGtk::SetInitialBounds(GtkWindow* parent,
const gfx::Rect& create_bounds) {
gfx::Rect saved_bounds(create_bounds.ToGdkRectangle());
- if (window_delegate_->GetSavedWindowBounds(&saved_bounds)) {
- if (!window_delegate_->ShouldRestoreWindowSize())
- saved_bounds.set_size(non_client_view_->GetPreferredSize());
+ if (GetWindow()->window_delegate()->GetSavedWindowBounds(&saved_bounds)) {
+ if (!GetWindow()->window_delegate()->ShouldRestoreWindowSize())
+ saved_bounds.set_size(GetWindow()->non_client_view()->GetPreferredSize());
WidgetGtk::SetBounds(saved_bounds);
} else {
if (create_bounds.IsEmpty()) {
@@ -500,7 +486,7 @@ void WindowGtk::SizeWindowToDefault(GtkWindow* parent) {
// We have no parent window, center over the screen.
center_rect = Screen::GetMonitorWorkAreaNearestWindow(GetNativeView());
}
- gfx::Size size = non_client_view_->GetPreferredSize();
+ gfx::Size size = GetWindow()->non_client_view()->GetPreferredSize();
gfx::Rect bounds(center_rect.x() + (center_rect.width() - size.width()) / 2,
center_rect.y() + (center_rect.height() - size.height()) / 2,
size.width(), size.height());
@@ -508,10 +494,9 @@ void WindowGtk::SizeWindowToDefault(GtkWindow* parent) {
}
void WindowGtk::OnDestroy(GtkWidget* widget) {
- non_client_view_->WindowClosing();
+ delegate_->OnWindowDestroying();
WidgetGtk::OnDestroy(widget);
- window_delegate_->DeleteDelegate();
- window_delegate_ = NULL;
+ delegate_->OnWindowDestroyed();
}
} // namespace views
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index 75a5702..ef1cde8 100644
--- a/views/window/window_gtk.h
+++ b/views/window/window_gtk.h
@@ -57,9 +57,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
virtual void SetIsAlwaysOnTop(bool always_on_top);
virtual NonClientFrameView* CreateFrameViewForWindow();
virtual void UpdateFrameAfterFrameChange();
- virtual WindowDelegate* GetDelegate() const;
- virtual NonClientView* GetNonClientView() const;
- virtual ClientView* GetClientView() const;
virtual gfx::NativeWindow GetNativeWindow() const;
virtual bool ShouldUseNativeFrame() const;
virtual void FrameTypeChanged();
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 43bfce5..3122a94 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -218,7 +218,8 @@ Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
const gfx::Rect& bounds,
WindowDelegate* window_delegate) {
WindowWin* window = new WindowWin(window_delegate);
- window->GetNonClientView()->SetFrameView(window->CreateFrameViewForWindow());
+ window->GetWindow()->non_client_view()->SetFrameView(
+ window->CreateFrameViewForWindow());
window->Init(parent, bounds);
return window;
}
@@ -341,7 +342,7 @@ void WindowWin::Close() {
return;
}
- if (non_client_view_->CanClose()) {
+ if (GetWindow()->non_client_view()->CanClose()) {
SaveWindowPosition();
RestoreEnabledIfNecessary();
WidgetWin::Close();
@@ -466,7 +467,7 @@ void WindowWin::SetUseDragFrame(bool use_drag_frame) {
void WindowWin::EnableClose(bool enable) {
// If the native frame is rendering its own close button, ask it to disable.
- non_client_view_->EnableClose(enable);
+ GetWindow()->non_client_view()->EnableClose(enable);
// Disable the native frame's close button regardless of whether or not the
// native frame is in use, since this also affects the system menu.
@@ -482,21 +483,22 @@ void WindowWin::EnableClose(bool enable) {
void WindowWin::DisableInactiveRendering() {
disable_inactive_rendering_ = true;
- non_client_view_->DisableInactiveRendering(disable_inactive_rendering_);
+ GetWindow()->non_client_view()->DisableInactiveRendering(
+ disable_inactive_rendering_);
}
void WindowWin::UpdateWindowTitle() {
// If the non-client view is rendering its own title, it'll need to relayout
// now.
- non_client_view_->Layout();
+ GetWindow()->non_client_view()->Layout();
// Update the native frame's text. We do this regardless of whether or not
// the native frame is being used, since this also updates the taskbar, etc.
std::wstring window_title;
if (IsAccessibleWidget())
- window_title = window_delegate_->GetAccessibleWindowTitle();
+ window_title = GetWindow()->window_delegate()->GetAccessibleWindowTitle();
else
- window_title = window_delegate_->GetWindowTitle();
+ window_title = GetWindow()->window_delegate()->GetWindowTitle();
base::i18n::AdjustStringForLocaleDirection(&window_title);
SetWindowText(GetNativeView(), window_title.c_str());
@@ -507,11 +509,11 @@ void WindowWin::UpdateWindowTitle() {
void WindowWin::UpdateWindowIcon() {
// If the non-client view is rendering its own icon, we need to tell it to
// repaint.
- non_client_view_->SchedulePaint();
+ GetWindow()->non_client_view()->SchedulePaint();
// Update the native frame's icon. We do this regardless of whether or not
// the native frame is being used, since this also updates the taskbar, etc.
- SkBitmap icon = window_delegate_->GetWindowIcon();
+ SkBitmap icon = GetWindow()->window_delegate()->GetWindowIcon();
if (!icon.isNull()) {
HICON windows_icon = IconUtil::CreateHICONFromSkBitmap(icon);
// We need to make sure to destroy the previous icon, otherwise we'll leak
@@ -523,7 +525,7 @@ void WindowWin::UpdateWindowIcon() {
DestroyIcon(old_icon);
}
- icon = window_delegate_->GetWindowAppIcon();
+ icon = GetWindow()->window_delegate()->GetWindowAppIcon();
if (!icon.isNull()) {
HICON windows_icon = IconUtil::CreateHICONFromSkBitmap(icon);
HICON old_icon = reinterpret_cast<HICON>(
@@ -552,18 +554,6 @@ void WindowWin::UpdateFrameAfterFrameChange() {
ResetWindowRegion(true);
}
-WindowDelegate* WindowWin::GetDelegate() const {
- return window_delegate_;
-}
-
-NonClientView* WindowWin::GetNonClientView() const {
- return non_client_view_;
-}
-
-ClientView* WindowWin::GetClientView() const {
- return non_client_view_->client_view();
-}
-
gfx::NativeWindow WindowWin::GetNativeWindow() const {
return GetNativeView();
}
@@ -585,8 +575,8 @@ void WindowWin::FrameTypeChanged() {
// DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the
// DWM doesn't render glass, and so is used in the custom frame case.
DWMNCRENDERINGPOLICY policy =
- non_client_view_->UseNativeFrame() ? DWMNCRP_ENABLED
- : DWMNCRP_DISABLED;
+ GetWindow()->non_client_view()->UseNativeFrame() ? DWMNCRP_ENABLED
+ : DWMNCRP_DISABLED;
DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY,
&policy, sizeof(DWMNCRENDERINGPOLICY));
}
@@ -599,7 +589,7 @@ void WindowWin::FrameTypeChanged() {
// Update the non-client view with the correct frame view for the active frame
// type.
- non_client_view_->UpdateFrame();
+ GetWindow()->non_client_view()->UpdateFrame();
// WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
// to notify our children too, since we can have MDI child windows who need to
@@ -622,10 +612,9 @@ gfx::Font WindowWin::GetWindowTitleFont() {
WindowWin::WindowWin(WindowDelegate* window_delegate)
: WidgetWin(),
+ Window(window_delegate),
ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
focus_on_creation_(true),
- window_delegate_(window_delegate),
- non_client_view_(new NonClientView(this)),
owning_hwnd_(NULL),
minimum_size_(100, 100),
is_modal_(false),
@@ -645,9 +634,6 @@ WindowWin::WindowWin(WindowDelegate* window_delegate)
set_native_window(this);
is_window_ = true;
InitClass();
- DCHECK(window_delegate_);
- DCHECK(!window_delegate_->window_);
- window_delegate_->window_ = this;
// Initialize these values to 0 so that subclasses can override the default
// behavior before calling Init.
set_window_style(0);
@@ -660,7 +646,7 @@ void WindowWin::Init(HWND parent, const gfx::Rect& bounds) {
owning_hwnd_ = parent;
// We call this after initializing our members since our implementations of
// assorted WidgetWin functions may be called during initialization.
- is_modal_ = window_delegate_->IsModal();
+ is_modal_ = GetWindow()->window_delegate()->IsModal();
if (is_modal_)
BecomeModal();
@@ -674,8 +660,9 @@ void WindowWin::Init(HWND parent, const gfx::Rect& bounds) {
// Create the ClientView, add it to the NonClientView and add the
// NonClientView to the RootView. This will cause everything to be parented.
- non_client_view_->set_client_view(window_delegate_->CreateClientView(this));
- WidgetWin::SetContentsView(non_client_view_);
+ GetWindow()->non_client_view()->set_client_view(
+ GetWindow()->window_delegate()->CreateClientView(this));
+ WidgetWin::SetContentsView(GetWindow()->non_client_view());
UpdateWindowTitle();
UpdateAccessibleRole();
@@ -690,14 +677,14 @@ void WindowWin::Init(HWND parent, const gfx::Rect& bounds) {
void WindowWin::SizeWindowToDefault() {
ui::CenterAndSizeWindow(owning_window(), GetNativeView(),
- non_client_view_->GetPreferredSize(),
+ GetWindow()->non_client_view()->GetPreferredSize(),
false);
}
gfx::Insets WindowWin::GetClientAreaInsets() const {
// Returning an empty Insets object causes the default handling in
// WidgetWin::OnNCCalcSize() to be invoked.
- if (GetNonClientView()->UseNativeFrame())
+ if (GetWindow()->non_client_view()->UseNativeFrame())
return gfx::Insets();
if (IsMaximized()) {
@@ -734,7 +721,7 @@ void WindowWin::OnActivateApp(BOOL active, DWORD thread_id) {
// Another application was activated, we should reset any state that
// disables inactive rendering now.
disable_inactive_rendering_ = false;
- non_client_view_->DisableInactiveRendering(false);
+ GetWindow()->non_client_view()->DisableInactiveRendering(false);
// Update the native frame too, since it could be rendering the non-client
// area.
CallDefaultNCActivateHandler(FALSE);
@@ -745,7 +732,7 @@ LRESULT WindowWin::OnAppCommand(HWND window, short app_command, WORD device,
int keystate) {
// We treat APPCOMMAND ids as an extension of our command namespace, and just
// let the delegate figure out what to do...
- if (!window_delegate_->ExecuteWindowsCommand(app_command))
+ if (!GetWindow()->window_delegate()->ExecuteWindowsCommand(app_command))
return WidgetWin::OnAppCommand(window, app_command, device, keystate);
return 0;
}
@@ -754,13 +741,13 @@ void WindowWin::OnCommand(UINT notification_code, int command_id, HWND window) {
// If the notification code is > 1 it means it is control specific and we
// should ignore it.
if (notification_code > 1 ||
- window_delegate_->ExecuteWindowsCommand(command_id)) {
+ GetWindow()->window_delegate()->ExecuteWindowsCommand(command_id)) {
WidgetWin::OnCommand(notification_code, command_id, window);
}
}
void WindowWin::OnDestroy() {
- non_client_view_->WindowClosing();
+ delegate_->OnWindowDestroying();
RestoreEnabledIfNecessary();
WidgetWin::OnDestroy();
}
@@ -778,15 +765,12 @@ LRESULT WindowWin::OnDwmCompositionChanged(UINT msg, WPARAM w_param,
}
void WindowWin::OnFinalMessage(HWND window) {
- // Delete and NULL the delegate here once we're guaranteed to get no more
- // messages.
- window_delegate_->DeleteDelegate();
- window_delegate_ = NULL;
+ delegate_->OnWindowDestroyed();
WidgetWin::OnFinalMessage(window);
}
void WindowWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) {
- gfx::Size min_window_size(GetNonClientView()->GetMinimumSize());
+ gfx::Size min_window_size(GetWindow()->non_client_view()->GetMinimumSize());
minmax_info->ptMinTrackSize.x = min_window_size.width();
minmax_info->ptMinTrackSize.y = min_window_size.height();
WidgetWin::OnGetMinMaxInfo(minmax_info);
@@ -802,7 +786,7 @@ static void EnableMenuItem(HMENU menu, UINT command, bool enabled) {
void WindowWin::OnInitMenu(HMENU menu) {
// We only need to manually enable the system menu if we're not using a native
// frame.
- if (non_client_view_->UseNativeFrame())
+ if (GetWindow()->non_client_view()->UseNativeFrame())
WidgetWin::OnInitMenu(menu);
bool is_fullscreen = IsFullscreen();
@@ -813,17 +797,20 @@ void WindowWin::OnInitMenu(HMENU menu) {
ScopedRedrawLock lock(this);
EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized);
EnableMenuItem(menu, SC_MOVE, is_restored);
- EnableMenuItem(menu, SC_SIZE, window_delegate_->CanResize() && is_restored);
+ EnableMenuItem(menu, SC_SIZE,
+ GetWindow()->window_delegate()->CanResize() && is_restored);
EnableMenuItem(menu, SC_MAXIMIZE,
- window_delegate_->CanMaximize() && !is_fullscreen && !is_maximized);
+ GetWindow()->window_delegate()->CanMaximize() &&
+ !is_fullscreen && !is_maximized);
EnableMenuItem(menu, SC_MINIMIZE,
- window_delegate_->CanMaximize() && !is_minimized);
+ GetWindow()->window_delegate()->CanMaximize() &&
+ !is_minimized);
}
void WindowWin::OnMouseLeave() {
// We only need to manually track WM_MOUSELEAVE messages between the client
// and non-client area when we're not using the native frame.
- if (non_client_view_->UseNativeFrame()) {
+ if (GetWindow()->non_client_view()->UseNativeFrame()) {
SetMsgHandled(FALSE);
return;
}
@@ -854,14 +841,14 @@ LRESULT WindowWin::OnNCActivate(BOOL active) {
// We can get WM_NCACTIVATE before we're actually visible. If we're not
// visible, no need to paint.
if (IsVisible())
- non_client_view_->SchedulePaint();
+ GetWindow()->non_client_view()->SchedulePaint();
// If we're active again, we should be allowed to render as inactive, so
// tell the non-client view. This must be done independently of the check for
// disable_inactive_rendering_ since that check is valid even if the frame
// is not active, but this can only be done if we've become active.
if (IsActive())
- non_client_view_->DisableInactiveRendering(false);
+ GetWindow()->non_client_view()->DisableInactiveRendering(false);
// Reset the disable inactive rendering state since activation has changed.
if (disable_inactive_rendering_) {
@@ -913,7 +900,7 @@ LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor))
client_rect->left += kAutoHideTaskbarThicknessPx;
if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) {
- if (GetNonClientView()->UseNativeFrame()) {
+ if (GetWindow()->non_client_view()->UseNativeFrame()) {
// Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of
// WM_NCHITTEST, having any nonclient area atop the window causes the
// caption buttons to draw onscreen but not respond to mouse
@@ -956,7 +943,8 @@ LRESULT WindowWin::OnNCHitTest(const CPoint& point) {
// provides any of the non-client area.
CPoint temp = point;
MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
- int component = non_client_view_->NonClientHitTest(gfx::Point(temp));
+ int component =
+ GetWindow()->non_client_view()->NonClientHitTest(gfx::Point(temp));
if (component != HTNOWHERE)
return component;
@@ -968,13 +956,13 @@ LRESULT WindowWin::OnNCHitTest(const CPoint& point) {
void WindowWin::OnNCPaint(HRGN rgn) {
// When using a custom frame, we want to avoid calling DefWindowProc() since
// that may render artifacts.
- SetMsgHandled(!non_client_view_->UseNativeFrame());
+ SetMsgHandled(!GetWindow()->non_client_view()->UseNativeFrame());
}
void WindowWin::OnNCLButtonDown(UINT ht_component, const CPoint& point) {
// When we're using a native frame, window controls work without us
// interfering.
- if (!non_client_view_->UseNativeFrame()) {
+ if (!GetWindow()->non_client_view()->UseNativeFrame()) {
switch (ht_component) {
case HTCLOSE:
case HTMINBUTTON:
@@ -1056,7 +1044,7 @@ LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param,
LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
// an explanation about why we need to handle this message.
- SetMsgHandled(!non_client_view_->UseNativeFrame());
+ SetMsgHandled(!GetWindow()->non_client_view()->UseNativeFrame());
return 0;
}
@@ -1064,7 +1052,7 @@ LRESULT WindowWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param,
LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
// an explanation about why we need to handle this message.
- SetMsgHandled(!non_client_view_->UseNativeFrame());
+ SetMsgHandled(!GetWindow()->non_client_view()->UseNativeFrame());
return 0;
}
@@ -1116,11 +1104,11 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) {
((notification_code & sc_mask) == SC_MOVE) ||
((notification_code & sc_mask) == SC_MAXIMIZE)))
return;
- if (!non_client_view_->UseNativeFrame()) {
+ if (!GetWindow()->non_client_view()->UseNativeFrame()) {
if ((notification_code & sc_mask) == SC_MINIMIZE ||
(notification_code & sc_mask) == SC_MAXIMIZE ||
(notification_code & sc_mask) == SC_RESTORE) {
- non_client_view_->ResetWindowControls();
+ GetWindow()->non_client_view()->ResetWindowControls();
} else if ((notification_code & sc_mask) == SC_MOVE ||
(notification_code & sc_mask) == SC_SIZE) {
if (lock_updates_) {
@@ -1146,7 +1134,7 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) {
}
// First see if the delegate can handle it.
- if (window_delegate_->ExecuteWindowsCommand(notification_code))
+ if (GetWindow()->window_delegate()->ExecuteWindowsCommand(notification_code))
return;
// Use the default implementation for any other command.
@@ -1244,7 +1232,7 @@ void WindowWin::SetInitialFocus() {
if (!focus_on_creation_)
return;
- View* v = window_delegate_->GetInitiallyFocusedView();
+ View* v = GetWindow()->window_delegate()->GetInitiallyFocusedView();
if (v) {
v->RequestFocus();
} else {
@@ -1261,13 +1249,14 @@ void WindowWin::SetInitialBounds(const gfx::Rect& create_bounds) {
// state will have been lost. Sadly there's no way to tell on Windows when
// a window is restored from maximized state, so we can't more accurately
// track maximized state independently of sizing information.
- window_delegate_->GetSavedMaximizedState(&saved_maximized_state_);
+ GetWindow()->window_delegate()->GetSavedMaximizedState(
+ &saved_maximized_state_);
// Restore the window's placement from the controller.
gfx::Rect saved_bounds(create_bounds.ToRECT());
- if (window_delegate_->GetSavedWindowBounds(&saved_bounds)) {
- if (!window_delegate_->ShouldRestoreWindowSize()) {
- saved_bounds.set_size(non_client_view_->GetPreferredSize());
+ if (GetWindow()->window_delegate()->GetSavedWindowBounds(&saved_bounds)) {
+ if (!GetWindow()->window_delegate()->ShouldRestoreWindowSize()) {
+ saved_bounds.set_size(GetWindow()->non_client_view()->GetPreferredSize());
} else {
// Make sure the bounds are at least the minimum size.
if (saved_bounds.width() < minimum_size_.width()) {
@@ -1319,14 +1308,14 @@ void WindowWin::RestoreEnabledIfNecessary() {
DWORD WindowWin::CalculateWindowStyle() {
DWORD window_styles =
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SYSMENU | WS_CAPTION;
- bool can_resize = window_delegate_->CanResize();
- bool can_maximize = window_delegate_->CanMaximize();
+ bool can_resize = GetWindow()->window_delegate()->CanResize();
+ bool can_maximize = GetWindow()->window_delegate()->CanMaximize();
if (can_maximize) {
window_styles |= WS_OVERLAPPEDWINDOW;
} else if (can_resize) {
window_styles |= WS_OVERLAPPED | WS_THICKFRAME;
}
- if (window_delegate_->AsDialogDelegate()) {
+ if (GetWindow()->window_delegate()->AsDialogDelegate()) {
window_styles |= DS_MODALFRAME;
// NOTE: Turning this off means we lose the close button, which is bad.
// Turning it on though means the user can maximize or size the window
@@ -1339,7 +1328,7 @@ DWORD WindowWin::CalculateWindowStyle() {
DWORD WindowWin::CalculateWindowExStyle() {
DWORD window_ex_styles = 0;
- if (window_delegate_->AsDialogDelegate())
+ if (GetWindow()->window_delegate()->AsDialogDelegate())
window_ex_styles |= WS_EX_DLGMODALFRAME;
return window_ex_styles;
}
@@ -1349,13 +1338,13 @@ void WindowWin::SaveWindowPosition() {
// by go/crash) that in some circumstances we can end up here after
// WM_DESTROY, at which point the window delegate is likely gone. So just
// bail.
- if (!window_delegate_)
+ if (!GetWindow()->window_delegate())
return;
bool maximized;
gfx::Rect bounds;
GetWindowBoundsAndMaximizedState(&bounds, &maximized);
- window_delegate_->SaveWindowPlacement(bounds, maximized);
+ GetWindow()->window_delegate()->SaveWindowPlacement(bounds, maximized);
}
void WindowWin::LockUpdates() {
@@ -1372,7 +1361,7 @@ void WindowWin::UnlockUpdates() {
void WindowWin::ResetWindowRegion(bool force) {
// A native frame uses the native window region, and we don't want to mess
// with it.
- if (non_client_view_->UseNativeFrame()) {
+ if (GetWindow()->non_client_view()->UseNativeFrame()) {
if (force)
SetWindowRgn(NULL, TRUE);
return;
@@ -1397,7 +1386,7 @@ void WindowWin::ResetWindowRegion(bool force) {
new_region = CreateRectRgnIndirect(&work_rect);
} else {
gfx::Path window_mask;
- non_client_view_->GetWindowMask(
+ GetWindow()->non_client_view()->GetWindowMask(
gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask);
new_region = window_mask.CreateNativeRegion();
}
@@ -1431,7 +1420,8 @@ void WindowWin::UpdateAccessibleRole() {
IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
if (SUCCEEDED(hr)) {
VARIANT var;
- AccessibilityTypes::Role role = window_delegate_->accessible_role();
+ AccessibilityTypes::Role role =
+ GetWindow()->window_delegate()->accessible_role();
if (role) {
var.vt = VT_I4;
var.lVal = ViewAccessibility::MSAARole(role);
@@ -1447,7 +1437,8 @@ void WindowWin::UpdateAccessibleState() {
IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
if (SUCCEEDED(hr)) {
VARIANT var;
- AccessibilityTypes::State state = window_delegate_->accessible_state();
+ AccessibilityTypes::State state =
+ GetWindow()->window_delegate()->accessible_state();
if (state) {
var.lVal = ViewAccessibility::MSAAState(state);
hr = pAccPropServices->SetHwndProp(GetNativeView(), OBJID_CLIENT,
diff --git a/views/window/window_win.h b/views/window/window_win.h
index aeab57f..e9db7687 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -96,9 +96,6 @@ class WindowWin : public WidgetWin,
virtual void SetIsAlwaysOnTop(bool always_on_top);
virtual NonClientFrameView* CreateFrameViewForWindow();
virtual void UpdateFrameAfterFrameChange();
- virtual WindowDelegate* GetDelegate() const;
- virtual NonClientView* GetNonClientView() const;
- virtual ClientView* GetClientView() const;
virtual gfx::NativeWindow GetNativeWindow() const;
virtual bool ShouldUseNativeFrame() const;
virtual void FrameTypeChanged();
@@ -240,15 +237,6 @@ class WindowWin : public WidgetWin,
// A delegate implementation that handles events received here.
internal::NativeWindowDelegate* delegate_;
- // Our window delegate (see Init method for documentation).
- WindowDelegate* window_delegate_;
-
- // The View that provides the non-client area of the window (title bar,
- // window controls, sizing borders etc). To use an implementation other than
- // the default, this class must be subclassed and this value set to the
- // desired implementation before calling |Init|.
- NonClientView* non_client_view_;
-
// Whether we should SetFocus() on a newly created window after
// Init(). Defaults to true.
bool focus_on_creation_;