summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-13 17:01:46 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-13 17:01:46 +0000
commit9756ba445d7c6c7be8b9c885e944ccbf21742b3f (patch)
tree96bd517c4df7a0f05c38531ac5b96838ab132b30 /chrome/browser/ui
parent6c572a070755401823bb0f84d36913dbe1032334 (diff)
downloadchromium_src-9756ba445d7c6c7be8b9c885e944ccbf21742b3f.zip
chromium_src-9756ba445d7c6c7be8b9c885e944ccbf21742b3f.tar.gz
chromium_src-9756ba445d7c6c7be8b9c885e944ccbf21742b3f.tar.bz2
Revert 85269 - Split the hierarchy.
* Widget ---- Now recognizes a supplied NativeWidget via InitParams. If this is specified then a default one is not created. Is now created directly rather than using a factory. NativeWidget creation is not performed until Init() is called. This means some functions that rely on a NativeWidget must not be called until _AFTER_ Init() (explains some of the function call reordering in this CL, e.g. moving SetOpacity() until after Init()). ResetLastMouseMovedFlag() moved to this API so that BaseTabStrip can call it in a cross-platform way. Made last remaining unimplemented methods on Widget pass-thru to NativeWidget implementations. * WidgetWin/WidgetGtk ---- The NativeWidget implementations now both require a NativeWidgetDelegate implementation upon construction. This is passed through the constructor by the static factory method NativeWidget::CreateNativeWidget and by subclasses such as WindowWin, BubbleWidgetWin, etc. Some classes that are constructed directly (e.g. LockWindow, in ChromeOS) never have a Widget created for them, so they create the Widget themselves in their base class initializer. Code in these classes (and their WindowWin/WindowGtk, BrowserFrameWin, BrowserFrameGtk subclasses) must now call GetWidget() etc to call Widget API methods since they are no longer subclasses. static_casting to this (and derived) types must now be done on the Widget's native_widget(). GetWindow() is renamed to GetContainingWindow() to avoid naming conflicts. * Window ---- Window is now a subclass of Widget. Now recognizes a supplied NativeWindow via InitParams. If this is specified then a default one is not created. Window::CloseWindow becomes an override of Widget::Close. CloseAllSecondaryWindows() becomes CloseAllSecondaryWidgets() and moves to widget.h IsAppWindow() is removed and replaced by set_is_secondary_widget on Widget. * MenuHost ---- Subclasses Widget now. * TabContentsViewViews ---- It looks like the Gtk-views code here was still using the old implementation of the Native version of this class - i.e. a class that subclassed TabContentsView AND WidgetGtk. A no-no. I had to write NativeTabContentsViewGtk, which is almost identical to NativeTabContentsViewWin with the Gtk bits of TabContentsViewGtk thrown in. * BrowserFrame ---- Platform-specific functionality is now restricted to BrowserFrameWin/BrowserFrameGtk behind a NativeBrowserFrame interface. Construction is exposed via a static factory method on NativeBrowserFrame. BrowserFrame becomes a concrete class that now subclasses Window. As a result, it no longer needs a GetWindow() accessor method, so people with a BrowserFrame* can just call Window methods directly on it. It is constructed directly, replacing the BrowserFrame::Create() method. NativeBrowserFrameDelegate is no longer needed. BrowserFrameChromeos is simpler as a couple of #ifdefs in BrowserFrame, so I got rid of that too. * AutocompletePopupWin/Gtk ---- No longer required. AutocompletePopupContentsView now just uses a Widget directly. * There is some lingering ugliness: - If you set a native_window field on Window::InitParams you must also manually set widget_init_params.native_widget. I will make InitParams do more of this automatically later. - It'd be nice for the ContentsView to be specified via InitParams. I'll get to this later. - NativeBrowserFrame could probably disappear as an interface. It only exists to provide a couple of methods that may be implemented in other ways. - delete_on_destroy should now be an ownership directionality enum. I will do this later. - Secondary-widgetness should somehow be inferred from transience. Later. - set_focus_on_creation for both the NativeWidgets should probably move to Widget if it is really needed. - WidgetWin/Gtk::SetInitialFocus seems like it could move to Widget. - I need to clean up function order in some cases. BUG=72040 TEST=none Review URL: http://codereview.chromium.org/7012006 TBR=ben@chromium.org Review URL: http://codereview.chromium.org/7011038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser_list_win.cc4
-rw-r--r--chrome/browser/ui/find_bar/find_bar_host_browsertest.cc14
-rw-r--r--chrome/browser/ui/gtk/constrained_window_gtk.cc9
-rw-r--r--chrome/browser/ui/gtk/constrained_window_gtk.h4
-rw-r--r--chrome/browser/ui/input_window_dialog_win.cc2
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.cc10
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.cc2
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc27
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h18
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc23
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h29
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_win.cc25
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h29
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc5
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc4
-rw-r--r--chrome/browser/ui/views/browser_bubble.cc11
-rw-r--r--chrome/browser/ui/views/browser_bubble.h4
-rw-r--r--chrome/browser/ui/views/browser_bubble_gtk.cc44
-rw-r--r--chrome/browser/ui/views/browser_bubble_win.cc33
-rw-r--r--chrome/browser/ui/views/bubble/border_widget_win.cc9
-rw-r--r--chrome/browser/ui/views/bubble/bubble.cc42
-rw-r--r--chrome/browser/ui/views/constrained_html_delegate_gtk.cc6
-rw-r--r--chrome/browser/ui/views/constrained_window_views.cc18
-rw-r--r--chrome/browser/ui/views/constrained_window_views.h15
-rw-r--r--chrome/browser/ui/views/dom_view_browsertest.cc2
-rw-r--r--chrome/browser/ui/views/download/download_started_animation_win.cc4
-rw-r--r--chrome/browser/ui/views/dropdown_bar_host.cc2
-rw-r--r--chrome/browser/ui/views/extensions/extension_popup.cc4
-rw-r--r--chrome/browser/ui/views/find_bar_host_interactive_uitest.cc10
-rw-r--r--chrome/browser/ui/views/find_bar_host_win.cc3
-rw-r--r--chrome/browser/ui/views/first_run_bubble.cc6
-rw-r--r--chrome/browser/ui/views/first_run_search_engine_view.cc2
-rw-r--r--chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc32
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc114
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.h37
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_gtk.cc79
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_gtk.h23
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.cc128
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.h26
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc73
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout.cc4
-rw-r--r--chrome/browser/ui/views/frame/contents_container.cc4
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.cc40
-rw-r--r--chrome/browser/ui/views/frame/native_browser_frame.h25
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc83
-rw-r--r--chrome/browser/ui/views/fullscreen_exit_bubble.cc4
-rw-r--r--chrome/browser/ui/views/generic_info_view_unittest.cc2
-rw-r--r--chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc3
-rw-r--r--chrome/browser/ui/views/html_dialog_view.cc5
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/ui/views/importer/import_progress_dialog_view.cc2
-rw-r--r--chrome/browser/ui/views/js_modal_dialog_views.cc2
-rw-r--r--chrome/browser/ui/views/native_constrained_window_win.cc8
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view.cc8
-rw-r--r--chrome/browser/ui/views/profile_tag_view.cc2
-rw-r--r--chrome/browser/ui/views/status_bubble_views.cc6
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc3
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h13
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc284
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h87
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc35
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h5
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc488
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h143
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc88
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_views.h24
-rw-r--r--chrome/browser/ui/views/tabs/base_tab_strip.cc7
-rw-r--r--chrome/browser/ui/views/tabs/dragged_tab_controller.cc18
-rw-r--r--chrome/browser/ui/views/tabs/dragged_tab_view.cc18
-rw-r--r--chrome/browser/ui/views/tabs/native_view_photobooth_win.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/task_manager_view.cc2
-rw-r--r--chrome/browser/ui/views/theme_install_bubble_view.cc4
75 files changed, 1396 insertions, 963 deletions
diff --git a/chrome/browser/ui/browser_list_win.cc b/chrome/browser/ui/browser_list_win.cc
index 9c8fe46..b29a938 100644
--- a/chrome/browser/ui/browser_list_win.cc
+++ b/chrome/browser/ui/browser_list_win.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/ui/browser_list.h"
-#include "views/widget/widget.h"
+#include "views/window/window.h"
// static
void BrowserList::AllBrowsersClosedAndAppExiting() {
- views::Widget::CloseAllSecondaryWidgets();
+ views::Window::CloseAllSecondaryWindows();
}
diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
index 30f2f70..a34b0c5 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -839,8 +839,11 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) {
// For some reason we can't use AddSelectedTabWithURL here on ChromeOS. It
// could be some delicate assumption about the tab starting off unselected or
// something relating to user gesture.
- browser()->AddBlankTab(true);
- ui_test_utils::NavigateToURL(browser(), url);
+ browser::NavigateParams params(browser(), url, PageTransition::TYPED);
+ params.disposition = NEW_BACKGROUND_TAB;
+ params.tabstrip_add_types = TabStripModel::ADD_NONE;
+ browser::Navigate(&params);
+ browser()->ActivateTabAt(1, false);
TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper();
EXPECT_NE(tab1, tab2);
@@ -960,8 +963,11 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) {
FindBarController::kKeepSelection);
// Now create a second tab and load the same page.
- browser()->AddBlankTab(true);
- ui_test_utils::NavigateToURL(browser(), url);
+ browser::NavigateParams params(browser(), url, PageTransition::TYPED);
+ params.disposition = NEW_BACKGROUND_TAB;
+ params.tabstrip_add_types = TabStripModel::ADD_NONE;
+ browser::Navigate(&params);
+ browser()->ActivateTabAt(1, false);
TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper();
EXPECT_NE(tab1, tab2);
diff --git a/chrome/browser/ui/gtk/constrained_window_gtk.cc b/chrome/browser/ui/gtk/constrained_window_gtk.cc
index 2078151..a6c2621 100644
--- a/chrome/browser/ui/gtk/constrained_window_gtk.cc
+++ b/chrome/browser/ui/gtk/constrained_window_gtk.cc
@@ -13,9 +13,6 @@
#if defined(TOUCH_UI)
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
-#elif defined(TOOLKIT_VIEWS)
-#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#else
#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
#endif
@@ -123,13 +120,7 @@ void ConstrainedWindowGtk::FocusConstrainedWindow() {
ConstrainedWindowGtk::TabContentsViewType*
ConstrainedWindowGtk::ContainingView() {
-#if defined(TOOLKIT_VIEWS)
- return static_cast<NativeTabContentsViewGtk*>(
- static_cast<TabContentsViewViews*>(owner_->view())->
- native_tab_contents_view());
-#else
return static_cast<TabContentsViewType*>(owner_->view());
-#endif
}
gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender,
diff --git a/chrome/browser/ui/gtk/constrained_window_gtk.h b/chrome/browser/ui/gtk/constrained_window_gtk.h
index 700f47c..b703409 100644
--- a/chrome/browser/ui/gtk/constrained_window_gtk.h
+++ b/chrome/browser/ui/gtk/constrained_window_gtk.h
@@ -18,8 +18,6 @@ class TabContents;
typedef struct _GdkColor GdkColor;
#if defined(TOUCH_UI)
class TabContentsViewTouch;
-#elif defined(TOOLKIT_VIEWS)
-class NativeTabContentsViewGtk;
#else
class TabContentsViewGtk;
#endif
@@ -52,8 +50,6 @@ class ConstrainedWindowGtk : public ConstrainedWindow {
public:
#if defined(TOUCH_UI)
typedef TabContentsViewTouch TabContentsViewType;
-#elif defined(TOOLKIT_VIEWS)
- typedef NativeTabContentsViewGtk TabContentsViewType;
#else
typedef TabContentsViewGtk TabContentsViewType;
#endif
diff --git a/chrome/browser/ui/input_window_dialog_win.cc b/chrome/browser/ui/input_window_dialog_win.cc
index 7012d10..058ffd1 100644
--- a/chrome/browser/ui/input_window_dialog_win.cc
+++ b/chrome/browser/ui/input_window_dialog_win.cc
@@ -220,7 +220,7 @@ void WinInputWindowDialog::Show() {
}
void WinInputWindowDialog::Close() {
- window_->Close();
+ window_->CloseWindow();
}
// static
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index ee035f2..a353dd5 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc
@@ -224,7 +224,7 @@ int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->client_view()->NonClientHitTest(point);
+ frame_->GetWindow()->client_view()->NonClientHitTest(point);
if (frame_component != HTNOWHERE)
return frame_component;
@@ -235,7 +235,7 @@ int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point,
NonClientBorderThickness(), NonClientBorderThickness(),
0, 0,
- frame_->window_delegate()->CanResize());
+ frame_->GetWindow()->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -340,7 +340,7 @@ void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) {
void PanelBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_)
- frame_->Close();
+ frame_->GetWindow()->CloseWindow();
}
void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) {
@@ -392,7 +392,7 @@ bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() {
- return frame_->window_delegate()->GetWindowIcon();
+ return frame_->GetWindow()->window_delegate()->GetWindowIcon();
}
int PanelBrowserFrameView::NonClientBorderThickness() const {
@@ -514,7 +514,7 @@ void PanelBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) {
void PanelBrowserFrameView::UpdateTitleBar() {
title_label_->SetText(
- frame_->window_delegate()->GetWindowTitle());
+ frame_->GetWindow()->window_delegate()->GetWindowTitle());
}
void PanelBrowserFrameView::OnActivationChanged(bool active) {
diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
index 6c6a63a..0883866 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -15,7 +15,7 @@
BrowserWindow* Panel::CreateNativePanel(Browser* browser, Panel* panel) {
BrowserView* view = new PanelBrowserView(browser, panel);
- (new BrowserFrame(view))->InitBrowserFrame();
+ BrowserFrame::Create(view, browser->profile());
view->GetWidget()->SetAlwaysOnTop(true);
view->GetWindow()->non_client_view()->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index a3ec9ae..d724051 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -117,22 +117,6 @@ class OptInButtonBorder : public views::Border {
DISALLOW_COPY_AND_ASSIGN(OptInButtonBorder);
};
-gfx::NativeView GetRelativeWindowForPopup(gfx::NativeView edit_native_view) {
-#if defined(OS_WIN)
- // When an IME is attached to the rich-edit control, retrieve its window
- // handle and show this popup window under the IME windows.
- // Otherwise, show this popup window under top-most windows.
- // TODO(hbono): http://b/1111369 if we exclude this popup window from the
- // display area of IME windows, this workaround becomes unnecessary.
- HWND ime_window = ImmGetDefaultIMEWnd(edit_native_view);
- return ime_window ? ime_window : HWND_NOTOPMOST;
-#elif defined(TOOLKIT_USES_GTK)
- GtkWidget* toplevel = gtk_widget_get_toplevel(edit_native_view);
- DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
- return toplevel;
-#endif
-}
-
} // namespace
class AutocompletePopupContentsView::InstantOptInView
@@ -224,7 +208,6 @@ AutocompletePopupContentsView::AutocompletePopupContentsView(
const views::View* location_bar)
: model_(new AutocompletePopupModel(this, edit_model, profile)),
opt_in_view_(NULL),
- popup_(NULL),
omnibox_view_(omnibox_view),
location_bar_(location_bar),
result_font_(font.DeriveFont(kEditFontAdjust)),
@@ -296,7 +279,7 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
// destroying the popup would cause us to read garbage when we unwind back
// to that level.
popup_->Close(); // This will eventually delete the popup.
- popup_ = NULL;
+ popup_.reset();
}
return;
}
@@ -345,16 +328,16 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
if (popup_ == NULL) {
// If the popup is currently closed, we need to create it.
- popup_ = new views::Widget;
+ popup_ = (new AutocompletePopupClass)->AsWeakPtr();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.can_activate = false;
params.transparent = true;
params.parent = location_bar_->GetWidget()->GetNativeView();
params.bounds = GetPopupBounds();
- popup_->Init(params);
+ popup_->GetWidget()->Init(params);
popup_->SetContentsView(this);
- popup_->MoveAbove(
- GetRelativeWindowForPopup(omnibox_view_->GetNativeView()));
+ popup_->MoveAbove(popup_->GetRelativeWindowForPopup(
+ omnibox_view_->GetNativeView()));
popup_->Show();
} else {
// Animate the popup shrinking, but don't animate growing larger since that
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
index 88f5160..7673bf0 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
@@ -16,6 +16,12 @@
#include "views/view.h"
#include "webkit/glue/window_open_disposition.h"
+#if defined(OS_WIN)
+#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h"
+#elif defined(TOOLKIT_USES_GTK)
+#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h"
+#endif
+
class AutocompleteEditModel;
struct AutocompleteMatch;
class AutocompleteResultView;
@@ -99,6 +105,11 @@ class AutocompletePopupContentsView : public views::View,
views::View* opt_in_view_;
private:
+#if defined(OS_WIN)
+ typedef AutocompletePopupWin AutocompletePopupClass;
+#elif defined(TOOLKIT_USES_GTK)
+ typedef AutocompletePopupGtk AutocompletePopupClass;
+#endif
class InstantOptInView;
// Returns true if the model has a match at the specified index.
@@ -133,8 +144,11 @@ class AutocompletePopupContentsView : public views::View,
// view.
void UserPressedOptIn(bool opt_in);
- // The popup that contains this view.
- views::Widget* popup_;
+ // The popup that contains this view. We create this, but it deletes itself
+ // when its window is destroyed. This is a WeakPtr because it's possible for
+ // the OS to destroy the window and thus delete this object before we're
+ // deleted, or without our knowledge.
+ base::WeakPtr<AutocompletePopupClass> popup_;
// The edit view that invokes us.
OmniboxView* omnibox_view_;
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc
new file mode 100644
index 0000000..d0299a8
--- /dev/null
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc
@@ -0,0 +1,23 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h"
+
+#include "chrome/browser/ui/gtk/gtk_util.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// AutocompletePopupGtk, public:
+
+AutocompletePopupGtk::AutocompletePopupGtk() {
+}
+
+AutocompletePopupGtk::~AutocompletePopupGtk() {
+}
+
+gfx::NativeView AutocompletePopupGtk::GetRelativeWindowForPopup(
+ gfx::NativeView edit_native_view) const {
+ GtkWidget* toplevel = gtk_widget_get_toplevel(edit_native_view);
+ DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
+ return toplevel;
+}
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h
new file mode 100644
index 0000000..ba07afc
--- /dev/null
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 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_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_GTK_H_
+#define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_GTK_H_
+#pragma once
+
+#include "base/memory/weak_ptr.h"
+#include "views/widget/widget_gtk.h"
+
+class AutocompletePopupGtk
+ : public views::WidgetGtk,
+ public base::SupportsWeakPtr<AutocompletePopupGtk> {
+ public:
+ // Creates the popup and shows it. |edit_view| is the edit that created us.
+ AutocompletePopupGtk();
+ virtual ~AutocompletePopupGtk();
+
+ // Returns the window the popup should be relative to. |edit_native_view| is
+ // the native view of the autocomplete edit.
+ gfx::NativeView GetRelativeWindowForPopup(
+ gfx::NativeView edit_native_view) const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutocompletePopupGtk);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_GTK_H_
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.cc
new file mode 100644
index 0000000..37dbf1e
--- /dev/null
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// AutocompletePopupWin, public:
+
+AutocompletePopupWin::AutocompletePopupWin() {
+}
+
+AutocompletePopupWin::~AutocompletePopupWin() {
+}
+
+gfx::NativeView AutocompletePopupWin::GetRelativeWindowForPopup(
+ gfx::NativeView edit_native_view) const {
+ // When an IME is attached to the rich-edit control, retrieve its window
+ // handle and show this popup window under the IME windows.
+ // Otherwise, show this popup window under top-most windows.
+ // TODO(hbono): http://b/1111369 if we exclude this popup window from the
+ // display area of IME windows, this workaround becomes unnecessary.
+ HWND ime_window = ImmGetDefaultIMEWnd(edit_native_view);
+ return ime_window ? ime_window : HWND_NOTOPMOST;
+}
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h
new file mode 100644
index 0000000..2f369e2
--- /dev/null
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 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_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_WIN_H_
+#define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_WIN_H_
+#pragma once
+
+#include "base/memory/weak_ptr.h"
+#include "views/widget/widget_win.h"
+
+class AutocompletePopupWin
+ : public views::WidgetWin,
+ public base::SupportsWeakPtr<AutocompletePopupWin> {
+ public:
+ // Creates the popup and shows it. |edit_view| is the edit that created us.
+ AutocompletePopupWin();
+ virtual ~AutocompletePopupWin();
+
+ // Returns the window the popup should be relative to. |edit_native_view| is
+ // the native view of the autocomplete edit.
+ gfx::NativeView GetRelativeWindowForPopup(
+ gfx::NativeView edit_native_view) const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWin);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_WIN_H_
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index f6103bd..997327f 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -1361,7 +1361,7 @@ class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase {
ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED);
// Close the window.
- window_->Close();
+ window_->CloseWindow();
window_ = NULL;
}
};
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
index 912a5b9..1a960db 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -346,7 +346,7 @@ std::wstring BookmarkBubbleView::accessible_name() {
void BookmarkBubbleView::Close() {
ApplyEdits();
- GetWidget()->Close();
+ static_cast<Bubble*>(GetWidget())->Close();
}
void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) {
@@ -387,8 +387,7 @@ void BookmarkBubbleView::ShowEditor() {
ShowWindow(GetWidget()->GetNativeView(), SW_HIDE);
#elif defined(TOOLKIT_USES_GTK)
gfx::NativeWindow parent = GTK_WINDOW(
- static_cast<views::WidgetGtk*>(GetWidget()->native_widget())->
- GetTransientParent());
+ static_cast<views::WidgetGtk*>(GetWidget())->GetTransientParent());
#endif
// Even though we just hid the window, we need to invoke Close to schedule
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
index 4690ce0..b8e25ef 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
@@ -237,7 +237,7 @@ void BookmarkEditorView::Show(HWND parent_hwnd) {
void BookmarkEditorView::Close() {
DCHECK(window());
- window()->Close();
+ window()->CloseWindow();
}
void BookmarkEditorView::ShowContextMenuForView(View* source,
@@ -391,7 +391,7 @@ void BookmarkEditorView::BookmarkNodeRemoved(BookmarkModel* model,
details_.existing_node->HasAncestor(node)) ||
(parent_ && parent_->HasAncestor(node))) {
// The node, or its parent was removed. Close the dialog.
- window()->Close();
+ window()->CloseWindow();
} else {
Reset();
}
diff --git a/chrome/browser/ui/views/browser_bubble.cc b/chrome/browser/ui/views/browser_bubble.cc
index d87180d..53541d7 100644
--- a/chrome/browser/ui/views/browser_bubble.cc
+++ b/chrome/browser/ui/views/browser_bubble.cc
@@ -18,7 +18,7 @@ BrowserBubbleHost* GetBubbleHostFromFrame(views::Widget* frame) {
return NULL;
BrowserBubbleHost* bubble_host = NULL;
- views::Window* window = frame->GetContainingWindow();
+ views::Window* window = frame->GetWindow();
if (window) {
bubble_host = BrowserView::GetBrowserViewForNativeWindow(
window->GetNativeWindow());
@@ -38,6 +38,7 @@ BrowserBubble::BrowserBubble(views::View* view,
view_(view),
relative_to_(relative_to),
arrow_location_(arrow_location),
+ visible_(false),
delegate_(NULL),
attached_(false),
bubble_host_(GetBubbleHostFromFrame(frame)) {
@@ -93,7 +94,7 @@ void BrowserBubble::BrowserWindowMoved() {
delegate_->BubbleBrowserWindowMoved(this);
else
Hide();
- if (popup_->IsVisible())
+ if (visible_)
Reposition();
}
@@ -143,9 +144,3 @@ void BrowserBubble::SetAbsoluteBounds(const gfx::Rect& window_bounds) {
SetBounds(relative_origin.x(), relative_origin.y(),
window_bounds.width(), window_bounds.height());
}
-
-void BrowserBubble::MovePopup(int x, int y, int w, int h) {
- popup_->SetBounds(gfx::Rect(x, y, w, h));
-}
-
-
diff --git a/chrome/browser/ui/views/browser_bubble.h b/chrome/browser/ui/views/browser_bubble.h
index c74d40b..64eb87e 100644
--- a/chrome/browser/ui/views/browser_bubble.h
+++ b/chrome/browser/ui/views/browser_bubble.h
@@ -73,6 +73,7 @@ class BrowserBubble {
// Show or hide the bubble.
virtual void Show(bool activate);
virtual void Hide();
+ bool visible() const { return visible_; }
// The contained view.
views::View* view() const { return view_; }
@@ -126,6 +127,9 @@ class BrowserBubble {
// The bounds relative to the frame.
gfx::Rect bounds_;
+ // Current visibility.
+ bool visible_;
+
// The delegate isn't owned by the bubble.
Delegate* delegate_;
diff --git a/chrome/browser/ui/views/browser_bubble_gtk.cc b/chrome/browser/ui/views/browser_bubble_gtk.cc
index 4339e05..bf905ed 100644
--- a/chrome/browser/ui/views/browser_bubble_gtk.cc
+++ b/chrome/browser/ui/views/browser_bubble_gtk.cc
@@ -23,8 +23,7 @@ namespace {
class BubbleWidget : public views::WidgetGtk {
public:
BubbleWidget(BrowserBubble* bubble, const gfx::Insets& content_margins)
- : views::WidgetGtk(new views::Widget),
- bubble_(bubble),
+ : bubble_(bubble),
border_contents_(new BorderContents) {
border_contents_->Init();
border_contents_->set_content_margins(content_margins);
@@ -48,7 +47,7 @@ class BubbleWidget : public views::WidgetGtk {
}
virtual void Hide() {
- if (IsActive() && bubble_) {
+ if (IsActive()&& bubble_) {
BrowserBubble::Delegate* delegate = bubble_->delegate();
if (delegate)
delegate->BubbleLostFocus(bubble_, false);
@@ -93,19 +92,18 @@ class BubbleWidget : public views::WidgetGtk {
void BrowserBubble::InitPopup(const gfx::Insets& content_margins) {
// TODO(port)
- BubbleWidget* bubble_widget = new BubbleWidget(this, content_margins);
- popup_ = bubble_widget->GetWidget();
+ BubbleWidget* pop = new BubbleWidget(this, content_margins);
+ pop->MakeTransparent();
+ pop->make_transient_to_parent();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
- params.transparent = true;
params.parent = frame_->GetNativeView();
- params.native_widget = bubble_widget;
- popup_->Init(params);
+ pop->Init(params);
#if defined(OS_CHROMEOS)
{
vector<int> params;
params.push_back(0); // don't show while screen is locked
chromeos::WmIpc::instance()->SetWindowType(
- popup_->GetNativeView(),
+ pop->GetNativeView(),
chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE,
&params);
}
@@ -117,32 +115,42 @@ void BrowserBubble::InitPopup(const gfx::Insets& content_margins) {
// that when |contents| gets added, it will already have a widget, and thus
// any NativeButtons it creates in ViewHierarchyChanged() will be functional
// (e.g. calling SetChecked() on checkboxes is safe).
- popup_->SetContentsView(contents_view);
+ pop->SetContentsView(contents_view);
// Added border_contents before |view_| so it will paint under it.
- contents_view->AddChildView(bubble_widget->border_contents());
+ contents_view->AddChildView(pop->border_contents());
contents_view->AddChildView(view_);
+ popup_ = pop;
+
ResizeToView();
Reposition();
AttachToBrowser();
}
+void BrowserBubble::MovePopup(int x, int y, int w, int h) {
+ views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_);
+ pop->SetBounds(gfx::Rect(x, y, w, h));
+}
+
void BrowserBubble::Show(bool activate) {
- if (!popup_->IsVisible()) {
- static_cast<BubbleWidget*>(popup_->native_widget())->ShowAndActivate(
- activate);
- }
+ if (visible_)
+ return;
+ static_cast<BubbleWidget*>(popup_)->ShowAndActivate(activate);
+ visible_ = true;
}
void BrowserBubble::Hide() {
- if (popup_->IsVisible())
- static_cast<BubbleWidget*>(popup_->native_widget())->Hide();
+ if (!visible_)
+ return;
+ views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_);
+ pop->Hide();
+ visible_ = false;
}
void BrowserBubble::ResizeToView() {
BorderContents* border_contents =
- static_cast<BubbleWidget*>(popup_->native_widget())->border_contents();
+ static_cast<BubbleWidget*>(popup_)->border_contents();
// Calculate and set the bounds for all windows and views.
gfx::Rect window_bounds;
diff --git a/chrome/browser/ui/views/browser_bubble_win.cc b/chrome/browser/ui/views/browser_bubble_win.cc
index ce4b66c..3effe25 100644
--- a/chrome/browser/ui/views/browser_bubble_win.cc
+++ b/chrome/browser/ui/views/browser_bubble_win.cc
@@ -14,8 +14,7 @@
class BubbleWidget : public views::WidgetWin {
public:
explicit BubbleWidget(BrowserBubble* bubble)
- : views::WidgetWin(new views::Widget),
- bubble_(bubble),
+ : bubble_(bubble),
border_widget_(new BorderWidgetWin) {
set_window_style(WS_POPUP | WS_CLIPCHILDREN);
set_window_ex_style(WS_EX_TOOLWINDOW);
@@ -109,18 +108,17 @@ class BubbleWidget : public views::WidgetWin {
void BrowserBubble::InitPopup(const gfx::Insets& content_margins) {
// popup_ is a Widget, but we need to do some WidgetWin stuff first, then
// we'll assign it into popup_.
- BubbleWidget* bubble_widget = new BubbleWidget(this);
+ BubbleWidget* pop = new BubbleWidget(this);
+ popup_ = pop;
- BorderWidgetWin* border_widget = bubble_widget->border_widget();
+ BorderWidgetWin* border_widget = pop->border_widget();
border_widget->InitBorderWidgetWin(new BorderContents,
frame_->GetNativeView());
border_widget->border_contents()->set_content_margins(content_margins);
- popup_ = bubble_widget->GetWidget();
// We make the BorderWidgetWin the owner of the Bubble HWND, so that the
// latter is displayed on top of the former.
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
- params.native_widget = bubble_widget;
params.parent = border_widget->GetNativeView();
popup_->Init(params);
popup_->SetContentsView(view_);
@@ -130,21 +128,30 @@ void BrowserBubble::InitPopup(const gfx::Insets& content_margins) {
AttachToBrowser();
}
+void BrowserBubble::MovePopup(int x, int y, int w, int h) {
+ views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_);
+ pop->SetBounds(gfx::Rect(x, y, w, h));
+}
+
void BrowserBubble::Show(bool activate) {
- if (!popup_->IsVisible()) {
- static_cast<BubbleWidget*>(popup_->native_widget())->ShowAndActivate(
- activate);
- }
+ if (visible_)
+ return;
+ BubbleWidget* pop = static_cast<BubbleWidget*>(popup_);
+ pop->ShowAndActivate(activate);
+ visible_ = true;
}
void BrowserBubble::Hide() {
- if (popup_->IsVisible())
- static_cast<BubbleWidget*>(popup_->native_widget())->Hide();
+ if (!visible_)
+ return;
+ views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_);
+ pop->Hide();
+ visible_ = false;
}
void BrowserBubble::ResizeToView() {
BorderWidgetWin* border_widget =
- static_cast<BubbleWidget*>(popup_->native_widget())->border_widget();
+ static_cast<BubbleWidget*>(popup_)->border_widget();
gfx::Rect window_bounds;
window_bounds = border_widget->SizeAndGetBounds(GetAbsoluteRelativeTo(),
diff --git a/chrome/browser/ui/views/bubble/border_widget_win.cc b/chrome/browser/ui/views/bubble/border_widget_win.cc
index 8c72485..2fd2fc7 100644
--- a/chrome/browser/ui/views/bubble/border_widget_win.cc
+++ b/chrome/browser/ui/views/bubble/border_widget_win.cc
@@ -7,11 +7,9 @@
#include <windows.h>
#include "chrome/browser/ui/views/bubble/border_contents.h"
-#include "views/widget/widget.h"
BorderWidgetWin::BorderWidgetWin()
- : views::WidgetWin(new views::Widget),
- border_contents_(NULL) {
+ : border_contents_(NULL) {
}
void BorderWidgetWin::InitBorderWidgetWin(BorderContents* border_contents,
@@ -23,9 +21,8 @@ void BorderWidgetWin::InitBorderWidgetWin(BorderContents* border_contents,
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.parent = owner;
- params.native_widget = this;
GetWidget()->Init(params);
- GetWidget()->SetContentsView(border_contents_);
+ SetContentsView(border_contents_);
SetWindowPos(owner, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOREDRAW);
}
@@ -40,7 +37,7 @@ gfx::Rect BorderWidgetWin::SizeAndGetBounds(
border_contents_->SizeAndGetBounds(position_relative_to, arrow_location,
false, contents_size, &contents_bounds,
&window_bounds);
- GetWidget()->SetBounds(window_bounds);
+ SetBounds(window_bounds);
// Return |contents_bounds| in screen coordinates.
contents_bounds.Offset(window_bounds.origin());
diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc
index 2f0b46d..87b47d7 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -121,11 +121,6 @@ void Bubble::AnimationProgressed(const ui::Animation* animation) {
Bubble::Bubble()
:
-#if defined(OS_WIN)
- views::WidgetWin(new views::Widget),
-#elif defined(TOOLKIT_USES_GTK)
- views::WidgetGtk(new views::Widget),
-#endif
#if defined(TOOLKIT_USES_GTK)
border_contents_(NULL),
#elif defined(OS_WIN)
@@ -134,7 +129,7 @@ Bubble::Bubble()
delegate_(NULL),
show_status_(kOpen),
fade_away_on_close_(false),
-#if defined(TOOLKIT_USES_GTK)
+#if defined(OS_LINUX)
type_(views::Widget::InitParams::TYPE_WINDOW),
#endif
#if defined(OS_CHROMEOS)
@@ -147,8 +142,7 @@ Bubble::Bubble()
#if defined(OS_CHROMEOS)
Bubble::Bubble(views::Widget::InitParams::Type type,
bool show_while_screen_is_locked)
- : views::WidgetGtk(new views::Widget),
- border_contents_(NULL),
+ : border_contents_(NULL),
delegate_(NULL),
show_status_(kOpen),
fade_away_on_close_(false),
@@ -174,7 +168,7 @@ void Bubble::InitBubble(views::Widget* parent,
// Create the main window.
#if defined(OS_WIN)
- views::Window* parent_window = parent->GetContainingWindow();
+ views::Window* parent_window = parent->GetWindow();
if (parent_window)
parent_window->DisableInactiveRendering();
set_window_style(WS_POPUP | WS_CLIPCHILDREN);
@@ -191,7 +185,7 @@ void Bubble::InitBubble(views::Widget* parent,
if (fade_in) {
border_->SetOpacity(0);
- GetWidget()->SetOpacity(0);
+ SetOpacity(0);
}
border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView());
@@ -201,7 +195,6 @@ void Bubble::InitBubble(views::Widget* parent,
// latter is displayed on top of the former.
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.parent = border_->GetNativeView();
- params.native_widget = this;
GetWidget()->Init(params);
SetWindowText(GetNativeView(), delegate_->accessible_name().c_str());
@@ -209,7 +202,8 @@ void Bubble::InitBubble(views::Widget* parent,
views::Widget::InitParams params(type_);
params.transparent = true;
params.parent_widget = parent;
- params.native_widget = this;
+ // TODO(beng): Figure out how to make this implicit or set via InitParams.
+ make_transient_to_parent();
GetWidget()->Init(params);
#if defined(OS_CHROMEOS)
{
@@ -229,7 +223,7 @@ void Bubble::InitBubble(views::Widget* parent,
// that when |contents| gets added, it will already have a widget, and thus
// any NativeButtons it creates in ViewHierarchyChanged() will be functional
// (e.g. calling SetChecked() on checkboxes is safe).
- GetWidget()->SetContentsView(contents_view);
+ SetContentsView(contents_view);
// Adding |contents| as a child has to be done before we call
// contents->GetPreferredSize() below, since some supplied views don't
// actually initialize themselves until they're added to a hierarchy.
@@ -268,10 +262,10 @@ void Bubble::InitBubble(views::Widget* parent,
gfx::Rect(gfx::Point(), window_bounds.size()));
contents->SetBoundsRect(contents_bounds);
#endif
- GetWidget()->SetBounds(window_bounds);
+ SetBounds(window_bounds);
// Register the Escape accelerator for closing.
- GetWidget()->GetFocusManager()->RegisterAccelerator(
+ GetFocusManager()->RegisterAccelerator(
views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
// Done creating the bubble.
@@ -286,7 +280,7 @@ void Bubble::InitBubble(views::Widget* parent,
if (fade_in)
FadeIn();
#elif defined(TOOLKIT_USES_GTK)
- GetWidget()->Show();
+ views::WidgetGtk::Show();
#endif
}
@@ -313,23 +307,23 @@ void Bubble::SizeToContents() {
gfx::Rect(gfx::Point(), window_bounds.size()));
contents_->SetBoundsRect(contents_bounds);
#endif
- GetWidget()->SetBounds(window_bounds);
+ SetBounds(window_bounds);
}
#if defined(OS_WIN)
void Bubble::OnActivate(UINT action, BOOL minimized, HWND window) {
// The popup should close when it is deactivated.
if (action == WA_INACTIVE) {
- GetWidget()->Close();
+ Close();
} else if (action == WA_ACTIVE) {
- DCHECK(GetWidget()->GetRootView()->has_children());
- GetWidget()->GetRootView()->GetChildViewAt(0)->RequestFocus();
+ DCHECK(GetRootView()->has_children());
+ GetRootView()->GetChildViewAt(0)->RequestFocus();
}
}
#elif defined(TOOLKIT_USES_GTK)
void Bubble::IsActiveChanged() {
- if (!GetWidget()->IsActive())
- GetWidget()->Close();
+ if (!IsActive())
+ Close();
}
#endif
@@ -337,15 +331,13 @@ void Bubble::DoClose(bool closed_by_escape) {
if (show_status_ == kClosed)
return;
- GetWidget()->GetFocusManager()->UnregisterAccelerator(
+ GetFocusManager()->UnregisterAccelerator(
views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
if (delegate_)
delegate_->BubbleClosing(this, closed_by_escape);
show_status_ = kClosed;
#if defined(OS_WIN)
border_->Close();
-#endif
-#if defined(OS_WIN)
WidgetWin::Close();
#elif defined(TOOLKIT_USES_GTK)
WidgetGtk::Close();
diff --git a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
index c39a093..fd71a09 100644
--- a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
+++ b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
@@ -70,8 +70,7 @@ class ConstrainedHtmlDelegateGtk : public views::WidgetGtk,
ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk(
Profile* profile,
HtmlDialogUIDelegate* delegate)
- : views::WidgetGtk(new views::Widget),
- HtmlDialogTabContentsDelegate(profile),
+ : HtmlDialogTabContentsDelegate(profile),
html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL),
tab_container_(NULL),
html_delegate_(delegate),
@@ -87,11 +86,10 @@ ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk(
PageTransition::START_PAGE);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
- params.native_widget = this;
GetWidget()->Init(params);
tab_container_ = new TabContentsContainer;
- GetWidget()->SetContentsView(tab_container_);
+ SetContentsView(tab_container_);
tab_container_->ChangeTabContents(&html_tab_contents_);
gfx::Size dialog_size;
diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc
index ef8f72c..8034744 100644
--- a/chrome/browser/ui/views/constrained_window_views.cc
+++ b/chrome/browser/ui/views/constrained_window_views.cc
@@ -576,11 +576,8 @@ ConstrainedWindowViews::ConstrainedWindowViews(
NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
GetWindow()->non_client_view()->SetFrameView(CreateFrameViewForWindow());
views::Window::InitParams params(window_delegate);
- params.native_window = native_constrained_window_->AsNativeWindow();
params.widget_init_params.child = true;
params.widget_init_params.parent = owner->GetNativeView();
- params.widget_init_params.native_widget =
- native_constrained_window_->AsNativeWindow()->AsNativeWidget();
GetWindow()->InitWindow(params);
}
@@ -611,7 +608,7 @@ void ConstrainedWindowViews::CloseConstrainedWindow() {
NotificationService::current()->Notify(NotificationType::CWINDOW_CLOSED,
Source<ConstrainedWindow>(this),
NotificationService::NoDetails());
- GetWindow()->Close();
+ GetWindow()->CloseWindow();
}
void ConstrainedWindowViews::FocusConstrainedWindow() {
@@ -624,13 +621,6 @@ void ConstrainedWindowViews::FocusConstrainedWindow() {
}
////////////////////////////////////////////////////////////////////////////////
-// ConstrainedWindowViews, views::Window overrides:
-
-views::NonClientFrameView* ConstrainedWindowViews::CreateFrameViewForWindow() {
- return new ConstrainedWindowFrameView(this);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation:
void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() {
@@ -643,12 +633,10 @@ void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() {
GetWindow()->Activate();
}
-views::internal::NativeWindowDelegate*
- ConstrainedWindowViews::AsNativeWindowDelegate() {
- return this;
+views::NonClientFrameView* ConstrainedWindowViews::CreateFrameViewForWindow() {
+ return new ConstrainedWindowFrameView(this);
}
-
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindow, public:
diff --git a/chrome/browser/ui/views/constrained_window_views.h b/chrome/browser/ui/views/constrained_window_views.h
index c09740c..98d1047 100644
--- a/chrome/browser/ui/views/constrained_window_views.h
+++ b/chrome/browser/ui/views/constrained_window_views.h
@@ -10,15 +10,11 @@
#include "content/browser/tab_contents/constrained_window.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
-#include "views/window/window.h"
class ConstrainedTabContentsWindowDelegate;
class ConstrainedWindowAnimation;
class ConstrainedWindowFrameView;
namespace views {
-namespace internal {
-class NativeWindowDelegate;
-}
class NativeWindow;
class NonClientFrameView;
class Window;
@@ -39,8 +35,6 @@ class NativeConstrainedWindowDelegate {
// Creates the frame view for the constrained window.
// TODO(beng): remove once ConstrainedWindowViews is-a views::Window.
virtual views::NonClientFrameView* CreateFrameViewForWindow() = 0;
-
- virtual views::internal::NativeWindowDelegate* AsNativeWindowDelegate() = 0;
};
class NativeConstrainedWindow {
@@ -60,8 +54,7 @@ class NativeConstrainedWindow {
// A ConstrainedWindow implementation that implements a Constrained Window as
// a child HWND with a custom window frame.
//
-class ConstrainedWindowViews : public views::Window,
- public ConstrainedWindow,
+class ConstrainedWindowViews : public ConstrainedWindow,
public NativeConstrainedWindowDelegate {
public:
ConstrainedWindowViews(TabContents* owner,
@@ -79,14 +72,10 @@ class ConstrainedWindowViews : public views::Window,
virtual void FocusConstrainedWindow() OVERRIDE;
private:
- // Overridden from views::Window:
- virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
-
// Overridden from NativeConstrainedWindowDelegate:
virtual void OnNativeConstrainedWindowDestroyed() OVERRIDE;
virtual void OnNativeConstrainedWindowMouseActivate() OVERRIDE;
- virtual views::internal::NativeWindowDelegate*
- AsNativeWindowDelegate() OVERRIDE;
+ virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
// The TabContents that owns and constrains this ConstrainedWindow.
TabContents* owner_;
diff --git a/chrome/browser/ui/views/dom_view_browsertest.cc b/chrome/browser/ui/views/dom_view_browsertest.cc
index 00bf748..f78b549 100644
--- a/chrome/browser/ui/views/dom_view_browsertest.cc
+++ b/chrome/browser/ui/views/dom_view_browsertest.cc
@@ -14,7 +14,7 @@ using views::Widget;
class DOMViewTest : public InProcessBrowserTest {
public:
Widget* CreatePopupWindow() {
- Widget* widget = new Widget;
+ Widget* widget = Widget::CreateWidget();
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 400, 400);
widget->Init(params);
diff --git a/chrome/browser/ui/views/download/download_started_animation_win.cc b/chrome/browser/ui/views/download/download_started_animation_win.cc
index f38a5b2..91099a0 100644
--- a/chrome/browser/ui/views/download/download_started_animation_win.cc
+++ b/chrome/browser/ui/views/download/download_started_animation_win.cc
@@ -101,14 +101,14 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin(
SetImage(kDownloadImage);
- popup_ = new views::Widget;
+ popup_ = views::Widget::CreateWidget();
+ popup_->SetOpacity(0x00);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.accept_events = false;
params.parent = tab_contents_->GetNativeView();
popup_->Init(params);
- popup_->SetOpacity(0x00);
popup_->SetContentsView(this);
Reposition();
popup_->Show();
diff --git a/chrome/browser/ui/views/dropdown_bar_host.cc b/chrome/browser/ui/views/dropdown_bar_host.cc
index d2313f0..9675589 100644
--- a/chrome/browser/ui/views/dropdown_bar_host.cc
+++ b/chrome/browser/ui/views/dropdown_bar_host.cc
@@ -61,7 +61,7 @@ void DropdownBarHost::Init(views::View* view,
delegate_ = delegate;
// Initialize the host.
- host_.reset(new views::Widget);
+ host_.reset(views::Widget::CreateWidget());
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
params.delete_on_destroy = false;
params.parent_widget = browser_view_->GetWidget();
diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc
index 723b4d6..aa7888b 100644
--- a/chrome/browser/ui/views/extensions/extension_popup.cc
+++ b/chrome/browser/ui/views/extensions/extension_popup.cc
@@ -77,11 +77,11 @@ ExtensionPopup::~ExtensionPopup() {
}
void ExtensionPopup::Show(bool activate) {
- if (popup_->IsVisible())
+ if (visible())
return;
#if defined(OS_WIN)
- frame_->GetContainingWindow()->DisableInactiveRendering();
+ frame_->GetWindow()->DisableInactiveRendering();
#endif
ResizeToView();
diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
index 40a1cf5..17cd52b 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -56,13 +56,7 @@ class FindInPageTest : public InProcessBrowserTest {
} // namespace
-#if defined(TOOLKIT_USES_GTK)
-#define MAYBE_CrashEscHandlers FLAKY_CrashEscHandlers
-#else
-#define MAYBE_CrashEscHandlers CrashEscHandlers
-#endif
-
-IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) {
+IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
ASSERT_TRUE(test_server()->Start());
// First we navigate to our test page (tab A).
@@ -77,7 +71,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) {
browser()->Find();
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
-
+
// Select tab A.
browser()->ActivateTabAt(0, true);
diff --git a/chrome/browser/ui/views/find_bar_host_win.cc b/chrome/browser/ui/views/find_bar_host_win.cc
index f30702c..69edc15 100644
--- a/chrome/browser/ui/views/find_bar_host_win.cc
+++ b/chrome/browser/ui/views/find_bar_host_win.cc
@@ -20,8 +20,7 @@ void FindBarHost::AudibleAlert() {
void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) {
RECT frame_rect = {0}, webcontents_rect = {0};
::GetWindowRect(
- static_cast<views::WidgetWin*>(host()->native_widget())->GetParent(),
- &frame_rect);
+ static_cast<views::WidgetWin*>(host())->GetParent(), &frame_rect);
::GetWindowRect(
find_bar_controller_->
tab_contents()->tab_contents()->view()->GetNativeView(),
diff --git a/chrome/browser/ui/views/first_run_bubble.cc b/chrome/browser/ui/views/first_run_bubble.cc
index 2e0a390..7db2137 100644
--- a/chrome/browser/ui/views/first_run_bubble.cc
+++ b/chrome/browser/ui/views/first_run_bubble.cc
@@ -491,7 +491,7 @@ FirstRunBubble* FirstRunBubble::Show(Profile* profile,
bubble->set_view(view);
bubble->InitBubble(
parent, position_relative_to, arrow_location, view, bubble);
- bubble->GetWidget()->GetFocusManager()->AddFocusChangeListener(view);
+ bubble->GetFocusManager()->AddFocusChangeListener(view);
view->BubbleShown();
return bubble;
}
@@ -504,7 +504,7 @@ FirstRunBubble::FirstRunBubble()
FirstRunBubble::~FirstRunBubble() {
enable_window_method_factory_.RevokeAll();
- GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_);
+ GetFocusManager()->RemoveFocusChangeListener(view_);
}
void FirstRunBubble::EnableParent() {
@@ -517,7 +517,7 @@ void FirstRunBubble::EnableParent() {
views::NativeWidget* parent =
views::NativeWidget::GetNativeWidgetForNativeView(GetParent());
if (parent)
- parent->GetWidget()->GetContainingWindow()->DisableInactiveRendering();
+ parent->GetWidget()->GetWindow()->DisableInactiveRendering();
// Reactivate the FirstRunBubble so it responds to OnActivate messages.
SetWindowPos(GetParent(), 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | SWP_SHOWWINDOW);
diff --git a/chrome/browser/ui/views/first_run_search_engine_view.cc b/chrome/browser/ui/views/first_run_search_engine_view.cc
index 386e41b..58f8beb 100644
--- a/chrome/browser/ui/views/first_run_search_engine_view.cc
+++ b/chrome/browser/ui/views/first_run_search_engine_view.cc
@@ -74,7 +74,7 @@ void ShowFirstRunDialog(Profile* profile,
window->Show();
views::AcceleratorHandler accelerator_handler;
MessageLoopForUI::current()->Run(&accelerator_handler);
- window->Close();
+ window->CloseWindow();
}
} // namespace first_run
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 3f25d88..86032fc 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
@@ -146,14 +146,15 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- int frame_component = frame_->client_view()->NonClientHitTest(point);
+ int frame_component =
+ 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.)
gfx::Rect sysmenu_rect(IconBounds());
// In maximized mode we extend the rect to the screen corner to take advantage
// of Fitts' Law.
- if (frame_->IsMaximized())
+ if (frame_->GetWindow()->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
if (sysmenu_rect.Contains(point))
@@ -170,7 +171,7 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point,
NonClientBorderThickness(), NonClientBorderThickness(),
kResizeAreaCornerSize, kResizeAreaCornerSize,
- frame_->window_delegate()->CanResize());
+ frame_->GetWindow()->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -179,7 +180,7 @@ void AppPanelBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->IsMaximized())
+ if (frame_->GetWindow()->IsMaximized())
return;
// Redefine the window visible region for the new size.
@@ -218,12 +219,13 @@ void AppPanelBrowserFrameView::UpdateWindowIcon() {
// AppPanelBrowserFrameView, views::View overrides:
void AppPanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- if (frame_->IsMaximized())
+ views::Window* window = frame_->GetWindow();
+ if (window->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
PaintTitleBar(canvas);
- if (!frame_->IsMaximized())
+ if (!window->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -239,7 +241,7 @@ void AppPanelBrowserFrameView::Layout() {
void AppPanelBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_)
- frame_->Close();
+ frame_->GetWindow()->CloseWindow();
}
///////////////////////////////////////////////////////////////////////////////
@@ -254,19 +256,19 @@ bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap AppPanelBrowserFrameView::GetFaviconForTabIconView() {
- return frame_->window_delegate()->GetWindowIcon();
+ return frame_->GetWindow()->window_delegate()->GetWindowIcon();
}
///////////////////////////////////////////////////////////////////////////////
// AppPanelBrowserFrameView, private:
int AppPanelBrowserFrameView::FrameBorderThickness() const {
- return frame_->IsMaximized() ? 0 : kFrameBorderThickness;
+ return frame_->GetWindow()->IsMaximized() ? 0 : kFrameBorderThickness;
}
int AppPanelBrowserFrameView::NonClientBorderThickness() const {
return FrameBorderThickness() +
- (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
}
int AppPanelBrowserFrameView::NonClientTopBorderHeight() const {
@@ -277,7 +279,7 @@ int AppPanelBrowserFrameView::NonClientTopBorderHeight() const {
int AppPanelBrowserFrameView::TitlebarBottomThickness() const {
return kTitlebarTopAndBottomEdgeThickness +
- (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
}
int AppPanelBrowserFrameView::IconSize() const {
@@ -301,7 +303,7 @@ gfx::Rect AppPanelBrowserFrameView::IconBounds() const {
// with restored windows, so when the window is restored, instead of
// calculating the remaining space from below the frame border, we calculate
// from below the top border-plus-padding.
- int unavailable_px_at_top = frame_->IsMaximized() ?
+ int unavailable_px_at_top = frame_->GetWindow()->IsMaximized() ?
frame_thickness : kTitlebarTopAndBottomEdgeThickness;
// When the icon is shorter than the minimum space we reserve for the caption
// button, we vertically center it. We want to bias rounding to put extra
@@ -399,13 +401,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_->client_view()->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_->window_delegate();
+ 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());
@@ -465,7 +467,7 @@ void AppPanelBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
void AppPanelBrowserFrameView::LayoutWindowControls() {
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
- bool is_maximized = frame_->IsMaximized();
+ bool is_maximized = frame_->GetWindow()->IsMaximized();
// There should always be the same number of non-border pixels visible to the
// side of the close button. In maximized mode we extend the button to the
// screen corner to obey Fitts' Law.
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index 0b0842e..94d0fa7 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -4,53 +4,23 @@
#include "chrome/browser/ui/views/frame/browser_frame.h"
-#include "base/command_line.h"
-#include "chrome/browser/themes/theme_service.h"
-#include "chrome/browser/themes/theme_service_factory.h"
-#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_root_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/native_browser_frame.h"
-#include "chrome/common/chrome_switches.h"
-#include "ui/base/theme_provider.h"
#include "views/widget/native_widget.h"
#include "views/widget/widget.h"
#include "views/window/native_window.h"
#include "views/window/window.h"
-#if defined(OS_WIN)
-#include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
-#endif
-
////////////////////////////////////////////////////////////////////////////////
// BrowserFrame, public:
-BrowserFrame::BrowserFrame(BrowserView* browser_view)
- : native_browser_frame_(NULL),
- root_view_(NULL),
- browser_frame_view_(NULL),
- browser_view_(browser_view) {
- browser_view_->set_frame(this);
- set_is_secondary_widget(false);
-}
-
BrowserFrame::~BrowserFrame() {
}
-void BrowserFrame::InitBrowserFrame() {
- native_browser_frame_ =
- NativeBrowserFrame::CreateNativeBrowserFrame(this, browser_view_);
- views::Window::InitParams params(browser_view_);
- params.native_window = native_browser_frame_->AsNativeWindow();
- params.widget_init_params.native_widget =
- params.native_window->AsNativeWidget();
- InitWindow(params);
-#if defined(OS_CHROMEOS)
- // On ChromeOS we always want top-level windows to appear active.
- if (!browser_view_->IsBrowserTypePopup())
- DisableInactiveRendering();
-#endif
+views::Window* BrowserFrame::GetWindow() {
+ return native_browser_frame_->AsNativeWindow()->GetWindow();
}
int BrowserFrame::GetMinimizeButtonOffset() const {
@@ -69,20 +39,12 @@ void BrowserFrame::UpdateThrobber(bool running) {
browser_frame_view_->UpdateThrobber(running);
}
+ui::ThemeProvider* BrowserFrame::GetThemeProviderForFrame() const {
+ return native_browser_frame_->GetThemeProviderForFrame();
+}
+
bool BrowserFrame::AlwaysUseNativeFrame() const {
- // App panel windows draw their own frame.
- if (browser_view_->IsBrowserTypePanel())
- return false;
-
- // We don't theme popup or app windows, so regardless of whether or not a
- // theme is active for normal browser windows, we don't want to use the custom
- // frame for popups/apps.
- if (!browser_view_->IsBrowserTypeNormal() && ShouldUseNativeFrame())
- return true;
-
- // Otherwise, we use the native frame when we're told we should by the theme
- // provider (e.g. no custom theme is active).
- return GetThemeProvider()->ShouldUseNativeFrame();
+ return native_browser_frame_->AlwaysUseNativeFrame();
}
views::View* BrowserFrame::GetFrameView() const {
@@ -90,68 +52,32 @@ views::View* BrowserFrame::GetFrameView() const {
}
void BrowserFrame::TabStripDisplayModeChanged() {
- if (GetRootView()->has_children()) {
- // Make sure the child of the root view gets Layout again.
- GetRootView()->GetChildViewAt(0)->InvalidateLayout();
- }
- GetRootView()->Layout();
native_browser_frame_->TabStripDisplayModeChanged();
}
-///////////////////////////////////////////////////////////////////////////////
-// BrowserFrameWin, views::Window overrides:
-
-bool BrowserFrame::IsMaximized() const {
-#if defined(OS_CHROMEOS)
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeosFrame)) {
- return !IsFullscreen() &&
- (!browser_view_->IsBrowserTypePopup() || Window::IsMaximized());
- }
-#endif
- return Window::IsMaximized();
-}
+////////////////////////////////////////////////////////////////////////////////
+// BrowserFrame, NativeBrowserFrameDelegate implementation:
-views::RootView* BrowserFrame::CreateRootView() {
+views::RootView* BrowserFrame::DelegateCreateRootView() {
root_view_ = new BrowserRootView(
browser_view_,
native_browser_frame_->AsNativeWindow()->AsNativeWidget()->GetWidget());
return root_view_;
}
-views::NonClientFrameView* BrowserFrame::CreateFrameViewForWindow() {
-#if defined(OS_WIN)
- if (AlwaysUseNativeFrame()) {
- browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_);
- } else {
-#endif
- browser_frame_view_ =
- browser::CreateBrowserNonClientFrameView(this, browser_view_);
-#if defined(OS_WIN)
- }
-#endif
+views::NonClientFrameView* BrowserFrame::DelegateCreateFrameViewForWindow() {
+ browser_frame_view_ =
+ native_browser_frame_->CreateBrowserNonClientFrameView();
return browser_frame_view_;
}
-bool BrowserFrame::GetAccelerator(int command_id,
- ui::Accelerator* accelerator) {
- return browser_view_->GetAccelerator(command_id, accelerator);
-}
-ThemeProvider* BrowserFrame::GetThemeProvider() const {
- return ThemeServiceFactory::GetForProfile(
- browser_view_->browser()->profile());
-}
+////////////////////////////////////////////////////////////////////////////////
+// BrowserFrame, protected:
-void BrowserFrame::OnNativeWindowActivationChanged(bool active) {
- if (active) {
- // When running under remote desktop, if the remote desktop client is not
- // active on the users desktop, then none of the windows contained in the
- // remote desktop will be activated. However, WindowWin::Activate will
- // still bring this browser window to the foreground. We explicitly set
- // ourselves as the last active browser window to ensure that we get treated
- // as such by the rest of Chrome.
- BrowserList::SetLastActive(browser_view_->browser());
- }
- Window::OnNativeWindowActivationChanged(active);
+BrowserFrame::BrowserFrame(BrowserView* browser_view)
+ : native_browser_frame_(NULL),
+ root_view_(NULL),
+ browser_frame_view_(NULL),
+ browser_view_(browser_view) {
}
-
diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h
index 2c07fd2..2a7ae13 100644
--- a/chrome/browser/ui/views/frame/browser_frame.h
+++ b/chrome/browser/ui/views/frame/browser_frame.h
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "build/build_config.h"
#include "chrome/browser/ui/views/frame/native_browser_frame_delegate.h"
-#include "views/window/window.h"
class AeroGlassNonClientView;
class BrowserNonClientFrameView;
@@ -35,15 +34,19 @@ class Window;
}
// This is a virtual interface that allows system specific browser frames.
-class BrowserFrame : public views::Window {
+class BrowserFrame : public NativeBrowserFrameDelegate {
public:
- explicit BrowserFrame(BrowserView* browser_view);
virtual ~BrowserFrame();
+ // Creates the appropriate BrowserFrame for this platform. The returned
+ // object is owned by the caller.
+ static BrowserFrame* Create(BrowserView* browser_view, Profile* profile);
+
static const gfx::Font& GetTitleFont();
- // Initialize the frame (creates the underlying native window).
- void InitBrowserFrame();
+ // Returns the Window associated with this frame. Guaranteed non-NULL after
+ // construction.
+ views::Window* GetWindow();
// Determine the distance of the left edge of the minimize button from the
// left edge of the window. Used in our Non-Client View's Layout.
@@ -61,6 +64,9 @@ class BrowserFrame : public views::Window {
// Tells the frame to update the throbber.
void UpdateThrobber(bool running);
+ // Returns the theme provider for this frame.
+ ui::ThemeProvider* GetThemeProviderForFrame() const;
+
// Returns true if the window should use the native frame view. This is true
// if there are no themes applied on Vista, or if there are themes applied and
// this browser window is an app or popup.
@@ -73,14 +79,19 @@ class BrowserFrame : public views::Window {
// its frame treatment if necessary.
void TabStripDisplayModeChanged();
- // Overridden from views::Window:
- virtual bool IsMaximized() const OVERRIDE;
- virtual views::RootView* CreateRootView() OVERRIDE;
- virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
- virtual bool GetAccelerator(int command_id,
- ui::Accelerator* accelerator) OVERRIDE;
- virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE;
- virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE;
+ protected:
+ // Overridden from NativeBrowserFrameDelegate:
+ virtual views::RootView* DelegateCreateRootView() OVERRIDE;
+ virtual views::NonClientFrameView* DelegateCreateFrameViewForWindow()
+ OVERRIDE;
+
+ // TODO(beng): Temporarily provided as a way to associate the subclass'
+ // implementation of NativeBrowserFrame with this.
+ void set_native_browser_frame(NativeBrowserFrame* native_browser_frame) {
+ native_browser_frame_ = native_browser_frame;
+ }
+
+ explicit BrowserFrame(BrowserView* browser_view);
private:
NativeBrowserFrame* native_browser_frame_;
diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.cc b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
index dd1cee8..110c599 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
@@ -17,23 +17,38 @@
#include "views/widget/root_view.h"
#include "views/window/hit_test.h"
+#if !defined(OS_CHROMEOS)
+// static (Factory method.)
+BrowserFrame* BrowserFrame::Create(BrowserView* browser_view,
+ Profile* profile) {
+ BrowserFrameGtk* frame = new BrowserFrameGtk(browser_view, profile);
+ frame->InitBrowserFrame();
+ return frame;
+}
+#endif
+
// static
const gfx::Font& BrowserFrame::GetTitleFont() {
static gfx::Font *title_font = new gfx::Font();
return *title_font;
}
-BrowserFrameGtk::BrowserFrameGtk(BrowserFrame* browser_frame,
- BrowserView* browser_view)
- : views::WindowGtk(browser_frame),
+BrowserFrameGtk::BrowserFrameGtk(BrowserView* browser_view, Profile* profile)
+ : BrowserFrame(browser_view),
+ ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
browser_view_(browser_view) {
- // Don't focus anything on creation, selecting a tab will set the focus.
- set_focus_on_creation(false);
+ set_native_browser_frame(this);
+ browser_view_->set_frame(this);
}
BrowserFrameGtk::~BrowserFrameGtk() {
}
+void BrowserFrameGtk::InitBrowserFrame() {
+ WindowGtk::GetWindow()->InitWindow(views::Window::InitParams(browser_view_));
+ // Don't focus anything on creation, selecting a tab will set the focus.
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserFrameGtk, NativeBrowserFrame implementation:
@@ -45,22 +60,58 @@ const views::NativeWindow* BrowserFrameGtk::AsNativeWindow() const {
return this;
}
+BrowserNonClientFrameView* BrowserFrameGtk::CreateBrowserNonClientFrameView() {
+ return browser::CreateBrowserNonClientFrameView(this, browser_view_);
+}
+
int BrowserFrameGtk::GetMinimizeButtonOffset() const {
NOTIMPLEMENTED();
return 0;
}
+ThemeProvider* BrowserFrameGtk::GetThemeProviderForFrame() const {
+ // This is implemented for a different interface than GetThemeProvider is,
+ // but they mean the same things.
+ return GetThemeProvider();
+}
+
+bool BrowserFrameGtk::AlwaysUseNativeFrame() const {
+ return false;
+}
+
void BrowserFrameGtk::TabStripDisplayModeChanged() {
- if (GetWidget()->GetRootView()->has_children()) {
+ if (GetRootView()->has_children()) {
// Make sure the child of the root view gets Layout again.
- GetWidget()->GetRootView()->GetChildViewAt(0)->InvalidateLayout();
+ GetRootView()->GetChildViewAt(0)->InvalidateLayout();
}
- GetWidget()->GetRootView()->Layout();
+ GetRootView()->Layout();
}
////////////////////////////////////////////////////////////////////////////////
// BrowserFrameGtk, WindowGtk overrides :
+ThemeProvider* BrowserFrameGtk::GetThemeProvider() const {
+ return ThemeServiceFactory::GetForProfile(
+ browser_view_->browser()->profile());
+}
+
+void BrowserFrameGtk::SetInitialFocus() {
+ browser_view_->RestoreFocus();
+}
+
+views::RootView* BrowserFrameGtk::CreateRootView() {
+ return delegate_->DelegateCreateRootView();
+}
+
+bool BrowserFrameGtk::GetAccelerator(int cmd_id,
+ ui::Accelerator* accelerator) {
+ return browser_view_->GetAccelerator(cmd_id, accelerator);
+}
+
+views::NonClientFrameView* BrowserFrameGtk::CreateFrameViewForWindow() {
+ return delegate_->DelegateCreateFrameViewForWindow();
+}
+
gboolean BrowserFrameGtk::OnWindowStateEvent(GtkWidget* widget,
GdkEventWindowState* event) {
bool was_full_screen = IsFullscreen();
@@ -81,15 +132,3 @@ gboolean BrowserFrameGtk::OnConfigureEvent(GtkWidget* widget,
browser_view_->WindowMoved();
return views::WindowGtk::OnConfigureEvent(widget, event);
}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeBrowserFrame, public:
-
-// static
-NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame(
- BrowserFrame* browser_frame,
- BrowserView* browser_view) {
- return new BrowserFrameGtk(browser_frame, browser_view);
-}
-
diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.h b/chrome/browser/ui/views/frame/browser_frame_gtk.h
index a499496..14536a1 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.h
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.h
@@ -14,27 +14,46 @@
class BrowserNonClientFrameView;
class BrowserRootView;
-class BrowserFrameGtk : public views::WindowGtk,
+class BrowserFrameGtk : public BrowserFrame,
+ public views::WindowGtk,
public NativeBrowserFrame {
public:
// Normally you will create this class by calling BrowserFrame::Create.
// Init must be called before using this class, which Create will do for you.
- BrowserFrameGtk(BrowserFrame* browser_frame, BrowserView* browser_view);
+ BrowserFrameGtk(BrowserView* browser_view, Profile* profile);
virtual ~BrowserFrameGtk();
+ // Creates a frame view and initializes the window. This
+ // initialization function must be called after construction, it is
+ // separate to avoid recursive calling of the frame from its
+ // constructor.
+ virtual void InitBrowserFrame();
+
protected:
// Overridden from NativeBrowserFrame:
virtual views::NativeWindow* AsNativeWindow() OVERRIDE;
virtual const views::NativeWindow* AsNativeWindow() const OVERRIDE;
+ virtual BrowserNonClientFrameView* CreateBrowserNonClientFrameView() OVERRIDE;
virtual int GetMinimizeButtonOffset() const OVERRIDE;
+ virtual ui::ThemeProvider* GetThemeProviderForFrame() const OVERRIDE;
+ virtual bool AlwaysUseNativeFrame() const OVERRIDE;
virtual void TabStripDisplayModeChanged() OVERRIDE;
// Overridden from views::WindowGtk:
+ virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE;
+ virtual void SetInitialFocus() OVERRIDE;
+ virtual views::RootView* CreateRootView();
+ virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
+ virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
virtual gboolean OnWindowStateEvent(GtkWidget* widget,
GdkEventWindowState* event);
virtual gboolean OnConfigureEvent(GtkWidget* widget,
GdkEventConfigure* event);
+ BrowserView* browser_view() const {
+ return browser_view_;
+ }
+
private:
NativeBrowserFrameDelegate* delegate_;
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc
index 1982d43..49e14db 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_win.cc
@@ -10,13 +10,19 @@
#include <set>
#include "chrome/browser/accessibility/browser_accessibility_state.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
#include "grit/theme_resources.h"
#include "ui/gfx/font.h"
#include "views/screen.h"
-#include "views/window/non_client_view.h"
-#include "views/window/window.h"
+#include "views/widget/root_view.h"
+#include "views/widget/widget_win.h"
+#include "views/window/window_win.h"
// static
static const int kClientEdgeThickness = 3;
@@ -27,14 +33,26 @@ static const int kDWMFrameTopOffset = 3;
// If not -1, windows are shown with this state.
static int explicit_show_state = -1;
+// static (Factory method.)
+BrowserFrame* BrowserFrame::Create(BrowserView* browser_view,
+ Profile* profile) {
+ BrowserFrame* frame = new BrowserFrameWin(browser_view, profile);
+
+ views::Window::InitParams params(browser_view);
+ frame->GetWindow()->InitWindow(params);
+ return frame;
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin, public:
-BrowserFrameWin::BrowserFrameWin(BrowserFrame* browser_frame,
- BrowserView* browser_view)
- : views::WindowWin(browser_frame),
+BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile)
+ : BrowserFrame(browser_view),
browser_view_(browser_view),
- browser_frame_(browser_frame) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)) {
+ set_native_browser_frame(this);
+ browser_view_->set_frame(this);
+ non_client_view()->SetFrameView(CreateFrameViewForWindow());
// Don't focus anything on creation, selecting a tab will set the focus.
set_focus_on_creation(false);
}
@@ -64,7 +82,7 @@ int BrowserFrameWin::GetShowState() const {
gfx::Insets BrowserFrameWin::GetClientAreaInsets() const {
// Use the default client insets for an opaque frame or a glass popup/app
// frame.
- if (!GetWindow()->non_client_view()->UseNativeFrame() ||
+ if (!non_client_view()->UseNativeFrame() ||
!browser_view_->IsBrowserTypeNormal()) {
return WindowWin::GetClientAreaInsets();
}
@@ -79,11 +97,9 @@ gfx::Insets BrowserFrameWin::GetClientAreaInsets() const {
return gfx::Insets(0, border_thickness, border_thickness, border_thickness);
}
-void BrowserFrameWin::UpdateFrameAfterFrameChange() {
- // We need to update the glass region on or off before the base class adjusts
- // the window region.
- UpdateDWMFrame();
- WindowWin::UpdateFrameAfterFrameChange();
+bool BrowserFrameWin::GetAccelerator(int cmd_id,
+ ui::Accelerator* accelerator) {
+ return browser_view_->GetAccelerator(cmd_id, accelerator);
}
void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) {
@@ -109,16 +125,51 @@ 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) {
- GetWindow()->non_client_view()->Layout();
- GetWindow()->non_client_view()->SchedulePaint();
+ non_client_view()->Layout();
+ non_client_view()->SchedulePaint();
}
}
+ThemeProvider* BrowserFrameWin::GetThemeProvider() const {
+ return ThemeServiceFactory::GetForProfile(
+ browser_view_->browser()->profile());
+}
+
void BrowserFrameWin::OnScreenReaderDetected() {
BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected();
WindowWin::OnScreenReaderDetected();
}
+///////////////////////////////////////////////////////////////////////////////
+// BrowserFrameWin, views::Window overrides:
+
+void BrowserFrameWin::Activate() {
+ // When running under remote desktop, if the remote desktop client is not
+ // active on the users desktop, then none of the windows contained in the
+ // remote desktop will be activated. However, WindowWin::Activate will still
+ // bring this browser window to the foreground. We explicitly set ourselves
+ // as the last active browser window to ensure that we get treated as such by
+ // the rest of Chrome.
+ BrowserList::SetLastActive(browser_view_->browser());
+
+ WindowWin::Activate();
+}
+
+void BrowserFrameWin::UpdateFrameAfterFrameChange() {
+ // We need to update the glass region on or off before the base class adjusts
+ // the window region.
+ UpdateDWMFrame();
+ WindowWin::UpdateFrameAfterFrameChange();
+}
+
+views::RootView* BrowserFrameWin::CreateRootView() {
+ return delegate_->DelegateCreateRootView();
+}
+
+views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() {
+ return delegate_->DelegateCreateFrameViewForWindow();
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin, NativeBrowserFrame implementation:
@@ -130,6 +181,12 @@ const views::NativeWindow* BrowserFrameWin::AsNativeWindow() const {
return this;
}
+BrowserNonClientFrameView* BrowserFrameWin::CreateBrowserNonClientFrameView() {
+ if (AlwaysUseNativeFrame())
+ return new GlassBrowserFrameView(this, browser_view_);
+ return browser::CreateBrowserNonClientFrameView(this, browser_view_);
+}
+
int BrowserFrameWin::GetMinimizeButtonOffset() const {
TITLEBARINFOEX titlebar_info;
titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
@@ -142,7 +199,36 @@ int BrowserFrameWin::GetMinimizeButtonOffset() const {
return minimize_button_corner.x;
}
+ui::ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const {
+ // This is implemented for a different interface than GetThemeProvider is,
+ // but they mean the same things.
+ return GetThemeProvider();
+}
+
+bool BrowserFrameWin::AlwaysUseNativeFrame() const {
+ // App panel windows draw their own frame.
+ if (browser_view_->IsBrowserTypePanel() && browser_view_->IsBrowserTypeApp())
+ return false;
+
+ // We don't theme popup or app windows, so regardless of whether or not a
+ // theme is active for normal browser windows, we don't want to use the custom
+ // frame for popups/apps.
+ if (!browser_view_->IsBrowserTypeNormal() &&
+ views::WidgetWin::IsAeroGlassEnabled())
+ return true;
+
+ // Otherwise, we use the native frame when we're told we should by the theme
+ // provider (e.g. no custom theme is active).
+ return GetThemeProvider()->ShouldUseNativeFrame();
+}
+
void BrowserFrameWin::TabStripDisplayModeChanged() {
+ if (GetRootView()->has_children()) {
+ // Make sure the child of the root view gets Layout again.
+ GetRootView()->GetChildViewAt(0)->InvalidateLayout();
+ }
+ GetRootView()->Layout();
+
UpdateDWMFrame();
}
@@ -151,7 +237,7 @@ void BrowserFrameWin::TabStripDisplayModeChanged() {
void BrowserFrameWin::UpdateDWMFrame() {
// Nothing to do yet, or we're not showing a DWM frame.
- if (!GetWindow()->client_view() || !browser_frame_->AlwaysUseNativeFrame())
+ if (!client_view() || !AlwaysUseNativeFrame())
return;
MARGINS margins = { 0 };
@@ -169,7 +255,7 @@ void BrowserFrameWin::UpdateDWMFrame() {
// borders.
if (!browser_view_->IsFullscreen()) {
gfx::Rect tabstrip_bounds(
- browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip()));
+ GetBoundsForTabStrip(browser_view_->tabstrip()));
margins.cyTopHeight = (browser_view_->UseVerticalTabs() ?
tabstrip_bounds.y() : tabstrip_bounds.bottom()) + kDWMFrameTopOffset;
}
@@ -189,13 +275,3 @@ const gfx::Font& BrowserFrame::GetTitleFont() {
return *title_font;
}
-////////////////////////////////////////////////////////////////////////////////
-// NativeBrowserFrame, public:
-
-// static
-NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame(
- BrowserFrame* browser_frame,
- BrowserView* browser_view) {
- return new BrowserFrameWin(browser_frame, browser_view);
-}
-
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.h b/chrome/browser/ui/views/frame/browser_frame_win.h
index d7249f4..c49f380 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.h
+++ b/chrome/browser/ui/views/frame/browser_frame_win.h
@@ -12,6 +12,7 @@
#include "views/window/window_win.h"
class BrowserView;
+class Profile;
///////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin
@@ -19,10 +20,13 @@ class BrowserView;
// BrowserFrame is a WindowWin subclass that provides the window frame for the
// Chrome browser window.
//
-class BrowserFrameWin : public views::WindowWin,
+class BrowserFrameWin : public BrowserFrame,
+ public views::WindowWin,
public NativeBrowserFrame {
public:
- BrowserFrameWin(BrowserFrame* browser_frame, BrowserView* browser_view);
+ // Normally you will create this class by calling BrowserFrame::Create.
+ // Init must be called before using this class, which Create will do for you.
+ BrowserFrameWin(BrowserView* browser_view, Profile* profile);
virtual ~BrowserFrameWin();
BrowserView* browser_view() const { return browser_view_; }
@@ -36,29 +40,41 @@ class BrowserFrameWin : public views::WindowWin,
// Overridden from views::WindowWin:
virtual int GetShowState() const OVERRIDE;
virtual gfx::Insets GetClientAreaInsets() const OVERRIDE;
- virtual void UpdateFrameAfterFrameChange() OVERRIDE;
+ virtual bool GetAccelerator(int cmd_id,
+ ui::Accelerator* accelerator) OVERRIDE;
virtual void OnEndSession(BOOL ending, UINT logoff) OVERRIDE;
virtual void OnInitMenuPopup(HMENU menu,
UINT position,
BOOL is_system_menu) OVERRIDE;
virtual void OnWindowPosChanged(WINDOWPOS* window_pos) OVERRIDE;
+ virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE;
virtual void OnScreenReaderDetected() OVERRIDE;
+ // Overridden from views::Window:
+ virtual void Activate() OVERRIDE;
+ virtual bool IsAppWindow() const OVERRIDE { return true; }
+ virtual void UpdateFrameAfterFrameChange() OVERRIDE;
+ virtual views::RootView* CreateRootView() OVERRIDE;
+ virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
+
// Overridden from NativeBrowserFrame:
virtual views::NativeWindow* AsNativeWindow() OVERRIDE;
virtual const views::NativeWindow* AsNativeWindow() const OVERRIDE;
+ virtual BrowserNonClientFrameView* CreateBrowserNonClientFrameView() OVERRIDE;
virtual int GetMinimizeButtonOffset() const OVERRIDE;
+ virtual ui::ThemeProvider* GetThemeProviderForFrame() const OVERRIDE;
+ virtual bool AlwaysUseNativeFrame() const OVERRIDE;
virtual void TabStripDisplayModeChanged() OVERRIDE;
private:
// Updates the DWM with the frame bounds.
void UpdateDWMFrame();
+ NativeBrowserFrameDelegate* delegate_;
+
// The BrowserView is our ClientView. This is a pointer to it.
BrowserView* browser_view_;
- BrowserFrame* browser_frame_;
-
DISALLOW_COPY_AND_ASSIGN(BrowserFrameWin);
};
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 1f6dee6..bc4b9fc 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -292,7 +292,7 @@ class ResizeCorner : public views::View {
// currently in a window.
views::Window* GetWindow() {
views::Widget* widget = GetWidget();
- return widget ? widget->GetContainingWindow() : NULL;
+ return widget ? widget->GetWindow() : NULL;
}
DISALLOW_COPY_AND_ASSIGN(ResizeCorner);
@@ -579,8 +579,8 @@ void BrowserView::Show() {
BrowserList::SetLastActive(browser());
// If the window is already visible, just activate it.
- if (frame_->IsVisible()) {
- frame_->Activate();
+ if (frame_->GetWindow()->IsVisible()) {
+ frame_->GetWindow()->Activate();
return;
}
@@ -596,12 +596,13 @@ void BrowserView::Show() {
// that should be added and this should be removed.
RestoreFocus();
- frame_->Show();
+ frame_->GetWindow()->Show();
}
void BrowserView::ShowInactive() {
- if (!frame_->IsVisible())
- frame_->ShowInactive();
+ views::Window* window = frame_->GetWindow();
+ if (!window->IsVisible())
+ window->ShowInactive();
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {
@@ -612,26 +613,26 @@ void BrowserView::SetBounds(const gfx::Rect& bounds) {
void BrowserView::Close() {
BrowserBubbleHost::Close();
- frame_->Close();
+ frame_->GetWindow()->CloseWindow();
}
void BrowserView::Activate() {
- frame_->Activate();
+ frame_->GetWindow()->Activate();
}
void BrowserView::Deactivate() {
- frame_->Deactivate();
+ frame_->GetWindow()->Deactivate();
}
bool BrowserView::IsActive() const {
- return frame_->IsActive();
+ return frame_->GetWindow()->IsActive();
}
void BrowserView::FlashFrame() {
#if defined(OS_WIN)
FLASHWINFO fwi;
fwi.cbSize = sizeof(fwi);
- fwi.hwnd = frame_->GetNativeWindow();
+ fwi.hwnd = frame_->GetWindow()->GetNativeWindow();
fwi.dwFlags = FLASHW_ALL;
fwi.uCount = 4;
fwi.dwTimeout = 0;
@@ -642,7 +643,7 @@ void BrowserView::FlashFrame() {
}
gfx::NativeWindow BrowserView::GetNativeHandle() {
- return GetWidget()->GetContainingWindow()->GetNativeWindow();
+ return GetWidget()->GetWindow()->GetNativeWindow();
}
BrowserWindowTesting* BrowserView::GetBrowserWindowTesting() {
@@ -707,9 +708,9 @@ void BrowserView::ToolbarSizeChanged(bool is_animating) {
}
void BrowserView::UpdateTitleBar() {
- frame_->UpdateWindowTitle();
+ frame_->GetWindow()->UpdateWindowTitle();
if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning())
- frame_->UpdateWindowIcon();
+ frame_->GetWindow()->UpdateWindowIcon();
}
void BrowserView::ShelfVisibilityChanged() {
@@ -745,15 +746,15 @@ void BrowserView::SetStarredState(bool is_starred) {
}
gfx::Rect BrowserView::GetRestoredBounds() const {
- return frame_->GetNormalBounds();
+ return frame_->GetWindow()->GetNormalBounds();
}
gfx::Rect BrowserView::GetBounds() const {
- return frame_->GetBounds();
+ return frame_->GetWindow()->GetBounds();
}
bool BrowserView::IsMaximized() const {
- return frame_->IsMaximized();
+ return frame_->GetWindow()->IsMaximized();
}
void BrowserView::SetFullscreen(bool fullscreen) {
@@ -765,12 +766,12 @@ void BrowserView::SetFullscreen(bool fullscreen) {
#else
// On Linux changing fullscreen is async. Ask the window to change it's
// fullscreen state, and when done invoke ProcessFullscreen.
- frame_->SetFullscreen(fullscreen);
+ frame_->GetWindow()->SetFullscreen(fullscreen);
#endif
}
bool BrowserView::IsFullscreen() const {
- return frame_->IsFullscreen();
+ return frame_->GetWindow()->IsFullscreen();
}
bool BrowserView::IsFullscreenBubbleVisible() const {
@@ -978,7 +979,7 @@ bool BrowserView::IsToolbarVisible() const {
void BrowserView::DisableInactiveFrame() {
#if defined(OS_WIN)
- frame_->DisableInactiveRendering();
+ frame_->GetWindow()->DisableInactiveRendering();
#endif // No tricks are needed to get the right behavior on Linux.
}
@@ -1112,7 +1113,7 @@ void BrowserView::ShowCreateChromeAppShortcutsDialog(Profile* profile,
}
void BrowserView::UserChangedTheme() {
- frame_->FrameTypeChanged();
+ frame_->GetWindow()->FrameTypeChanged();
}
int BrowserView::GetExtraRenderViewHeight() const {
@@ -1597,7 +1598,7 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
bounds->height() + toolbar_->GetPreferredSize().height());
}
- gfx::Rect window_rect = frame_->non_client_view()->
+ gfx::Rect window_rect = frame_->GetWindow()->non_client_view()->
GetWindowBoundsForClientBounds(*bounds);
window_rect.set_origin(bounds->origin());
@@ -1679,7 +1680,7 @@ bool BrowserView::CanClose() {
// Tab strip isn't empty. Hide the frame (so it appears to have closed
// immediately) and close all the tabs, allowing the renderers to shut
// down. When the tab strip is empty we'll be called back again.
- frame_->HideWindow();
+ frame_->GetWindow()->HideWindow();
browser_->OnWindowClosing();
return false;
}
@@ -1687,7 +1688,7 @@ bool BrowserView::CanClose() {
// Empty TabStripModel, it's now safe to allow the Window to be closed.
NotificationService::current()->Notify(
NotificationType::WINDOW_CLOSED,
- Source<gfx::NativeWindow>(frame_->GetNativeWindow()),
+ Source<gfx::NativeWindow>(frame_->GetWindow()->GetNativeWindow()),
NotificationService::NoDetails());
return true;
}
@@ -1697,9 +1698,10 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
// The following code is not in the LayoutManager because it's
// independent of layout and also depends on the ResizeCorner which
// is private.
- if (!frame_->IsMaximized() && !frame_->IsFullscreen()) {
+ if (!frame_->GetWindow()->IsMaximized() &&
+ !frame_->GetWindow()->IsFullscreen()) {
CRect client_rect;
- ::GetClientRect(frame_->GetNativeWindow(), &client_rect);
+ ::GetClientRect(frame_->GetWindow()->GetNativeWindow(), &client_rect);
gfx::Size resize_corner_size = ResizeCorner::GetSize();
gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(),
client_rect.bottom - resize_corner_size.height(),
@@ -1801,7 +1803,8 @@ void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) {
SkColor BrowserView::GetInfoBarSeparatorColor() const {
// NOTE: Keep this in sync with ToolbarView::OnPaint()!
- return (IsTabStripVisible() || !frame_->non_client_view()->UseNativeFrame()) ?
+ return (IsTabStripVisible() ||
+ !frame_->GetWindow()->non_client_view()->UseNativeFrame()) ?
ResourceBundle::toolbar_separator_color : SK_ColorBLACK;
}
@@ -1931,7 +1934,7 @@ void BrowserView::Init() {
if (AeroPeekManager::Enabled()) {
aeropeek_manager_.reset(new AeroPeekManager(
- frame_->GetNativeWindow()));
+ frame_->GetWindow()->GetNativeWindow()));
browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get());
}
#endif
@@ -1999,7 +2002,7 @@ void BrowserView::InitSystemMenu() {
BuildSystemMenuForAppOrPopupWindow();
system_menu_.reset(
new views::NativeMenuWin(system_menu_contents_.get(),
- frame_->GetNativeWindow()));
+ frame_->GetWindow()->GetNativeWindow()));
system_menu_->Rebuild();
}
#endif
@@ -2251,7 +2254,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
#endif
}
#if defined(OS_WIN)
- static_cast<views::WindowWin*>(frame_->native_window())->PushForceHidden();
+ static_cast<views::WindowWin*>(
+ frame_->GetWindow()->native_window())->PushForceHidden();
#endif
// Notify bookmark bar, so it can set itself to the appropriate drawing state.
@@ -2260,7 +2264,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
// Toggle fullscreen mode.
#if defined(OS_WIN)
- frame_->SetFullscreen(fullscreen);
+ frame_->GetWindow()->SetFullscreen(fullscreen);
#endif // No need to invoke SetFullscreen for linux as this code is executed
// once we're already fullscreen on linux.
@@ -2292,7 +2296,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
ignore_layout_ = false;
Layout();
#if defined(OS_WIN)
- static_cast<views::WindowWin*>(frame_->native_window())->PopForceHidden();
+ static_cast<views::WindowWin*>(
+ frame_->GetWindow()->native_window())->PopForceHidden();
#endif
}
@@ -2575,9 +2580,11 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
// Create the view and the frame. The frame will attach itself via the view
// so we don't need to do anything with the pointer.
BrowserView* view = new BrowserView(browser);
- (new BrowserFrame(view))->InitBrowserFrame();
+ BrowserFrame::Create(view, browser->profile());
+
view->GetWindow()->non_client_view()->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
+
return view;
}
#endif
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index 16ebf34..ebd0403 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -556,8 +556,8 @@ void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
// TODO(alekseys): layout sidebar minitabs and adjust reserved rect
// accordingly.
gfx::Rect browser_reserved_rect;
- if (!browser_view_->frame_->IsMaximized() &&
- !browser_view_->frame_->IsFullscreen()) {
+ if (!browser_view_->frame_->GetWindow()->IsMaximized() &&
+ !browser_view_->frame_->GetWindow()->IsFullscreen()) {
gfx::Size resize_corner_size = browser_view_->GetResizeCornerSize();
if (!resize_corner_size.IsEmpty()) {
gfx::Rect bounds = browser_view_->GetContentsBounds();
diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc
index 2f5bd45..b3b96ef 100644
--- a/chrome/browser/ui/views/frame/contents_container.cc
+++ b/chrome/browser/ui/views/frame/contents_container.cc
@@ -152,6 +152,8 @@ void ContentsContainer::Layout() {
void ContentsContainer::CreateOverlay(int initial_opacity) {
DCHECK(!active_overlay_);
+ active_overlay_ = views::Widget::CreateWidget();
+ active_overlay_->SetOpacity(initial_opacity);
gfx::Point screen_origin;
views::View::ConvertPointToScreen(active_, &screen_origin);
gfx::Rect overlay_bounds(screen_origin, active_->size());
@@ -160,13 +162,11 @@ void ContentsContainer::CreateOverlay(int initial_opacity) {
params.accept_events = false;
params.parent = active_->GetWidget()->GetNativeView();
params.bounds = overlay_bounds;
- active_overlay_ = new views::Widget;
active_overlay_->Init(params);
overlay_view_ = new OverlayContentView(this);
overlay_view_->set_background(
views::Background::CreateSolidBackground(SK_ColorWHITE));
active_overlay_->SetContentsView(overlay_view_);
- active_overlay_->SetOpacity(initial_opacity);
active_overlay_->Show();
active_overlay_->MoveAboveWidget(active_->GetWidget());
}
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 11e2950..f3daf8f 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -130,7 +130,8 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
// a tab strip until the left end of this window without considering the size
// of window controls in RTL languages.
if (base::i18n::IsRTL()) {
- if (!browser_view_->ShouldShowOffTheRecordAvatar() && frame_->IsMaximized())
+ if (!browser_view_->ShouldShowOffTheRecordAvatar() &&
+ frame_->GetWindow()->IsMaximized())
tabstrip_x += otr_avatar_bounds_.x();
minimize_button_offset = width();
}
@@ -140,7 +141,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
profile_button_->GetPreferredSize().width() +
ProfileMenuButton::kProfileTagHorizontalSpacing : 0);
int tabstrip_width = minimize_button_offset - tabstrip_x -
- (frame_->IsMaximized() ?
+ (frame_->GetWindow()->IsMaximized() ?
maximized_spacing : kNewTabCaptionRestoredSpacing);
return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
std::max(0, tabstrip_width),
@@ -177,7 +178,7 @@ bool GlassBrowserFrameView::AlwaysUseNativeFrame() const {
gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
- HWND hwnd = frame_->GetNativeWindow();
+ HWND hwnd = frame_->GetWindow()->GetNativeWindow();
if (!browser_view_->IsTabStripVisible() && hwnd) {
// If we don't have a tabstrip, we're either a popup or an app window, in
// which case we have a standard size non-client area and can just use
@@ -205,7 +206,8 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point))
return HTNOWHERE;
- int frame_component = frame_->client_view()->NonClientHitTest(point);
+ int frame_component =
+ 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.
@@ -227,7 +229,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_->window_delegate()->CanResize());
+ frame_->GetWindow()->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -252,7 +254,7 @@ void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
PaintToolbarBackground(canvas);
if (browser_view_->ShouldShowOffTheRecordAvatar())
PaintOTRAvatar(canvas);
- if (!frame_->IsMaximized())
+ if (!frame_->GetWindow()->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -265,12 +267,12 @@ void GlassBrowserFrameView::Layout() {
bool GlassBrowserFrameView::HitTest(const gfx::Point& l) const {
// The ProfileMenuButton intrudes into the client area when the window is
// maximized.
- if (frame_->IsMaximized() && show_profile_button() &&
+ if (frame_->GetWindow()->IsMaximized() && show_profile_button() &&
profile_button_->IsVisible() &&
profile_button_->GetMirroredBounds().Contains(l)) {
return true;
} else {
- return !frame_->client_view()->bounds().Contains(l);
+ return !GetWindow()->client_view()->bounds().Contains(l);
}
}
@@ -278,12 +280,14 @@ bool GlassBrowserFrameView::HitTest(const gfx::Point& l) const {
// GlassBrowserFrameView, private:
int GlassBrowserFrameView::FrameBorderThickness() const {
- return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ views::Window* window = frame_->GetWindow();
+ return (window->IsMaximized() || window->IsFullscreen()) ?
0 : GetSystemMetrics(SM_CXSIZEFRAME);
}
int GlassBrowserFrameView::NonClientBorderThickness() const {
- if (frame_->IsMaximized() || frame_->IsFullscreen())
+ views::Window* window = frame_->GetWindow();
+ if (window->IsMaximized() || window->IsFullscreen())
return 0;
return browser_view_->UseVerticalTabs() ?
@@ -294,7 +298,7 @@ int GlassBrowserFrameView::NonClientBorderThickness() const {
int GlassBrowserFrameView::NonClientTopBorderHeight(
bool restored,
bool ignore_vertical_tabs) const {
- if (!restored && frame_->IsFullscreen())
+ if (!restored && frame_->GetWindow()->IsFullscreen())
return 0;
// We'd like to use FrameBorderThickness() here, but the maximized Aero glass
// frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border
@@ -432,7 +436,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_->client_view()->y() +
+ (frame_->GetWindow()->client_view()->y() +
browser_view_->GetToolbarBounds().y() +
tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height());
int client_area_bottom =
@@ -493,7 +497,7 @@ void GlassBrowserFrameView::LayoutOTRAvatar() {
browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
otr_restored_y = otr_bottom - otr_avatar_icon.height();
}
- int otr_y = frame_->IsMaximized() ?
+ int otr_y = frame_->GetWindow()->IsMaximized() ?
(NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
otr_restored_y;
otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(),
@@ -532,7 +536,7 @@ void GlassBrowserFrameView::LayoutProfileTag() {
ProfileMenuButton::kProfileTagHorizontalSpacing -
// - the width of the profile button
profile_button_->GetPreferredSize().width();
- int y_maximized_offset = frame_->IsMaximized() ?
+ int y_maximized_offset = frame_->GetWindow()->IsMaximized() ?
kProfileElementMaximizedYOffset : 0;
profile_button_->SetBounds(
x_tag,
@@ -566,7 +570,7 @@ void GlassBrowserFrameView::StartThrobber() {
throbber_running_ = true;
throbber_frame_ = 0;
InitThrobberIcons();
- SendMessage(frame_->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
@@ -588,13 +592,13 @@ void GlassBrowserFrameView::StopThrobber() {
// Fallback to class icon.
if (!frame_icon) {
frame_icon = reinterpret_cast<HICON>(GetClassLongPtr(
- frame_->GetNativeWindow(), GCLP_HICONSM));
+ frame_->GetWindow()->GetNativeWindow(), GCLP_HICONSM));
}
// This will reset the small icon which we set in the throbber code.
// WM_SETICON with NULL icon restores the icon for title bar but not
// for taskbar. See http://crbug.com/29996
- SendMessage(frame_->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(frame_icon));
}
@@ -602,7 +606,7 @@ void GlassBrowserFrameView::StopThrobber() {
void GlassBrowserFrameView::DisplayNextThrobberFrame() {
throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
- SendMessage(frame_->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
diff --git a/chrome/browser/ui/views/frame/native_browser_frame.h b/chrome/browser/ui/views/frame/native_browser_frame.h
index 120fa1f..f72ec29 100644
--- a/chrome/browser/ui/views/frame/native_browser_frame.h
+++ b/chrome/browser/ui/views/frame/native_browser_frame.h
@@ -6,27 +6,38 @@
#define CHROME_BROWSER_UI_VIEWS_FRAME_NATIVE_BROWSER_FRAME_H_
#pragma once
-class BrowserView;
+class BrowserNonClientFrameView;
+
+namespace gfx {
+class Rect;
+}
+
+namespace ui {
+class ThemeProvider;
+}
+
+namespace views {
+class NativeWindow;
+class View;
+}
class NativeBrowserFrame {
public:
virtual ~NativeBrowserFrame() {}
- // Construct a platform-specific implementation of this interface.
- static NativeBrowserFrame* CreateNativeBrowserFrame(
- BrowserFrame* browser_frame,
- BrowserView* browser_view);
-
virtual views::NativeWindow* AsNativeWindow() = 0;
virtual const views::NativeWindow* AsNativeWindow() const = 0;
protected:
friend class BrowserFrame;
+ virtual BrowserNonClientFrameView* CreateBrowserNonClientFrameView() = 0;
+
// BrowserFrame pass-thrus ---------------------------------------------------
// See browser_frame.h for documentation:
virtual int GetMinimizeButtonOffset() const = 0;
- // TODO(beng): replace with some kind of "framechanged" signal to Window.
+ virtual ui::ThemeProvider* GetThemeProviderForFrame() const = 0;
+ virtual bool AlwaysUseNativeFrame() const = 0;
virtual void TabStripDisplayModeChanged() = 0;
};
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 7efd98b..da4ca70 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -138,7 +138,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
window_icon_(NULL),
frame_(frame),
browser_view_(browser_view) {
- ui::ThemeProvider* tp = frame_->GetThemeProvider();
+ ui::ThemeProvider* tp = frame_->GetThemeProviderForFrame();
SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND);
SkBitmap* background =
tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND);
@@ -243,7 +243,8 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForReservedArea() const {
int OpaqueBrowserFrameView::NonClientTopBorderHeight(
bool restored,
bool ignore_vertical_tabs) const {
- views::WindowDelegate* delegate = frame_->window_delegate();
+ views::Window* window = frame_->GetWindow();
+ 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
@@ -257,7 +258,7 @@ int OpaqueBrowserFrameView::NonClientTopBorderHeight(
return FrameBorderThickness(restored) -
((browser_view_->IsTabStripVisible() && !restored &&
- frame_->IsMaximized()) ? kTabstripTopShadowThickness : 0);
+ window->IsMaximized()) ? kTabstripTopShadowThickness : 0);
}
///////////////////////////////////////////////////////////////////////////////
@@ -286,7 +287,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
profile_button_->GetPreferredSize().width() +
ProfileMenuButton::kProfileTagHorizontalSpacing : 0);
int tabstrip_width = minimize_button_->x() - tabstrip_x -
- (frame_->IsMaximized() ?
+ (frame_->GetWindow()->IsMaximized() ?
maximized_spacing : kNewTabCaptionRestoredSpacing);
int tabstrip_height = 0;
if (tabstrip)
@@ -298,8 +299,8 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
bool restored) const {
return NonClientTopBorderHeight(restored, true) + ((!restored &&
- (frame_->IsMaximized() ||
- frame_->IsFullscreen())) ?
+ (frame_->GetWindow()->IsMaximized() ||
+ frame_->GetWindow()->IsFullscreen())) ?
0 : kNonClientRestoredExtraThickness);
}
@@ -314,7 +315,7 @@ gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight(false, false) + border_thickness);
- views::WindowDelegate* delegate = frame_->window_delegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
int min_titlebar_width = (2 * FrameBorderThickness(false)) +
kIconLeftSpacing +
(delegate && delegate->ShouldShowWindowIcon() ?
@@ -359,14 +360,14 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->client_view()->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.
gfx::Rect sysmenu_rect(IconBounds());
// In maximized mode we extend the rect to the screen corner to take advantage
// of Fitts' Law.
- if (frame_->IsMaximized())
+ if (frame_->GetWindow()->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
if (sysmenu_rect.Contains(point))
@@ -394,7 +395,7 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
profile_button_->GetMirroredBounds().Contains(point))
return HTCLIENT;
- views::WindowDelegate* delegate = frame_->window_delegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return HTCAPTION;
@@ -410,7 +411,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->IsMaximized() || frame_->IsFullscreen())
+ if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen())
return;
views::GetDefaultWindowMask(size, window_mask);
@@ -446,10 +447,11 @@ void OpaqueBrowserFrameView::RunMenu(views::View* source,
// OpaqueBrowserFrameView, views::View overrides:
void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- if (frame_->IsFullscreen())
+ views::Window* window = frame_->GetWindow();
+ if (window->IsFullscreen())
return; // Nothing is visible, so don't bother to paint.
- if (frame_->IsMaximized())
+ if (window->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
@@ -459,7 +461,7 @@ void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
PaintToolbarBackground(canvas);
if (browser_view_->ShouldShowOffTheRecordAvatar())
PaintOTRAvatar(canvas);
- if (!frame_->IsMaximized())
+ if (!window->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -481,7 +483,8 @@ bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
bool vertical_tabs = browser_view_->UseVerticalTabs();
gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip());
gfx::Point tabstrip_origin(tabstrip_bounds.origin());
- View::ConvertPointToView(frame_->client_view(), this, &tabstrip_origin);
+ View::ConvertPointToView(frame_->GetWindow()->client_view(),
+ this, &tabstrip_origin);
tabstrip_bounds.set_origin(tabstrip_origin);
if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) ||
(vertical_tabs && l.x() > tabstrip_bounds.right())) {
@@ -491,13 +494,13 @@ bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
// Claim it only if we're also not in the compact navigation buttons.
if (browser_view_->UseCompactNavigationBar()) {
if (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(),
- frame_->client_view(),
+ frame_->GetWindow()->client_view(),
static_cast<const View*>(this),
l)) {
return false;
}
if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(),
- frame_->client_view(),
+ frame_->GetWindow()->client_view(),
static_cast<const View*>(this),
l)) {
return false;
@@ -522,14 +525,15 @@ void OpaqueBrowserFrameView::GetAccessibleState(
void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
+ views::Window* window = frame_->GetWindow();
if (sender == minimize_button_)
- frame_->Minimize();
+ window->Minimize();
else if (sender == maximize_button_)
- frame_->Maximize();
+ window->Maximize();
else if (sender == restore_button_)
- frame_->Restore();
+ window->Restore();
else if (sender == close_button_)
- frame_->Close();
+ window->CloseWindow();
}
///////////////////////////////////////////////////////////////////////////////
@@ -544,7 +548,7 @@ bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap OpaqueBrowserFrameView::GetFaviconForTabIconView() {
- views::WindowDelegate* delegate = frame_->window_delegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return SkBitmap();
@@ -568,7 +572,8 @@ void OpaqueBrowserFrameView::Observe(NotificationType type,
// OpaqueBrowserFrameView, private:
int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
- return (!restored && (frame_->IsMaximized() || frame_->IsFullscreen())) ?
+ views::Window* window = frame_->GetWindow();
+ return (!restored && (window->IsMaximized() || window->IsFullscreen())) ?
0 : kFrameBorderThickness;
}
@@ -578,8 +583,9 @@ int OpaqueBrowserFrameView::TopResizeHeight() const {
int OpaqueBrowserFrameView::NonClientBorderThickness() const {
// When we fill the screen, we don't show a client edge.
+ views::Window* window = frame_->GetWindow();
return FrameBorderThickness(false) +
- ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
+ ((window->IsMaximized() || window->IsFullscreen()) ?
0 : kClientEdgeThickness);
}
@@ -590,13 +596,14 @@ void OpaqueBrowserFrameView::ModifyMaximizedFramePainting(
int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const {
// Maximized buttons start at window top so that even if their images aren't
// drawn flush with the screen edge, they still obey Fitts' Law.
- return (!restored && frame_->IsMaximized()) ?
+ return (!restored && frame_->GetWindow()->IsMaximized()) ?
FrameBorderThickness(false) : kFrameShadowThickness;
}
int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const {
return kTitlebarTopAndBottomEdgeThickness +
- ((!restored && frame_->IsMaximized()) ? 0 : kClientEdgeThickness);
+ ((!restored && frame_->GetWindow()->IsMaximized()) ?
+ 0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::IconSize() const {
@@ -613,7 +620,7 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
int size = IconSize();
int frame_thickness = FrameBorderThickness(false);
int y;
- views::WindowDelegate* delegate = frame_->window_delegate();
+ 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
@@ -624,7 +631,7 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
// with restored windows, so when the window is restored, instead of
// calculating the remaining space from below the frame border, we calculate
// from below the 3D edge.
- int unavailable_px_at_top = frame_->IsMaximized() ?
+ int unavailable_px_at_top = frame_->GetWindow()->IsMaximized() ?
frame_thickness : kTitlebarTopAndBottomEdgeThickness;
// When the icon is shorter than the minimum space we reserve for the
// caption button, we vertically center it. We want to bias rounding to put
@@ -761,6 +768,8 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
ui::ThemeProvider* tp = GetThemeProvider();
+ views::Window* window = frame_->GetWindow();
+
// Window frame mode and color
SkBitmap* theme_frame;
@@ -819,13 +828,13 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = top_center->height() - kClientEdgeThickness;
canvas->TileImageInt(*top_center, 0,
- frame_->client_view()->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_->window_delegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL";
return;
@@ -977,7 +986,7 @@ void OpaqueBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
ui::ThemeProvider* tp = GetThemeProvider();
- int client_area_top = frame_->client_view()->y();
+ int client_area_top = frame_->GetWindow()->client_view()->y();
int image_top = client_area_top;
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
@@ -1063,7 +1072,7 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
}
void OpaqueBrowserFrameView::LayoutWindowControls() {
- bool is_maximized = frame_->IsMaximized();
+ bool is_maximized = frame_->GetWindow()->IsMaximized();
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
int caption_y = CaptionButtonY(false);
@@ -1086,7 +1095,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// as maximized mode.
// TODO(oshima): Optimize the relayout logic to defer the frame view's
// relayout until it is necessary, i.e when it becomes visible.
- if (is_maximized || frame_->IsFullscreen()) {
+ if (is_maximized || frame_->GetWindow()->IsFullscreen()) {
minimize_button_->SetVisible(false);
restore_button_->SetVisible(false);
maximize_button_->SetVisible(false);
@@ -1112,7 +1121,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// When the window is restored, we show a maximized button; otherwise, we show
// a restore button.
- bool is_restored = !is_maximized && !frame_->IsMinimized();
+ bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized();
views::ImageButton* invisible_button = is_restored ?
restore_button_ : maximize_button_;
invisible_button->SetVisible(false);
@@ -1141,7 +1150,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_->window_delegate();
+ views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
if (delegate && delegate->ShouldShowWindowIcon())
window_icon_->SetBoundsRect(icon_bounds);
@@ -1173,7 +1182,7 @@ void OpaqueBrowserFrameView::LayoutOTRAvatar() {
browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
otr_restored_y = otr_bottom - otr_avatar_icon.height();
}
- int otr_y = frame_->IsMaximized() ?
+ int otr_y = frame_->GetWindow()->IsMaximized() ?
(NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
otr_restored_y;
otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing,
@@ -1206,7 +1215,7 @@ void OpaqueBrowserFrameView::LayoutProfileTag() {
profile_button_->GetPreferredSize().width();
// Adjust for different default font sizes on different Windows platforms.
int y_tag = profile_button_->font().GetHeight() < 14 ? 2 : 0;
- int y_maximized_offset = frame_->IsMaximized() ?
+ int y_maximized_offset = frame_->GetWindow()->IsMaximized() ?
kProfileElementMaximizedYOffset : 0;
profile_button_->SetBounds(
x_tag,
diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble.cc b/chrome/browser/ui/views/fullscreen_exit_bubble.cc
index 1c18697..d72552d 100644
--- a/chrome/browser/ui/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/ui/views/fullscreen_exit_bubble.cc
@@ -132,7 +132,8 @@ FullscreenExitBubble::FullscreenExitBubble(
this, UTF16ToWideHack(accelerator.GetShortcutText()));
// Initialize the popup.
- popup_ = new views::Widget;
+ popup_ = views::Widget::CreateWidget();
+ popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.can_activate = false;
@@ -141,7 +142,6 @@ FullscreenExitBubble::FullscreenExitBubble(
params.bounds = GetPopupRect(false);
popup_->Init(params);
popup_->SetContentsView(view_);
- popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
popup_->Show(); // This does not activate the popup.
// Start the initial delay timer and begin watching the mouse.
diff --git a/chrome/browser/ui/views/generic_info_view_unittest.cc b/chrome/browser/ui/views/generic_info_view_unittest.cc
index 5fe6dc2..d38512f 100644
--- a/chrome/browser/ui/views/generic_info_view_unittest.cc
+++ b/chrome/browser/ui/views/generic_info_view_unittest.cc
@@ -29,7 +29,7 @@ TEST_F(GenericInfoViewTest, GenericInfoView) {
const string16 kName = ASCIIToUTF16("Name");
const string16 kValue = ASCIIToUTF16("Value");
- views::Widget* widget = new views::Widget;
+ views::Widget* widget = views::Widget::CreateWidget();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
diff --git a/chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc b/chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc
index d6ec1fc1..4ae9a79 100644
--- a/chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc
+++ b/chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc
@@ -11,7 +11,6 @@ void HandleWebKeyboardEvent(views::Widget* widget,
const NativeWebKeyboardEvent& event) {
if (widget && event.os_event && !event.skip_in_browser) {
views::KeyEvent views_event(reinterpret_cast<GdkEvent*>(event.os_event));
- static_cast<views::WidgetGtk*>(widget->native_widget())->
- HandleKeyboardEvent(views_event);
+ static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(views_event);
}
}
diff --git a/chrome/browser/ui/views/html_dialog_view.cc b/chrome/browser/ui/views/html_dialog_view.cc
index 55f4148..010b943 100644
--- a/chrome/browser/ui/views/html_dialog_view.cc
+++ b/chrome/browser/ui/views/html_dialog_view.cc
@@ -148,7 +148,7 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) {
delegate_ = NULL; // We will not communicate further with the delegate.
dialog_delegate->OnDialogClosed(json_retval);
}
- window()->Close();
+ window()->CloseWindow();
}
void HtmlDialogView::OnWindowClosed() {
@@ -193,8 +193,7 @@ void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
DefWindowProc(event.os_event.hwnd, event.os_event.message,
event.os_event.wParam, event.os_event.lParam);
#elif defined(TOOLKIT_USES_GTK)
- views::WindowGtk* window_gtk =
- static_cast<views::WindowGtk*>(window()->native_window());
+ views::WindowGtk* window_gtk = static_cast<views::WindowGtk*>(window());
if (event.os_event && !event.skip_in_browser) {
views::KeyEvent views_event(reinterpret_cast<GdkEvent*>(event.os_event));
window_gtk->HandleKeyboardEvent(views_event);
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index c913ca2..2db7e15 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -263,7 +263,7 @@ void HungRendererDialogView::EndForTabContents(TabContents* contents) {
DCHECK(contents);
if (contents_ && contents_->GetRenderProcessHost() ==
contents->GetRenderProcessHost()) {
- window()->Close();
+ window()->CloseWindow();
// Since we're closing, we no longer need this TabContents.
contents_ = NULL;
}
diff --git a/chrome/browser/ui/views/importer/import_progress_dialog_view.cc b/chrome/browser/ui/views/importer/import_progress_dialog_view.cc
index 624dda5..f82f6b6 100644
--- a/chrome/browser/ui/views/importer/import_progress_dialog_view.cc
+++ b/chrome/browser/ui/views/importer/import_progress_dialog_view.cc
@@ -275,7 +275,7 @@ void ImportProgressDialogView::ImportEnded() {
// In every case, we need to close the UI now.
importing_ = false;
importer_host_->SetObserver(NULL);
- window()->Close();
+ window()->CloseWindow();
if (importer_observer_)
importer_observer_->ImportCompleted();
}
diff --git a/chrome/browser/ui/views/js_modal_dialog_views.cc b/chrome/browser/ui/views/js_modal_dialog_views.cc
index 6bccb5d..12d0664 100644
--- a/chrome/browser/ui/views/js_modal_dialog_views.cc
+++ b/chrome/browser/ui/views/js_modal_dialog_views.cc
@@ -54,7 +54,7 @@ void JSModalDialogViews::ActivateAppModalDialog() {
}
void JSModalDialogViews::CloseAppModalDialog() {
- window()->Close();
+ window()->CloseWindow();
}
void JSModalDialogViews::AcceptAppModalDialog() {
diff --git a/chrome/browser/ui/views/native_constrained_window_win.cc b/chrome/browser/ui/views/native_constrained_window_win.cc
index 134e87b..bf7e21c 100644
--- a/chrome/browser/ui/views/native_constrained_window_win.cc
+++ b/chrome/browser/ui/views/native_constrained_window_win.cc
@@ -16,8 +16,7 @@ class NativeConstrainedWindowWin : public NativeConstrainedWindow,
public views::WindowWin {
public:
explicit NativeConstrainedWindowWin(NativeConstrainedWindowDelegate* delegate)
- : views::WindowWin(delegate->AsNativeWindowDelegate()),
- delegate_(delegate) {
+ : delegate_(delegate) {
}
virtual ~NativeConstrainedWindowWin() {
@@ -42,6 +41,11 @@ class NativeConstrainedWindowWin : public NativeConstrainedWindow,
return WindowWin::OnMouseActivate(message, w_param, l_param);
}
+ // Overridden from views::Window:
+ virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE {
+ return delegate_->CreateFrameViewForWindow();
+ }
+
NativeConstrainedWindowDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(NativeConstrainedWindowWin);
diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc
index 4cf5569..f403913 100644
--- a/chrome/browser/ui/views/notifications/balloon_view.cc
+++ b/chrome/browser/ui/views/notifications/balloon_view.cc
@@ -316,21 +316,21 @@ void BalloonViewImpl::Show(Balloon* balloon) {
gfx::Rect contents_rect = GetContentsRectangle();
html_contents_.reset(new BalloonViewHost(balloon));
html_contents_->SetPreferredSize(gfx::Size(10000, 10000));
- html_container_ = new Widget;
+ html_container_ = Widget::CreateWidget();
+ html_container_->SetAlwaysOnTop(true);
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.bounds = contents_rect;
html_container_->Init(params);
html_container_->SetContentsView(html_contents_->view());
- html_container_->SetAlwaysOnTop(true);
gfx::Rect balloon_rect(x(), y(), GetTotalWidth(), GetTotalHeight());
- frame_container_ = new Widget;
+ frame_container_ = Widget::CreateWidget();
frame_container_->set_widget_delegate(this);
+ frame_container_->SetAlwaysOnTop(true);
params.transparent = true;
params.bounds = balloon_rect;
frame_container_->Init(params);
frame_container_->SetContentsView(this);
- frame_container_->SetAlwaysOnTop(true);
frame_container_->MoveAboveWidget(html_container_);
close_button_->SetImage(views::CustomButton::BS_NORMAL,
diff --git a/chrome/browser/ui/views/profile_tag_view.cc b/chrome/browser/ui/views/profile_tag_view.cc
index ed96923..97a03e8 100644
--- a/chrome/browser/ui/views/profile_tag_view.cc
+++ b/chrome/browser/ui/views/profile_tag_view.cc
@@ -77,7 +77,7 @@ void ProfileTagView::CreateProfileTagBitmaps() {
return;
profile_tag_bitmaps_created_ = true;
- ui::ThemeProvider* theme_provider = frame_->GetThemeProvider();
+ ui::ThemeProvider* theme_provider = frame_->GetThemeProviderForFrame();
bool aero = theme_provider->ShouldUseNativeFrame();
SkBitmap* profile_tag_center = aero ?
theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_CENTER_AERO) :
diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc
index 2a24177..cc6a345 100644
--- a/chrome/browser/ui/views/status_bubble_views.cc
+++ b/chrome/browser/ui/views/status_bubble_views.cc
@@ -558,19 +558,19 @@ StatusBubbleViews::~StatusBubbleViews() {
void StatusBubbleViews::Init() {
if (!popup_.get()) {
- popup_.reset(new Widget);
+ popup_.reset(Widget::CreateWidget());
views::Widget* frame = base_view_->GetWidget();
if (!view_)
view_ = new StatusView(this, popup_.get(), frame->GetThemeProvider());
if (!expand_view_.get())
expand_view_.reset(new StatusViewExpander(this, view_));
+ popup_->SetOpacity(0x00);
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.accept_events = false;
params.delete_on_destroy = false;
params.parent = frame->GetNativeView();
popup_->Init(params);
- popup_->SetOpacity(0x00);
popup_->SetContentsView(view_);
Reposition();
popup_->Show();
@@ -794,7 +794,7 @@ bool StatusBubbleViews::IsFrameVisible() {
if (!frame->IsVisible())
return false;
- views::Window* window = frame->GetContainingWindow();
+ views::Window* window = frame->GetWindow();
return !window || !window->IsMinimized();
}
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc
index ce63670..6ac2a5b8 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -38,8 +37,6 @@ void NativeTabContentsContainerGtk::DetachContents(TabContents* contents) {
// Now detach the TabContents.
Detach();
-
- static_cast<TabContentsViewViews*>(contents->view())->Unparent();
}
void NativeTabContentsContainerGtk::SetFastResize(bool fast_resize) {
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h
index 680aac6..d3e63ba 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h
@@ -7,14 +7,9 @@
#pragma once
class TabContents;
-namespace gfx {
+namespace gfx{
class Size;
}
-namespace views {
-namespace internal {
-class NativeWidgetDelegate;
-}
-}
namespace internal {
@@ -35,16 +30,14 @@ class NativeTabContentsViewDelegate {
virtual void OnNativeTabContentsViewHidden() = 0;
virtual void OnNativeTabContentsViewSized(const gfx::Size& size) = 0;
- virtual void OnNativeTabContentsViewWheelZoom(bool zoom_in) = 0;
+ virtual void OnNativeTabContentsViewWheelZoom(int distance) = 0;
// TODO(beng):
// These two can be replaced by an override of Widget::OnMouseEvent.
virtual void OnNativeTabContentsViewMouseDown() = 0;
- virtual void OnNativeTabContentsViewMouseMove(bool motion) = 0;
+ virtual void OnNativeTabContentsViewMouseMove() = 0;
virtual void OnNativeTabContentsViewDraggingEnded() = 0;
-
- virtual views::internal::NativeWidgetDelegate* AsNativeWidgetDelegate() = 0;
};
} // namespace internal
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc
deleted file mode 100644
index 7845b75..0000000
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h"
-
-#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
-#include "chrome/browser/tab_contents/web_drag_dest_gtk.h"
-#include "chrome/browser/ui/gtk/constrained_window_gtk.h"
-#include "chrome/browser/ui/gtk/tab_contents_drag_source.h"
-#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h"
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/tab_contents/tab_contents_view.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
-
-using WebKit::WebDragOperation;
-using WebKit::WebDragOperationsMask;
-using WebKit::WebInputEvent;
-
-namespace {
-
-// Called when the content view gtk widget is tabbed to, or after the call to
-// gtk_widget_child_focus() in TakeFocus(). We return true
-// and grab focus if we don't have it. The call to
-// FocusThroughTabTraversal(bool) forwards the "move focus forward" effect to
-// webkit.
-gboolean OnFocus(GtkWidget* widget, GtkDirectionType focus,
- TabContents* tab_contents) {
- // If we already have focus, let the next widget have a shot at it. We will
- // reach this situation after the call to gtk_widget_child_focus() in
- // TakeFocus().
- if (gtk_widget_is_focus(widget))
- return FALSE;
-
- gtk_widget_grab_focus(widget);
- bool reverse = focus == GTK_DIR_TAB_BACKWARD;
- tab_contents->FocusThroughTabTraversal(reverse);
- return TRUE;
-}
-
-// See tab_contents_view_gtk.cc for discussion of mouse scroll zooming.
-gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event,
- internal::NativeTabContentsViewDelegate* delegate) {
- if ((event->state & gtk_accelerator_get_default_mod_mask()) ==
- GDK_CONTROL_MASK) {
- if (event->direction == GDK_SCROLL_DOWN) {
- delegate->OnNativeTabContentsViewWheelZoom(false);
- return TRUE;
- }
- if (event->direction == GDK_SCROLL_UP) {
- delegate->OnNativeTabContentsViewWheelZoom(true);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-gfx::NativeView GetHiddenTabHostWindow() {
- static views::Widget* widget = NULL;
-
- if (!widget) {
- widget = new views::Widget;
- // We don't want this widget to be closed automatically, this causes
- // problems in tests that close the last non-secondary window.
- widget->set_is_secondary_widget(false);
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
- widget->Init(params);
- }
-
- return static_cast<views::WidgetGtk*>(widget->native_widget())->
- window_contents();
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeTabContentsViewGtk, public:
-
-NativeTabContentsViewGtk::NativeTabContentsViewGtk(
- internal::NativeTabContentsViewDelegate* delegate)
- : views::WidgetGtk(delegate->AsNativeWidgetDelegate()),
- delegate_(delegate),
- ignore_next_char_event_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(drag_source_(
- new TabContentsDragSource(delegate->GetTabContents()->view()))) {
-}
-
-NativeTabContentsViewGtk::~NativeTabContentsViewGtk() {
- delegate_ = NULL;
- CloseNow();
-}
-
-void NativeTabContentsViewGtk::AttachConstrainedWindow(
- ConstrainedWindowGtk* constrained_window) {
- DCHECK(find(constrained_windows_.begin(), constrained_windows_.end(),
- constrained_window) == constrained_windows_.end());
-
- constrained_windows_.push_back(constrained_window);
- AddChild(constrained_window->widget());
-
- gfx::Size requested_size;
- views::WidgetGtk::GetRequestedSize(&requested_size);
- PositionConstrainedWindows(requested_size);
-}
-
-void NativeTabContentsViewGtk::RemoveConstrainedWindow(
- ConstrainedWindowGtk* constrained_window) {
- std::vector<ConstrainedWindowGtk*>::iterator item =
- find(constrained_windows_.begin(), constrained_windows_.end(),
- constrained_window);
- DCHECK(item != constrained_windows_.end());
- RemoveChild((*item)->widget());
- constrained_windows_.erase(item);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeTabContentsViewGtk, NativeTabContentsView implementation:
-
-void NativeTabContentsViewGtk::InitNativeTabContentsView() {
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
- params.native_widget = this;
- params.delete_on_destroy = false;
- GetWidget()->Init(params);
-
- // We need to own the widget in order to attach/detach the native view to a
- // container.
- gtk_object_ref(GTK_OBJECT(GetWidget()->GetNativeView()));
-}
-
-void NativeTabContentsViewGtk::Unparent() {
- // Note that we do not DCHECK on focus_manager_ as it may be NULL when used
- // with an external tab container.
- NativeWidget::ReparentNativeView(GetNativeView(), GetHiddenTabHostWindow());
-}
-
-RenderWidgetHostView* NativeTabContentsViewGtk::CreateRenderWidgetHostView(
- RenderWidgetHost* render_widget_host) {
- RenderWidgetHostViewGtk* view =
- new RenderWidgetHostViewGtk(render_widget_host);
- view->InitAsChild();
- g_signal_connect(view->native_view(), "focus",
- G_CALLBACK(OnFocus), delegate_->GetTabContents());
- g_signal_connect(view->native_view(), "scroll-event",
- G_CALLBACK(OnMouseScroll), delegate_);
-
- // Let widget know that the tab contents has been painted.
- views::WidgetGtk::RegisterChildExposeHandler(view->native_view());
-
- // Renderer target DnD.
- if (delegate_->GetTabContents()->ShouldAcceptDragAndDrop())
- drag_dest_.reset(new WebDragDestGtk(delegate_->GetTabContents(),
- view->native_view()));
-
- gtk_fixed_put(GTK_FIXED(GetWidget()->GetNativeView()), view->native_view(), 0,
- 0);
- return view;
-}
-
-gfx::NativeWindow NativeTabContentsViewGtk::GetTopLevelNativeWindow() const {
- GtkWidget* window = gtk_widget_get_ancestor(GetWidget()->GetNativeView(),
- GTK_TYPE_WINDOW);
- return window ? GTK_WINDOW(window) : NULL;
-}
-
-void NativeTabContentsViewGtk::SetPageTitle(const std::wstring& title) {
- // Set the window name to include the page title so it's easier to spot
- // when debugging (e.g. via xwininfo -tree).
- if (GDK_IS_WINDOW(GetNativeView()->window))
- gdk_window_set_title(GetNativeView()->window, WideToUTF8(title).c_str());
-}
-
-void NativeTabContentsViewGtk::StartDragging(const WebDropData& drop_data,
- WebKit::WebDragOperationsMask ops,
- const SkBitmap& image,
- const gfx::Point& image_offset) {
- drag_source_->StartDragging(drop_data, ops, &last_mouse_down_,
- image, image_offset);
-}
-
-void NativeTabContentsViewGtk::CancelDrag() {
-}
-
-bool NativeTabContentsViewGtk::IsDoingDrag() const {
- return false;
-}
-
-void NativeTabContentsViewGtk::SetDragCursor(
- WebKit::WebDragOperation operation) {
- if (drag_dest_.get())
- drag_dest_->UpdateDragStatus(operation);
-}
-
-views::NativeWidget* NativeTabContentsViewGtk::AsNativeWidget() {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeTabContentsViewGtk, views::WidgetGtk overrides:
-
-// Called when the mouse moves within the widget. We notify SadTabView if it's
-// not NULL, else our delegate.
-gboolean NativeTabContentsViewGtk::OnMotionNotify(GtkWidget* widget,
- GdkEventMotion* event) {
- if (delegate_->IsShowingSadTab())
- return views::WidgetGtk::OnMotionNotify(widget, event);
-
- delegate_->OnNativeTabContentsViewMouseMove(true);
- return FALSE;
-}
-
-gboolean NativeTabContentsViewGtk::OnLeaveNotify(GtkWidget* widget,
- GdkEventCrossing* event) {
- if (delegate_->IsShowingSadTab())
- return views::WidgetGtk::OnLeaveNotify(widget, event);
-
- delegate_->OnNativeTabContentsViewMouseMove(false);
- return FALSE;
-}
-
-gboolean NativeTabContentsViewGtk::OnButtonPress(GtkWidget* widget,
- GdkEventButton* event) {
- if (delegate_->IsShowingSadTab())
- return views::WidgetGtk::OnButtonPress(widget, event);
- last_mouse_down_ = *event;
- return views::WidgetGtk::OnButtonPress(widget, event);
-}
-
-void NativeTabContentsViewGtk::OnSizeAllocate(GtkWidget* widget,
- GtkAllocation* allocation) {
- gfx::Size size(allocation->width, allocation->height);
- delegate_->OnNativeTabContentsViewSized(size);
- if (size != size_)
- PositionConstrainedWindows(size);
- size_ = size;
- views::WidgetGtk::OnSizeAllocate(widget, allocation);
-}
-
-void NativeTabContentsViewGtk::OnShow(GtkWidget* widget) {
- delegate_->OnNativeTabContentsViewShown();
- views::WidgetGtk::OnShow(widget);
-}
-
-void NativeTabContentsViewGtk::OnHide(GtkWidget* widget) {
- // OnHide can be called during widget destruction (gtk_widget_dispose calls
- // gtk_widget_hide) so we make sure we do not call back through to the
- // delegate after it's already deleted.
- if (delegate_)
- delegate_->OnNativeTabContentsViewHidden();
- views::WidgetGtk::OnHide(widget);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeTabContentsViewGtk, private:
-
-void NativeTabContentsViewGtk::PositionConstrainedWindows(
- const gfx::Size& view_size) {
- // Place each ConstrainedWindow in the center of the view.
- int half_view_width = view_size.width() / 2;
-
- typedef std::vector<ConstrainedWindowGtk*>::iterator iterator;
-
- for (iterator f = constrained_windows_.begin(),
- l = constrained_windows_.end(); f != l; ++f) {
- GtkWidget* widget = (*f)->widget();
-
- GtkRequisition requisition;
- gtk_widget_size_request(widget, &requisition);
-
- int child_x = std::max(half_view_width - (requisition.width / 2), 0);
- PositionChild(widget, child_x, 0, 0, 0);
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeTabContentsView, public:
-
-// static
-NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView(
- internal::NativeTabContentsViewDelegate* delegate) {
- return new NativeTabContentsViewGtk(delegate);
-}
-
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h
deleted file mode 100644
index e44b490..0000000
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2011 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_UI_VIEWS_TAB_CONTENTS_NATIVE_TAB_CONTENTS_VIEW_GTK_H_
-#define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_NATIVE_TAB_CONTENTS_VIEW_GTK_H_
-#pragma once
-
-#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view.h"
-#include "views/widget/widget_gtk.h"
-
-class ConstrainedWindowGtk;
-class TabContents;
-class TabContentsDragSource;
-class WebDragDestGtk;
-
-class NativeTabContentsViewGtk : public views::WidgetGtk,
- public NativeTabContentsView {
- public:
- explicit NativeTabContentsViewGtk(
- internal::NativeTabContentsViewDelegate* delegate);
- virtual ~NativeTabContentsViewGtk();
-
- // Unlike Windows, ConstrainedWindows need to collaborate with the
- // TabContentsViewGtk to position the dialogs.
- void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
- void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
-
-
- private:
- // Overridden from NativeTabContentsView:
- virtual void InitNativeTabContentsView() OVERRIDE;
- virtual void Unparent() OVERRIDE;
- virtual RenderWidgetHostView* CreateRenderWidgetHostView(
- RenderWidgetHost* render_widget_host) OVERRIDE;
- virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
- virtual void SetPageTitle(const std::wstring& title) OVERRIDE;
- virtual void StartDragging(const WebDropData& drop_data,
- WebKit::WebDragOperationsMask ops,
- const SkBitmap& image,
- const gfx::Point& image_offset) OVERRIDE;
- virtual void CancelDrag() OVERRIDE;
- virtual bool IsDoingDrag() const OVERRIDE;
- virtual void SetDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
- virtual views::NativeWidget* AsNativeWidget() OVERRIDE;
-
- // Overridden from views::WidgetGtk:
- virtual gboolean OnMotionNotify(GtkWidget* widget,
- GdkEventMotion* event) OVERRIDE;
- virtual gboolean OnLeaveNotify(GtkWidget* widget,
- GdkEventCrossing* event) OVERRIDE;
- virtual gboolean OnButtonPress(GtkWidget* widget,
- GdkEventButton* event) OVERRIDE;
- virtual void OnSizeAllocate(GtkWidget* widget,
- GtkAllocation* allocation) OVERRIDE;
- virtual void OnShow(GtkWidget* widget) OVERRIDE;
- virtual void OnHide(GtkWidget* widget) OVERRIDE;
-
- void PositionConstrainedWindows(const gfx::Size& view_size);
-
- internal::NativeTabContentsViewDelegate* delegate_;
-
- // Whether to ignore the next CHAR keyboard event.
- bool ignore_next_char_event_;
-
- // Handles drags from this TabContentsView.
- scoped_ptr<TabContentsDragSource> drag_source_;
-
- // The event for the last mouse down we handled. We need this for drags.
- GdkEventButton last_mouse_down_;
-
- // The helper object that handles drag destination related interactions with
- // GTK.
- scoped_ptr<WebDragDestGtk> drag_dest_;
-
- // Current size. See comment in WidgetGtk as to why this is cached.
- gfx::Size size_;
-
- // Each individual UI for constrained dialogs currently displayed. The
- // objects in this vector are owned by the TabContents, not the view.
- std::vector<ConstrainedWindowGtk*> constrained_windows_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeTabContentsViewGtk);
-};
-
-#endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_NATIVE_TAB_CONTENTS_VIEW_GTK_H_
-
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc
index 9474fec..4f0bc23 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc
@@ -30,10 +30,7 @@ HWND GetHiddenTabHostWindow() {
static views::Widget* widget = NULL;
if (!widget) {
- widget = new views::Widget;
- // We don't want this widget to be closed automatically, this causes
- // problems in tests that close the last non-secondary window.
- widget->set_is_secondary_widget(false);
+ widget = views::Widget::CreateWidget();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
widget->Init(params);
// If a background window requests focus, the hidden tab host will
@@ -52,8 +49,8 @@ HWND GetHiddenTabHostWindow() {
NativeTabContentsViewWin::NativeTabContentsViewWin(
internal::NativeTabContentsViewDelegate* delegate)
- : views::WidgetWin(delegate->AsNativeWidgetDelegate()),
- delegate_(delegate) {
+ : delegate_(delegate),
+ focus_manager_(NULL) {
}
NativeTabContentsViewWin::~NativeTabContentsViewWin() {
@@ -74,7 +71,6 @@ void NativeTabContentsViewWin::EndDragging() {
void NativeTabContentsViewWin::InitNativeTabContentsView() {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
- params.native_widget = this;
params.delete_on_destroy = false;
params.parent = GetHiddenTabHostWindow();
GetWidget()->Init(params);
@@ -86,6 +82,9 @@ void NativeTabContentsViewWin::InitNativeTabContentsView() {
}
void NativeTabContentsViewWin::Unparent() {
+ // Remember who our FocusManager is, we won't be able to access it once
+ // unparented.
+ focus_manager_ = views::WidgetWin::GetFocusManager();
// Note that we do not DCHECK on focus_manager_ as it may be NULL when used
// with an external tab container.
NativeWidget::ReparentNativeView(GetNativeView(), GetHiddenTabHostWindow());
@@ -167,7 +166,7 @@ LRESULT NativeTabContentsViewWin::OnMouseRange(UINT msg,
break;
}
case WM_MOUSEMOVE:
- delegate_->OnNativeTabContentsViewMouseMove(true);
+ delegate_->OnNativeTabContentsViewMouseMove();
break;
default:
break;
@@ -187,7 +186,7 @@ LRESULT NativeTabContentsViewWin::OnReflectedMessage(UINT msg,
// This message is reflected from the view() to this window.
if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) {
delegate_->OnNativeTabContentsViewWheelZoom(
- GET_WHEEL_DELTA_WPARAM(message->wParam) > 0);
+ GET_WHEEL_DELTA_WPARAM(message->wParam));
return 1;
}
break;
@@ -264,6 +263,22 @@ void NativeTabContentsViewWin::OnNCPaint(HRGN rgn) {
// here since the view will draw everything correctly.
}
+views::FocusManager* NativeTabContentsViewWin::GetFocusManager() {
+ views::FocusManager* focus_manager = WidgetWin::GetFocusManager();
+ if (focus_manager) {
+ // If focus_manager_ is non NULL, it means we have been reparented, in which
+ // case its value may not be valid anymore.
+ focus_manager_ = NULL;
+ return focus_manager;
+ }
+ // TODO(jcampan): we should DCHECK on focus_manager_, as it should not be
+ // NULL. We are not doing it as it breaks some unit-tests. We should
+ // probably have an empty TabContentView implementation for the unit-tests,
+ // that would prevent that code being executed in the unit-test case.
+ // DCHECK(focus_manager_);
+ return focus_manager_;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeTabContentsViewWin, private:
@@ -305,7 +320,7 @@ bool NativeTabContentsViewWin::ScrollZoom(int scroll_type) {
break;
}
- delegate_->OnNativeTabContentsViewWheelZoom(distance > 0);
+ delegate_->OnNativeTabContentsViewWheelZoom(distance);
return true;
}
return false;
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h
index 6b1f195..4f8c60a 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h
@@ -61,6 +61,7 @@ class NativeTabContentsViewWin : public views::WidgetWin,
virtual void OnSize(UINT param, const WTL::CSize& size) OVERRIDE;
virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param) OVERRIDE;
virtual void OnNCPaint(HRGN rgn) OVERRIDE;
+ virtual views::FocusManager* GetFocusManager() OVERRIDE;
// Backend for all scroll messages, the |message| parameter indicates which
// one it is.
@@ -76,6 +77,10 @@ class NativeTabContentsViewWin : public views::WidgetWin,
// Used to handle the drag-and-drop.
scoped_refptr<TabContentsDragWin> drag_handler_;
+ // The FocusManager associated with this tab. Stored as it is not directly
+ // accessible when un-parented.
+ views::FocusManager* focus_manager_;
+
DISALLOW_COPY_AND_ASSIGN(NativeTabContentsViewWin);
};
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc
new file mode 100644
index 0000000..6b8c426
--- /dev/null
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc
@@ -0,0 +1,488 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h"
+
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "build/build_config.h"
+#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
+#include "chrome/browser/tab_contents/web_drag_dest_gtk.h"
+#include "chrome/browser/ui/gtk/constrained_window_gtk.h"
+#include "chrome/browser/ui/gtk/tab_contents_drag_source.h"
+#include "chrome/browser/ui/views/sad_tab_view.h"
+#include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/renderer_host/render_view_host_factory.h"
+#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_delegate.h"
+#include "ui/gfx/canvas_skia_paint.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
+#include "views/controls/native/native_view_host.h"
+#include "views/focus/view_storage.h"
+#include "views/screen.h"
+#include "views/widget/root_view.h"
+#include "views/widget/widget_gtk.h"
+
+using WebKit::WebDragOperation;
+using WebKit::WebDragOperationsMask;
+using WebKit::WebInputEvent;
+
+
+namespace {
+
+// Called when the content view gtk widget is tabbed to, or after the call to
+// gtk_widget_child_focus() in TakeFocus(). We return true
+// and grab focus if we don't have it. The call to
+// FocusThroughTabTraversal(bool) forwards the "move focus forward" effect to
+// webkit.
+gboolean OnFocus(GtkWidget* widget, GtkDirectionType focus,
+ TabContents* tab_contents) {
+ // If we already have focus, let the next widget have a shot at it. We will
+ // reach this situation after the call to gtk_widget_child_focus() in
+ // TakeFocus().
+ if (gtk_widget_is_focus(widget))
+ return FALSE;
+
+ gtk_widget_grab_focus(widget);
+ bool reverse = focus == GTK_DIR_TAB_BACKWARD;
+ tab_contents->FocusThroughTabTraversal(reverse);
+ return TRUE;
+}
+
+// Called when the mouse leaves the widget. We notify our delegate.
+// WidgetGtk also defines OnLeaveNotify, so we use the name OnLeaveNotify2
+// here.
+gboolean OnLeaveNotify2(GtkWidget* widget, GdkEventCrossing* event,
+ TabContents* tab_contents) {
+ if (tab_contents->delegate())
+ tab_contents->delegate()->ContentsMouseEvent(
+ tab_contents, views::Screen::GetCursorScreenPoint(), false);
+ return FALSE;
+}
+
+// Called when the mouse moves within the widget.
+gboolean CallMouseMove(GtkWidget* widget, GdkEventMotion* event,
+ TabContentsViewGtk* tab_contents_view) {
+ return tab_contents_view->OnMouseMove(widget, event);
+}
+
+// See tab_contents_view_gtk.cc for discussion of mouse scroll zooming.
+gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event,
+ TabContents* tab_contents) {
+ if ((event->state & gtk_accelerator_get_default_mod_mask()) ==
+ GDK_CONTROL_MASK) {
+ if (tab_contents->delegate()) {
+ if (event->direction == GDK_SCROLL_DOWN) {
+ tab_contents->delegate()->ContentsZoomChange(false);
+ return TRUE;
+ } else if (event->direction == GDK_SCROLL_UP) {
+ tab_contents->delegate()->ContentsZoomChange(true);
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+} // namespace
+
+// static
+TabContentsView* TabContentsView::Create(TabContents* tab_contents) {
+ return new TabContentsViewGtk(tab_contents);
+}
+
+TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents)
+ : TabContentsView(tab_contents),
+ sad_tab_(NULL),
+ ignore_next_char_event_(false) {
+ drag_source_.reset(new TabContentsDragSource(this));
+ last_focused_view_storage_id_ =
+ views::ViewStorage::GetInstance()->CreateStorageID();
+}
+
+TabContentsViewGtk::~TabContentsViewGtk() {
+ // Make sure to remove any stored view we may still have in the ViewStorage.
+ //
+ // It is possible the view went away before us, so we only do this if the
+ // view is registered.
+ views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+ if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
+ view_storage->RemoveView(last_focused_view_storage_id_);
+
+ // Just deleting the object doesn't destroy the GtkWidget. We need to do that
+ // manually, and synchronously, since subsequent signal handlers may expect
+ // to locate this object.
+ CloseNow();
+}
+
+void TabContentsViewGtk::AttachConstrainedWindow(
+ ConstrainedWindowGtk* constrained_window) {
+ DCHECK(find(constrained_windows_.begin(), constrained_windows_.end(),
+ constrained_window) == constrained_windows_.end());
+
+ constrained_windows_.push_back(constrained_window);
+ AddChild(constrained_window->widget());
+
+ gfx::Rect bounds;
+ GetContainerBounds(&bounds);
+ SetFloatingPosition(bounds.size());
+}
+
+void TabContentsViewGtk::RemoveConstrainedWindow(
+ ConstrainedWindowGtk* constrained_window) {
+ std::vector<ConstrainedWindowGtk*>::iterator item =
+ find(constrained_windows_.begin(), constrained_windows_.end(),
+ constrained_window);
+ DCHECK(item != constrained_windows_.end());
+ RemoveChild((*item)->widget());
+ constrained_windows_.erase(item);
+}
+
+void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) {
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
+ params.delete_on_destroy = false;
+ params.bounds = gfx::Rect(initial_size);
+ GetWidget()->Init(params);
+ // We need to own the widget in order to attach/detach the native view
+ // to container.
+ gtk_object_ref(GTK_OBJECT(GetNativeView()));
+}
+
+RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget(
+ RenderWidgetHost* render_widget_host) {
+ if (render_widget_host->view()) {
+ // During testing, the view will already be set up in most cases to the
+ // test view, so we don't want to clobber it with a real one. To verify that
+ // this actually is happening (and somebody isn't accidentally creating the
+ // view twice), we check for the RVH Factory, which will be set when we're
+ // making special ones (which go along with the special views).
+ DCHECK(RenderViewHostFactory::has_factory());
+ return render_widget_host->view();
+ }
+
+ // If we were showing sad tab, remove it now.
+ if (sad_tab_ != NULL) {
+ SetContentsView(new views::View());
+ sad_tab_ = NULL;
+ }
+
+ RenderWidgetHostViewGtk* view =
+ new RenderWidgetHostViewGtk(render_widget_host);
+ view->InitAsChild();
+ g_signal_connect(view->native_view(), "focus",
+ G_CALLBACK(OnFocus), tab_contents());
+ g_signal_connect(view->native_view(), "leave-notify-event",
+ G_CALLBACK(OnLeaveNotify2), tab_contents());
+ g_signal_connect(view->native_view(), "motion-notify-event",
+ G_CALLBACK(CallMouseMove), this);
+ g_signal_connect(view->native_view(), "scroll-event",
+ G_CALLBACK(OnMouseScroll), tab_contents());
+ gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK);
+
+ // Let widget know that the tab contents has been painted.
+ views::WidgetGtk::RegisterChildExposeHandler(view->native_view());
+
+ // Renderer target DnD.
+ if (tab_contents()->ShouldAcceptDragAndDrop())
+ drag_dest_.reset(new WebDragDestGtk(tab_contents(), view->native_view()));
+
+ gtk_fixed_put(GTK_FIXED(GetNativeView()), view->native_view(), 0, 0);
+ return view;
+}
+
+gfx::NativeView TabContentsViewGtk::GetNativeView() const {
+ return WidgetGtk::GetNativeView();
+}
+
+gfx::NativeView TabContentsViewGtk::GetContentNativeView() const {
+ RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
+ if (!rwhv)
+ return NULL;
+ return rwhv->GetNativeView();
+}
+
+gfx::NativeWindow TabContentsViewGtk::GetTopLevelNativeWindow() const {
+ GtkWidget* window = gtk_widget_get_ancestor(GetNativeView(), GTK_TYPE_WINDOW);
+ return window ? GTK_WINDOW(window) : NULL;
+}
+
+void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
+ // Callers expect the requested bounds not the actual bounds. For example,
+ // during init callers expect 0x0, but Gtk layout enforces a min size of 1x1.
+ *out = GetClientAreaScreenBounds();
+
+ gfx::Size size;
+ WidgetGtk::GetRequestedSize(&size);
+ out->set_size(size);
+}
+
+void TabContentsViewGtk::StartDragging(const WebDropData& drop_data,
+ WebDragOperationsMask ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
+ drag_source_->StartDragging(drop_data, ops, &last_mouse_down_,
+ image, image_offset);
+}
+
+void TabContentsViewGtk::SetPageTitle(const std::wstring& title) {
+ // Set the window name to include the page title so it's easier to spot
+ // when debugging (e.g. via xwininfo -tree).
+ gfx::NativeView content_view = GetContentNativeView();
+ if (content_view && content_view->window)
+ gdk_window_set_title(content_view->window, WideToUTF8(title).c_str());
+}
+
+void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus status,
+ int /* error_code */) {
+ SadTabView::Kind kind =
+ status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
+ SadTabView::KILLED : SadTabView::CRASHED;
+ sad_tab_ = new SadTabView(tab_contents(), kind);
+ SetContentsView(sad_tab_);
+}
+
+void TabContentsViewGtk::SizeContents(const gfx::Size& size) {
+ // TODO(brettw) this is a hack and should be removed. See tab_contents_view.h.
+
+ // We're contained in a fixed. To have the fixed relay us out to |size|, set
+ // the size request, which triggers OnSizeAllocate.
+ gtk_widget_set_size_request(GetNativeView(), size.width(), size.height());
+
+ // We need to send this immediately.
+ RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
+ if (rwhv)
+ rwhv->SetSize(size);
+}
+
+void TabContentsViewGtk::Focus() {
+ if (tab_contents()->interstitial_page()) {
+ tab_contents()->interstitial_page()->Focus();
+ return;
+ }
+
+ if (tab_contents()->is_crashed() && sad_tab_ != NULL) {
+ sad_tab_->RequestFocus();
+ return;
+ }
+
+ if (constrained_windows_.size()) {
+ constrained_windows_.back()->FocusConstrainedWindow();
+ return;
+ }
+
+ RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
+ gtk_widget_grab_focus(rwhv ? rwhv->GetNativeView() : GetNativeView());
+}
+
+void TabContentsViewGtk::SetInitialFocus() {
+ if (tab_contents()->FocusLocationBarByDefault())
+ tab_contents()->SetFocusToLocationBar(false);
+ else
+ Focus();
+}
+
+void TabContentsViewGtk::StoreFocus() {
+ views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+
+ if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
+ view_storage->RemoveView(last_focused_view_storage_id_);
+
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
+ if (focus_manager) {
+ // |focus_manager| can be NULL if the tab has been detached but still
+ // exists.
+ views::View* focused_view = focus_manager->GetFocusedView();
+ if (focused_view)
+ view_storage->StoreView(last_focused_view_storage_id_, focused_view);
+ }
+}
+
+void TabContentsViewGtk::RestoreFocus() {
+ views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+ views::View* last_focused_view =
+ view_storage->RetrieveView(last_focused_view_storage_id_);
+ if (!last_focused_view) {
+ SetInitialFocus();
+ } else {
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
+
+ // If you hit this DCHECK, please report it to Jay (jcampan).
+ DCHECK(focus_manager != NULL) << "No focus manager when restoring focus.";
+
+ if (last_focused_view->IsFocusableInRootView() && focus_manager &&
+ focus_manager->ContainsView(last_focused_view)) {
+ last_focused_view->RequestFocus();
+ } else {
+ // The focused view may not belong to the same window hierarchy (e.g.
+ // if the location bar was focused and the tab is dragged out), or it may
+ // no longer be focusable (e.g. if the location bar was focused and then
+ // we switched to fullscreen mode). In that case we default to the
+ // default focus.
+ SetInitialFocus();
+ }
+ view_storage->RemoveView(last_focused_view_storage_id_);
+ }
+}
+
+void TabContentsViewGtk::GetViewBounds(gfx::Rect* out) const {
+ *out = GetWindowScreenBounds();
+}
+
+void TabContentsViewGtk::UpdateDragCursor(WebDragOperation operation) {
+ if (drag_dest_.get())
+ drag_dest_->UpdateDragStatus(operation);
+}
+
+void TabContentsViewGtk::GotFocus() {
+ if (tab_contents()->delegate())
+ tab_contents()->delegate()->TabContentsFocused(tab_contents());
+}
+
+void TabContentsViewGtk::TakeFocus(bool reverse) {
+ if (tab_contents()->delegate() &&
+ !tab_contents()->delegate()->TakeFocus(reverse)) {
+
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
+
+ // We may not have a focus manager if the tab has been switched before this
+ // message arrived.
+ if (focus_manager)
+ focus_manager->AdvanceFocus(reverse);
+ }
+}
+
+void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) {
+ // Allow delegates to handle the context menu operation first.
+ if (tab_contents()->delegate()->HandleContextMenu(params))
+ return;
+
+ context_menu_.reset(new RenderViewContextMenuViews(tab_contents(), params));
+ context_menu_->Init();
+
+ gfx::Point screen_point(params.x, params.y);
+ views::View::ConvertPointToScreen(GetRootView(), &screen_point);
+
+ // Enable recursive tasks on the message loop so we can get updates while
+ // the context menu is being displayed.
+ bool old_state = MessageLoop::current()->NestableTasksAllowed();
+ MessageLoop::current()->SetNestableTasksAllowed(true);
+ context_menu_->RunMenuAt(screen_point.x(), screen_point.y());
+ MessageLoop::current()->SetNestableTasksAllowed(old_state);
+}
+
+void TabContentsViewGtk::ShowPopupMenu(const gfx::Rect& bounds,
+ int item_height,
+ double item_font_size,
+ int selected_item,
+ const std::vector<WebMenuItem>& items,
+ bool right_aligned) {
+ // External popup menus are only used on Mac.
+ NOTREACHED();
+}
+
+gboolean TabContentsViewGtk::OnButtonPress(GtkWidget* widget,
+ GdkEventButton* event) {
+ last_mouse_down_ = *event;
+ return views::WidgetGtk::OnButtonPress(widget, event);
+}
+
+void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget,
+ GtkAllocation* allocation) {
+ gfx::Size new_size(allocation->width, allocation->height);
+
+ // Always call WasSized() to allow checking to make sure the
+ // RenderWidgetHostView is the right size.
+ WasSized(new_size);
+}
+
+gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) {
+ if (tab_contents()->render_view_host() &&
+ !tab_contents()->render_view_host()->IsRenderViewLive() &&
+ sad_tab_) {
+ gfx::CanvasSkiaPaint canvas(event);
+ sad_tab_->Paint(&canvas);
+ }
+ return false; // False indicates other widgets should get the event as well.
+}
+
+void TabContentsViewGtk::OnShow(GtkWidget* widget) {
+ WasShown();
+}
+
+void TabContentsViewGtk::OnHide(GtkWidget* widget) {
+ WasHidden();
+}
+
+void TabContentsViewGtk::WasHidden() {
+ tab_contents()->HideContents();
+}
+
+void TabContentsViewGtk::WasShown() {
+ tab_contents()->ShowContents();
+}
+
+void TabContentsViewGtk::WasSized(const gfx::Size& size) {
+ // We have to check that the RenderWidgetHostView is the proper size.
+ // It can be wrong in cases where the renderer has died and the host
+ // view needed to be recreated.
+ bool needs_resize = size != size_;
+
+ if (needs_resize) {
+ size_ = size;
+ if (tab_contents()->interstitial_page())
+ tab_contents()->interstitial_page()->SetSize(size);
+ }
+
+ RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
+ if (rwhv && rwhv->GetViewBounds().size() != size)
+ rwhv->SetSize(size);
+ if (sad_tab_ && sad_tab_->size() != size)
+ sad_tab_->SetSize(size);
+
+ if (needs_resize)
+ SetFloatingPosition(size);
+}
+
+void TabContentsViewGtk::SetFloatingPosition(const gfx::Size& size) {
+ // Place each ConstrainedWindow in the center of the view.
+ int half_view_width = size.width() / 2;
+
+ typedef std::vector<ConstrainedWindowGtk*>::iterator iterator;
+
+ for (iterator f = constrained_windows_.begin(),
+ l = constrained_windows_.end(); f != l; ++f) {
+ GtkWidget* widget = (*f)->widget();
+
+ GtkRequisition requisition;
+ gtk_widget_size_request(widget, &requisition);
+
+ int child_x = std::max(half_view_width - (requisition.width / 2), 0);
+ PositionChild(widget, child_x, 0, 0, 0);
+ }
+}
+
+// Called when the mouse moves within the widget. We notify SadTabView if it's
+// not NULL, else our delegate.
+gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget,
+ GdkEventMotion* event) {
+ if (sad_tab_ != NULL)
+ WidgetGtk::OnMotionNotify(widget, event);
+ else if (tab_contents()->delegate())
+ tab_contents()->delegate()->ContentsMouseEvent(
+ tab_contents(), views::Screen::GetCursorScreenPoint(), true);
+ return FALSE;
+}
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h
new file mode 100644
index 0000000..0834a60
--- /dev/null
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h
@@ -0,0 +1,143 @@
+// Copyright (c) 2011 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_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
+#define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
+#pragma once
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/tab_contents/tab_contents_view.h"
+#include "ui/gfx/size.h"
+#include "views/widget/widget_gtk.h"
+
+class ConstrainedWindowGtk;
+typedef struct _GtkFloatingContainer GtkFloatingContainer;
+class RenderViewContextMenuViews;
+class SadTabView;
+class SkBitmap;
+class TabContentsDragSource;
+class WebDragDestGtk;
+namespace gfx {
+class Point;
+}
+namespace views {
+class NativeViewHost;
+}
+
+// Gtk-specific implementation of the TabContentsView for the views-based front
+// end. It is a WidgetGtk that contains all of the contents of the tab and
+// associated child views.
+class TabContentsViewGtk : public TabContentsView,
+ public views::WidgetGtk {
+ public:
+ // The corresponding TabContents is passed in the constructor, and manages our
+ // lifetime. This doesn't need to be the case, but is this way currently
+ // because that's what was easiest when they were split.
+ explicit TabContentsViewGtk(TabContents* tab_contents);
+ virtual ~TabContentsViewGtk();
+
+ // Unlike Windows, ConstrainedWindows need to collaborate with the
+ // TabContentsViewGtk to position the dialogs.
+ void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
+ void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
+
+ gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event);
+
+ // TabContentsView implementation --------------------------------------------
+
+ virtual void CreateView(const gfx::Size& initial_size);
+ virtual RenderWidgetHostView* CreateViewForWidget(
+ RenderWidgetHost* render_widget_host);
+ virtual gfx::NativeView GetNativeView() const;
+ virtual gfx::NativeView GetContentNativeView() const;
+ virtual gfx::NativeWindow GetTopLevelNativeWindow() const;
+ virtual void GetContainerBounds(gfx::Rect* out) const;
+ virtual void SetPageTitle(const std::wstring& title);
+ virtual void OnTabCrashed(base::TerminationStatus status,
+ int error_code);
+ virtual void SizeContents(const gfx::Size& size);
+ virtual void Focus();
+ virtual void SetInitialFocus();
+ virtual void StoreFocus();
+ virtual void RestoreFocus();
+ virtual void GetViewBounds(gfx::Rect* out) const;
+
+ // Backend implementation of RenderViewHostDelegate::View.
+ virtual void ShowContextMenu(const ContextMenuParams& params);
+ virtual void ShowPopupMenu(const gfx::Rect& bounds,
+ int item_height,
+ double item_font_size,
+ int selected_item,
+ const std::vector<WebMenuItem>& items,
+ bool right_aligned);
+ virtual void StartDragging(const WebDropData& drop_data,
+ WebKit::WebDragOperationsMask ops_allowed,
+ const SkBitmap& image,
+ const gfx::Point& image_offset);
+ virtual void UpdateDragCursor(WebKit::WebDragOperation operation);
+ virtual void GotFocus();
+ virtual void TakeFocus(bool reverse);
+
+ private:
+ // Signal handlers -----------------------------------------------------------
+
+ // Overridden from views::WidgetGtk:
+ virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event);
+ virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation);
+ virtual gboolean OnPaint(GtkWidget* widget, GdkEventExpose* event);
+ virtual void OnShow(GtkWidget* widget);
+ virtual void OnHide(GtkWidget* widget);
+
+ // Handles notifying the TabContents and other operations when the window was
+ // shown or hidden.
+ void WasHidden();
+ void WasShown();
+
+ // Handles resizing of the contents. This will notify the RenderWidgetHostView
+ // of the change, reposition popups, and the find in page bar.
+ void WasSized(const gfx::Size& size);
+
+ // For any floating views (ConstrainedDialogs) this function centers them
+ // within this view. It's called whem a ConstrainedDialog is attached and
+ // when this view is resized.
+ void SetFloatingPosition(const gfx::Size& size);
+
+ // ---------------------------------------------------------------------------
+
+ // Used to render the sad tab. This will be non-NULL only when the sad tab is
+ // visible.
+ SadTabView* sad_tab_;
+
+ // Whether to ignore the next CHAR keyboard event.
+ bool ignore_next_char_event_;
+
+ // The id used in the ViewStorage to store the last focused view.
+ int last_focused_view_storage_id_;
+
+ // The context menu. Callbacks are asynchronous so we need to keep it around.
+ scoped_ptr<RenderViewContextMenuViews> context_menu_;
+
+ // Handles drags from this TabContentsView.
+ scoped_ptr<TabContentsDragSource> drag_source_;
+
+ // The event for the last mouse down we handled. We need this for drags.
+ GdkEventButton last_mouse_down_;
+
+ // The helper object that handles drag destination related interactions with
+ // GTK.
+ scoped_ptr<WebDragDestGtk> drag_dest_;
+
+ // Current size. See comment in WidgetGtk as to why this is cached.
+ gfx::Size size_;
+
+ // Each individual UI for constrained dialogs currently displayed. The
+ // objects in this vector are owned by the TabContents, not the view.
+ std::vector<ConstrainedWindowGtk*> constrained_windows_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
index 3d88f73..ab4f4c4 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
+#include <windows.h>
+
#include <vector>
#include "base/time.h"
@@ -24,10 +26,6 @@
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#endif
-
using WebKit::WebDragOperation;
using WebKit::WebDragOperationNone;
using WebKit::WebDragOperationsMask;
@@ -40,10 +38,10 @@ TabContentsView* TabContentsView::Create(TabContents* tab_contents) {
TabContentsViewViews::TabContentsViewViews(TabContents* tab_contents)
: TabContentsView(tab_contents),
- native_tab_contents_view_(NULL),
- sad_tab_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(native_tab_contents_view_(
+ NativeTabContentsView::CreateNativeTabContentsView(this))),
close_tab_after_drag_ends_(false),
- focus_manager_(NULL) {
+ sad_tab_(NULL) {
last_focused_view_storage_id_ =
views::ViewStorage::GetInstance()->CreateStorageID();
}
@@ -59,16 +57,11 @@ TabContentsViewViews::~TabContentsViewViews() {
}
void TabContentsViewViews::Unparent() {
- // Remember who our FocusManager is, we won't be able to access it once
- // un-parented.
- focus_manager_ = GetFocusManager();
- CHECK(native_tab_contents_view_);
+ CHECK(native_tab_contents_view_.get());
native_tab_contents_view_->Unparent();
}
void TabContentsViewViews::CreateView(const gfx::Size& initial_size) {
- native_tab_contents_view_ =
- NativeTabContentsView::CreateNativeTabContentsView(this);
native_tab_contents_view_->InitNativeTabContentsView();
}
@@ -86,7 +79,7 @@ RenderWidgetHostView* TabContentsViewViews::CreateViewForWidget(
// If we were showing sad tab, remove it now.
if (sad_tab_) {
- SetContentsView(new views::View());
+ GetWidget()->SetContentsView(new views::View());
sad_tab_ = NULL;
}
@@ -95,7 +88,7 @@ RenderWidgetHostView* TabContentsViewViews::CreateViewForWidget(
}
gfx::NativeView TabContentsViewViews::GetNativeView() const {
- return Widget::GetNativeView();
+ return GetWidget()->GetNativeView();
}
gfx::NativeView TabContentsViewViews::GetContentNativeView() const {
@@ -104,11 +97,11 @@ gfx::NativeView TabContentsViewViews::GetContentNativeView() const {
}
gfx::NativeWindow TabContentsViewViews::GetTopLevelNativeWindow() const {
- return GetTopLevelWidget()->GetNativeWindow();
+ return native_tab_contents_view_->GetTopLevelNativeWindow();
}
void TabContentsViewViews::GetContainerBounds(gfx::Rect* out) const {
- *out = GetClientAreaScreenBounds();
+ *out = GetWidget()->GetClientAreaScreenBounds();
}
void TabContentsViewViews::StartDragging(const WebDropData& drop_data,
@@ -126,18 +119,18 @@ void TabContentsViewViews::OnTabCrashed(base::TerminationStatus status,
int /* error_code */) {
// Force an invalidation to render sad tab.
// Note that it's possible to get this message after the window was destroyed.
- if (GetNativeView()) {
+ if (::IsWindow(GetNativeView())) {
SadTabView::Kind kind =
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
SadTabView::KILLED : SadTabView::CRASHED;
sad_tab_ = new SadTabView(tab_contents(), kind);
- SetContentsView(sad_tab_);
+ GetWidget()->SetContentsView(sad_tab_);
sad_tab_->SchedulePaint();
}
}
void TabContentsViewViews::SizeContents(const gfx::Size& size) {
- SetSize(size);
+ GetWidget()->SetSize(size);
}
void TabContentsViewViews::Focus() {
@@ -159,8 +152,8 @@ void TabContentsViewViews::Focus() {
}
RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
- GetFocusManager()->FocusNativeView(rwhv ? rwhv->GetNativeView()
- : GetNativeView());
+ GetWidget()->GetFocusManager()->FocusNativeView(rwhv ? rwhv->GetNativeView()
+ : GetNativeView());
}
void TabContentsViewViews::SetInitialFocus() {
@@ -230,7 +223,7 @@ void TabContentsViewViews::CancelDragAndCloseTab() {
}
void TabContentsViewViews::GetViewBounds(gfx::Rect* out) const {
- *out = GetWindowScreenBounds();
+ *out = GetWidget()->GetWindowScreenBounds();
}
void TabContentsViewViews::UpdateDragCursor(WebDragOperation operation) {
@@ -254,6 +247,14 @@ void TabContentsViewViews::TakeFocus(bool reverse) {
}
}
+views::Widget* TabContentsViewViews::GetWidget() {
+ return native_tab_contents_view_->AsNativeWidget()->GetWidget();
+}
+
+const views::Widget* TabContentsViewViews::GetWidget() const {
+ return native_tab_contents_view_->AsNativeWidget()->GetWidget();
+}
+
void TabContentsViewViews::CloseTab() {
tab_contents()->Close(tab_contents()->render_view_host());
}
@@ -266,14 +267,14 @@ void TabContentsViewViews::ShowContextMenu(const ContextMenuParams& params) {
context_menu_.reset(new RenderViewContextMenuViews(tab_contents(), params));
context_menu_->Init();
- gfx::Point screen_point(params.x, params.y);
- views::View::ConvertPointToScreen(GetRootView(), &screen_point);
+ POINT screen_pt = { params.x, params.y };
+ MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1);
// Enable recursive tasks on the message loop so we can get updates while
// the context menu is being displayed.
bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(true);
- context_menu_->RunMenuAt(screen_point.x(), screen_point.y());
+ context_menu_->RunMenuAt(screen_pt.x, screen_pt.y);
MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
@@ -314,9 +315,11 @@ void TabContentsViewViews::OnNativeTabContentsViewSized(const gfx::Size& size) {
rwhv->SetSize(size);
}
-void TabContentsViewViews::OnNativeTabContentsViewWheelZoom(bool zoom_in) {
- if (tab_contents()->delegate())
+void TabContentsViewViews::OnNativeTabContentsViewWheelZoom(int distance) {
+ if (tab_contents()->delegate()) {
+ bool zoom_in = distance > 0;
tab_contents()->delegate()->ContentsZoomChange(zoom_in);
+ }
}
void TabContentsViewViews::OnNativeTabContentsViewMouseDown() {
@@ -325,12 +328,12 @@ void TabContentsViewViews::OnNativeTabContentsViewMouseDown() {
tab_contents()->delegate()->ActivateContents(tab_contents());
}
-void TabContentsViewViews::OnNativeTabContentsViewMouseMove(bool motion) {
+void TabContentsViewViews::OnNativeTabContentsViewMouseMove() {
// Let our delegate know that the mouse moved (useful for resetting status
// bubble state).
if (tab_contents()->delegate()) {
tab_contents()->delegate()->ContentsMouseEvent(
- tab_contents(), views::Screen::GetCursorScreenPoint(), motion);
+ tab_contents(), views::Screen::GetCursorScreenPoint(), true);
}
}
@@ -341,28 +344,3 @@ void TabContentsViewViews::OnNativeTabContentsViewDraggingEnded() {
}
tab_contents()->SystemDragEnded();
}
-
-views::internal::NativeWidgetDelegate*
- TabContentsViewViews::AsNativeWidgetDelegate() {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TabContentsViewViews, views::Widget overrides:
-
-views::FocusManager* TabContentsViewViews::GetFocusManager() {
- views::FocusManager* focus_manager = Widget::GetFocusManager();
- if (focus_manager) {
- // If focus_manager_ is non NULL, it means we have been reparented, in which
- // case its value may not be valid anymore.
- focus_manager_ = NULL;
- return focus_manager;
- }
- // TODO(jcampan): we should DCHECK on focus_manager_, as it should not be
- // NULL. We are not doing it as it breaks some unit-tests. We should
- // probably have an empty TabContentView implementation for the unit-tests,
- // that would prevent that code being executed in the unit-test case.
- // DCHECK(focus_manager_);
- return focus_manager_;
-}
-
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h
index 0bd78ff..bc7b622 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h
@@ -10,7 +10,6 @@
#include "base/timer.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h"
#include "content/browser/tab_contents/tab_contents_view.h"
-#include "views/widget/widget.h"
class NativeTabContentsView;
class RenderViewContextMenuViews;
@@ -28,8 +27,7 @@ class Widget;
// Views-specific implementation of the TabContentsView.
// TODO(beng): Remove last remnants of Windows-specificity, and make this
// subclass Widget.
-class TabContentsViewViews : public views::Widget,
- public TabContentsView,
+class TabContentsViewViews : public TabContentsView,
public internal::NativeTabContentsViewDelegate {
public:
// The corresponding TabContents is passed in the constructor, and manages our
@@ -42,10 +40,6 @@ class TabContentsViewViews : public views::Widget,
// not receive any messages.
virtual void Unparent();
- NativeTabContentsView* native_tab_contents_view() const {
- return native_tab_contents_view_;
- }
-
// Overridden from TabContentsView:
virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget(
@@ -87,15 +81,13 @@ class TabContentsViewViews : public views::Widget,
virtual void OnNativeTabContentsViewShown() OVERRIDE;
virtual void OnNativeTabContentsViewHidden() OVERRIDE;
virtual void OnNativeTabContentsViewSized(const gfx::Size& size) OVERRIDE;
- virtual void OnNativeTabContentsViewWheelZoom(bool zoom_in) OVERRIDE;
+ virtual void OnNativeTabContentsViewWheelZoom(int distance) OVERRIDE;
virtual void OnNativeTabContentsViewMouseDown() OVERRIDE;
- virtual void OnNativeTabContentsViewMouseMove(bool motion) OVERRIDE;
+ virtual void OnNativeTabContentsViewMouseMove() OVERRIDE;
virtual void OnNativeTabContentsViewDraggingEnded() OVERRIDE;
- virtual views::internal::NativeWidgetDelegate* AsNativeWidgetDelegate()
- OVERRIDE;
- // Overridden from views::Widget:
- virtual views::FocusManager* GetFocusManager() OVERRIDE;
+ views::Widget* GetWidget();
+ const views::Widget* GetWidget() const;
// A helper method for closing the tab.
void CloseTab();
@@ -116,7 +108,7 @@ class TabContentsViewViews : public views::Widget,
// ---------------------------------------------------------------------------
- NativeTabContentsView* native_tab_contents_view_;
+ scoped_ptr<NativeTabContentsView> native_tab_contents_view_;
// Used to render the sad tab. This will be non-NULL only when the sad tab is
// visible.
@@ -135,10 +127,6 @@ class TabContentsViewViews : public views::Widget,
// Used to close the tab after the stack has unwound.
base::OneShotTimer<TabContentsViewViews> close_tab_timer_;
- // The FocusManager associated with this tab. Stored as it is not directly
- // accessible when un-parented.
- views::FocusManager* focus_manager_;
-
DISALLOW_COPY_AND_ASSIGN(TabContentsViewViews);
};
diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.cc b/chrome/browser/ui/views/tabs/base_tab_strip.cc
index ad3df63..8178edd 100644
--- a/chrome/browser/ui/views/tabs/base_tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/base_tab_strip.cc
@@ -94,14 +94,15 @@ class BaseTabStrip::RemoveTabDelegate
// This can be null during shutdown. See http://crbug.com/42737.
if (!widget)
return;
-
- widget->ResetLastMouseMoveFlag();
-
// Force the close button (that slides under the mouse) to highlight by
// saying the mouse just moved, but sending the same coordinates.
DWORD pos = GetMessagePos();
POINT cursor_point = {GET_X_LPARAM(pos), GET_Y_LPARAM(pos)};
MapWindowPoints(NULL, widget->GetNativeView(), &cursor_point, 1);
+
+ static_cast<views::WidgetWin*>(widget)->ResetLastMouseMoveFlag();
+ // Return to message loop - otherwise we may disrupt some operation that's
+ // in progress.
SendMessage(widget->GetNativeView(), WM_MOUSEMOVE, 0,
MAKELPARAM(cursor_point.x, cursor_point.y));
#else
diff --git a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
index 0045a8b..cb0965c 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
@@ -203,7 +203,8 @@ class DraggedTabController::DockDisplayer : public ui::AnimationDelegate {
hidden_(false),
in_enable_area_(info.in_enable_area()) {
#if defined(OS_WIN)
- popup_ = new views::Widget;
+ popup_ = views::Widget::CreateWidget();
+ popup_->SetOpacity(0x00);
// TODO(sky): This should "just work" on Gtk now.
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
@@ -211,7 +212,6 @@ class DraggedTabController::DockDisplayer : public ui::AnimationDelegate {
params.bounds = info.GetPopupRect();
popup_->Init(params);
popup_->SetContentsView(new DockView(info.type()));
- popup_->SetOpacity(0x00);
if (info.in_enable_area())
animation_.Reset(1);
else
@@ -265,15 +265,23 @@ class DraggedTabController::DockDisplayer : public ui::AnimationDelegate {
virtual void AnimationEnded(const ui::Animation* animation) {
if (!hidden_)
return;
- popup_->Close();
+#if defined(OS_WIN)
+ static_cast<views::WidgetWin*>(popup_)->Close();
+#else
+ NOTIMPLEMENTED();
+#endif
delete this;
}
virtual void UpdateLayeredAlpha() {
+#if defined(OS_WIN)
double scale = in_enable_area_ ? 1 : .5;
- popup_->SetOpacity(static_cast<unsigned char>(animation_.GetCurrentValue() *
- scale * 255.0));
+ static_cast<views::WidgetWin*>(popup_)->SetOpacity(
+ static_cast<BYTE>(animation_.GetCurrentValue() * scale * 255.0));
popup_->GetRootView()->SchedulePaint();
+#else
+ NOTIMPLEMENTED();
+#endif
}
private:
diff --git a/chrome/browser/ui/views/tabs/dragged_tab_view.cc b/chrome/browser/ui/views/tabs/dragged_tab_view.cc
index ce763ba..b099339 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/ui/views/tabs/dragged_tab_view.cc
@@ -39,16 +39,9 @@ DraggedTabView::DraggedTabView(const std::vector<views::View*>& renderers,
contents_size_(contents_size) {
set_parent_owned(false);
- container_.reset(new views::Widget);
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
- params.transparent = true;
- params.keep_on_top = true;
- params.delete_on_destroy = false;
- params.bounds = gfx::Rect(PreferredContainerSize());
- container_->Init(params);
- container_->SetContentsView(this);
+ container_.reset(views::Widget::CreateWidget());
#if defined(OS_WIN)
- static_cast<views::WidgetWin*>(container_->native_widget())->
+ static_cast<views::WidgetWin*>(container_.get())->
set_can_update_layered_window(false);
BOOL drag;
@@ -57,6 +50,13 @@ DraggedTabView::DraggedTabView(const std::vector<views::View*>& renderers,
show_contents_on_drag_ = false;
}
#endif
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
+ params.transparent = true;
+ params.keep_on_top = true;
+ params.delete_on_destroy = false;
+ params.bounds = gfx::Rect(PreferredContainerSize());
+ container_->Init(params);
+ container_->SetContentsView(this);
container_->SetOpacity(kTransparentAlpha);
container_->SetBounds(gfx::Rect(gfx::Point(), params.bounds.size()));
}
diff --git a/chrome/browser/ui/views/tabs/native_view_photobooth_win.cc b/chrome/browser/ui/views/tabs/native_view_photobooth_win.cc
index 4bfd3609..a010e3d 100644
--- a/chrome/browser/ui/views/tabs/native_view_photobooth_win.cc
+++ b/chrome/browser/ui/views/tabs/native_view_photobooth_win.cc
@@ -151,7 +151,7 @@ void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) {
gfx::Rect capture_bounds(window_position.x(), window_position.y(),
contents_rect.right - contents_rect.left,
contents_rect.bottom - contents_rect.top);
- capture_window_ = new views::Widget;
+ capture_window_ = views::Widget::CreateWidget();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.bounds = capture_bounds;
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index e3f62d2..bafe9a1 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -450,7 +450,7 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) {
int tab_id;
if (GetWidget() &&
- GetWidget()->GetContainingWindow()->non_client_view()->UseNativeFrame()) {
+ GetWidget()->GetWindow()->non_client_view()->UseNativeFrame()) {
tab_id = IDR_THEME_TAB_BACKGROUND_V;
} else {
tab_id = data().incognito ? 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 15790fa..45c9545 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -860,7 +860,7 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
arrow_view = new views::ImageView;
arrow_view->SetImage(GetDropArrowImage(point_down));
- arrow_window = new views::Widget;
+ arrow_window = views::Widget::CreateWidget();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.keep_on_top = true;
params.transparent = true;
diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc
index 93ee630..eef260f 100644
--- a/chrome/browser/ui/views/task_manager_view.cc
+++ b/chrome/browser/ui/views/task_manager_view.cc
@@ -561,7 +561,7 @@ void TaskManagerView::Show(bool highlight_background_resources) {
if (instance_) {
if (instance_->highlight_background_resources_ !=
highlight_background_resources) {
- instance_->window()->Close();
+ instance_->window()->CloseWindow();
} else {
// If there's a Task manager window open already, just activate it.
instance_->window()->Activate();
diff --git a/chrome/browser/ui/views/theme_install_bubble_view.cc b/chrome/browser/ui/views/theme_install_bubble_view.cc
index b099af95..9f35eff 100644
--- a/chrome/browser/ui/views/theme_install_bubble_view.cc
+++ b/chrome/browser/ui/views/theme_install_bubble_view.cc
@@ -70,14 +70,14 @@ ThemeInstallBubbleView::ThemeInstallBubbleView(TabContents* tab_contents)
NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
NotificationService::AllSources());
- popup_ = new views::Widget;
+ popup_ = views::Widget::CreateWidget();
+ popup_->SetOpacity(0xCC);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.accept_events = false;
params.parent = tab_contents->GetNativeView();
popup_->Init(params);
popup_->SetContentsView(this);
- popup_->SetOpacity(0xCC);
Reposition();
popup_->Show();