summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/frame/browser_frame_view_chromeos.cc2
-rw-r--r--chrome/browser/chromeos/frame/browser_view.cc15
-rw-r--r--chrome/browser/chromeos/frame/bubble_frame_view.cc2
-rw-r--r--chrome/browser/chromeos/frame/bubble_window.cc10
-rw-r--r--chrome/browser/chromeos/frame/bubble_window.h2
-rw-r--r--chrome/browser/chromeos/frame/dom_browser_view.cc2
-rw-r--r--chrome/browser/chromeos/frame/panel_controller.cc2
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window.cc2
-rw-r--r--chrome/browser/chromeos/login/background_view.cc2
-rw-r--r--chrome/browser/chromeos/login/helper.cc6
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc19
-rw-r--r--chrome/browser/chromeos/login/user_controller.cc2
-rw-r--r--chrome/browser/chromeos/login/user_controller_gtk.cc15
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc2
-rw-r--r--chrome/browser/chromeos/native_dialog_window.cc2
-rw-r--r--chrome/browser/chromeos/notifications/balloon_view.cc2
-rw-r--r--chrome/browser/chromeos/notifications/notification_panel.cc13
-rw-r--r--chrome/browser/chromeos/panels/panel_scroller.cc2
-rw-r--r--chrome/browser/external_tab_container_win.cc15
-rw-r--r--chrome/browser/first_run/try_chrome_dialog_view.cc2
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc5
-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
-rw-r--r--chrome/chrome_browser.gypi22
-rw-r--r--chrome/test/interactive_ui/view_event_test_base.cc2
-rw-r--r--content/browser/tab_contents/tab_contents.h2
-rw-r--r--views/accessibility/native_view_accessibility_win.cc2
-rw-r--r--views/controls/combobox/native_combobox_views_unittest.cc2
-rw-r--r--views/controls/menu/menu_host.cc24
-rw-r--r--views/controls/menu/menu_host.h11
-rw-r--r--views/controls/menu/menu_host_gtk.cc13
-rw-r--r--views/controls/menu/menu_host_gtk.h4
-rw-r--r--views/controls/menu/menu_host_win.cc13
-rw-r--r--views/controls/menu/menu_host_win.h4
-rw-r--r--views/controls/menu/native_menu_host_delegate.h6
-rw-r--r--views/controls/native/native_view_host_gtk.cc2
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.cc14
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.h4
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_win.cc2
-rw-r--r--views/controls/tabbed_pane/tabbed_pane_unittest.cc2
-rw-r--r--views/controls/table/table_view_unittest.cc4
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc2
-rw-r--r--views/controls/textfield/native_textfield_views_unittest.cc2
-rw-r--r--views/examples/widget_example.cc6
-rw-r--r--views/focus/accelerator_handler_gtk_unittest.cc5
-rw-r--r--views/focus/focus_manager_gtk.cc2
-rw-r--r--views/focus/focus_manager_unittest.cc46
-rw-r--r--views/focus/view_storage.cc2
-rw-r--r--views/focus/view_storage.h2
-rw-r--r--views/view.cc2
-rw-r--r--views/view_unittest.cc218
-rw-r--r--views/widget/drop_target_gtk.cc10
-rw-r--r--views/widget/native_widget.h26
-rw-r--r--views/widget/native_widget_delegate.h4
-rw-r--r--views/widget/native_widget_test_utils_gtk.cc4
-rw-r--r--views/widget/native_widget_test_utils_win.cc4
-rw-r--r--views/widget/tooltip_manager_gtk.cc6
-rw-r--r--views/widget/widget.cc59
-rw-r--r--views/widget/widget.h92
-rw-r--r--views/widget/widget_gtk.cc223
-rw-r--r--views/widget/widget_gtk.h59
-rw-r--r--views/widget/widget_win.cc192
-rw-r--r--views/widget/widget_win.h42
-rw-r--r--views/widget/widget_win_unittest.cc2
-rw-r--r--views/window/custom_frame_view.cc2
-rw-r--r--views/window/dialog_client_view.cc2
-rw-r--r--views/window/native_frame_view.cc12
-rw-r--r--views/window/native_frame_view.h6
-rw-r--r--views/window/native_window.h7
-rw-r--r--views/window/native_window_delegate.h10
-rw-r--r--views/window/window.cc63
-rw-r--r--views/window/window.h32
-rw-r--r--views/window/window_gtk.cc69
-rw-r--r--views/window/window_gtk.h10
-rw-r--r--views/window/window_win.cc93
-rw-r--r--views/window/window_win.h12
149 files changed, 1760 insertions, 2184 deletions
diff --git a/chrome/browser/chromeos/frame/browser_frame_view_chromeos.cc b/chrome/browser/chromeos/frame/browser_frame_view_chromeos.cc
index 9841d72..ee07456 100644
--- a/chrome/browser/chromeos/frame/browser_frame_view_chromeos.cc
+++ b/chrome/browser/chromeos/frame/browser_frame_view_chromeos.cc
@@ -49,7 +49,7 @@ views::View* BrowserFrameViewChromeos::GetEventHandlerForPoint(
const gfx::Point& point) {
if (point.y() < kTopPad) {
gfx::Point nc_point(point.x(), kTopPad);
- views::NonClientView* nc_view = frame()->GetWindow()->non_client_view();
+ views::NonClientView* nc_view = frame()->non_client_view();
View::ConvertPointToView(this, nc_view, &nc_point);
return nc_view->GetEventHandlerForPoint(nc_point);
}
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc
index 4a64ad6..2134ee6 100644
--- a/chrome/browser/chromeos/frame/browser_view.cc
+++ b/chrome/browser/chromeos/frame/browser_view.cc
@@ -240,12 +240,7 @@ void BrowserView::Init() {
status_area_->Init();
InitSystemMenu();
- // The ContextMenuController has to be set to a NonClientView but
- // not to a NonClientFrameView because a TabStrip is not a child of
- // a NonClientFrameView even though visually a TabStrip is over a
- // NonClientFrameView.
- BrowserFrameGtk* gtk_frame = static_cast<BrowserFrameGtk*>(frame());
- gtk_frame->non_client_view()->SetContextMenuController(this);
+ frame()->non_client_view()->SetContextMenuController(this);
// Listen to wrench menu opens.
if (toolbar())
@@ -257,7 +252,7 @@ void BrowserView::Init() {
params.push_back(browser()->active_index());
params.push_back(gtk_get_current_event_time());
WmIpc::instance()->SetWindowType(
- GTK_WIDGET(frame()->GetWindow()->GetNativeWindow()),
+ GTK_WIDGET(frame()->GetNativeWindow()),
WM_IPC_WINDOW_CHROME_TOPLEVEL,
&params);
}
@@ -271,7 +266,7 @@ void BrowserView::ShowInactive() {
}
void BrowserView::ShowInternal(bool is_active) {
- bool was_visible = frame()->GetWindow()->IsVisible();
+ bool was_visible = frame()->IsVisible();
if (is_active)
::BrowserView::Show();
else
@@ -282,7 +277,7 @@ void BrowserView::ShowInternal(bool is_active) {
params.push_back(browser()->tab_count());
params.push_back(browser()->active_index());
WmIpc::instance()->SetWindowType(
- GTK_WIDGET(frame()->GetWindow()->GetNativeWindow()),
+ GTK_WIDGET(frame()->GetNativeWindow()),
WM_IPC_WINDOW_CHROME_TOPLEVEL,
&params);
}
@@ -435,6 +430,6 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
view = new chromeos::PanelBrowserView(browser);
else
view = new chromeos::BrowserView(browser);
- BrowserFrame::Create(view, browser->profile());
+ (new BrowserFrame(view))->InitBrowserFrame();
return view;
}
diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc
index b7ab455..ebc0abf 100644
--- a/chrome/browser/chromeos/frame/bubble_frame_view.cc
+++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc
@@ -228,7 +228,7 @@ void BubbleFrameView::OnPaint(gfx::Canvas* canvas) {
void BubbleFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (close_button_ != NULL && sender == close_button_)
- frame_->CloseWindow();
+ frame_->Close();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/frame/bubble_window.cc b/chrome/browser/chromeos/frame/bubble_window.cc
index a530438..4b1ff08 100644
--- a/chrome/browser/chromeos/frame/bubble_window.cc
+++ b/chrome/browser/chromeos/frame/bubble_window.cc
@@ -30,7 +30,8 @@ namespace chromeos {
// static
const SkColor BubbleWindow::kBackgroundColor = SK_ColorWHITE;
-BubbleWindow::BubbleWindow() {
+BubbleWindow::BubbleWindow(views::Window* window)
+ : views::WindowGtk::WindowGtk(window) {
MakeTransparent();
}
@@ -58,7 +59,7 @@ void BubbleWindow::InitNativeWidget(const views::Widget::InitParams& params) {
void BubbleWindow::TrimMargins(int margin_left, int margin_right,
int margin_top, int margin_bottom,
int border_radius) {
- gfx::Size size = non_client_view()->GetPreferredSize();
+ gfx::Size size = GetWindow()->non_client_view()->GetPreferredSize();
const int w = size.width() - margin_left - margin_right;
const int h = size.height() - margin_top - margin_bottom;
GdkRectangle rect0 = {0, border_radius, w, h - 2 * border_radius};
@@ -113,14 +114,17 @@ views::Window* BubbleWindow::Create(
const gfx::Rect& bounds,
Style style,
views::WindowDelegate* window_delegate) {
- views::Window* window = new BubbleWindow();
+ views::Window* window = new views::Window;
+ BubbleWindow* bubble_window = new BubbleWindow(window);
window->non_client_view()->SetFrameView(
new BubbleFrameView(window, window_delegate, style));
views::Window::InitParams params(window_delegate);
params.parent_window = parent;
+ params.native_window = bubble_window;
params.widget_init_params.parent = GTK_WIDGET(parent);
params.widget_init_params.bounds = bounds;
params.widget_init_params.parent = GTK_WIDGET(parent);
+ params.widget_init_params.native_widget = bubble_window;
window->InitWindow(params);
if (style == STYLE_XSHAPE) {
diff --git a/chrome/browser/chromeos/frame/bubble_window.h b/chrome/browser/chromeos/frame/bubble_window.h
index bf69687..070e745 100644
--- a/chrome/browser/chromeos/frame/bubble_window.h
+++ b/chrome/browser/chromeos/frame/bubble_window.h
@@ -38,7 +38,7 @@ class BubbleWindow : public views::WindowGtk {
static const SkColor kBackgroundColor;
protected:
- BubbleWindow();
+ explicit BubbleWindow(views::Window* window);
// Overidden from views::WindowGtk:
virtual void InitNativeWidget(
diff --git a/chrome/browser/chromeos/frame/dom_browser_view.cc b/chrome/browser/chromeos/frame/dom_browser_view.cc
index 5dd25af..9906b95 100644
--- a/chrome/browser/chromeos/frame/dom_browser_view.cc
+++ b/chrome/browser/chromeos/frame/dom_browser_view.cc
@@ -20,7 +20,7 @@ DOMBrowserView::~DOMBrowserView() {}
// static
BrowserWindow* DOMBrowserView::CreateDOMWindow(Browser* browser) {
DOMBrowserView* view = new DOMBrowserView(browser);
- BrowserFrame::Create(view, browser->profile());
+ (new BrowserFrame(view))->InitBrowserFrame();
return view;
}
diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc
index 3b2a932..2e82b3a 100644
--- a/chrome/browser/chromeos/frame/panel_controller.cc
+++ b/chrome/browser/chromeos/frame/panel_controller.cc
@@ -183,7 +183,7 @@ void PanelController::Init(bool initial_focus,
WmIpcPanelUserResizeType resize_type) {
gfx::Rect title_bounds(0, 0, window_bounds.width(), kTitleHeight);
- title_window_ = views::Widget::CreateWidget();
+ title_window_ = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.transparent = true;
params.bounds = title_bounds;
diff --git a/chrome/browser/chromeos/input_method/candidate_window.cc b/chrome/browser/chromeos/input_method/candidate_window.cc
index c1c7d64..96afc5c 100644
--- a/chrome/browser/chromeos/input_method/candidate_window.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window.cc
@@ -1281,7 +1281,7 @@ bool CandidateWindowController::Impl::Init() {
void CandidateWindowController::Impl::CreateView() {
// Create a non-decorated frame.
- frame_.reset(views::Widget::CreateWidget());
+ frame_.reset(new views::Widget);
// The size is initially zero.
frame_->Init(
views::Widget::InitParams(views::Widget::InitParams::TYPE_POPUP));
diff --git a/chrome/browser/chromeos/login/background_view.cc b/chrome/browser/chromeos/login/background_view.cc
index 249d9b0..9db4d5f 100644
--- a/chrome/browser/chromeos/login/background_view.cc
+++ b/chrome/browser/chromeos/login/background_view.cc
@@ -143,7 +143,7 @@ views::Widget* BackgroundView::CreateWindowContainingView(
BackgroundView** view) {
ResetXCursor();
- Widget* window = Widget::CreateWidget();
+ Widget* window = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.bounds = bounds;
window->Init(params);
diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc
index 3b35d0f..5eb5438 100644
--- a/chrome/browser/chromeos/login/helper.cc
+++ b/chrome/browser/chromeos/login/helper.cc
@@ -103,12 +103,10 @@ void ThrobberHostView::StartThrobber() {
views::SmoothedThrobber* throbber = CreateDefaultSmoothedThrobber();
throbber->set_stop_delay_ms(0);
gfx::Rect throbber_bounds = CalculateThrobberBounds(throbber);
+ throbber_bounds.Offset(host_view_->GetScreenBounds().origin());
- throbber_widget_ = views::Widget::CreateWidget();
- static_cast<views::WidgetGtk*>(throbber_widget_->native_widget())->
- make_transient_to_parent();
+ throbber_widget_ = new views::Widget;
- throbber_bounds.Offset(host_view_->GetScreenBounds().origin());
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.bounds = throbber_bounds;
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index 7971a35..2189333 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -198,7 +198,9 @@ static base::LazyInstance<ScreenLockObserver> g_screen_lock_observer(
// focus/events inside the grab widget.
class LockWindow : public views::WidgetGtk {
public:
- LockWindow() : toplevel_focus_widget_(NULL) {
+ LockWindow()
+ : views::WidgetGtk(new views::Widget),
+ toplevel_focus_widget_(NULL) {
EnableDoubleBuffer(true);
}
@@ -289,7 +291,8 @@ class GrabWidgetRootView
class GrabWidget : public views::WidgetGtk {
public:
explicit GrabWidget(chromeos::ScreenLocker* screen_locker)
- : screen_locker_(screen_locker),
+ : views::WidgetGtk(new views::Widget),
+ screen_locker_(screen_locker),
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
grab_failure_count_(0),
kbd_grab_status_(GDK_GRAB_INVALID_TIME),
@@ -730,9 +733,10 @@ void ScreenLocker::Init() {
gfx::Rect init_bounds(views::Screen::GetMonitorAreaNearestPoint(left_top));
LockWindow* lock_window = new LockWindow();
- lock_window_ = lock_window;
+ lock_window_ = lock_window->GetWidget();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = init_bounds;
+ params.native_widget = lock_window;
lock_window_->Init(params);
gtk_widget_modify_bg(
lock_window_->GetNativeView(), GTK_STATE_NORMAL, &kGdkBlack);
@@ -755,12 +759,13 @@ void ScreenLocker::Init() {
// TryGrabAllInputs() method later. (Nobody else needs to use it, so moving
// its declaration to the header instead of keeping it in an anonymous
// namespace feels a bit ugly.)
- GrabWidget* cast_lock_widget = new GrabWidget(this);
- lock_widget_ = cast_lock_widget;
+ GrabWidget* grab_widget = new GrabWidget(this);
+ lock_widget_ = grab_widget->GetWidget();
views::Widget::InitParams lock_params(
views::Widget::InitParams::TYPE_CONTROL);
lock_params.transparent = true;
lock_params.parent_widget = lock_window_;
+ lock_params.native_widget = grab_widget;
lock_widget_->Init(lock_params);
if (screen_lock_view_) {
GrabWidgetRootView* root_view = new GrabWidgetRootView(screen_lock_view_);
@@ -790,11 +795,11 @@ void ScreenLocker::Init() {
lock_window_->SetContentsView(background_view_);
lock_window_->Show();
- cast_lock_widget->ClearGtkGrab();
+ grab_widget->ClearGtkGrab();
// Call this after lock_window_->Show(); otherwise the 1st invocation
// of gdk_xxx_grab() will always fail.
- cast_lock_widget->TryGrabAllInputs();
+ grab_widget->TryGrabAllInputs();
// Add the window to its own group so that its grab won't be stolen if
// gtk_grab_add() gets called on behalf on a non-screen-locker widget (e.g.
diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc
index 74cd658..0be3961 100644
--- a/chrome/browser/chromeos/login/user_controller.cc
+++ b/chrome/browser/chromeos/login/user_controller.cc
@@ -419,7 +419,7 @@ void UserController::CreateBorderWindow(int index,
height += 2 * kBorderSize + kUserImageSize + kVerticalIntervalSize;
}
- border_window_ = Widget::CreateWidget();
+ border_window_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.transparent = true;
params.bounds = gfx::Rect(0, 0, width, height);
diff --git a/chrome/browser/chromeos/login/user_controller_gtk.cc b/chrome/browser/chromeos/login/user_controller_gtk.cc
index 941a424..2edef3e 100644
--- a/chrome/browser/chromeos/login/user_controller_gtk.cc
+++ b/chrome/browser/chromeos/login/user_controller_gtk.cc
@@ -14,7 +14,7 @@ namespace {
class ControlsWidget : public WidgetGtk {
public:
- ControlsWidget() {
+ ControlsWidget() : WidgetGtk(new views::Widget) {
}
private:
@@ -38,7 +38,8 @@ class ControlsWidget : public WidgetGtk {
class ClickNotifyingWidget : public WidgetGtk {
public:
explicit ClickNotifyingWidget(UserController* controller)
- : controller_(controller) {
+ : WidgetGtk(new views::Widget),
+ controller_(controller) {
}
private:
@@ -54,14 +55,16 @@ class ClickNotifyingWidget : public WidgetGtk {
DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget);
};
-views::Widget* InitWidget(views::Widget* widget, const gfx::Rect& bounds) {
+views::Widget* InitWidget(views::NativeWidget* native_widget,
+ const gfx::Rect& bounds) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.transparent = true;
params.bounds = bounds;
- widget->Init(params);
- GdkWindow* gdk_window = widget->GetNativeView()->window;
+ params.native_widget = native_widget;
+ native_widget->GetWidget()->Init(params);
+ GdkWindow* gdk_window = native_widget->GetWidget()->GetNativeView()->window;
gdk_window_set_back_pixmap(gdk_window, NULL, false);
- return widget;
+ return native_widget->GetWidget();
}
} // namespace
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index d04aae1..2580f39 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -580,7 +580,7 @@ void WizardController::InitiateOOBEUpdate() {
views::Widget* WizardController::CreateScreenWindow(
const gfx::Rect& bounds, bool initial_show) {
- widget_ = views::Widget::CreateWidget();
+ widget_ = new views::Widget;
views::Widget::InitParams widget_params(
views::Widget::InitParams::TYPE_WINDOW);
// Window transparency makes background flicker through controls that
diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc
index 61ed3c8..7960580 100644
--- a/chrome/browser/chromeos/native_dialog_window.cc
+++ b/chrome/browser/chromeos/native_dialog_window.cc
@@ -155,7 +155,7 @@ void NativeDialogHost::OnCheckResize(GtkWidget* widget) {
void NativeDialogHost::OnDialogDestroy(GtkWidget* widget) {
dialog_ = NULL;
destroy_signal_id_ = 0;
- window()->CloseWindow();
+ window()->Close();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/chromeos/notifications/balloon_view.cc b/chrome/browser/chromeos/notifications/balloon_view.cc
index 8264192..61ee225 100644
--- a/chrome/browser/chromeos/notifications/balloon_view.cc
+++ b/chrome/browser/chromeos/notifications/balloon_view.cc
@@ -267,7 +267,7 @@ void BalloonViewImpl::Layout() {
void BalloonViewImpl::ViewHierarchyChanged(
bool is_add, View* parent, View* child) {
if (is_add && GetWidget() && !control_view_host_.get() && controls_) {
- control_view_host_.reset(views::Widget::CreateWidget());
+ control_view_host_.reset(new views::Widget);
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_CONTROL);
params.double_buffer = true;
diff --git a/chrome/browser/chromeos/notifications/notification_panel.cc b/chrome/browser/chromeos/notifications/notification_panel.cc
index 4711f6b..9902529 100644
--- a/chrome/browser/chromeos/notifications/notification_panel.cc
+++ b/chrome/browser/chromeos/notifications/notification_panel.cc
@@ -72,8 +72,7 @@ chromeos::BalloonViewImpl* GetBalloonViewOf(const Balloon* balloon) {
// renderer's native gtk widgets are moved one by one via
// View::VisibleBoundsInRootChanged() notification, which makes scrolling not
// smooth.
-// TODO: this should subclass Widget and not WidgetGtk.
-class ViewportWidget : public views::WidgetGtk {
+class ViewportWidget : public views::Widget {
public:
explicit ViewportWidget(chromeos::NotificationPanel* panel)
: panel_(panel),
@@ -425,7 +424,7 @@ NotificationPanel::~NotificationPanel() {
void NotificationPanel::Show() {
if (!panel_widget_) {
- panel_widget_ = views::Widget::CreateWidget();
+ panel_widget_ = new views::Widget;
// TODO(oshima): Using window because Popup widget behaves weird
// when resizing. This needs to be investigated.
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
@@ -447,15 +446,15 @@ void NotificationPanel::Show() {
panel_widget_->SetContentsView(scroll_view_.get());
// Add the view port after scroll_view is attached to the panel widget.
- ViewportWidget* widget = new ViewportWidget(this);
- container_host_ = widget;
+ ViewportWidget* viewport_widget = new ViewportWidget(this);
+ container_host_ = viewport_widget;
container_host_->Init(
views::Widget::InitParams(views::Widget::InitParams::TYPE_CONTROL));
container_host_->SetContentsView(balloon_container_.get());
// The window_contents_ is onwed by the Widget. Increase ref count
// so that window_contents does not get deleted when detached.
- g_object_ref(widget->window_contents());
- native->Attach(widget->window_contents());
+ g_object_ref(viewport_widget->GetNativeView());
+ native->Attach(viewport_widget->GetNativeView());
UnregisterNotification();
panel_controller_.reset(
diff --git a/chrome/browser/chromeos/panels/panel_scroller.cc b/chrome/browser/chromeos/panels/panel_scroller.cc
index c09a912..5680da1 100644
--- a/chrome/browser/chromeos/panels/panel_scroller.cc
+++ b/chrome/browser/chromeos/panels/panel_scroller.cc
@@ -80,7 +80,7 @@ PanelScroller::~PanelScroller() {
// static
PanelScroller* PanelScroller::CreateWindow() {
- views::Widget* widget = views::Widget::CreateWidget();
+ views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 100, 800);
widget->Init(params);
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index dd9784b..b3787d7 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -87,7 +87,8 @@ base::LazyInstance<ExternalTabContainer::PendingTabs>
ExternalTabContainer::ExternalTabContainer(
AutomationProvider* automation, AutomationResourceMessageFilter* filter)
- : automation_(automation),
+ : views::WidgetWin(new views::Widget),
+ automation_(automation),
tab_contents_container_(NULL),
tab_handle_(0),
ignore_next_load_notification_(false),
@@ -137,6 +138,7 @@ bool ExternalTabContainer::Init(Profile* profile,
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.bounds = bounds;
+ params.native_widget = this;
GetWidget()->Init(params);
if (!IsWindow()) {
NOTREACHED();
@@ -217,9 +219,8 @@ void ExternalTabContainer::Uninitialize() {
if (tab_contents_.get()) {
UnregisterRenderViewHost(tab_contents_->render_view_host());
- if (GetRootView()) {
- GetRootView()->RemoveAllChildViews(true);
- }
+ if (GetWidget()->GetRootView())
+ GetWidget()->GetRootView()->RemoveAllChildViews(true);
NotificationService::current()->Notify(
NotificationType::EXTERNAL_TAB_CLOSED,
@@ -571,7 +572,7 @@ void ExternalTabContainer::ShowPageInfo(Profile* profile,
PageInfoBubbleView* page_info_bubble =
new ExternalTabPageInfoBubbleView(this, NULL, profile, url,
ssl, show_history);
- Bubble* bubble = Bubble::Show(this, bounds, BubbleBorder::TOP_LEFT,
+ Bubble* bubble = Bubble::Show(GetWidget(), bounds, BubbleBorder::TOP_LEFT,
page_info_bubble, page_info_bubble);
page_info_bubble->set_bubble(bubble);
}
@@ -1002,7 +1003,7 @@ void ExternalTabContainer::LoadAccelerators() {
CopyAcceleratorTable(accelerator_table, accelerators, count);
- focus_manager_ = GetFocusManager();
+ focus_manager_ = GetWidget()->GetFocusManager();
DCHECK(focus_manager_);
// Let's fill our own accelerator table.
@@ -1078,7 +1079,7 @@ void ExternalTabContainer::SetupExternalTabView() {
layout->AddView(info_bar_container);
layout->StartRow(1, 0);
layout->AddView(tab_contents_container_);
- SetContentsView(external_tab_view_);
+ GetWidget()->SetContentsView(external_tab_view_);
// Note that SetTabContents must be called after AddChildView is called
tab_contents_container_->ChangeTabContents(tab_contents());
}
diff --git a/chrome/browser/first_run/try_chrome_dialog_view.cc b/chrome/browser/first_run/try_chrome_dialog_view.cc
index 8509bdd..3d07f11 100644
--- a/chrome/browser/first_run/try_chrome_dialog_view.cc
+++ b/chrome/browser/first_run/try_chrome_dialog_view.cc
@@ -66,7 +66,7 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal(
gfx::Size icon_size = icon->GetPreferredSize();
// An approximate window size. After Layout() we'll get better bounds.
- popup_ = views::Widget::CreateWidget();
+ popup_ = new views::Widget;
if (!popup_) {
NOTREACHED();
return DIALOG_ERROR;
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index f5bbf4e..e51751b 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -868,7 +868,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5VideoJs) {
}
// Checks that scripts can retrieve the correct window size while prerendering.
+#if defined(TOOLKIT_VIEWS)
+// TODO(beng): Widget hierarchy split causes this to fail http://crbug.com/82363
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderWindowSize) {
+#else
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowSize) {
+#endif
PrerenderTestURL("files/prerender/prerender_size.html",
FINAL_STATUS_USED,
1);
diff --git a/chrome/browser/ui/browser_list_win.cc b/chrome/browser/ui/browser_list_win.cc
index b29a938..9c8fe46 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/window/window.h"
+#include "views/widget/widget.h"
// static
void BrowserList::AllBrowsersClosedAndAppExiting() {
- views::Window::CloseAllSecondaryWindows();
+ views::Widget::CloseAllSecondaryWidgets();
}
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 a34b0c5..30f2f70 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -839,11 +839,8 @@ 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::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);
+ browser()->AddBlankTab(true);
+ ui_test_utils::NavigateToURL(browser(), url);
TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper();
EXPECT_NE(tab1, tab2);
@@ -963,11 +960,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) {
FindBarController::kKeepSelection);
// Now create a second tab and load the same page.
- 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);
+ browser()->AddBlankTab(true);
+ ui_test_utils::NavigateToURL(browser(), url);
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 a6c2621..2078151 100644
--- a/chrome/browser/ui/gtk/constrained_window_gtk.cc
+++ b/chrome/browser/ui/gtk/constrained_window_gtk.cc
@@ -13,6 +13,9 @@
#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
@@ -120,7 +123,13 @@ 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 b703409..700f47c 100644
--- a/chrome/browser/ui/gtk/constrained_window_gtk.h
+++ b/chrome/browser/ui/gtk/constrained_window_gtk.h
@@ -18,6 +18,8 @@ class TabContents;
typedef struct _GdkColor GdkColor;
#if defined(TOUCH_UI)
class TabContentsViewTouch;
+#elif defined(TOOLKIT_VIEWS)
+class NativeTabContentsViewGtk;
#else
class TabContentsViewGtk;
#endif
@@ -50,6 +52,8 @@ 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 058ffd1..7012d10 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_->CloseWindow();
+ window_->Close();
}
// static
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index a353dd5..ee035f2 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_->GetWindow()->client_view()->NonClientHitTest(point);
+ frame_->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_->GetWindow()->window_delegate()->CanResize());
+ frame_->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_->GetWindow()->CloseWindow();
+ frame_->Close();
}
void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) {
@@ -392,7 +392,7 @@ bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() {
- return frame_->GetWindow()->window_delegate()->GetWindowIcon();
+ return frame_->window_delegate()->GetWindowIcon();
}
int PanelBrowserFrameView::NonClientBorderThickness() const {
@@ -514,7 +514,7 @@ void PanelBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) {
void PanelBrowserFrameView::UpdateTitleBar() {
title_label_->SetText(
- frame_->GetWindow()->window_delegate()->GetWindowTitle());
+ frame_->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 0883866..6c6a63a 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);
- BrowserFrame::Create(view, browser->profile());
+ (new BrowserFrame(view))->InitBrowserFrame();
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 d724051..a3ec9ae 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -117,6 +117,22 @@ 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
@@ -208,6 +224,7 @@ 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)),
@@ -279,7 +296,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_.reset();
+ popup_ = NULL;
}
return;
}
@@ -328,16 +345,16 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
if (popup_ == NULL) {
// If the popup is currently closed, we need to create it.
- popup_ = (new AutocompletePopupClass)->AsWeakPtr();
+ popup_ = new views::Widget;
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_->GetWidget()->Init(params);
+ popup_->Init(params);
popup_->SetContentsView(this);
- popup_->MoveAbove(popup_->GetRelativeWindowForPopup(
- omnibox_view_->GetNativeView()));
+ popup_->MoveAbove(
+ 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 7673bf0..88f5160 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
@@ -16,12 +16,6 @@
#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;
@@ -105,11 +99,6 @@ 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.
@@ -144,11 +133,8 @@ class AutocompletePopupContentsView : public views::View,
// view.
void UserPressedOptIn(bool opt_in);
- // 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 popup that contains this view.
+ views::Widget* 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
deleted file mode 100644
index d0299a8..0000000
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc
+++ /dev/null
@@ -1,23 +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/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
deleted file mode 100644
index ba07afc..0000000
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h
+++ /dev/null
@@ -1,29 +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_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
deleted file mode 100644
index 37dbf1e..0000000
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.cc
+++ /dev/null
@@ -1,25 +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/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
deleted file mode 100644
index 2f369e2..0000000
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h
+++ /dev/null
@@ -1,29 +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_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 997327f..f6103bd 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_->CloseWindow();
+ window_->Close();
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 1a960db..912a5b9 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();
- static_cast<Bubble*>(GetWidget())->Close();
+ GetWidget()->Close();
}
void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) {
@@ -387,7 +387,8 @@ void BookmarkBubbleView::ShowEditor() {
ShowWindow(GetWidget()->GetNativeView(), SW_HIDE);
#elif defined(TOOLKIT_USES_GTK)
gfx::NativeWindow parent = GTK_WINDOW(
- static_cast<views::WidgetGtk*>(GetWidget())->GetTransientParent());
+ static_cast<views::WidgetGtk*>(GetWidget()->native_widget())->
+ 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 b8e25ef..4690ce0 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()->CloseWindow();
+ window()->Close();
}
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()->CloseWindow();
+ window()->Close();
} else {
Reset();
}
diff --git a/chrome/browser/ui/views/browser_bubble.cc b/chrome/browser/ui/views/browser_bubble.cc
index 53541d7..d87180d 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->GetWindow();
+ views::Window* window = frame->GetContainingWindow();
if (window) {
bubble_host = BrowserView::GetBrowserViewForNativeWindow(
window->GetNativeWindow());
@@ -38,7 +38,6 @@ 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)) {
@@ -94,7 +93,7 @@ void BrowserBubble::BrowserWindowMoved() {
delegate_->BubbleBrowserWindowMoved(this);
else
Hide();
- if (visible_)
+ if (popup_->IsVisible())
Reposition();
}
@@ -144,3 +143,9 @@ 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 64eb87e..c74d40b 100644
--- a/chrome/browser/ui/views/browser_bubble.h
+++ b/chrome/browser/ui/views/browser_bubble.h
@@ -73,7 +73,6 @@ 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_; }
@@ -127,9 +126,6 @@ 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 bf905ed..4339e05 100644
--- a/chrome/browser/ui/views/browser_bubble_gtk.cc
+++ b/chrome/browser/ui/views/browser_bubble_gtk.cc
@@ -23,7 +23,8 @@ namespace {
class BubbleWidget : public views::WidgetGtk {
public:
BubbleWidget(BrowserBubble* bubble, const gfx::Insets& content_margins)
- : bubble_(bubble),
+ : views::WidgetGtk(new views::Widget),
+ bubble_(bubble),
border_contents_(new BorderContents) {
border_contents_->Init();
border_contents_->set_content_margins(content_margins);
@@ -47,7 +48,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);
@@ -92,18 +93,19 @@ class BubbleWidget : public views::WidgetGtk {
void BrowserBubble::InitPopup(const gfx::Insets& content_margins) {
// TODO(port)
- BubbleWidget* pop = new BubbleWidget(this, content_margins);
- pop->MakeTransparent();
- pop->make_transient_to_parent();
+ BubbleWidget* bubble_widget = new BubbleWidget(this, content_margins);
+ popup_ = bubble_widget->GetWidget();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.transparent = true;
params.parent = frame_->GetNativeView();
- pop->Init(params);
+ params.native_widget = bubble_widget;
+ popup_->Init(params);
#if defined(OS_CHROMEOS)
{
vector<int> params;
params.push_back(0); // don't show while screen is locked
chromeos::WmIpc::instance()->SetWindowType(
- pop->GetNativeView(),
+ popup_->GetNativeView(),
chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE,
&params);
}
@@ -115,42 +117,32 @@ 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).
- pop->SetContentsView(contents_view);
+ popup_->SetContentsView(contents_view);
// Added border_contents before |view_| so it will paint under it.
- contents_view->AddChildView(pop->border_contents());
+ contents_view->AddChildView(bubble_widget->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 (visible_)
- return;
- static_cast<BubbleWidget*>(popup_)->ShowAndActivate(activate);
- visible_ = true;
+ if (!popup_->IsVisible()) {
+ static_cast<BubbleWidget*>(popup_->native_widget())->ShowAndActivate(
+ activate);
+ }
}
void BrowserBubble::Hide() {
- if (!visible_)
- return;
- views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_);
- pop->Hide();
- visible_ = false;
+ if (popup_->IsVisible())
+ static_cast<BubbleWidget*>(popup_->native_widget())->Hide();
}
void BrowserBubble::ResizeToView() {
BorderContents* border_contents =
- static_cast<BubbleWidget*>(popup_)->border_contents();
+ static_cast<BubbleWidget*>(popup_->native_widget())->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 3effe25..ce4b66c 100644
--- a/chrome/browser/ui/views/browser_bubble_win.cc
+++ b/chrome/browser/ui/views/browser_bubble_win.cc
@@ -14,7 +14,8 @@
class BubbleWidget : public views::WidgetWin {
public:
explicit BubbleWidget(BrowserBubble* bubble)
- : bubble_(bubble),
+ : views::WidgetWin(new views::Widget),
+ bubble_(bubble),
border_widget_(new BorderWidgetWin) {
set_window_style(WS_POPUP | WS_CLIPCHILDREN);
set_window_ex_style(WS_EX_TOOLWINDOW);
@@ -108,17 +109,18 @@ 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* pop = new BubbleWidget(this);
- popup_ = pop;
+ BubbleWidget* bubble_widget = new BubbleWidget(this);
- BorderWidgetWin* border_widget = pop->border_widget();
+ BorderWidgetWin* border_widget = bubble_widget->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_);
@@ -128,30 +130,21 @@ 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 (visible_)
- return;
- BubbleWidget* pop = static_cast<BubbleWidget*>(popup_);
- pop->ShowAndActivate(activate);
- visible_ = true;
+ if (!popup_->IsVisible()) {
+ static_cast<BubbleWidget*>(popup_->native_widget())->ShowAndActivate(
+ activate);
+ }
}
void BrowserBubble::Hide() {
- if (!visible_)
- return;
- views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_);
- pop->Hide();
- visible_ = false;
+ if (popup_->IsVisible())
+ static_cast<BubbleWidget*>(popup_->native_widget())->Hide();
}
void BrowserBubble::ResizeToView() {
BorderWidgetWin* border_widget =
- static_cast<BubbleWidget*>(popup_)->border_widget();
+ static_cast<BubbleWidget*>(popup_->native_widget())->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 2fd2fc7..8c72485 100644
--- a/chrome/browser/ui/views/bubble/border_widget_win.cc
+++ b/chrome/browser/ui/views/bubble/border_widget_win.cc
@@ -7,9 +7,11 @@
#include <windows.h>
#include "chrome/browser/ui/views/bubble/border_contents.h"
+#include "views/widget/widget.h"
BorderWidgetWin::BorderWidgetWin()
- : border_contents_(NULL) {
+ : views::WidgetWin(new views::Widget),
+ border_contents_(NULL) {
}
void BorderWidgetWin::InitBorderWidgetWin(BorderContents* border_contents,
@@ -21,8 +23,9 @@ 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);
- SetContentsView(border_contents_);
+ GetWidget()->SetContentsView(border_contents_);
SetWindowPos(owner, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOREDRAW);
}
@@ -37,7 +40,7 @@ gfx::Rect BorderWidgetWin::SizeAndGetBounds(
border_contents_->SizeAndGetBounds(position_relative_to, arrow_location,
false, contents_size, &contents_bounds,
&window_bounds);
- SetBounds(window_bounds);
+ GetWidget()->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 87b47d7..2f0b46d 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -121,6 +121,11 @@ 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)
@@ -129,7 +134,7 @@ Bubble::Bubble()
delegate_(NULL),
show_status_(kOpen),
fade_away_on_close_(false),
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
type_(views::Widget::InitParams::TYPE_WINDOW),
#endif
#if defined(OS_CHROMEOS)
@@ -142,7 +147,8 @@ Bubble::Bubble()
#if defined(OS_CHROMEOS)
Bubble::Bubble(views::Widget::InitParams::Type type,
bool show_while_screen_is_locked)
- : border_contents_(NULL),
+ : views::WidgetGtk(new views::Widget),
+ border_contents_(NULL),
delegate_(NULL),
show_status_(kOpen),
fade_away_on_close_(false),
@@ -168,7 +174,7 @@ void Bubble::InitBubble(views::Widget* parent,
// Create the main window.
#if defined(OS_WIN)
- views::Window* parent_window = parent->GetWindow();
+ views::Window* parent_window = parent->GetContainingWindow();
if (parent_window)
parent_window->DisableInactiveRendering();
set_window_style(WS_POPUP | WS_CLIPCHILDREN);
@@ -185,7 +191,7 @@ void Bubble::InitBubble(views::Widget* parent,
if (fade_in) {
border_->SetOpacity(0);
- SetOpacity(0);
+ GetWidget()->SetOpacity(0);
}
border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView());
@@ -195,6 +201,7 @@ 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());
@@ -202,8 +209,7 @@ void Bubble::InitBubble(views::Widget* parent,
views::Widget::InitParams params(type_);
params.transparent = true;
params.parent_widget = parent;
- // TODO(beng): Figure out how to make this implicit or set via InitParams.
- make_transient_to_parent();
+ params.native_widget = this;
GetWidget()->Init(params);
#if defined(OS_CHROMEOS)
{
@@ -223,7 +229,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).
- SetContentsView(contents_view);
+ GetWidget()->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.
@@ -262,10 +268,10 @@ void Bubble::InitBubble(views::Widget* parent,
gfx::Rect(gfx::Point(), window_bounds.size()));
contents->SetBoundsRect(contents_bounds);
#endif
- SetBounds(window_bounds);
+ GetWidget()->SetBounds(window_bounds);
// Register the Escape accelerator for closing.
- GetFocusManager()->RegisterAccelerator(
+ GetWidget()->GetFocusManager()->RegisterAccelerator(
views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
// Done creating the bubble.
@@ -280,7 +286,7 @@ void Bubble::InitBubble(views::Widget* parent,
if (fade_in)
FadeIn();
#elif defined(TOOLKIT_USES_GTK)
- views::WidgetGtk::Show();
+ GetWidget()->Show();
#endif
}
@@ -307,23 +313,23 @@ void Bubble::SizeToContents() {
gfx::Rect(gfx::Point(), window_bounds.size()));
contents_->SetBoundsRect(contents_bounds);
#endif
- SetBounds(window_bounds);
+ GetWidget()->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) {
- Close();
+ GetWidget()->Close();
} else if (action == WA_ACTIVE) {
- DCHECK(GetRootView()->has_children());
- GetRootView()->GetChildViewAt(0)->RequestFocus();
+ DCHECK(GetWidget()->GetRootView()->has_children());
+ GetWidget()->GetRootView()->GetChildViewAt(0)->RequestFocus();
}
}
#elif defined(TOOLKIT_USES_GTK)
void Bubble::IsActiveChanged() {
- if (!IsActive())
- Close();
+ if (!GetWidget()->IsActive())
+ GetWidget()->Close();
}
#endif
@@ -331,13 +337,15 @@ void Bubble::DoClose(bool closed_by_escape) {
if (show_status_ == kClosed)
return;
- GetFocusManager()->UnregisterAccelerator(
+ GetWidget()->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 fd71a09..c39a093 100644
--- a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
+++ b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
@@ -70,7 +70,8 @@ class ConstrainedHtmlDelegateGtk : public views::WidgetGtk,
ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk(
Profile* profile,
HtmlDialogUIDelegate* delegate)
- : HtmlDialogTabContentsDelegate(profile),
+ : views::WidgetGtk(new views::Widget),
+ HtmlDialogTabContentsDelegate(profile),
html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL),
tab_container_(NULL),
html_delegate_(delegate),
@@ -86,10 +87,11 @@ 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;
- SetContentsView(tab_container_);
+ GetWidget()->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 8034744..ef8f72c 100644
--- a/chrome/browser/ui/views/constrained_window_views.cc
+++ b/chrome/browser/ui/views/constrained_window_views.cc
@@ -576,8 +576,11 @@ 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);
}
@@ -608,7 +611,7 @@ void ConstrainedWindowViews::CloseConstrainedWindow() {
NotificationService::current()->Notify(NotificationType::CWINDOW_CLOSED,
Source<ConstrainedWindow>(this),
NotificationService::NoDetails());
- GetWindow()->CloseWindow();
+ GetWindow()->Close();
}
void ConstrainedWindowViews::FocusConstrainedWindow() {
@@ -621,6 +624,13 @@ void ConstrainedWindowViews::FocusConstrainedWindow() {
}
////////////////////////////////////////////////////////////////////////////////
+// ConstrainedWindowViews, views::Window overrides:
+
+views::NonClientFrameView* ConstrainedWindowViews::CreateFrameViewForWindow() {
+ return new ConstrainedWindowFrameView(this);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation:
void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() {
@@ -633,10 +643,12 @@ void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() {
GetWindow()->Activate();
}
-views::NonClientFrameView* ConstrainedWindowViews::CreateFrameViewForWindow() {
- return new ConstrainedWindowFrameView(this);
+views::internal::NativeWindowDelegate*
+ ConstrainedWindowViews::AsNativeWindowDelegate() {
+ return this;
}
+
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindow, public:
diff --git a/chrome/browser/ui/views/constrained_window_views.h b/chrome/browser/ui/views/constrained_window_views.h
index 98d1047..c09740c 100644
--- a/chrome/browser/ui/views/constrained_window_views.h
+++ b/chrome/browser/ui/views/constrained_window_views.h
@@ -10,11 +10,15 @@
#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;
@@ -35,6 +39,8 @@ 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 {
@@ -54,7 +60,8 @@ class NativeConstrainedWindow {
// A ConstrainedWindow implementation that implements a Constrained Window as
// a child HWND with a custom window frame.
//
-class ConstrainedWindowViews : public ConstrainedWindow,
+class ConstrainedWindowViews : public views::Window,
+ public ConstrainedWindow,
public NativeConstrainedWindowDelegate {
public:
ConstrainedWindowViews(TabContents* owner,
@@ -72,10 +79,14 @@ class ConstrainedWindowViews : public ConstrainedWindow,
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::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
+ virtual views::internal::NativeWindowDelegate*
+ AsNativeWindowDelegate() 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 f78b549..00bf748 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 = Widget::CreateWidget();
+ Widget* widget = new Widget;
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 91099a0..f38a5b2 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_ = views::Widget::CreateWidget();
- popup_->SetOpacity(0x00);
+ popup_ = new views::Widget;
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 9675589..d2313f0 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(views::Widget::CreateWidget());
+ host_.reset(new views::Widget);
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 aa7888b..723b4d6 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 (visible())
+ if (popup_->IsVisible())
return;
#if defined(OS_WIN)
- frame_->GetWindow()->DisableInactiveRendering();
+ frame_->GetContainingWindow()->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 17cd52b..40a1cf5 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -56,7 +56,13 @@ class FindInPageTest : public InProcessBrowserTest {
} // namespace
-IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
+#if defined(TOOLKIT_USES_GTK)
+#define MAYBE_CrashEscHandlers FLAKY_CrashEscHandlers
+#else
+#define MAYBE_CrashEscHandlers CrashEscHandlers
+#endif
+
+IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) {
ASSERT_TRUE(test_server()->Start());
// First we navigate to our test page (tab A).
@@ -71,7 +77,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, 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 69edc15..f30702c 100644
--- a/chrome/browser/ui/views/find_bar_host_win.cc
+++ b/chrome/browser/ui/views/find_bar_host_win.cc
@@ -20,7 +20,8 @@ void FindBarHost::AudibleAlert() {
void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) {
RECT frame_rect = {0}, webcontents_rect = {0};
::GetWindowRect(
- static_cast<views::WidgetWin*>(host())->GetParent(), &frame_rect);
+ static_cast<views::WidgetWin*>(host()->native_widget())->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 7db2137..2e0a390 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->GetFocusManager()->AddFocusChangeListener(view);
+ bubble->GetWidget()->GetFocusManager()->AddFocusChangeListener(view);
view->BubbleShown();
return bubble;
}
@@ -504,7 +504,7 @@ FirstRunBubble::FirstRunBubble()
FirstRunBubble::~FirstRunBubble() {
enable_window_method_factory_.RevokeAll();
- GetFocusManager()->RemoveFocusChangeListener(view_);
+ GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_);
}
void FirstRunBubble::EnableParent() {
@@ -517,7 +517,7 @@ void FirstRunBubble::EnableParent() {
views::NativeWidget* parent =
views::NativeWidget::GetNativeWidgetForNativeView(GetParent());
if (parent)
- parent->GetWidget()->GetWindow()->DisableInactiveRendering();
+ parent->GetWidget()->GetContainingWindow()->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 58f8beb..386e41b 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->CloseWindow();
+ window->Close();
}
} // 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 86032fc..3f25d88 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,15 +146,14 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- int frame_component =
- frame_->GetWindow()->client_view()->NonClientHitTest(point);
+ int frame_component = frame_->client_view()->NonClientHitTest(point);
// See if we're in the sysmenu region. (We check the ClientView first to be
// consistent with OpaqueBrowserFrameView; it's not really necessary here.)
gfx::Rect sysmenu_rect(IconBounds());
// In maximized mode we extend the rect to the screen corner to take advantage
// of Fitts' Law.
- if (frame_->GetWindow()->IsMaximized())
+ if (frame_->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
if (sysmenu_rect.Contains(point))
@@ -171,7 +170,7 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point,
NonClientBorderThickness(), NonClientBorderThickness(),
kResizeAreaCornerSize, kResizeAreaCornerSize,
- frame_->GetWindow()->window_delegate()->CanResize());
+ frame_->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -180,7 +179,7 @@ void AppPanelBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->GetWindow()->IsMaximized())
+ if (frame_->IsMaximized())
return;
// Redefine the window visible region for the new size.
@@ -219,13 +218,12 @@ void AppPanelBrowserFrameView::UpdateWindowIcon() {
// AppPanelBrowserFrameView, views::View overrides:
void AppPanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- views::Window* window = frame_->GetWindow();
- if (window->IsMaximized())
+ if (frame_->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
PaintTitleBar(canvas);
- if (!window->IsMaximized())
+ if (!frame_->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -241,7 +239,7 @@ void AppPanelBrowserFrameView::Layout() {
void AppPanelBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_)
- frame_->GetWindow()->CloseWindow();
+ frame_->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -256,19 +254,19 @@ bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap AppPanelBrowserFrameView::GetFaviconForTabIconView() {
- return frame_->GetWindow()->window_delegate()->GetWindowIcon();
+ return frame_->window_delegate()->GetWindowIcon();
}
///////////////////////////////////////////////////////////////////////////////
// AppPanelBrowserFrameView, private:
int AppPanelBrowserFrameView::FrameBorderThickness() const {
- return frame_->GetWindow()->IsMaximized() ? 0 : kFrameBorderThickness;
+ return frame_->IsMaximized() ? 0 : kFrameBorderThickness;
}
int AppPanelBrowserFrameView::NonClientBorderThickness() const {
return FrameBorderThickness() +
- (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
}
int AppPanelBrowserFrameView::NonClientTopBorderHeight() const {
@@ -279,7 +277,7 @@ int AppPanelBrowserFrameView::NonClientTopBorderHeight() const {
int AppPanelBrowserFrameView::TitlebarBottomThickness() const {
return kTitlebarTopAndBottomEdgeThickness +
- (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
+ (frame_->IsMaximized() ? 0 : kClientEdgeThickness);
}
int AppPanelBrowserFrameView::IconSize() const {
@@ -303,7 +301,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_->GetWindow()->IsMaximized() ?
+ int unavailable_px_at_top = frame_->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
@@ -401,13 +399,13 @@ void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = titlebar_bottom->height() - kClientEdgeThickness;
canvas->TileImageInt(*titlebar_bottom, 0,
- frame_->GetWindow()->client_view()->y() - edge_height,
+ frame_->client_view()->y() - edge_height,
width(), edge_height);
}
void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WindowDelegate* d = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* d = frame_->window_delegate();
canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(),
SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(),
title_bounds_.width(), title_bounds_.height());
@@ -467,7 +465,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_->GetWindow()->IsMaximized();
+ bool is_maximized = frame_->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 94d0fa7..0b0842e 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -4,23 +4,53 @@
#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() {
}
-views::Window* BrowserFrame::GetWindow() {
- return native_browser_frame_->AsNativeWindow()->GetWindow();
+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
}
int BrowserFrame::GetMinimizeButtonOffset() const {
@@ -39,12 +69,20 @@ void BrowserFrame::UpdateThrobber(bool running) {
browser_frame_view_->UpdateThrobber(running);
}
-ui::ThemeProvider* BrowserFrame::GetThemeProviderForFrame() const {
- return native_browser_frame_->GetThemeProviderForFrame();
-}
-
bool BrowserFrame::AlwaysUseNativeFrame() const {
- return native_browser_frame_->AlwaysUseNativeFrame();
+ // 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();
}
views::View* BrowserFrame::GetFrameView() const {
@@ -52,32 +90,68 @@ 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();
}
-////////////////////////////////////////////////////////////////////////////////
-// BrowserFrame, NativeBrowserFrameDelegate implementation:
+///////////////////////////////////////////////////////////////////////////////
+// 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();
+}
-views::RootView* BrowserFrame::DelegateCreateRootView() {
+views::RootView* BrowserFrame::CreateRootView() {
root_view_ = new BrowserRootView(
browser_view_,
native_browser_frame_->AsNativeWindow()->AsNativeWidget()->GetWidget());
return root_view_;
}
-views::NonClientFrameView* BrowserFrame::DelegateCreateFrameViewForWindow() {
- browser_frame_view_ =
- native_browser_frame_->CreateBrowserNonClientFrameView();
+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
return browser_frame_view_;
}
+bool BrowserFrame::GetAccelerator(int command_id,
+ ui::Accelerator* accelerator) {
+ return browser_view_->GetAccelerator(command_id, accelerator);
+}
-////////////////////////////////////////////////////////////////////////////////
-// BrowserFrame, protected:
+ThemeProvider* BrowserFrame::GetThemeProvider() const {
+ return ThemeServiceFactory::GetForProfile(
+ browser_view_->browser()->profile());
+}
-BrowserFrame::BrowserFrame(BrowserView* browser_view)
- : native_browser_frame_(NULL),
- root_view_(NULL),
- browser_frame_view_(NULL),
- browser_view_(browser_view) {
+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);
}
+
diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h
index 2a7ae13..2c07fd2 100644
--- a/chrome/browser/ui/views/frame/browser_frame.h
+++ b/chrome/browser/ui/views/frame/browser_frame.h
@@ -10,6 +10,7 @@
#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;
@@ -34,19 +35,15 @@ class Window;
}
// This is a virtual interface that allows system specific browser frames.
-class BrowserFrame : public NativeBrowserFrameDelegate {
+class BrowserFrame : public views::Window {
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();
- // Returns the Window associated with this frame. Guaranteed non-NULL after
- // construction.
- views::Window* GetWindow();
+ // Initialize the frame (creates the underlying native window).
+ void InitBrowserFrame();
// 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.
@@ -64,9 +61,6 @@ class BrowserFrame : public NativeBrowserFrameDelegate {
// 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.
@@ -79,19 +73,14 @@ class BrowserFrame : public NativeBrowserFrameDelegate {
// its frame treatment if necessary.
void TabStripDisplayModeChanged();
- 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);
+ // 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;
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 110c599..dd1cee8 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
@@ -17,38 +17,23 @@
#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(BrowserView* browser_view, Profile* profile)
- : BrowserFrame(browser_view),
- ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
+BrowserFrameGtk::BrowserFrameGtk(BrowserFrame* browser_frame,
+ BrowserView* browser_view)
+ : views::WindowGtk(browser_frame),
browser_view_(browser_view) {
- set_native_browser_frame(this);
- browser_view_->set_frame(this);
+ // Don't focus anything on creation, selecting a tab will set the focus.
+ set_focus_on_creation(false);
}
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:
@@ -60,58 +45,22 @@ 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 (GetRootView()->has_children()) {
+ if (GetWidget()->GetRootView()->has_children()) {
// Make sure the child of the root view gets Layout again.
- GetRootView()->GetChildViewAt(0)->InvalidateLayout();
+ GetWidget()->GetRootView()->GetChildViewAt(0)->InvalidateLayout();
}
- GetRootView()->Layout();
+ GetWidget()->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();
@@ -132,3 +81,15 @@ 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 14536a1..a499496 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.h
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.h
@@ -14,46 +14,27 @@
class BrowserNonClientFrameView;
class BrowserRootView;
-class BrowserFrameGtk : public BrowserFrame,
- public views::WindowGtk,
+class BrowserFrameGtk : 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(BrowserView* browser_view, Profile* profile);
+ BrowserFrameGtk(BrowserFrame* browser_frame, BrowserView* browser_view);
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 49e14db..1982d43 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_win.cc
@@ -10,19 +10,13 @@
#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/widget/root_view.h"
-#include "views/widget/widget_win.h"
-#include "views/window/window_win.h"
+#include "views/window/non_client_view.h"
+#include "views/window/window.h"
// static
static const int kClientEdgeThickness = 3;
@@ -33,26 +27,14 @@ 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(BrowserView* browser_view, Profile* profile)
- : BrowserFrame(browser_view),
+BrowserFrameWin::BrowserFrameWin(BrowserFrame* browser_frame,
+ BrowserView* browser_view)
+ : views::WindowWin(browser_frame),
browser_view_(browser_view),
- ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)) {
- set_native_browser_frame(this);
- browser_view_->set_frame(this);
- non_client_view()->SetFrameView(CreateFrameViewForWindow());
+ browser_frame_(browser_frame) {
// Don't focus anything on creation, selecting a tab will set the focus.
set_focus_on_creation(false);
}
@@ -82,7 +64,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 (!non_client_view()->UseNativeFrame() ||
+ if (!GetWindow()->non_client_view()->UseNativeFrame() ||
!browser_view_->IsBrowserTypeNormal()) {
return WindowWin::GetClientAreaInsets();
}
@@ -97,9 +79,11 @@ gfx::Insets BrowserFrameWin::GetClientAreaInsets() const {
return gfx::Insets(0, border_thickness, border_thickness, border_thickness);
}
-bool BrowserFrameWin::GetAccelerator(int cmd_id,
- ui::Accelerator* accelerator) {
- return browser_view_->GetAccelerator(cmd_id, accelerator);
+void BrowserFrameWin::UpdateFrameAfterFrameChange() {
+ // We need to update the glass region on or off before the base class adjusts
+ // the window region.
+ UpdateDWMFrame();
+ WindowWin::UpdateFrameAfterFrameChange();
}
void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) {
@@ -125,51 +109,16 @@ 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) {
- non_client_view()->Layout();
- non_client_view()->SchedulePaint();
+ GetWindow()->non_client_view()->Layout();
+ GetWindow()->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:
@@ -181,12 +130,6 @@ 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);
@@ -199,36 +142,7 @@ 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();
}
@@ -237,7 +151,7 @@ void BrowserFrameWin::TabStripDisplayModeChanged() {
void BrowserFrameWin::UpdateDWMFrame() {
// Nothing to do yet, or we're not showing a DWM frame.
- if (!client_view() || !AlwaysUseNativeFrame())
+ if (!GetWindow()->client_view() || !browser_frame_->AlwaysUseNativeFrame())
return;
MARGINS margins = { 0 };
@@ -255,7 +169,7 @@ void BrowserFrameWin::UpdateDWMFrame() {
// borders.
if (!browser_view_->IsFullscreen()) {
gfx::Rect tabstrip_bounds(
- GetBoundsForTabStrip(browser_view_->tabstrip()));
+ browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip()));
margins.cyTopHeight = (browser_view_->UseVerticalTabs() ?
tabstrip_bounds.y() : tabstrip_bounds.bottom()) + kDWMFrameTopOffset;
}
@@ -275,3 +189,13 @@ 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 c49f380..d7249f4 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.h
+++ b/chrome/browser/ui/views/frame/browser_frame_win.h
@@ -12,7 +12,6 @@
#include "views/window/window_win.h"
class BrowserView;
-class Profile;
///////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin
@@ -20,13 +19,10 @@ class Profile;
// BrowserFrame is a WindowWin subclass that provides the window frame for the
// Chrome browser window.
//
-class BrowserFrameWin : public BrowserFrame,
- public views::WindowWin,
+class BrowserFrameWin : public views::WindowWin,
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.
- BrowserFrameWin(BrowserView* browser_view, Profile* profile);
+ BrowserFrameWin(BrowserFrame* browser_frame, BrowserView* browser_view);
virtual ~BrowserFrameWin();
BrowserView* browser_view() const { return browser_view_; }
@@ -40,41 +36,29 @@ class BrowserFrameWin : public BrowserFrame,
// Overridden from views::WindowWin:
virtual int GetShowState() const OVERRIDE;
virtual gfx::Insets GetClientAreaInsets() const OVERRIDE;
- virtual bool GetAccelerator(int cmd_id,
- ui::Accelerator* accelerator) OVERRIDE;
+ virtual void UpdateFrameAfterFrameChange() 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 bc4b9fc..1f6dee6 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->GetWindow() : NULL;
+ return widget ? widget->GetContainingWindow() : 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_->GetWindow()->IsVisible()) {
- frame_->GetWindow()->Activate();
+ if (frame_->IsVisible()) {
+ frame_->Activate();
return;
}
@@ -596,13 +596,12 @@ void BrowserView::Show() {
// that should be added and this should be removed.
RestoreFocus();
- frame_->GetWindow()->Show();
+ frame_->Show();
}
void BrowserView::ShowInactive() {
- views::Window* window = frame_->GetWindow();
- if (!window->IsVisible())
- window->ShowInactive();
+ if (!frame_->IsVisible())
+ frame_->ShowInactive();
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {
@@ -613,26 +612,26 @@ void BrowserView::SetBounds(const gfx::Rect& bounds) {
void BrowserView::Close() {
BrowserBubbleHost::Close();
- frame_->GetWindow()->CloseWindow();
+ frame_->Close();
}
void BrowserView::Activate() {
- frame_->GetWindow()->Activate();
+ frame_->Activate();
}
void BrowserView::Deactivate() {
- frame_->GetWindow()->Deactivate();
+ frame_->Deactivate();
}
bool BrowserView::IsActive() const {
- return frame_->GetWindow()->IsActive();
+ return frame_->IsActive();
}
void BrowserView::FlashFrame() {
#if defined(OS_WIN)
FLASHWINFO fwi;
fwi.cbSize = sizeof(fwi);
- fwi.hwnd = frame_->GetWindow()->GetNativeWindow();
+ fwi.hwnd = frame_->GetNativeWindow();
fwi.dwFlags = FLASHW_ALL;
fwi.uCount = 4;
fwi.dwTimeout = 0;
@@ -643,7 +642,7 @@ void BrowserView::FlashFrame() {
}
gfx::NativeWindow BrowserView::GetNativeHandle() {
- return GetWidget()->GetWindow()->GetNativeWindow();
+ return GetWidget()->GetContainingWindow()->GetNativeWindow();
}
BrowserWindowTesting* BrowserView::GetBrowserWindowTesting() {
@@ -708,9 +707,9 @@ void BrowserView::ToolbarSizeChanged(bool is_animating) {
}
void BrowserView::UpdateTitleBar() {
- frame_->GetWindow()->UpdateWindowTitle();
+ frame_->UpdateWindowTitle();
if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning())
- frame_->GetWindow()->UpdateWindowIcon();
+ frame_->UpdateWindowIcon();
}
void BrowserView::ShelfVisibilityChanged() {
@@ -746,15 +745,15 @@ void BrowserView::SetStarredState(bool is_starred) {
}
gfx::Rect BrowserView::GetRestoredBounds() const {
- return frame_->GetWindow()->GetNormalBounds();
+ return frame_->GetNormalBounds();
}
gfx::Rect BrowserView::GetBounds() const {
- return frame_->GetWindow()->GetBounds();
+ return frame_->GetBounds();
}
bool BrowserView::IsMaximized() const {
- return frame_->GetWindow()->IsMaximized();
+ return frame_->IsMaximized();
}
void BrowserView::SetFullscreen(bool fullscreen) {
@@ -766,12 +765,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_->GetWindow()->SetFullscreen(fullscreen);
+ frame_->SetFullscreen(fullscreen);
#endif
}
bool BrowserView::IsFullscreen() const {
- return frame_->GetWindow()->IsFullscreen();
+ return frame_->IsFullscreen();
}
bool BrowserView::IsFullscreenBubbleVisible() const {
@@ -979,7 +978,7 @@ bool BrowserView::IsToolbarVisible() const {
void BrowserView::DisableInactiveFrame() {
#if defined(OS_WIN)
- frame_->GetWindow()->DisableInactiveRendering();
+ frame_->DisableInactiveRendering();
#endif // No tricks are needed to get the right behavior on Linux.
}
@@ -1113,7 +1112,7 @@ void BrowserView::ShowCreateChromeAppShortcutsDialog(Profile* profile,
}
void BrowserView::UserChangedTheme() {
- frame_->GetWindow()->FrameTypeChanged();
+ frame_->FrameTypeChanged();
}
int BrowserView::GetExtraRenderViewHeight() const {
@@ -1598,7 +1597,7 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
bounds->height() + toolbar_->GetPreferredSize().height());
}
- gfx::Rect window_rect = frame_->GetWindow()->non_client_view()->
+ gfx::Rect window_rect = frame_->non_client_view()->
GetWindowBoundsForClientBounds(*bounds);
window_rect.set_origin(bounds->origin());
@@ -1680,7 +1679,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_->GetWindow()->HideWindow();
+ frame_->HideWindow();
browser_->OnWindowClosing();
return false;
}
@@ -1688,7 +1687,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_->GetWindow()->GetNativeWindow()),
+ Source<gfx::NativeWindow>(frame_->GetNativeWindow()),
NotificationService::NoDetails());
return true;
}
@@ -1698,10 +1697,9 @@ 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_->GetWindow()->IsMaximized() &&
- !frame_->GetWindow()->IsFullscreen()) {
+ if (!frame_->IsMaximized() && !frame_->IsFullscreen()) {
CRect client_rect;
- ::GetClientRect(frame_->GetWindow()->GetNativeWindow(), &client_rect);
+ ::GetClientRect(frame_->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(),
@@ -1803,8 +1801,7 @@ void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) {
SkColor BrowserView::GetInfoBarSeparatorColor() const {
// NOTE: Keep this in sync with ToolbarView::OnPaint()!
- return (IsTabStripVisible() ||
- !frame_->GetWindow()->non_client_view()->UseNativeFrame()) ?
+ return (IsTabStripVisible() || !frame_->non_client_view()->UseNativeFrame()) ?
ResourceBundle::toolbar_separator_color : SK_ColorBLACK;
}
@@ -1934,7 +1931,7 @@ void BrowserView::Init() {
if (AeroPeekManager::Enabled()) {
aeropeek_manager_.reset(new AeroPeekManager(
- frame_->GetWindow()->GetNativeWindow()));
+ frame_->GetNativeWindow()));
browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get());
}
#endif
@@ -2002,7 +1999,7 @@ void BrowserView::InitSystemMenu() {
BuildSystemMenuForAppOrPopupWindow();
system_menu_.reset(
new views::NativeMenuWin(system_menu_contents_.get(),
- frame_->GetWindow()->GetNativeWindow()));
+ frame_->GetNativeWindow()));
system_menu_->Rebuild();
}
#endif
@@ -2254,8 +2251,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
#endif
}
#if defined(OS_WIN)
- static_cast<views::WindowWin*>(
- frame_->GetWindow()->native_window())->PushForceHidden();
+ static_cast<views::WindowWin*>(frame_->native_window())->PushForceHidden();
#endif
// Notify bookmark bar, so it can set itself to the appropriate drawing state.
@@ -2264,7 +2260,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
// Toggle fullscreen mode.
#if defined(OS_WIN)
- frame_->GetWindow()->SetFullscreen(fullscreen);
+ frame_->SetFullscreen(fullscreen);
#endif // No need to invoke SetFullscreen for linux as this code is executed
// once we're already fullscreen on linux.
@@ -2296,8 +2292,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
ignore_layout_ = false;
Layout();
#if defined(OS_WIN)
- static_cast<views::WindowWin*>(
- frame_->GetWindow()->native_window())->PopForceHidden();
+ static_cast<views::WindowWin*>(frame_->native_window())->PopForceHidden();
#endif
}
@@ -2580,11 +2575,9 @@ 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);
- BrowserFrame::Create(view, browser->profile());
-
+ (new BrowserFrame(view))->InitBrowserFrame();
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 ebd0403..16ebf34 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_->GetWindow()->IsMaximized() &&
- !browser_view_->frame_->GetWindow()->IsFullscreen()) {
+ if (!browser_view_->frame_->IsMaximized() &&
+ !browser_view_->frame_->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 b3b96ef..2f5bd45 100644
--- a/chrome/browser/ui/views/frame/contents_container.cc
+++ b/chrome/browser/ui/views/frame/contents_container.cc
@@ -152,8 +152,6 @@ 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());
@@ -162,11 +160,13 @@ 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 f3daf8f..11e2950 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -130,8 +130,7 @@ 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_->GetWindow()->IsMaximized())
+ if (!browser_view_->ShouldShowOffTheRecordAvatar() && frame_->IsMaximized())
tabstrip_x += otr_avatar_bounds_.x();
minimize_button_offset = width();
}
@@ -141,7 +140,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
profile_button_->GetPreferredSize().width() +
ProfileMenuButton::kProfileTagHorizontalSpacing : 0);
int tabstrip_width = minimize_button_offset - tabstrip_x -
- (frame_->GetWindow()->IsMaximized() ?
+ (frame_->IsMaximized() ?
maximized_spacing : kNewTabCaptionRestoredSpacing);
return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
std::max(0, tabstrip_width),
@@ -178,7 +177,7 @@ bool GlassBrowserFrameView::AlwaysUseNativeFrame() const {
gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
- HWND hwnd = frame_->GetWindow()->GetNativeWindow();
+ HWND hwnd = frame_->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
@@ -206,8 +205,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point))
return HTNOWHERE;
- int frame_component =
- frame_->GetWindow()->client_view()->NonClientHitTest(point);
+ int frame_component = frame_->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.
@@ -229,7 +227,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int window_component = GetHTComponentForFrame(point, frame_border_thickness,
nonclient_border_thickness, frame_border_thickness,
kResizeAreaCornerSize - frame_border_thickness,
- frame_->GetWindow()->window_delegate()->CanResize());
+ frame_->window_delegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
}
@@ -254,7 +252,7 @@ void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
PaintToolbarBackground(canvas);
if (browser_view_->ShouldShowOffTheRecordAvatar())
PaintOTRAvatar(canvas);
- if (!frame_->GetWindow()->IsMaximized())
+ if (!frame_->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -267,12 +265,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_->GetWindow()->IsMaximized() && show_profile_button() &&
+ if (frame_->IsMaximized() && show_profile_button() &&
profile_button_->IsVisible() &&
profile_button_->GetMirroredBounds().Contains(l)) {
return true;
} else {
- return !GetWindow()->client_view()->bounds().Contains(l);
+ return !frame_->client_view()->bounds().Contains(l);
}
}
@@ -280,14 +278,12 @@ bool GlassBrowserFrameView::HitTest(const gfx::Point& l) const {
// GlassBrowserFrameView, private:
int GlassBrowserFrameView::FrameBorderThickness() const {
- views::Window* window = frame_->GetWindow();
- return (window->IsMaximized() || window->IsFullscreen()) ?
+ return (frame_->IsMaximized() || frame_->IsFullscreen()) ?
0 : GetSystemMetrics(SM_CXSIZEFRAME);
}
int GlassBrowserFrameView::NonClientBorderThickness() const {
- views::Window* window = frame_->GetWindow();
- if (window->IsMaximized() || window->IsFullscreen())
+ if (frame_->IsMaximized() || frame_->IsFullscreen())
return 0;
return browser_view_->UseVerticalTabs() ?
@@ -298,7 +294,7 @@ int GlassBrowserFrameView::NonClientBorderThickness() const {
int GlassBrowserFrameView::NonClientTopBorderHeight(
bool restored,
bool ignore_vertical_tabs) const {
- if (!restored && frame_->GetWindow()->IsFullscreen())
+ if (!restored && frame_->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
@@ -436,7 +432,7 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
// of how tall the toolbar itself is.
int client_area_top = browser_view_->UseVerticalTabs() ?
client_area_bounds.y() :
- (frame_->GetWindow()->client_view()->y() +
+ (frame_->client_view()->y() +
browser_view_->GetToolbarBounds().y() +
tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height());
int client_area_bottom =
@@ -497,7 +493,7 @@ void GlassBrowserFrameView::LayoutOTRAvatar() {
browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
otr_restored_y = otr_bottom - otr_avatar_icon.height();
}
- int otr_y = frame_->GetWindow()->IsMaximized() ?
+ int otr_y = frame_->IsMaximized() ?
(NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
otr_restored_y;
otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(),
@@ -536,7 +532,7 @@ void GlassBrowserFrameView::LayoutProfileTag() {
ProfileMenuButton::kProfileTagHorizontalSpacing -
// - the width of the profile button
profile_button_->GetPreferredSize().width();
- int y_maximized_offset = frame_->GetWindow()->IsMaximized() ?
+ int y_maximized_offset = frame_->IsMaximized() ?
kProfileElementMaximizedYOffset : 0;
profile_button_->SetBounds(
x_tag,
@@ -570,7 +566,7 @@ void GlassBrowserFrameView::StartThrobber() {
throbber_running_ = true;
throbber_frame_ = 0;
InitThrobberIcons();
- SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame_->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
}
@@ -592,13 +588,13 @@ void GlassBrowserFrameView::StopThrobber() {
// Fallback to class icon.
if (!frame_icon) {
frame_icon = reinterpret_cast<HICON>(GetClassLongPtr(
- frame_->GetWindow()->GetNativeWindow(), GCLP_HICONSM));
+ frame_->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_->GetWindow()->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame_->GetNativeWindow(), WM_SETICON,
static_cast<WPARAM>(ICON_SMALL),
reinterpret_cast<LPARAM>(frame_icon));
}
@@ -606,7 +602,7 @@ void GlassBrowserFrameView::StopThrobber() {
void GlassBrowserFrameView::DisplayNextThrobberFrame() {
throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
- SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON,
+ SendMessage(frame_->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 f72ec29..120fa1f 100644
--- a/chrome/browser/ui/views/frame/native_browser_frame.h
+++ b/chrome/browser/ui/views/frame/native_browser_frame.h
@@ -6,38 +6,27 @@
#define CHROME_BROWSER_UI_VIEWS_FRAME_NATIVE_BROWSER_FRAME_H_
#pragma once
-class BrowserNonClientFrameView;
-
-namespace gfx {
-class Rect;
-}
-
-namespace ui {
-class ThemeProvider;
-}
-
-namespace views {
-class NativeWindow;
-class View;
-}
+class BrowserView;
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;
- virtual ui::ThemeProvider* GetThemeProviderForFrame() const = 0;
- virtual bool AlwaysUseNativeFrame() const = 0;
+ // TODO(beng): replace with some kind of "framechanged" signal to Window.
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 da4ca70..7efd98b 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_->GetThemeProviderForFrame();
+ ui::ThemeProvider* tp = frame_->GetThemeProvider();
SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND);
SkBitmap* background =
tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND);
@@ -243,8 +243,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForReservedArea() const {
int OpaqueBrowserFrameView::NonClientTopBorderHeight(
bool restored,
bool ignore_vertical_tabs) const {
- views::Window* window = frame_->GetWindow();
- views::WindowDelegate* delegate = window->window_delegate();
+ views::WindowDelegate* delegate = frame_->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
@@ -258,7 +257,7 @@ int OpaqueBrowserFrameView::NonClientTopBorderHeight(
return FrameBorderThickness(restored) -
((browser_view_->IsTabStripVisible() && !restored &&
- window->IsMaximized()) ? kTabstripTopShadowThickness : 0);
+ frame_->IsMaximized()) ? kTabstripTopShadowThickness : 0);
}
///////////////////////////////////////////////////////////////////////////////
@@ -287,7 +286,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
profile_button_->GetPreferredSize().width() +
ProfileMenuButton::kProfileTagHorizontalSpacing : 0);
int tabstrip_width = minimize_button_->x() - tabstrip_x -
- (frame_->GetWindow()->IsMaximized() ?
+ (frame_->IsMaximized() ?
maximized_spacing : kNewTabCaptionRestoredSpacing);
int tabstrip_height = 0;
if (tabstrip)
@@ -299,8 +298,8 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
bool restored) const {
return NonClientTopBorderHeight(restored, true) + ((!restored &&
- (frame_->GetWindow()->IsMaximized() ||
- frame_->GetWindow()->IsFullscreen())) ?
+ (frame_->IsMaximized() ||
+ frame_->IsFullscreen())) ?
0 : kNonClientRestoredExtraThickness);
}
@@ -315,7 +314,7 @@ gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight(false, false) + border_thickness);
- views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* delegate = frame_->window_delegate();
int min_titlebar_width = (2 * FrameBorderThickness(false)) +
kIconLeftSpacing +
(delegate && delegate->ShouldShowWindowIcon() ?
@@ -360,14 +359,14 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
return HTNOWHERE;
int frame_component =
- frame_->GetWindow()->client_view()->NonClientHitTest(point);
+ frame_->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_->GetWindow()->IsMaximized())
+ if (frame_->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
if (sysmenu_rect.Contains(point))
@@ -395,7 +394,7 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
profile_button_->GetMirroredBounds().Contains(point))
return HTCLIENT;
- views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* delegate = frame_->window_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return HTCAPTION;
@@ -411,7 +410,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
DCHECK(window_mask);
- if (frame_->GetWindow()->IsMaximized() || frame_->GetWindow()->IsFullscreen())
+ if (frame_->IsMaximized() || frame_->IsFullscreen())
return;
views::GetDefaultWindowMask(size, window_mask);
@@ -447,11 +446,10 @@ void OpaqueBrowserFrameView::RunMenu(views::View* source,
// OpaqueBrowserFrameView, views::View overrides:
void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
- views::Window* window = frame_->GetWindow();
- if (window->IsFullscreen())
+ if (frame_->IsFullscreen())
return; // Nothing is visible, so don't bother to paint.
- if (window->IsMaximized())
+ if (frame_->IsMaximized())
PaintMaximizedFrameBorder(canvas);
else
PaintRestoredFrameBorder(canvas);
@@ -461,7 +459,7 @@ void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
PaintToolbarBackground(canvas);
if (browser_view_->ShouldShowOffTheRecordAvatar())
PaintOTRAvatar(canvas);
- if (!window->IsMaximized())
+ if (!frame_->IsMaximized())
PaintRestoredClientEdge(canvas);
}
@@ -483,8 +481,7 @@ 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_->GetWindow()->client_view(),
- this, &tabstrip_origin);
+ View::ConvertPointToView(frame_->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())) {
@@ -494,13 +491,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_->GetWindow()->client_view(),
+ frame_->client_view(),
static_cast<const View*>(this),
l)) {
return false;
}
if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(),
- frame_->GetWindow()->client_view(),
+ frame_->client_view(),
static_cast<const View*>(this),
l)) {
return false;
@@ -525,15 +522,14 @@ void OpaqueBrowserFrameView::GetAccessibleState(
void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
- views::Window* window = frame_->GetWindow();
if (sender == minimize_button_)
- window->Minimize();
+ frame_->Minimize();
else if (sender == maximize_button_)
- window->Maximize();
+ frame_->Maximize();
else if (sender == restore_button_)
- window->Restore();
+ frame_->Restore();
else if (sender == close_button_)
- window->CloseWindow();
+ frame_->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -548,7 +544,7 @@ bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const {
}
SkBitmap OpaqueBrowserFrameView::GetFaviconForTabIconView() {
- views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* delegate = frame_->window_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL, returning safe default.";
return SkBitmap();
@@ -572,8 +568,7 @@ void OpaqueBrowserFrameView::Observe(NotificationType type,
// OpaqueBrowserFrameView, private:
int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
- views::Window* window = frame_->GetWindow();
- return (!restored && (window->IsMaximized() || window->IsFullscreen())) ?
+ return (!restored && (frame_->IsMaximized() || frame_->IsFullscreen())) ?
0 : kFrameBorderThickness;
}
@@ -583,9 +578,8 @@ 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) +
- ((window->IsMaximized() || window->IsFullscreen()) ?
+ ((frame_->IsMaximized() || frame_->IsFullscreen()) ?
0 : kClientEdgeThickness);
}
@@ -596,14 +590,13 @@ 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_->GetWindow()->IsMaximized()) ?
+ return (!restored && frame_->IsMaximized()) ?
FrameBorderThickness(false) : kFrameShadowThickness;
}
int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const {
return kTitlebarTopAndBottomEdgeThickness +
- ((!restored && frame_->GetWindow()->IsMaximized()) ?
- 0 : kClientEdgeThickness);
+ ((!restored && frame_->IsMaximized()) ? 0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::IconSize() const {
@@ -620,7 +613,7 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
int size = IconSize();
int frame_thickness = FrameBorderThickness(false);
int y;
- views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* delegate = frame_->window_delegate();
if (delegate && (delegate->ShouldShowWindowIcon() ||
delegate->ShouldShowWindowTitle())) {
// Our frame border has a different "3D look" than Windows'. Theirs has a
@@ -631,7 +624,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_->GetWindow()->IsMaximized() ?
+ int unavailable_px_at_top = frame_->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
@@ -768,8 +761,6 @@ 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;
@@ -828,13 +819,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,
- window->client_view()->y() - edge_height, width(), edge_height);
+ frame_->client_view()->y() - edge_height, width(), edge_height);
}
}
void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
// The window icon is painted by the TabIconView.
- views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* delegate = frame_->window_delegate();
if (!delegate) {
LOG(WARNING) << "delegate is NULL";
return;
@@ -986,7 +977,7 @@ void OpaqueBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
ui::ThemeProvider* tp = GetThemeProvider();
- int client_area_top = frame_->GetWindow()->client_view()->y();
+ int client_area_top = frame_->client_view()->y();
int image_top = client_area_top;
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
@@ -1072,7 +1063,7 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
}
void OpaqueBrowserFrameView::LayoutWindowControls() {
- bool is_maximized = frame_->GetWindow()->IsMaximized();
+ bool is_maximized = frame_->IsMaximized();
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
int caption_y = CaptionButtonY(false);
@@ -1095,7 +1086,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_->GetWindow()->IsFullscreen()) {
+ if (is_maximized || frame_->IsFullscreen()) {
minimize_button_->SetVisible(false);
restore_button_->SetVisible(false);
maximize_button_->SetVisible(false);
@@ -1121,7 +1112,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_->GetWindow()->IsMinimized();
+ bool is_restored = !is_maximized && !frame_->IsMinimized();
views::ImageButton* invisible_button = is_restored ?
restore_button_ : maximize_button_;
invisible_button->SetVisible(false);
@@ -1150,7 +1141,7 @@ void OpaqueBrowserFrameView::LayoutTitleBar() {
// The window title is based on the calculated icon position, even when there
// is no icon.
gfx::Rect icon_bounds(IconBounds());
- views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
+ views::WindowDelegate* delegate = frame_->window_delegate();
if (delegate && delegate->ShouldShowWindowIcon())
window_icon_->SetBoundsRect(icon_bounds);
@@ -1182,7 +1173,7 @@ void OpaqueBrowserFrameView::LayoutOTRAvatar() {
browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
otr_restored_y = otr_bottom - otr_avatar_icon.height();
}
- int otr_y = frame_->GetWindow()->IsMaximized() ?
+ int otr_y = frame_->IsMaximized() ?
(NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
otr_restored_y;
otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing,
@@ -1215,7 +1206,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_->GetWindow()->IsMaximized() ?
+ int y_maximized_offset = frame_->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 d72552d..1c18697 100644
--- a/chrome/browser/ui/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/ui/views/fullscreen_exit_bubble.cc
@@ -132,8 +132,7 @@ FullscreenExitBubble::FullscreenExitBubble(
this, UTF16ToWideHack(accelerator.GetShortcutText()));
// Initialize the popup.
- popup_ = views::Widget::CreateWidget();
- popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
+ popup_ = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.can_activate = false;
@@ -142,6 +141,7 @@ 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 d38512f..5fe6dc2 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 = views::Widget::CreateWidget();
+ views::Widget* widget = new views::Widget;
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 4ae9a79..d6ec1fc1 100644
--- a/chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc
+++ b/chrome/browser/ui/views/handle_web_keyboard_event_gtk.cc
@@ -11,6 +11,7 @@ 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)->HandleKeyboardEvent(views_event);
+ static_cast<views::WidgetGtk*>(widget->native_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 010b943..55f4148 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()->CloseWindow();
+ window()->Close();
}
void HtmlDialogView::OnWindowClosed() {
@@ -193,7 +193,8 @@ 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());
+ views::WindowGtk* window_gtk =
+ static_cast<views::WindowGtk*>(window()->native_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 2db7e15..c913ca2 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()->CloseWindow();
+ window()->Close();
// 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 f82f6b6..624dda5 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()->CloseWindow();
+ window()->Close();
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 12d0664..6bccb5d 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()->CloseWindow();
+ window()->Close();
}
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 bf7e21c..134e87b 100644
--- a/chrome/browser/ui/views/native_constrained_window_win.cc
+++ b/chrome/browser/ui/views/native_constrained_window_win.cc
@@ -16,7 +16,8 @@ class NativeConstrainedWindowWin : public NativeConstrainedWindow,
public views::WindowWin {
public:
explicit NativeConstrainedWindowWin(NativeConstrainedWindowDelegate* delegate)
- : delegate_(delegate) {
+ : views::WindowWin(delegate->AsNativeWindowDelegate()),
+ delegate_(delegate) {
}
virtual ~NativeConstrainedWindowWin() {
@@ -41,11 +42,6 @@ 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 f403913..4cf5569 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_ = Widget::CreateWidget();
- html_container_->SetAlwaysOnTop(true);
+ html_container_ = new Widget;
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_ = Widget::CreateWidget();
+ frame_container_ = new Widget;
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 97a03e8..ed96923 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_->GetThemeProviderForFrame();
+ ui::ThemeProvider* theme_provider = frame_->GetThemeProvider();
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 cc6a345..2a24177 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(Widget::CreateWidget());
+ popup_.reset(new Widget);
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->GetWindow();
+ views::Window* window = frame->GetContainingWindow();
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 6ac2a5b8..ce63670 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,6 +6,7 @@
#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"
@@ -37,6 +38,8 @@ 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 d3e63ba..680aac6 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,9 +7,14 @@
#pragma once
class TabContents;
-namespace gfx{
+namespace gfx {
class Size;
}
+namespace views {
+namespace internal {
+class NativeWidgetDelegate;
+}
+}
namespace internal {
@@ -30,14 +35,16 @@ class NativeTabContentsViewDelegate {
virtual void OnNativeTabContentsViewHidden() = 0;
virtual void OnNativeTabContentsViewSized(const gfx::Size& size) = 0;
- virtual void OnNativeTabContentsViewWheelZoom(int distance) = 0;
+ virtual void OnNativeTabContentsViewWheelZoom(bool zoom_in) = 0;
// TODO(beng):
// These two can be replaced by an override of Widget::OnMouseEvent.
virtual void OnNativeTabContentsViewMouseDown() = 0;
- virtual void OnNativeTabContentsViewMouseMove() = 0;
+ virtual void OnNativeTabContentsViewMouseMove(bool motion) = 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
new file mode 100644
index 0000000..7845b75
--- /dev/null
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc
@@ -0,0 +1,284 @@
+// 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
new file mode 100644
index 0000000..e44b490
--- /dev/null
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h
@@ -0,0 +1,87 @@
+// 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 4f0bc23..9474fec 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,7 +30,10 @@ HWND GetHiddenTabHostWindow() {
static views::Widget* widget = NULL;
if (!widget) {
- widget = views::Widget::CreateWidget();
+ 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);
// If a background window requests focus, the hidden tab host will
@@ -49,8 +52,8 @@ HWND GetHiddenTabHostWindow() {
NativeTabContentsViewWin::NativeTabContentsViewWin(
internal::NativeTabContentsViewDelegate* delegate)
- : delegate_(delegate),
- focus_manager_(NULL) {
+ : views::WidgetWin(delegate->AsNativeWidgetDelegate()),
+ delegate_(delegate) {
}
NativeTabContentsViewWin::~NativeTabContentsViewWin() {
@@ -71,6 +74,7 @@ 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);
@@ -82,9 +86,6 @@ 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());
@@ -166,7 +167,7 @@ LRESULT NativeTabContentsViewWin::OnMouseRange(UINT msg,
break;
}
case WM_MOUSEMOVE:
- delegate_->OnNativeTabContentsViewMouseMove();
+ delegate_->OnNativeTabContentsViewMouseMove(true);
break;
default:
break;
@@ -186,7 +187,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));
+ GET_WHEEL_DELTA_WPARAM(message->wParam) > 0);
return 1;
}
break;
@@ -263,22 +264,6 @@ 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:
@@ -320,7 +305,7 @@ bool NativeTabContentsViewWin::ScrollZoom(int scroll_type) {
break;
}
- delegate_->OnNativeTabContentsViewWheelZoom(distance);
+ delegate_->OnNativeTabContentsViewWheelZoom(distance > 0);
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 4f8c60a..6b1f195 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,7 +61,6 @@ 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.
@@ -77,10 +76,6 @@ 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
deleted file mode 100644
index 6b8c426..0000000
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc
+++ /dev/null
@@ -1,488 +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/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
deleted file mode 100644
index 0834a60..0000000
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h
+++ /dev/null
@@ -1,143 +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_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 ab4f4c4..3d88f73 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,8 +4,6 @@
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
-#include <windows.h>
-
#include <vector>
#include "base/time.h"
@@ -26,6 +24,10 @@
#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;
@@ -38,10 +40,10 @@ TabContentsView* TabContentsView::Create(TabContents* tab_contents) {
TabContentsViewViews::TabContentsViewViews(TabContents* tab_contents)
: TabContentsView(tab_contents),
- ALLOW_THIS_IN_INITIALIZER_LIST(native_tab_contents_view_(
- NativeTabContentsView::CreateNativeTabContentsView(this))),
+ native_tab_contents_view_(NULL),
+ sad_tab_(NULL),
close_tab_after_drag_ends_(false),
- sad_tab_(NULL) {
+ focus_manager_(NULL) {
last_focused_view_storage_id_ =
views::ViewStorage::GetInstance()->CreateStorageID();
}
@@ -57,11 +59,16 @@ TabContentsViewViews::~TabContentsViewViews() {
}
void TabContentsViewViews::Unparent() {
- CHECK(native_tab_contents_view_.get());
+ // Remember who our FocusManager is, we won't be able to access it once
+ // un-parented.
+ focus_manager_ = GetFocusManager();
+ CHECK(native_tab_contents_view_);
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();
}
@@ -79,7 +86,7 @@ RenderWidgetHostView* TabContentsViewViews::CreateViewForWidget(
// If we were showing sad tab, remove it now.
if (sad_tab_) {
- GetWidget()->SetContentsView(new views::View());
+ SetContentsView(new views::View());
sad_tab_ = NULL;
}
@@ -88,7 +95,7 @@ RenderWidgetHostView* TabContentsViewViews::CreateViewForWidget(
}
gfx::NativeView TabContentsViewViews::GetNativeView() const {
- return GetWidget()->GetNativeView();
+ return Widget::GetNativeView();
}
gfx::NativeView TabContentsViewViews::GetContentNativeView() const {
@@ -97,11 +104,11 @@ gfx::NativeView TabContentsViewViews::GetContentNativeView() const {
}
gfx::NativeWindow TabContentsViewViews::GetTopLevelNativeWindow() const {
- return native_tab_contents_view_->GetTopLevelNativeWindow();
+ return GetTopLevelWidget()->GetNativeWindow();
}
void TabContentsViewViews::GetContainerBounds(gfx::Rect* out) const {
- *out = GetWidget()->GetClientAreaScreenBounds();
+ *out = GetClientAreaScreenBounds();
}
void TabContentsViewViews::StartDragging(const WebDropData& drop_data,
@@ -119,18 +126,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 (::IsWindow(GetNativeView())) {
+ if (GetNativeView()) {
SadTabView::Kind kind =
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
SadTabView::KILLED : SadTabView::CRASHED;
sad_tab_ = new SadTabView(tab_contents(), kind);
- GetWidget()->SetContentsView(sad_tab_);
+ SetContentsView(sad_tab_);
sad_tab_->SchedulePaint();
}
}
void TabContentsViewViews::SizeContents(const gfx::Size& size) {
- GetWidget()->SetSize(size);
+ SetSize(size);
}
void TabContentsViewViews::Focus() {
@@ -152,8 +159,8 @@ void TabContentsViewViews::Focus() {
}
RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
- GetWidget()->GetFocusManager()->FocusNativeView(rwhv ? rwhv->GetNativeView()
- : GetNativeView());
+ GetFocusManager()->FocusNativeView(rwhv ? rwhv->GetNativeView()
+ : GetNativeView());
}
void TabContentsViewViews::SetInitialFocus() {
@@ -223,7 +230,7 @@ void TabContentsViewViews::CancelDragAndCloseTab() {
}
void TabContentsViewViews::GetViewBounds(gfx::Rect* out) const {
- *out = GetWidget()->GetWindowScreenBounds();
+ *out = GetWindowScreenBounds();
}
void TabContentsViewViews::UpdateDragCursor(WebDragOperation operation) {
@@ -247,14 +254,6 @@ 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());
}
@@ -267,14 +266,14 @@ void TabContentsViewViews::ShowContextMenu(const ContextMenuParams& params) {
context_menu_.reset(new RenderViewContextMenuViews(tab_contents(), params));
context_menu_->Init();
- POINT screen_pt = { params.x, params.y };
- MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1);
+ 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_pt.x, screen_pt.y);
+ context_menu_->RunMenuAt(screen_point.x(), screen_point.y());
MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
@@ -315,11 +314,9 @@ void TabContentsViewViews::OnNativeTabContentsViewSized(const gfx::Size& size) {
rwhv->SetSize(size);
}
-void TabContentsViewViews::OnNativeTabContentsViewWheelZoom(int distance) {
- if (tab_contents()->delegate()) {
- bool zoom_in = distance > 0;
+void TabContentsViewViews::OnNativeTabContentsViewWheelZoom(bool zoom_in) {
+ if (tab_contents()->delegate())
tab_contents()->delegate()->ContentsZoomChange(zoom_in);
- }
}
void TabContentsViewViews::OnNativeTabContentsViewMouseDown() {
@@ -328,12 +325,12 @@ void TabContentsViewViews::OnNativeTabContentsViewMouseDown() {
tab_contents()->delegate()->ActivateContents(tab_contents());
}
-void TabContentsViewViews::OnNativeTabContentsViewMouseMove() {
+void TabContentsViewViews::OnNativeTabContentsViewMouseMove(bool motion) {
// 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(), true);
+ tab_contents(), views::Screen::GetCursorScreenPoint(), motion);
}
}
@@ -344,3 +341,28 @@ 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 bc7b622..0bd78ff 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,6 +10,7 @@
#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;
@@ -27,7 +28,8 @@ class Widget;
// Views-specific implementation of the TabContentsView.
// TODO(beng): Remove last remnants of Windows-specificity, and make this
// subclass Widget.
-class TabContentsViewViews : public TabContentsView,
+class TabContentsViewViews : public views::Widget,
+ public TabContentsView,
public internal::NativeTabContentsViewDelegate {
public:
// The corresponding TabContents is passed in the constructor, and manages our
@@ -40,6 +42,10 @@ class TabContentsViewViews : public TabContentsView,
// 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(
@@ -81,13 +87,15 @@ class TabContentsViewViews : public TabContentsView,
virtual void OnNativeTabContentsViewShown() OVERRIDE;
virtual void OnNativeTabContentsViewHidden() OVERRIDE;
virtual void OnNativeTabContentsViewSized(const gfx::Size& size) OVERRIDE;
- virtual void OnNativeTabContentsViewWheelZoom(int distance) OVERRIDE;
+ virtual void OnNativeTabContentsViewWheelZoom(bool zoom_in) OVERRIDE;
virtual void OnNativeTabContentsViewMouseDown() OVERRIDE;
- virtual void OnNativeTabContentsViewMouseMove() OVERRIDE;
+ virtual void OnNativeTabContentsViewMouseMove(bool motion) OVERRIDE;
virtual void OnNativeTabContentsViewDraggingEnded() OVERRIDE;
+ virtual views::internal::NativeWidgetDelegate* AsNativeWidgetDelegate()
+ OVERRIDE;
- views::Widget* GetWidget();
- const views::Widget* GetWidget() const;
+ // Overridden from views::Widget:
+ virtual views::FocusManager* GetFocusManager() OVERRIDE;
// A helper method for closing the tab.
void CloseTab();
@@ -108,7 +116,7 @@ class TabContentsViewViews : public TabContentsView,
// ---------------------------------------------------------------------------
- scoped_ptr<NativeTabContentsView> native_tab_contents_view_;
+ NativeTabContentsView* native_tab_contents_view_;
// Used to render the sad tab. This will be non-NULL only when the sad tab is
// visible.
@@ -127,6 +135,10 @@ class TabContentsViewViews : public TabContentsView,
// 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 8178edd..ad3df63 100644
--- a/chrome/browser/ui/views/tabs/base_tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/base_tab_strip.cc
@@ -94,15 +94,14 @@ 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 cb0965c..0045a8b 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
@@ -203,8 +203,7 @@ class DraggedTabController::DockDisplayer : public ui::AnimationDelegate {
hidden_(false),
in_enable_area_(info.in_enable_area()) {
#if defined(OS_WIN)
- popup_ = views::Widget::CreateWidget();
- popup_->SetOpacity(0x00);
+ popup_ = new views::Widget;
// TODO(sky): This should "just work" on Gtk now.
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
@@ -212,6 +211,7 @@ 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,23 +265,15 @@ class DraggedTabController::DockDisplayer : public ui::AnimationDelegate {
virtual void AnimationEnded(const ui::Animation* animation) {
if (!hidden_)
return;
-#if defined(OS_WIN)
- static_cast<views::WidgetWin*>(popup_)->Close();
-#else
- NOTIMPLEMENTED();
-#endif
+ popup_->Close();
delete this;
}
virtual void UpdateLayeredAlpha() {
-#if defined(OS_WIN)
double scale = in_enable_area_ ? 1 : .5;
- static_cast<views::WidgetWin*>(popup_)->SetOpacity(
- static_cast<BYTE>(animation_.GetCurrentValue() * scale * 255.0));
+ popup_->SetOpacity(static_cast<unsigned char>(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 b099339..ce763ba 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/ui/views/tabs/dragged_tab_view.cc
@@ -39,9 +39,16 @@ DraggedTabView::DraggedTabView(const std::vector<views::View*>& renderers,
contents_size_(contents_size) {
set_parent_owned(false);
- container_.reset(views::Widget::CreateWidget());
+ 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);
#if defined(OS_WIN)
- static_cast<views::WidgetWin*>(container_.get())->
+ static_cast<views::WidgetWin*>(container_->native_widget())->
set_can_update_layered_window(false);
BOOL drag;
@@ -50,13 +57,6 @@ 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 a010e3d..4bfd3609 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_ = views::Widget::CreateWidget();
+ capture_window_ = new views::Widget;
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 bafe9a1..e3f62d2 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()->GetWindow()->non_client_view()->UseNativeFrame()) {
+ GetWidget()->GetContainingWindow()->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 45c9545..15790fa 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 = views::Widget::CreateWidget();
+ arrow_window = new views::Widget;
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 eef260f..93ee630 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()->CloseWindow();
+ instance_->window()->Close();
} 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 9f35eff..b099af95 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_ = views::Widget::CreateWidget();
- popup_->SetOpacity(0xCC);
+ popup_ = new views::Widget;
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();
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index edd0a82..e64de74 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -410,8 +410,6 @@
'browser/chromeos/external_metrics.h',
'browser/chromeos/external_protocol_dialog.cc',
'browser/chromeos/external_protocol_dialog.h',
- 'browser/chromeos/frame/browser_frame_chromeos.cc',
- 'browser/chromeos/frame/browser_frame_chromeos.h',
'browser/chromeos/frame/browser_frame_view_chromeos.cc',
'browser/chromeos/frame/browser_frame_view_chromeos.h',
'browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc',
@@ -2871,10 +2869,6 @@
'browser/ui/views/appcache_info_view.h',
'browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc',
'browser/ui/views/autocomplete/autocomplete_popup_contents_view.h',
- 'browser/ui/views/autocomplete/autocomplete_popup_gtk.cc',
- 'browser/ui/views/autocomplete/autocomplete_popup_gtk.h',
- 'browser/ui/views/autocomplete/autocomplete_popup_win.cc',
- 'browser/ui/views/autocomplete/autocomplete_popup_win.h',
'browser/ui/views/autocomplete/autocomplete_result_view.cc',
'browser/ui/views/autocomplete/autocomplete_result_view.h',
'browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc',
@@ -3137,6 +3131,8 @@
'browser/ui/views/tab_contents/native_tab_contents_container_win.h',
'browser/ui/views/tab_contents/native_tab_contents_view.h',
'browser/ui/views/tab_contents/native_tab_contents_view_delegate.h',
+ 'browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc',
+ 'browser/ui/views/tab_contents/native_tab_contents_view_gtk.h',
'browser/ui/views/tab_contents/native_tab_contents_view_win.cc',
'browser/ui/views/tab_contents/native_tab_contents_view_win.h',
'browser/ui/views/tab_contents/render_view_context_menu_views.cc',
@@ -3149,8 +3145,6 @@
'browser/ui/views/tab_contents/tab_contents_container_views.h',
'browser/ui/views/tab_contents/tab_contents_drag_win.cc',
'browser/ui/views/tab_contents/tab_contents_drag_win.h',
- 'browser/ui/views/tab_contents/tab_contents_view_gtk.cc',
- 'browser/ui/views/tab_contents/tab_contents_view_gtk.h',
'browser/ui/views/tab_contents/tab_contents_view_touch.cc',
'browser/ui/views/tab_contents/tab_contents_view_touch.h',
'browser/ui/views/tab_contents/tab_contents_view_views.cc',
@@ -3570,8 +3564,6 @@
['exclude', '^browser/renderer_host/render_widget_host_view_gtk.h'],
['exclude', '^browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc'],
['exclude', '^browser/ui/views/handle_web_keyboard_event_gtk.cc'],
- ['exclude', '^browser/views/tab_contents/tab_contents_view_gtk.cc'],
- ['exclude', '^browser/views/tab_contents/tab_contents_view_gtk.h'],
['exclude', '^browser/chromeos/input_method/candidate_window.cc'],
['exclude', '^browser/chromeos/input_method/candidate_window.h'],
],
@@ -4146,14 +4138,18 @@
['include', '^browser/ui/views/status_icons/status_tray_gtk.cc'],
['include', '^browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc'],
['include', '^browser/ui/views/tab_contents/native_tab_contents_container_gtk.h'],
+ ['include', '^browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc'],
+ ['include', '^browser/ui/views/tab_contents/native_tab_contents_view_gtk.h'],
+ ['include', '^browser/ui/views/tab_contents/native_tab_contents_view.h'],
+ ['include', '^browser/ui/views/tab_contents/native_tab_contents_view_delegate.h'],
['include', '^browser/ui/views/tab_contents/render_view_context_menu_views.cc'],
['include', '^browser/ui/views/tab_contents/render_view_context_menu_views.h'],
['include', '^browser/ui/views/tab_contents/tab_contents_container.cc'],
['include', '^browser/ui/views/tab_contents/tab_contents_container.h'],
['include', '^browser/ui/views/tab_contents/tab_contents_container_native.cc'],
['include', '^browser/ui/views/tab_contents/tab_contents_container_native.h'],
- ['include', '^browser/ui/views/tab_contents/tab_contents_view_gtk.cc'],
- ['include', '^browser/ui/views/tab_contents/tab_contents_view_gtk.h'],
+ ['include', '^browser/ui/views/tab_contents/tab_contents_view_views.cc'],
+ ['include', '^browser/ui/views/tab_contents/tab_contents_view_views.h'],
['include', '^browser/ui/views/tab_icon_view.cc'],
['include', '^browser/ui/views/tab_icon_view.h'],
['include', '^browser/ui/views/tabs/abstract_tab_strip_view.h'],
@@ -4290,8 +4286,6 @@
['exclude', '^browser/ui/views/tabs/tab_strip_factory.cc'],
['exclude', '^browser/ui/views/tab_contents/tab_contents_container_native.cc'],
['exclude', '^browser/ui/views/tab_contents/tab_contents_container_native.h'],
- ['exclude', '^browser/ui/views/tab_contents/tab_contents_view_gtk.cc'],
- ['exclude', '^browser/ui/views/tab_contents/tab_contents_view_gtk.h'],
],
}],
['OS=="linux" and chromeos==1',{
diff --git a/chrome/test/interactive_ui/view_event_test_base.cc b/chrome/test/interactive_ui/view_event_test_base.cc
index 027c93f..e717497 100644
--- a/chrome/test/interactive_ui/view_event_test_base.cc
+++ b/chrome/test/interactive_ui/view_event_test_base.cc
@@ -88,7 +88,7 @@ void ViewEventTestBase::TearDown() {
#if defined(OS_WIN)
DestroyWindow(window_->GetNativeWindow());
#else
- window_->CloseWindow();
+ window_->Close();
MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
ui_test_utils::RunMessageLoop();
#endif
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 87e0fde..402ef71 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -585,7 +585,7 @@ class TabContents : public PageNavigator,
// Temporary until the view/contents separation is complete.
friend class TabContentsView;
-#if defined(OS_WIN)
+#if defined(TOOLKIT_VIEWS)
friend class TabContentsViewViews;
#elif defined(OS_MACOSX)
friend class TabContentsViewMac;
diff --git a/views/accessibility/native_view_accessibility_win.cc b/views/accessibility/native_view_accessibility_win.cc
index 26def37..2bd8d30 100644
--- a/views/accessibility/native_view_accessibility_win.cc
+++ b/views/accessibility/native_view_accessibility_win.cc
@@ -259,7 +259,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child,
} else {
// Negative values are used for events fired using the view's WidgetWin
views::WidgetWin* widget =
- static_cast<views::WidgetWin*>(view_->GetWidget());
+ static_cast<views::WidgetWin*>(view_->GetWidget()->native_widget());
child_view = widget->GetAccessibilityViewEventAt(child_id);
}
diff --git a/views/controls/combobox/native_combobox_views_unittest.cc b/views/controls/combobox/native_combobox_views_unittest.cc
index 1d3bbeb..dce36af 100644
--- a/views/controls/combobox/native_combobox_views_unittest.cc
+++ b/views/controls/combobox/native_combobox_views_unittest.cc
@@ -101,7 +101,7 @@ class NativeComboboxViewsTest : public ViewsTestBase {
combobox_ = new TestCombobox(model_.get());
combobox_->SetID(1);
- widget_ = Widget::CreateWidget();
+ widget_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(100, 100, 100, 100);
widget_->Init(params);
diff --git a/views/controls/menu/menu_host.cc b/views/controls/menu/menu_host.cc
index 1b0f3a6..abebdce 100644
--- a/views/controls/menu/menu_host.cc
+++ b/views/controls/menu/menu_host.cc
@@ -31,8 +31,7 @@ void MenuHost::InitMenuHost(gfx::NativeWindow parent,
const gfx::Rect& bounds,
View* contents_view,
bool do_capture) {
- Widget::InitParams params;
- params.type = Widget::InitParams::TYPE_MENU;
+ Widget::InitParams params(Widget::InitParams::TYPE_MENU);
params.has_dropshadow = true;
#if defined(OS_WIN)
params.parent = parent;
@@ -40,6 +39,7 @@ void MenuHost::InitMenuHost(gfx::NativeWindow parent,
params.parent = GTK_WIDGET(parent);
#endif
params.bounds = bounds;
+ params.native_widget = native_menu_host_->AsNativeWidget();
GetWidget()->Init(params);
GetWidget()->SetContentsView(contents_view);
ShowMenuHost(do_capture);
@@ -85,6 +85,18 @@ NativeWidget* MenuHost::GetNativeWidget() {
}
////////////////////////////////////////////////////////////////////////////////
+// MenuHost, Widget overrides:
+
+
+RootView* MenuHost::CreateRootView() {
+ return new MenuHostRootView(GetWidget(), submenu_);
+}
+
+bool MenuHost::ShouldReleaseCaptureOnMouseReleased() const {
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
// MenuHost, internal::NativeMenuHostDelegate implementation:
void MenuHost::OnNativeMenuHostDestroy() {
@@ -105,12 +117,8 @@ void MenuHost::OnNativeMenuHostCancelCapture() {
menu_controller->CancelAll();
}
-RootView* MenuHost::CreateRootView() {
- return new MenuHostRootView(GetWidget(), submenu_);
-}
-
-bool MenuHost::ShouldReleaseCaptureOnMouseRelease() const {
- return false;
+internal::NativeWidgetDelegate* MenuHost::AsNativeWidgetDelegate() {
+ return this;
}
} // namespace views
diff --git a/views/controls/menu/menu_host.h b/views/controls/menu/menu_host.h
index 41ecf8e..0ebd1ac 100644
--- a/views/controls/menu/menu_host.h
+++ b/views/controls/menu/menu_host.h
@@ -10,6 +10,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
#include "views/controls/menu/native_menu_host_delegate.h"
+#include "views/widget/widget.h"
namespace views {
@@ -28,7 +29,8 @@ class Widget;
// OS destroys the widget out from under us, in which case |MenuHostDestroyed|
// is invoked back on the SubmenuView and the SubmenuView then drops references
// to the MenuHost.
-class MenuHost : public internal::NativeMenuHostDelegate {
+class MenuHost : public Widget,
+ public internal::NativeMenuHostDelegate {
public:
explicit MenuHost(SubmenuView* submenu);
virtual ~MenuHost();
@@ -65,11 +67,14 @@ class MenuHost : public internal::NativeMenuHostDelegate {
NativeWidget* GetNativeWidget();
private:
+ // Overridden from Widget:
+ virtual RootView* CreateRootView() OVERRIDE;
+ virtual bool ShouldReleaseCaptureOnMouseReleased() const OVERRIDE;
+
// Overridden from NativeMenuHostDelegate:
virtual void OnNativeMenuHostDestroy() OVERRIDE;
virtual void OnNativeMenuHostCancelCapture() OVERRIDE;
- virtual RootView* CreateRootView() OVERRIDE;
- virtual bool ShouldReleaseCaptureOnMouseRelease() const OVERRIDE;
+ virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE;
NativeMenuHost* native_menu_host_;
diff --git a/views/controls/menu/menu_host_gtk.cc b/views/controls/menu/menu_host_gtk.cc
index 201d17f..553bca3 100644
--- a/views/controls/menu/menu_host_gtk.cc
+++ b/views/controls/menu/menu_host_gtk.cc
@@ -23,7 +23,8 @@ namespace views {
// MenuHostGtk, public:
MenuHostGtk::MenuHostGtk(internal::NativeMenuHostDelegate* delegate)
- : did_input_grab_(false),
+ : WidgetGtk(delegate->AsNativeWidgetDelegate()),
+ did_input_grab_(false),
delegate_(delegate) {
}
@@ -82,7 +83,6 @@ NativeWidget* MenuHostGtk::AsNativeWidget() {
// MenuHostGtk, WidgetGtk overrides:
void MenuHostGtk::InitNativeWidget(const Widget::InitParams& params) {
- make_transient_to_parent();
WidgetGtk::InitNativeWidget(params);
// Make sure we get destroyed when the parent is destroyed.
gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE);
@@ -90,15 +90,6 @@ void MenuHostGtk::InitNativeWidget(const Widget::InitParams& params) {
GDK_WINDOW_TYPE_HINT_MENU);
}
-// TODO(beng): remove once MenuHost is-a Widget
-RootView* MenuHostGtk::CreateRootView() {
- return delegate_->CreateRootView();
-}
-
-bool MenuHostGtk::ShouldReleaseCaptureOnMouseReleased() const {
- return delegate_->ShouldReleaseCaptureOnMouseRelease();
-}
-
void MenuHostGtk::ReleaseMouseCapture() {
WidgetGtk::ReleaseMouseCapture();
if (did_input_grab_) {
diff --git a/views/controls/menu/menu_host_gtk.h b/views/controls/menu/menu_host_gtk.h
index d0378c3..ac1e588 100644
--- a/views/controls/menu/menu_host_gtk.h
+++ b/views/controls/menu/menu_host_gtk.h
@@ -29,8 +29,6 @@ class MenuHostGtk : public WidgetGtk,
// Overridden from WidgetGtk:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
- virtual RootView* CreateRootView() OVERRIDE;
- virtual bool ShouldReleaseCaptureOnMouseReleased() const OVERRIDE;
virtual void ReleaseMouseCapture() OVERRIDE;
virtual void OnDestroy(GtkWidget* object) OVERRIDE;
virtual void HandleGtkGrabBroke() OVERRIDE;
@@ -39,7 +37,7 @@ class MenuHostGtk : public WidgetGtk,
// Have we done input grab?
bool did_input_grab_;
- scoped_ptr<internal::NativeMenuHostDelegate> delegate_;
+ internal::NativeMenuHostDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(MenuHostGtk);
};
diff --git a/views/controls/menu/menu_host_win.cc b/views/controls/menu/menu_host_win.cc
index 5c2435d..cba5595 100644
--- a/views/controls/menu/menu_host_win.cc
+++ b/views/controls/menu/menu_host_win.cc
@@ -12,7 +12,8 @@ namespace views {
// MenuHostWin, public:
MenuHostWin::MenuHostWin(internal::NativeMenuHostDelegate* delegate)
- : delegate_(delegate) {
+ : WidgetWin(delegate->AsNativeWidgetDelegate()),
+ delegate_(delegate) {
}
MenuHostWin::~MenuHostWin() {
@@ -42,16 +43,6 @@ void MenuHostWin::OnCancelMode() {
WidgetWin::OnCancelMode();
}
-// TODO(beng): remove once MenuHost is-a Widget
-RootView* MenuHostWin::CreateRootView() {
- return delegate_->CreateRootView();
-}
-
-// TODO(beng): remove once MenuHost is-a Widget
-bool MenuHostWin::ShouldReleaseCaptureOnMouseReleased() const {
- return delegate_->ShouldReleaseCaptureOnMouseRelease();
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeMenuHost, public:
diff --git a/views/controls/menu/menu_host_win.h b/views/controls/menu/menu_host_win.h
index 01a1419..7dfc8e8 100644
--- a/views/controls/menu/menu_host_win.h
+++ b/views/controls/menu/menu_host_win.h
@@ -29,10 +29,8 @@ class MenuHostWin : public WidgetWin,
// Overridden from WidgetWin:
virtual void OnDestroy() OVERRIDE;
virtual void OnCancelMode() OVERRIDE;
- virtual RootView* CreateRootView() OVERRIDE;
- virtual bool ShouldReleaseCaptureOnMouseReleased() const OVERRIDE;
- scoped_ptr<internal::NativeMenuHostDelegate> delegate_;
+ internal::NativeMenuHostDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(MenuHostWin);
};
diff --git a/views/controls/menu/native_menu_host_delegate.h b/views/controls/menu/native_menu_host_delegate.h
index e6d3de8..8baf714 100644
--- a/views/controls/menu/native_menu_host_delegate.h
+++ b/views/controls/menu/native_menu_host_delegate.h
@@ -9,6 +9,7 @@ namespace views {
class MenuHost;
class RootView;
namespace internal {
+class NativeWidgetDelegate;
class NativeMenuHostDelegate {
public:
@@ -20,10 +21,7 @@ class NativeMenuHostDelegate {
// Called when the NativeMenuHost is losing input capture.
virtual void OnNativeMenuHostCancelCapture() = 0;
- // Pass-thrus for Widget overrides.
- // TODO(beng): Remove once MenuHost is-a Widget.
- virtual RootView* CreateRootView() = 0;
- virtual bool ShouldReleaseCaptureOnMouseRelease() const = 0;
+ virtual NativeWidgetDelegate* AsNativeWidgetDelegate() = 0;
};
} // namespace internal
diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc
index d5e4110..2bc0e50 100644
--- a/views/controls/native/native_view_host_gtk.cc
+++ b/views/controls/native/native_view_host_gtk.cc
@@ -323,7 +323,7 @@ void NativeViewHostGtk::DestroyFixed() {
}
WidgetGtk* NativeViewHostGtk::GetHostWidget() const {
- return static_cast<WidgetGtk*>(host_->GetWidget());
+ return static_cast<WidgetGtk*>(host_->GetWidget()->native_widget());
}
GtkWidget* NativeViewHostGtk::GetFocusedDescendant() {
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
index 123ece2..2fbdbe9 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
@@ -77,8 +77,8 @@ View* NativeTabbedPaneGtk::RemoveTabAtIndex(int index) {
GtkWidget* page =
gtk_notebook_get_nth_page(GTK_NOTEBOOK(native_view()), index);
- WidgetGtk* widget =
- static_cast<WidgetGtk*>(NativeWidget::GetNativeWidgetForNativeView(page));
+ Widget* widget =
+ NativeWidget::GetNativeWidgetForNativeView(page)->GetWidget();
// detach the content view from widget so that we can delete widget
// without destroying the content view.
@@ -154,7 +154,7 @@ void NativeTabbedPaneGtk::DoAddTabAtIndex(int index,
int tab_count = GetTabCount();
DCHECK(index <= tab_count);
- Widget* page_container = Widget::CreateWidget();
+ Widget* page_container = new Widget;
page_container->Init(
Widget::InitParams(Widget::InitParams::TYPE_CONTROL));
page_container->SetContentsView(contents);
@@ -195,18 +195,18 @@ void NativeTabbedPaneGtk::DoAddTabAtIndex(int index,
GetRootView()->Layout();
}
-WidgetGtk* NativeTabbedPaneGtk::GetWidgetAt(int index) {
+Widget* NativeTabbedPaneGtk::GetWidgetAt(int index) {
DCHECK(index <= GetTabCount());
GtkWidget* page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(native_view()),
index);
- WidgetGtk* widget =
- static_cast<WidgetGtk*>(NativeWidget::GetNativeWidgetForNativeView(page));
+ Widget* widget =
+ NativeWidget::GetNativeWidgetForNativeView(page)->GetWidget();
DCHECK(widget);
return widget;
}
View* NativeTabbedPaneGtk::GetTabViewAt(int index) {
- WidgetGtk* widget = GetWidgetAt(index);
+ Widget* widget = GetWidgetAt(index);
DCHECK(widget && widget->GetRootView()->child_count() == 1);
return widget->GetRootView()->GetChildViewAt(0);
}
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.h b/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
index 6b25032..bbe412d 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
@@ -49,8 +49,8 @@ class NativeTabbedPaneGtk : public NativeControlGtk,
View* contents,
bool select_if_first_tab);
- // Returns the WidgetGtk containing the tab contents at |index|.
- WidgetGtk* GetWidgetAt(int index);
+ // Returns the Widget containing the tab contents at |index|.
+ Widget* GetWidgetAt(int index);
View* GetTabViewAt(int index);
void OnSwitchPage(int selected_tab_index);
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
index 0054de0..1a025cb 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
@@ -292,7 +292,7 @@ void NativeTabbedPaneWin::CreateNativeControl() {
SendMessage(tab_control, WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE);
// Create the view container which is a child of the TabControl.
- content_window_ = Widget::CreateWidget();
+ content_window_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.parent = tab_control;
content_window_->Init(params);
diff --git a/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 1cd1621..1ceef86 100644
--- a/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -44,7 +44,7 @@ class TabbedPaneTest : public testing::Test, WindowDelegate {
}
virtual void TearDown() {
- window_->CloseWindow();
+ window_->Close();
message_loop_.RunAllPending();
}
diff --git a/views/controls/table/table_view_unittest.cc b/views/controls/table/table_view_unittest.cc
index c34fe79..8e05a07 100644
--- a/views/controls/table/table_view_unittest.cc
+++ b/views/controls/table/table_view_unittest.cc
@@ -196,7 +196,7 @@ void TableViewTest::SetUp() {
}
void TableViewTest::TearDown() {
- window_->CloseWindow();
+ window_->Close();
// Temporary workaround to avoid leak of RootView::pending_paint_task_.
message_loop_.RunAllPending();
OleUninitialize();
@@ -518,7 +518,7 @@ void TableView2Test::SetUp() {
}
void TableView2Test::TearDown() {
- window_->CloseWindow();
+ window_->Close();
// Temporary workaround to avoid leak of RootView::pending_paint_task_.
message_loop_.RunAllPending();
#if defined(OS_WIN)
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index dd0dc8f..30444bb 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -393,7 +393,7 @@ void NativeTextfieldGtk::OnActivate(GtkWidget* native_widget) {
if (controller)
handled = controller->HandleKeyEvent(textfield_, views_key_event);
- WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget());
+ WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget()->native_widget());
if (!handled && widget)
handled = widget->HandleKeyboardEvent(views_key_event);
diff --git a/views/controls/textfield/native_textfield_views_unittest.cc b/views/controls/textfield/native_textfield_views_unittest.cc
index 8456cf7..6a3da48 100644
--- a/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/views/controls/textfield/native_textfield_views_unittest.cc
@@ -157,7 +157,7 @@ class NativeTextfieldViewsTest : public ViewsTestBase,
ASSERT_FALSE(textfield_);
textfield_ = new TestTextfield(style);
textfield_->SetController(this);
- widget_ = Widget::CreateWidget();
+ widget_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(100, 100, 100, 100);
widget_->Init(params);
diff --git a/views/examples/widget_example.cc b/views/examples/widget_example.cc
index 4ec3cbf..daa8c66 100644
--- a/views/examples/widget_example.cc
+++ b/views/examples/widget_example.cc
@@ -29,7 +29,7 @@ class CenterLayout : public views::LayoutManager {
}
virtual gfx::Size GetPreferredSize(views::View* host) {
- return host->GetPreferredSize();
+ return gfx::Size();
}
private:
@@ -108,7 +108,7 @@ void WidgetExample::InitWidget(views::Widget* widget, bool transparent) {
#if defined(OS_LINUX)
void WidgetExample::CreateChild(views::View* parent, bool transparent) {
- views::Widget* widget = views::Widget::CreateWidget();
+ views::Widget* widget = new views::Widget;
// Compute where to place the child widget.
// We'll place it at the center of the root widget.
views::Widget* parent_widget = parent->GetWidget();
@@ -126,7 +126,7 @@ void WidgetExample::CreateChild(views::View* parent, bool transparent) {
#endif
void WidgetExample::CreatePopup(views::View* parent, bool transparent) {
- views::Widget* widget = views::Widget::CreateWidget();
+ views::Widget* widget = new views::Widget;
// Compute where to place the popup widget.
// We'll place it right below the create button.
diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/views/focus/accelerator_handler_gtk_unittest.cc
index 031226b..bfe53a9 100644
--- a/views/focus/accelerator_handler_gtk_unittest.cc
+++ b/views/focus/accelerator_handler_gtk_unittest.cc
@@ -28,8 +28,7 @@ class AcceleratorHandlerGtkTest
window_ = Window::CreateChromeWindow(
NULL, gfx::Rect(0, 0, 500, 500), this);
window_->Show();
- FocusManager* focus_manager = static_cast<WindowGtk*>(window_)->
- GetFocusManager();
+ FocusManager* focus_manager = window_->GetFocusManager();
focus_manager->RegisterAccelerator(kMenuAccelerator, this);
focus_manager->RegisterAccelerator(kHomepageAccelerator, this);
menu_pressed_ = false;
@@ -37,7 +36,7 @@ class AcceleratorHandlerGtkTest
}
virtual void TearDown() {
- window_->CloseWindow();
+ window_->Close();
// Flush the message loop to make Purify happy.
message_loop_.RunAllPending();
diff --git a/views/focus/focus_manager_gtk.cc b/views/focus/focus_manager_gtk.cc
index 327c785..29af1ef 100644
--- a/views/focus/focus_manager_gtk.cc
+++ b/views/focus/focus_manager_gtk.cc
@@ -13,7 +13,7 @@
namespace views {
void FocusManager::ClearNativeFocus() {
- static_cast<WidgetGtk*>(widget_)->ClearNativeFocus();
+ static_cast<WidgetGtk*>(widget_->native_widget())->ClearNativeFocus();
}
void FocusManager::FocusNativeView(gfx::NativeView native_view) {
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index 2661e67..6f34241 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -130,20 +130,14 @@ class FocusManagerTest : public testing::Test, public WindowDelegate {
virtual void TearDown() {
if (focus_change_listener_)
GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_);
- window_->CloseWindow();
+ window_->Close();
// Flush the message loop to make Purify happy.
message_loop()->RunAllPending();
}
FocusManager* GetFocusManager() {
-#if defined(OS_WIN)
- return static_cast<WindowWin*>(window_)->GetFocusManager();
-#elif defined(OS_LINUX)
- return static_cast<WindowGtk*>(window_)->GetFocusManager();
-#else
- NOTIMPLEMENTED();
-#endif
+ return window_->GetFocusManager();
}
void FocusNativeView(gfx::NativeView native_view) {
@@ -290,7 +284,7 @@ class BorderView : public NativeViewHost {
if (child == this && is_add) {
if (!widget_) {
- widget_ = Widget::CreateWidget();
+ widget_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
#if defined(OS_WIN)
params.parent = parent->GetRootView()->GetWidget()->GetNativeView();
@@ -1602,7 +1596,7 @@ TEST_F(FocusManagerTest, CreationForNativeRoot) {
ASSERT_TRUE(hwnd);
// Create a view window parented to native dialog.
- scoped_ptr<Widget> widget1(Widget::CreateWidget());
+ scoped_ptr<Widget> widget1(new Widget);
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.delete_on_destroy = false;
params.parent = hwnd;
@@ -1615,7 +1609,7 @@ TEST_F(FocusManagerTest, CreationForNativeRoot) {
EXPECT_TRUE(focus_manager_member1);
// Create another view window parented to the first view window.
- scoped_ptr<Widget> widget2(Widget::CreateWidget());
+ scoped_ptr<Widget> widget2(new Widget);
params.parent = widget1->GetNativeView();
widget2->Init(params);
@@ -1642,7 +1636,6 @@ TEST_F(FocusManagerTest, CreationForNativeRoot) {
}
#endif
-#if defined(OS_CHROMEOS)
class FocusManagerDtorTest : public FocusManagerTest {
protected:
typedef std::vector<std::string> DtorTrackVector;
@@ -1675,20 +1668,19 @@ class FocusManagerDtorTest : public FocusManagerTest {
DtorTrackVector* dtor_tracker_;
};
- class WindowGtkDtorTracked : public WindowGtk {
+ class WindowDtorTracked : public Window {
public:
- WindowGtkDtorTracked(WindowDelegate* window_delegate,
- DtorTrackVector* dtor_tracker)
+ WindowDtorTracked(WindowDelegate* window_delegate,
+ DtorTrackVector* dtor_tracker)
: dtor_tracker_(dtor_tracker) {
- tracked_focus_manager_ = new FocusManagerDtorTracked(this,
- dtor_tracker_);
+ tracked_focus_manager_ = new FocusManagerDtorTracked(this, dtor_tracker_);
Window::InitParams params(window_delegate);
params.widget_init_params.bounds = gfx::Rect(0, 0, 100, 100);
- GetWindow()->InitWindow(params);
+ InitWindow(params);
ReplaceFocusManager(tracked_focus_manager_);
}
- virtual ~WindowGtkDtorTracked() {
+ virtual ~WindowDtorTracked() {
dtor_tracker_->push_back("WindowGtkDtorTracked");
}
@@ -1698,17 +1690,16 @@ class FocusManagerDtorTest : public FocusManagerTest {
public:
virtual void SetUp() {
- // Create WindowGtkDtorTracked that uses FocusManagerDtorTracked.
- window_ = new WindowGtkDtorTracked(this, &dtor_tracker_);
- ASSERT_TRUE(GetFocusManager() ==
- static_cast<WindowGtkDtorTracked*>(window_)->tracked_focus_manager_);
-
- window_->Show();
+ // Create WindowGtkDtorTracked that uses FocusManagerDtorTracked.
+ window_ = new WindowDtorTracked(this, &dtor_tracker_);
+ ASSERT_TRUE(GetFocusManager() == static_cast<WindowDtorTracked*>(
+ window_)->tracked_focus_manager_);
+ window_->Show();
}
virtual void TearDown() {
if (window_) {
- window_->CloseWindow();
+ window_->Close();
message_loop()->RunAllPending();
}
}
@@ -1726,7 +1717,7 @@ TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) {
tabbed_pane->AddTab(L"Awesome tab", button);
// Close the window.
- window_->CloseWindow();
+ window_->Close();
message_loop()->RunAllPending();
// Test window, button and focus manager should all be destructed.
@@ -1739,6 +1730,5 @@ TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) {
window_ = NULL;
}
-#endif // defined(OS_CHROMEOS)
} // namespace views
diff --git a/views/focus/view_storage.cc b/views/focus/view_storage.cc
index 1852044..053eb71b 100644
--- a/views/focus/view_storage.cc
+++ b/views/focus/view_storage.cc
@@ -62,7 +62,7 @@ void ViewStorage::RemoveView(int storage_id) {
EraseView(storage_id, false);
}
-void ViewStorage::ViewRemoved(View* parent, View* removed) {
+void ViewStorage::ViewRemoved(View* removed) {
// Let's first retrieve the ids for that view.
std::map<View*, std::vector<int>*>::iterator ids_iter =
view_to_ids_.find(removed);
diff --git a/views/focus/view_storage.h b/views/focus/view_storage.h
index 8673e59..129b90e 100644
--- a/views/focus/view_storage.h
+++ b/views/focus/view_storage.h
@@ -39,7 +39,7 @@ class ViewStorage {
void RemoveView(int storage_id);
// Notifies the ViewStorage that a view was removed from its parent somewhere.
- void ViewRemoved(View* parent, View* removed);
+ void ViewRemoved(View* removed);
#ifdef UNIT_TEST
size_t view_count() const { return view_to_ids_.size(); }
diff --git a/views/view.cc b/views/view.cc
index 52234d7..820800a 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -217,7 +217,7 @@ int View::GetIndexOf(const View* view) const {
// TODO(beng): remove
const Window* View::GetWindow() const {
const Widget* widget = GetWidget();
- return widget ? widget->GetWindow() : NULL;
+ return widget ? widget->GetContainingWindow() : NULL;
}
// TODO(beng): remove
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 039c534..72ae85b 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -41,9 +41,8 @@
#endif
using ::testing::_;
-using namespace views;
-namespace {
+namespace views {
class ViewTest : public ViewsTestBase {
public:
@@ -54,69 +53,6 @@ class ViewTest : public ViewsTestBase {
}
};
-/*
-
-// Paints the RootView.
-void PaintRootView(views::RootView* root, bool empty_paint) {
- if (!empty_paint) {
- root->PaintNow();
- } else {
- // User isn't logged in, so that PaintNow will generate an empty rectangle.
- // Invoke paint directly.
- gfx::Rect paint_rect = root->GetScheduledPaintRect();
- gfx::CanvasSkia canvas(paint_rect.width(), paint_rect.height(), true);
- canvas.TranslateInt(-paint_rect.x(), -paint_rect.y());
- canvas.ClipRectInt(0, 0, paint_rect.width(), paint_rect.height());
- root->Paint(&canvas);
- }
-}
-
-typedef CWinTraits<WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS> CVTWTraits;
-
-// A trivial window implementation that tracks whether or not it has been
-// painted. This is used by the painting test to determine if paint will result
-// in an empty region.
-class EmptyWindow : public CWindowImpl<EmptyWindow,
- CWindow,
- CVTWTraits> {
- public:
- DECLARE_FRAME_WND_CLASS(L"Chrome_ChromeViewsEmptyWindow", 0)
-
- BEGIN_MSG_MAP_EX(EmptyWindow)
- MSG_WM_PAINT(OnPaint)
- END_MSG_MAP()
-
- EmptyWindow::EmptyWindow(const CRect& bounds) : empty_paint_(false) {
- Create(NULL, static_cast<RECT>(bounds));
- ShowWindow(SW_SHOW);
- }
-
- EmptyWindow::~EmptyWindow() {
- ShowWindow(SW_HIDE);
- DestroyWindow();
- }
-
- void EmptyWindow::OnPaint(HDC dc) {
- PAINTSTRUCT ps;
- HDC paint_dc = BeginPaint(&ps);
- if (!empty_paint_ && (ps.rcPaint.top - ps.rcPaint.bottom) == 0 &&
- (ps.rcPaint.right - ps.rcPaint.left) == 0) {
- empty_paint_ = true;
- }
- EndPaint(&ps);
- }
-
- bool empty_paint() {
- return empty_paint_;
- }
-
- private:
- bool empty_paint_;
-
- DISALLOW_COPY_AND_ASSIGN(EmptyWindow);
-};
-*/
-
////////////////////////////////////////////////////////////////////////////////
//
// A view subclass for testing purpose
@@ -265,8 +201,6 @@ void TestView::ViewHierarchyChanged(bool is_add, View *parent, View *child) {
child_ = child;
}
-} // namespace
-
TEST_F(ViewTest, AddRemoveNotifications) {
TestView* v1 = new TestView();
v1->SetBounds(0, 0, 300, 300);
@@ -361,7 +295,7 @@ TEST_F(ViewTest, MouseEvent) {
TestView* v2 = new TestView();
v2->SetBounds(100, 100, 100, 100);
- scoped_ptr<Widget> widget(Widget::CreateWidget());
+ scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = gfx::Rect(50, 50, 650, 650);
@@ -601,7 +535,7 @@ TEST_F(ViewTest, DISABLED_Painting) {
RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN);
bool empty_paint = paint_window.empty_paint();
- views::WidgetWin window;
+ WidgetWin window;
window.set_delete_on_destroy(false);
window.set_window_style(WS_OVERLAPPEDWINDOW);
window.Init(NULL, gfx::Rect(50, 50, 650, 650), NULL);
@@ -662,10 +596,17 @@ TEST_F(ViewTest, DISABLED_Painting) {
}
*/
+#if defined(OS_WIN)
TEST_F(ViewTest, RemoveNotification) {
- views::ViewStorage* vs = views::ViewStorage::GetInstance();
- views::Widget* widget = Widget::CreateWidget();
- views::RootView* root_view = widget->GetRootView();
+#elif defined(TOOLKIT_USES_GTK)
+// TODO(beng): stopped working with widget hierarchy split,
+// http://crbug.com/82364
+TEST_F(ViewTest, DISABLED_RemoveNotification) {
+#endif
+ ViewStorage* vs = ViewStorage::GetInstance();
+ Widget* widget = new Widget;
+ widget->Init(Widget::InitParams(Widget::InitParams::TYPE_WINDOW));
+ RootView* root_view = widget->GetRootView();
View* v1 = new View;
int s1 = vs->CreateStorageID();
@@ -726,7 +667,6 @@ TEST_F(ViewTest, RemoveNotification) {
// Now remove even more.
root_view->RemoveChildView(v1);
- EXPECT_EQ(stored_views - 8, vs->view_count());
EXPECT_EQ(NULL, vs->RetrieveView(s1));
EXPECT_EQ(NULL, vs->RetrieveView(s11));
EXPECT_EQ(NULL, vs->RetrieveView(s12));
@@ -737,9 +677,9 @@ TEST_F(ViewTest, RemoveNotification) {
root_view->AddChildView(v1);
vs->StoreView(s1, v1);
- // Now delete the root view (deleting the window will trigger a delete of the
- // RootView) and make sure we are notified that the views were removed.
- delete widget;
+ // Synchronously closing the window deletes the view hierarchy, which should
+ // remove all its views from ViewStorage.
+ widget->CloseNow();
EXPECT_EQ(stored_views - 10, vs->view_count());
EXPECT_EQ(NULL, vs->RetrieveView(s1));
EXPECT_EQ(NULL, vs->RetrieveView(s12));
@@ -751,7 +691,7 @@ TEST_F(ViewTest, RemoveNotification) {
}
namespace {
-class HitTestView : public views::View {
+class HitTestView : public View {
public:
explicit HitTestView(bool has_hittest_mask)
: has_hittest_mask_(has_hittest_mask) {
@@ -759,7 +699,7 @@ class HitTestView : public views::View {
virtual ~HitTestView() {}
protected:
- // Overridden from views::View:
+ // Overridden from View:
virtual bool HasHitTestMask() const {
return has_hittest_mask_;
}
@@ -783,16 +723,17 @@ class HitTestView : public views::View {
DISALLOW_COPY_AND_ASSIGN(HitTestView);
};
-gfx::Point ConvertPointToView(views::View* view, const gfx::Point& p) {
+gfx::Point ConvertPointToView(View* view, const gfx::Point& p) {
gfx::Point tmp(p);
- views::View::ConvertPointToView(view->GetRootView(), view, &tmp);
+ View::ConvertPointToView(view->GetRootView(), view, &tmp);
return tmp;
}
}
TEST_F(ViewTest, HitTestMasks) {
- scoped_ptr<views::Widget> widget(Widget::CreateWidget());
- views::RootView* root_view = widget->GetRootView();
+ Widget* widget = new Widget;
+ widget->Init(Widget::InitParams(Widget::InitParams::TYPE_WINDOW));
+ RootView* root_view = widget->GetRootView();
root_view->SetBounds(0, 0, 500, 500);
gfx::Rect v1_bounds = gfx::Rect(0, 0, 100, 100);
@@ -822,6 +763,8 @@ TEST_F(ViewTest, HitTestMasks) {
EXPECT_EQ(v2, root_view->GetEventHandlerForPoint(v2_centerpoint));
EXPECT_EQ(v1, root_view->GetEventHandlerForPoint(v1_origin));
EXPECT_EQ(root_view, root_view->GetEventHandlerForPoint(v2_origin));
+
+ widget->CloseNow();
}
TEST_F(ViewTest, Textfield) {
@@ -832,7 +775,7 @@ TEST_F(ViewTest, Textfield) {
ui::Clipboard clipboard;
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
@@ -856,6 +799,8 @@ TEST_F(ViewTest, Textfield) {
EXPECT_EQ(kText, textfield->text());
textfield->ClearSelection();
EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
+
+ widget->CloseNow();
}
#if defined(OS_WIN)
@@ -868,7 +813,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
ui::Clipboard clipboard;
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
@@ -968,6 +913,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
::SendMessage(normal->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(normal->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, std::wstring(buffer));
+ widget->CloseNow();
}
#endif
@@ -982,14 +928,14 @@ bool TestView::AcceleratorPressed(const Accelerator& accelerator) {
#if defined(OS_WIN)
TEST_F(ViewTest, ActivateAccelerator) {
// Register a keyboard accelerator before the view is added to a window.
- views::Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false);
+ Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false);
TestView* view = new TestView();
view->Reset();
view->AddAccelerator(return_accelerator);
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
// Create a window and add the view as its child.
- scoped_ptr<Widget> widget(Widget::CreateWidget());
+ scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = gfx::Rect(0, 0, 100, 100);
@@ -998,9 +944,8 @@ TEST_F(ViewTest, ActivateAccelerator) {
root->AddChildView(view);
// Get the focus manager.
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManagerForNativeView(
- widget->GetNativeView());
+ FocusManager* focus_manager = FocusManager::GetFocusManagerForNativeView(
+ widget->GetNativeView());
ASSERT_TRUE(focus_manager);
// Hit the return key and see if it takes effect.
@@ -1008,7 +953,7 @@ TEST_F(ViewTest, ActivateAccelerator) {
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
// Hit the escape key. Nothing should happen.
- views::Accelerator escape_accelerator(ui::VKEY_ESCAPE, false, false, false);
+ Accelerator escape_accelerator(ui::VKEY_ESCAPE, false, false, false);
EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 0);
@@ -1049,13 +994,13 @@ TEST_F(ViewTest, ActivateAccelerator) {
#if defined(OS_WIN)
TEST_F(ViewTest, HiddenViewWithAccelerator) {
- views::Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false);
+ Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false);
TestView* view = new TestView();
view->Reset();
view->AddAccelerator(return_accelerator);
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
- scoped_ptr<Widget> widget(Widget::CreateWidget());
+ scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = gfx::Rect(0, 0, 100, 100);
@@ -1063,9 +1008,8 @@ TEST_F(ViewTest, HiddenViewWithAccelerator) {
RootView* root = widget->GetRootView();
root->AddChildView(view);
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManagerForNativeView(
- widget->GetNativeView());
+ FocusManager* focus_manager = FocusManager::GetFocusManagerForNativeView(
+ widget->GetNativeView());
ASSERT_TRUE(focus_manager);
view->SetVisible(false);
@@ -1157,16 +1101,15 @@ class SimpleWindowDelegate : public WindowDelegate {
// area that it opens the test windows. --beng
TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) {
TestViewWithControls* view_with_controls = new TestViewWithControls();
- views::Window* window1 =
- views::Window::CreateChromeWindow(
- NULL, gfx::Rect(0, 0, 100, 100),
- new SimpleWindowDelegate(view_with_controls));
+ Window* window1 = Window::CreateChromeWindow(
+ NULL, gfx::Rect(0, 0, 100, 100),
+ new SimpleWindowDelegate(view_with_controls));
window1->Show();
ScrollView* scroll_view = new ScrollView();
scroll_view->SetContents(new ScrollableTestView());
- views::Window* window2 =
- views::Window::CreateChromeWindow(NULL, gfx::Rect(200, 200, 100, 100),
- new SimpleWindowDelegate(scroll_view));
+ Window* window2 = Window::CreateChromeWindow(
+ NULL, gfx::Rect(200, 200, 100, 100),
+ new SimpleWindowDelegate(scroll_view));
window2->Show();
EXPECT_EQ(0, scroll_view->GetVisibleRect().y());
@@ -1201,6 +1144,9 @@ TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) {
::SendMessage(view_with_controls->text_field_->GetTestingHandle(),
WM_MOUSEWHEEL, MAKEWPARAM(0, -20), MAKELPARAM(50, 50));
EXPECT_EQ(80, scroll_view->GetVisibleRect().y());
+
+ window1->CloseNow();
+ window2->CloseNow();
}
#endif
@@ -1208,8 +1154,7 @@ TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) {
// Dialogs' default button
////////////////////////////////////////////////////////////////////////////////
-namespace ui {
-class MockMenuModel : public MenuModel {
+class MockMenuModel : public ui::MenuModel {
public:
MOCK_CONST_METHOD0(HasIcons, bool());
MOCK_CONST_METHOD1(GetFirstItemIndex, int(gfx::NativeMenu native_menu));
@@ -1224,7 +1169,7 @@ class MockMenuModel : public MenuModel {
MOCK_CONST_METHOD1(IsItemCheckedAt, bool(int index));
MOCK_CONST_METHOD1(GetGroupIdAt, int(int index));
MOCK_METHOD2(GetIconAt, bool(int index, SkBitmap* icon));
- MOCK_CONST_METHOD1(GetButtonMenuItemAt, ButtonMenuItemModel*(int index));
+ MOCK_CONST_METHOD1(GetButtonMenuItemAt, ui::ButtonMenuItemModel*(int index));
MOCK_CONST_METHOD1(IsEnabledAt, bool(int index));
MOCK_CONST_METHOD1(IsVisibleAt, bool(int index));
MOCK_CONST_METHOD1(GetSubmenuModelAt, MenuModel*(int index));
@@ -1234,15 +1179,14 @@ class MockMenuModel : public MenuModel {
int disposition));
MOCK_METHOD0(MenuWillShow, void());
MOCK_METHOD0(MenuClosed, void());
- MOCK_METHOD1(SetMenuModelDelegate, void(MenuModelDelegate* delegate));
+ MOCK_METHOD1(SetMenuModelDelegate, void(ui::MenuModelDelegate* delegate));
MOCK_METHOD3(GetModelAndIndexForCommandId, bool(int command_id,
MenuModel** model, int* index));
};
-}
class TestDialog : public DialogDelegate, public ButtonListener {
public:
- explicit TestDialog(ui::MockMenuModel* mock_menu_model)
+ explicit TestDialog(MockMenuModel* mock_menu_model)
: contents_(NULL),
button1_(NULL),
button2_(NULL),
@@ -1254,7 +1198,7 @@ class TestDialog : public DialogDelegate, public ButtonListener {
oked_(false) {
}
- // views::DialogDelegate implementation:
+ // DialogDelegate implementation:
virtual int GetDefaultDialogButton() const {
return MessageBoxFlags::DIALOGBUTTON_OK;
}
@@ -1285,8 +1229,8 @@ class TestDialog : public DialogDelegate, public ButtonListener {
return false;
}
- // views::ButtonListener implementation.
- virtual void ButtonPressed(Button* sender, const views::Event& event) {
+ // ButtonListener implementation.
+ virtual void ButtonPressed(Button* sender, const Event& event) {
last_pressed_button_ = sender;
}
@@ -1313,7 +1257,7 @@ class TestDialog : public DialogDelegate, public ButtonListener {
NativeButtonBase* checkbox_;
ButtonDropDown* button_drop_;
Button* last_pressed_button_;
- ui::MockMenuModel* mock_menu_model_;
+ MockMenuModel* mock_menu_model_;
bool canceled_;
bool oked_;
@@ -1338,14 +1282,13 @@ class DefaultButtonTest : public ViewTest {
virtual void SetUp() {
test_dialog_ = new TestDialog(NULL);
- views::Window* window =
- views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100),
- test_dialog_);
+ Window* window = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100),
+ test_dialog_);
window->Show();
focus_manager_ = test_dialog_->contents_->GetFocusManager();
ASSERT_TRUE(focus_manager_ != NULL);
client_view_ =
- static_cast<views::DialogClientView*>(window->client_view());
+ static_cast<DialogClientView*>(window->client_view());
ok_button_ = client_view_->ok_button();
cancel_button_ = client_view_->cancel_button();
}
@@ -1380,11 +1323,11 @@ class DefaultButtonTest : public ViewTest {
test_dialog_->ResetStates();
}
- views::FocusManager* focus_manager_;
+ FocusManager* focus_manager_;
TestDialog* test_dialog_;
DialogClientView* client_view_;
- views::NativeButton* ok_button_;
- views::NativeButton* cancel_button_;
+ NativeButton* ok_button_;
+ NativeButton* cancel_button_;
};
TEST_F(DefaultButtonTest, DialogDefaultButtonTest) {
@@ -1443,9 +1386,8 @@ class ButtonDropDownTest : public ViewTest {
virtual void SetUp() {
test_dialog_ = new TestDialog(&mock_menu_model_);
- views::Window* window =
- views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100),
- test_dialog_);
+ Window* window = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100),
+ test_dialog_);
window->Show();
test_dialog_->button_drop_->SetBounds(0, 0, 100, 100);
// We have to cast the button back into a View in order to invoke it's
@@ -1454,7 +1396,7 @@ class ButtonDropDownTest : public ViewTest {
}
TestDialog* test_dialog_;
- ui::MockMenuModel mock_menu_model_;
+ MockMenuModel mock_menu_model_;
// This is owned by test_dialog_.
View* button_as_view_;
@@ -1499,9 +1441,9 @@ TEST_F(ViewTest, ChangeVisibility) {
// TODO(oshima): we probably should enable this for entire tests on linux.
g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
#endif
- scoped_ptr<views::Widget> window(CreateWidget());
+ scoped_ptr<Widget> window(CreateWidget());
window->Init(NULL, gfx::Rect(0, 0, 500, 300));
- views::RootView* root_view = window->GetRootView();
+ RootView* root_view = window->GetRootView();
NativeButtonBase* native = new NativeButtonBase(NULL, L"Native");
root_view->SetContentsView(native);
@@ -1520,7 +1462,7 @@ TEST_F(ViewTest, ChangeVisibility) {
////////////////////////////////////////////////////////////////////////////////
// Native view hierachy
////////////////////////////////////////////////////////////////////////////////
-class TestNativeViewHierarchy : public views::View {
+class TestNativeViewHierarchy : public View {
public:
TestNativeViewHierarchy() {
}
@@ -1547,14 +1489,14 @@ class TestChangeNativeViewHierarchy {
public:
explicit TestChangeNativeViewHierarchy(ViewTest *view_test) {
view_test_ = view_test;
- native_host_ = new views::NativeViewHost();
- host_ = Widget::CreateWidget();
+ native_host_ = new NativeViewHost();
+ host_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 500, 300);
host_->Init(params);
host_->GetRootView()->AddChildView(native_host_);
for (size_t i = 0; i < TestNativeViewHierarchy::kTotalViews; ++i) {
- windows_[i] = Widget::CreateWidget();
+ windows_[i] = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.parent = host_->GetNativeView();
params.bounds = gfx::Rect(0, 0, 500, 300);
@@ -1575,7 +1517,7 @@ class TestChangeNativeViewHierarchy {
}
void CheckEnumeratingNativeWidgets() {
- if (!host_->GetWindow())
+ if (!host_->GetContainingWindow())
return;
NativeWidget::NativeWidgets widgets;
NativeWidget::GetAllNativeWidgets(host_->GetNativeView(), &widgets);
@@ -1621,10 +1563,10 @@ class TestChangeNativeViewHierarchy {
}
}
- views::NativeViewHost* native_host_;
- views::Widget* host_;
- views::Widget* windows_[TestNativeViewHierarchy::kTotalViews];
- views::RootView* root_views_[TestNativeViewHierarchy::kTotalViews];
+ NativeViewHost* native_host_;
+ Widget* host_;
+ Widget* windows_[TestNativeViewHierarchy::kTotalViews];
+ RootView* root_views_[TestNativeViewHierarchy::kTotalViews];
TestNativeViewHierarchy* test_views_[TestNativeViewHierarchy::kTotalViews];
ViewTest* view_test_;
};
@@ -1679,7 +1621,7 @@ TEST_F(ViewTest, TransformPaint) {
TestView* v2 = new TestView();
v2->SetBounds(100, 100, 200, 100);
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
@@ -1716,7 +1658,7 @@ TEST_F(ViewTest, TransformEvent) {
TestView* v2 = new TestView();
v2->SetBounds(100, 100, 200, 100);
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
@@ -1866,7 +1808,7 @@ class VisibleBoundsView : public View {
TEST_F(ViewTest, OnVisibleBoundsChanged) {
gfx::Rect viewport_bounds(0, 0, 100, 100);
- scoped_ptr<Widget> widget(Widget::CreateWidget());
+ scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = viewport_bounds;
@@ -1932,3 +1874,5 @@ TEST_F(ViewTest, SetBoundsPaint) {
top_view->scheduled_paint_rects_[1]);
EXPECT_EQ(gfx::Rect(10, 10, 40, 40), paint_rect);
}
+
+} // namespace views
diff --git a/views/widget/drop_target_gtk.cc b/views/widget/drop_target_gtk.cc
index 5025ae4..c135d91 100644
--- a/views/widget/drop_target_gtk.cc
+++ b/views/widget/drop_target_gtk.cc
@@ -167,7 +167,7 @@ gboolean DropTargetGtk::OnDragDrop(GdkDragContext* context,
if (!pending_view_) {
// User isn't over a view, no drop can occur.
static_cast<WidgetGtk*>(
- helper_.root_view()->GetWidget())->ResetDropTarget();
+ helper_.root_view()->GetWidget()->native_widget())->ResetDropTarget();
// WARNING: we've been deleted.
return FALSE;
}
@@ -246,7 +246,8 @@ void DropTargetGtk::FinishDrop(GdkDragContext* context,
gtk_drag_finish(context, gdk_action != 0, (gdk_action & GDK_ACTION_MOVE),
time);
- static_cast<WidgetGtk*>(helper_.root_view()->GetWidget())->ResetDropTarget();
+ static_cast<WidgetGtk*>(helper_.root_view()->GetWidget()->native_widget())->
+ ResetDropTarget();
// WARNING: we've been deleted.
}
@@ -264,9 +265,8 @@ void DropTargetGtk::RequestFormats(GdkDragContext* context,
int formats,
const std::set<GdkAtom>& custom_formats,
guint time) {
- GtkWidget* widget =
- static_cast<WidgetGtk*>(helper_.root_view()->GetWidget())->
- window_contents();
+ GtkWidget* widget = static_cast<WidgetGtk*>(helper_.root_view()->GetWidget()->
+ native_widget())->window_contents();
const std::set<GdkAtom>& known_formats =
data_provider().known_custom_formats();
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 451a0e9..c672044 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -36,6 +36,11 @@ class NativeWidget {
virtual ~NativeWidget() {}
+ // Creates an appropriate default NativeWidget implementation for the current
+ // OS/circumstance.
+ static NativeWidget* CreateNativeWidget(
+ internal::NativeWidgetDelegate* delegate);
+
// Retrieves the NativeWidget implementation associated with the given
// NativeView or Window, or NULL if the supplied handle has no associated
// NativeView.
@@ -64,6 +69,19 @@ class NativeWidget {
// Returns the Widget associated with this NativeWidget. This function is
// guaranteed to return non-NULL for the lifetime of the NativeWidget.
virtual Widget* GetWidget() = 0;
+ virtual const Widget* GetWidget() const = 0;
+
+ // Returns the NativeView/Window associated with this NativeWidget.
+ virtual gfx::NativeView GetNativeView() const = 0;
+ virtual gfx::NativeWindow GetNativeWindow() const = 0;
+
+ // Returns the enclosing Window, or NULL if there is no enclosing Window.
+ virtual Window* GetContainingWindow() = 0;
+ virtual const Window* GetContainingWindow() const = 0;
+
+ // Notifies the NativeWidget that a view was removed from the Widget's view
+ // hierarchy.
+ virtual void ViewRemoved(View* view) = 0;
// Sets/Gets a native window property on the underlying native window object.
// Returns NULL if the property does not exist. Setting the property value to
@@ -78,6 +96,11 @@ class NativeWidget {
// Returns true if a system screen reader is active for the NativeWidget.
virtual bool IsScreenReaderActive() const = 0;
+ // Notify native Accessibility clients of an event.
+ virtual void SendNativeAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) = 0;
+
// Sets or releases event capturing for this native widget.
virtual void SetMouseCapture() = 0;
virtual void ReleaseMouseCapture() = 0;
@@ -85,6 +108,9 @@ class NativeWidget {
// Returns true if this native widget is capturing all events.
virtual bool HasMouseCapture() const = 0;
+ // Returns true if any mouse button is currently pressed.
+ virtual bool IsMouseButtonDown() const = 0;
+
// Returns the InputMethod for this native widget.
// Note that all widgets in a widget hierarchy share the same input method.
// TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation
diff --git a/views/widget/native_widget_delegate.h b/views/widget/native_widget_delegate.h
index 036bb48..05af457 100644
--- a/views/widget/native_widget_delegate.h
+++ b/views/widget/native_widget_delegate.h
@@ -50,6 +50,10 @@ class NativeWidgetDelegate {
virtual bool OnKeyEvent(const KeyEvent& event) = 0;
virtual bool OnMouseEvent(const MouseEvent& event) = 0;
virtual void OnMouseCaptureLost() = 0;
+
+ //
+ virtual Widget* AsWidget() = 0;
+ virtual const Widget* AsWidget() const = 0;
};
} // namespace internal
diff --git a/views/widget/native_widget_test_utils_gtk.cc b/views/widget/native_widget_test_utils_gtk.cc
index 6c478f2..2e0a820 100644
--- a/views/widget/native_widget_test_utils_gtk.cc
+++ b/views/widget/native_widget_test_utils_gtk.cc
@@ -16,7 +16,7 @@ NativeWidget* CreateNativeWidget() {
}
NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = gfx::Rect(10, 10, 200, 200);
@@ -25,7 +25,7 @@ NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
}
NativeWidget* CreateNativeWidgetWithParent(NativeWidget* parent) {
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.delete_on_destroy = false;
params.parent = parent ? parent->GetWidget()->GetNativeView() : NULL;
diff --git a/views/widget/native_widget_test_utils_win.cc b/views/widget/native_widget_test_utils_win.cc
index 59e1d8d..fd89efe 100644
--- a/views/widget/native_widget_test_utils_win.cc
+++ b/views/widget/native_widget_test_utils_win.cc
@@ -15,7 +15,7 @@ NativeWidget* CreateNativeWidget() {
}
NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = gfx::Rect(10, 10, 200, 200);
@@ -24,7 +24,7 @@ NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
}
NativeWidget* CreateNativeWidgetWithParent(NativeWidget* parent) {
- Widget* widget = Widget::CreateWidget();
+ Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.delete_on_destroy = false;
params.child = false; // Implicitly set to true by ctor with TYPE_CONTROL.
diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc
index dfc0e39..7c8c0dd 100644
--- a/views/widget/tooltip_manager_gtk.cc
+++ b/views/widget/tooltip_manager_gtk.cc
@@ -85,12 +85,12 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard,
view = keyboard_view_;
view_loc.SetPoint(view->width() / 2, view->height() / 2);
} else if (!for_keyboard) {
- RootView* root_view = widget_->GetRootView();
+ RootView* root_view = widget_->GetWidget()->GetRootView();
view = root_view->GetEventHandlerForPoint(gfx::Point(x, y));
view_loc.SetPoint(x, y);
View::ConvertPointFromWidget(view, &view_loc);
} else {
- FocusManager* focus_manager = widget_->GetFocusManager();
+ FocusManager* focus_manager = widget_->GetWidget()->GetFocusManager();
if (focus_manager) {
view = focus_manager->GetFocusedView();
if (view)
@@ -116,7 +116,7 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard,
int max_width, line_count;
gfx::Point screen_loc(x, y);
- View::ConvertPointToScreen(widget_->GetRootView(), &screen_loc);
+ View::ConvertPointToScreen(widget_->GetWidget()->GetRootView(), &screen_loc);
TrimTooltipToFit(&text, &max_width, &line_count, screen_loc.x(),
screen_loc.y());
tooltip_window_.SetTooltipText(text);
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index a7c03d9..e02f8f9d 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -9,6 +9,7 @@
#include "ui/gfx/compositor/compositor.h"
#include "views/focus/view_storage.h"
#include "views/ime/input_method.h"
+#include "views/views_delegate.h"
#include "views/widget/default_theme_provider.h"
#include "views/widget/root_view.h"
#include "views/widget/native_widget.h"
@@ -21,6 +22,7 @@ namespace views {
Widget::InitParams::InitParams()
: type(TYPE_WINDOW),
child(false),
+ transient(false),
transparent(false),
accept_events(true),
can_activate(true),
@@ -37,6 +39,7 @@ Widget::InitParams::InitParams()
Widget::InitParams::InitParams(Type type)
: type(type),
child(type == TYPE_CONTROL),
+ transient(type == TYPE_POPUP || type == TYPE_MENU),
transparent(false),
accept_events(true),
can_activate(type != TYPE_POPUP && type != TYPE_MENU),
@@ -63,41 +66,50 @@ Widget::Widget()
last_mouse_event_was_move_(false),
native_widget_(NULL),
widget_delegate_(NULL),
- dragged_view_(NULL) {
+ dragged_view_(NULL),
+ delete_on_destroy_(false),
+ is_secondary_widget_(true) {
}
Widget::~Widget() {
+ DestroyRootView();
+
+ if (!delete_on_destroy_)
+ delete native_widget_;
}
void Widget::Init(const InitParams& params) {
+ delete_on_destroy_ = params.delete_on_destroy;
+ native_widget_ =
+ params.native_widget ? params.native_widget
+ : NativeWidget::CreateNativeWidget(this);
GetRootView();
default_theme_provider_.reset(new DefaultThemeProvider);
+ if (params.type == InitParams::TYPE_MENU)
+ is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown();
native_widget_->InitNativeWidget(params);
}
// Unconverted methods (see header) --------------------------------------------
gfx::NativeView Widget::GetNativeView() const {
- return NULL;
+ return native_widget_->GetNativeView();
}
gfx::NativeWindow Widget::GetNativeWindow() const {
- return NULL;
-}
-
-void Widget::GenerateMousePressedForView(View* view, const gfx::Point& point) {
+ return native_widget_->GetNativeWindow();
}
bool Widget::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
return false;
}
-Window* Widget::GetWindow() {
- return NULL;
+Window* Widget::GetContainingWindow() {
+ return native_widget_->GetContainingWindow();
}
-const Window* Widget::GetWindow() const {
- return NULL;
+const Window* Widget::GetContainingWindow() const {
+ return native_widget_->GetContainingWindow();
}
void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
@@ -108,7 +120,8 @@ void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
FocusManager* focus_manager = GetFocusManager();
if (focus_manager)
focus_manager->ViewRemoved(child);
- ViewStorage::GetInstance()->ViewRemoved(parent, child);
+ ViewStorage::GetInstance()->ViewRemoved(child);
+ native_widget_->ViewRemoved(child);
}
}
@@ -273,6 +286,10 @@ void Widget::SetCursor(gfx::NativeCursor cursor) {
native_widget_->SetCursor(cursor);
}
+void Widget::ResetLastMouseMoveFlag() {
+ last_mouse_event_was_move_ = false;
+}
+
FocusTraversable* Widget::GetFocusTraversable() {
return root_view_.get();
}
@@ -293,6 +310,18 @@ void Widget::SetFocusTraversableParentView(View* parent_view) {
root_view_->SetFocusTraversableParentView(parent_view);
}
+void Widget::NotifyAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type,
+ bool send_native_event) {
+ // Send the notification to the delegate.
+ if (ViewsDelegate::views_delegate)
+ ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type);
+
+ if (send_native_event)
+ native_widget_->SendNativeAccessibilityEvent(view, event_type);
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, NativeWidgetDelegate implementation:
@@ -407,6 +436,14 @@ void Widget::OnMouseCaptureLost() {
is_mouse_button_pressed_ = false;
}
+Widget* Widget::AsWidget() {
+ return this;
+}
+
+const Widget* Widget::AsWidget() const {
+ return this;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, FocusTraversable implementation:
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 110ee20..3c74618 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -52,12 +52,20 @@ class Window;
// Widget is a platform-independent type that communicates with a platform or
// context specific NativeWidget implementation.
//
-// TODO(beng): Note that this class being non-abstract means that we have a
-// violation of Google style in that we are using multiple
-// inheritance. The intention is to split this into a separate
-// object associated with but not equal to a NativeWidget
-// implementation. Multiple inheritance is required for this
-// transitional step.
+// A special note on ownership:
+//
+// Depending on the value of "delete_on_destroy", the Widget either owns or
+// is owned by its NativeWidget:
+//
+// delete_on_destroy = true (default)
+// The Widget instance is owned by its NativeWidget. When the NativeWidget
+// is destroyed (in response to a native destruction message), it deletes
+// the Widget from its destructor.
+// delete_on_destroy = false (non-default)
+// The Widget instance owns its NativeWidget. This state implies someone
+// else wants to control the lifetime of this object. When they destroy
+// the Widget it is responsible for destroying the NativeWidget (from its
+// destructor).
//
class Widget : public internal::NativeWidgetDelegate,
public FocusTraversable {
@@ -76,6 +84,7 @@ class Widget : public internal::NativeWidgetDelegate,
Type type;
bool child;
+ bool transient;
bool transparent;
bool accept_events;
bool can_activate;
@@ -95,13 +104,14 @@ class Widget : public internal::NativeWidgetDelegate,
Widget();
virtual ~Widget();
- // Creates a Widget instance with the supplied params.
- static Widget* CreateWidget();
-
// Enumerates all windows pertaining to us and notifies their
// view hierarchies that the locale has changed.
static void NotifyLocaleChanged();
+ // Closes all Widgets that aren't identified as "secondary widgets". Called
+ // during application shutdown when the last non-secondary widget is closed.
+ static void CloseAllSecondaryWidgets();
+
// Converts a rectangle from one Widget's coordinate system to another's.
// Returns false if the conversion couldn't be made, because either these two
// Widgets do not have a common ancestor or they are not on the screen yet.
@@ -114,22 +124,15 @@ class Widget : public internal::NativeWidgetDelegate,
// Unconverted methods -------------------------------------------------------
- // TODO(beng):
- // Widget subclasses are still implementing these methods by overriding from
- // here rather than by implementing NativeWidget.
+ // TODO(beng): reorder, they've been converted now.
// Returns the gfx::NativeView associated with this Widget.
- virtual gfx::NativeView GetNativeView() const;
+ gfx::NativeView GetNativeView() const;
// Returns the gfx::NativeWindow associated with this Widget. This may return
// NULL on some platforms if the widget was created with a type other than
// TYPE_WINDOW.
- virtual gfx::NativeWindow GetNativeWindow() const;
-
- // Starts a drag operation for the specified view. |point| is a position in
- // |view| coordinates that the drag was initiated from.
- virtual void GenerateMousePressedForView(View* view,
- const gfx::Point& point);
+ gfx::NativeWindow GetNativeWindow() const;
// Returns the accelerator given a command id. Returns false if there is
// no accelerator associated with a given id, which is a common condition.
@@ -137,15 +140,15 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns the Window containing this Widget, or NULL if not contained in a
// window.
- virtual Window* GetWindow();
- virtual const Window* GetWindow() const;
+ Window* GetContainingWindow();
+ const Window* GetContainingWindow() const;
// Forwarded from the RootView so that the widget can do any cleanup.
- virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
+ void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// Performs any necessary cleanup and forwards to RootView.
- virtual void NotifyNativeViewHierarchyChanged(bool attached,
- gfx::NativeView native_view);
+ void NotifyNativeViewHierarchyChanged(bool attached,
+ gfx::NativeView native_view);
// Converted methods ---------------------------------------------------------
@@ -188,7 +191,7 @@ class Widget : public internal::NativeWidgetDelegate,
void SetShape(gfx::NativeRegion shape);
// Hides the widget then closes it after a return to the message loop.
- void Close();
+ virtual void Close();
// TODO(beng): Move off public API.
// Closes the widget immediately. Compare to |Close|. This will destroy the
@@ -212,6 +215,16 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns the RootView contained by this Widget.
RootView* GetRootView();
+ // A secondary widget is one that is automatically closed (via Close()) when
+ // all non-secondary widgets are closed.
+ // Default is true.
+ // TODO(beng): This is an ugly API, should be handled implicitly via
+ // transience.
+ void set_is_secondary_widget(bool is_secondary_widget) {
+ is_secondary_widget_ = is_secondary_widget;
+ }
+ bool is_secondary_widget() const { return is_secondary_widget_; }
+
// Returns whether the Widget is visible to the user.
bool IsVisible() const;
@@ -257,6 +270,12 @@ class Widget : public internal::NativeWidgetDelegate,
// before the current is restored.
void SetCursor(gfx::NativeCursor cursor);
+ // Resets the last move flag so that we can go around the optimization
+ // that disregards duplicate mouse moves when ending animation requires
+ // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation
+ // to cause the close button to highlight.
+ void ResetLastMouseMoveFlag();
+
// Retrieves the focus traversable for this widget.
FocusTraversable* GetFocusTraversable();
@@ -280,10 +299,10 @@ class Widget : public internal::NativeWidgetDelegate,
// cases where the view is a native control that's already sending a
// native accessibility event and the duplicate event would cause
// problems.
- virtual void NotifyAccessibilityEvent(
+ void NotifyAccessibilityEvent(
View* view,
ui::AccessibilityTypes::Event event_type,
- bool send_native_event) = 0;
+ bool send_native_event);
NativeWidget* native_widget() { return native_widget_; }
@@ -299,6 +318,8 @@ class Widget : public internal::NativeWidgetDelegate,
virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE;
virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
+ virtual Widget* AsWidget() OVERRIDE;
+ virtual const Widget* AsWidget() const OVERRIDE;
// Overridden from FocusTraversable:
virtual FocusSearch* GetFocusSearch() OVERRIDE;
@@ -306,6 +327,9 @@ class Widget : public internal::NativeWidgetDelegate,
virtual View* GetFocusTraversableParentView() OVERRIDE;
protected:
+ // TODO(beng): Remove WidgetGtk's dependence on the mouse state flags.
+ friend class WidgetGtk;
+
// Creates the RootView to be used within this Widget. Subclasses may override
// to create custom RootViews that do specialized event processing.
// TODO(beng): Investigate whether or not this is needed.
@@ -316,19 +340,15 @@ class Widget : public internal::NativeWidgetDelegate,
// TODO(beng): remove once we fold those objects onto this one.
void DestroyRootView();
- // TODO(beng): Temporarily provided as a way to associate the subclass'
- // implementation of NativeWidget with this.
- void set_native_widget(NativeWidget* native_widget) {
- native_widget_ = native_widget;
- }
-
// Used for testing.
void ReplaceFocusManager(FocusManager* focus_manager);
+ // TODO(beng): Remove WidgetGtk's dependence on these:
// TODO(msw): Make this mouse state member private.
// If true, the mouse is currently down.
bool is_mouse_button_pressed_;
+ // TODO(beng): Remove WidgetGtk's dependence on these:
// TODO(msw): Make these mouse state members private.
// The following are used to detect duplicate mouse move events and not
// deliver them. Displaying a window may result in the system generating
@@ -370,6 +390,12 @@ class Widget : public internal::NativeWidgetDelegate,
// The compositor for accelerated drawing.
scoped_refptr<ui::Compositor> compositor_;
+ // See class documentation for Widget above for a note about ownership.
+ bool delete_on_destroy_;
+
+ // See set_is_secondary_widget().
+ bool is_secondary_widget_;
+
DISALLOW_COPY_AND_ASSIGN(Widget);
};
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index b506dac..bbb0fd5 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -284,9 +284,9 @@ bool WidgetGtk::debug_paint_enabled_ = false;
////////////////////////////////////////////////////////////////////////////////
// WidgetGtk, public:
-WidgetGtk::WidgetGtk()
+WidgetGtk::WidgetGtk(internal::NativeWidgetDelegate* delegate)
: is_window_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
+ delegate_(delegate),
widget_(NULL),
window_contents_(NULL),
child_(false),
@@ -301,6 +301,7 @@ WidgetGtk::WidgetGtk()
transient_to_parent_(false),
got_initial_focus_in_(false),
has_focus_(false),
+ focus_on_creation_(true),
always_on_top_(false),
is_double_buffered_(false),
should_handle_menu_key_release_(false),
@@ -311,7 +312,6 @@ WidgetGtk::WidgetGtk()
// the widget.
TouchFactory::GetInstance();
#endif
- set_native_widget(this);
static bool installed_message_loop_observer = false;
if (!installed_message_loop_observer) {
installed_message_loop_observer = true;
@@ -325,8 +325,9 @@ WidgetGtk::~WidgetGtk() {
// We need to delete the input method before calling DestroyRootView(),
// because it'll set focus_manager_ to NULL.
input_method_.reset();
- DestroyRootView();
DCHECK(delete_on_destroy_ || widget_ == NULL);
+ if (delete_on_destroy_)
+ delete delegate_;
}
GtkWindow* WidgetGtk::GetTransientParent() const {
@@ -443,7 +444,7 @@ void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) {
}
void WidgetGtk::IsActiveChanged() {
- WidgetDelegate* d = widget_delegate();
+ WidgetDelegate* d = GetWidget()->widget_delegate();
if (d) {
bool a = IsActive();
d->OnWidgetActivated(a);
@@ -451,8 +452,11 @@ void WidgetGtk::IsActiveChanged() {
}
void WidgetGtk::SetInitialFocus() {
- View* v = widget_delegate() ?
- widget_delegate()->GetInitiallyFocusedView() : NULL;
+ if (!focus_on_creation_)
+ return;
+
+ View* v = GetWidget()->widget_delegate() ?
+ GetWidget()->widget_delegate()->GetInitiallyFocusedView() : NULL;
if (v)
v->RequestFocus();
}
@@ -496,52 +500,13 @@ void WidgetGtk::ActiveWindowChanged(GdkWindow* active_window) {
}
if (was_active != IsActive()) {
IsActiveChanged();
- GetRootView()->SchedulePaint();
+ GetWidget()->GetRootView()->SchedulePaint();
}
}
////////////////////////////////////////////////////////////////////////////////
// WidgetGtk, Widget implementation:
-gfx::NativeView WidgetGtk::GetNativeView() const {
- return widget_;
-}
-
-gfx::NativeWindow WidgetGtk::GetNativeWindow() const {
- return child_ ? NULL : GTK_WINDOW(widget_);
-}
-
-bool WidgetGtk::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
- NOTIMPLEMENTED();
- return false;
-}
-
-Window* WidgetGtk::GetWindow() {
- return GetWindowImpl(widget_);
-}
-
-const Window* WidgetGtk::GetWindow() const {
- return GetWindowImpl(widget_);
-}
-
-void WidgetGtk::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
- Widget::ViewHierarchyChanged(is_add, parent, child);
- if (drop_target_.get())
- drop_target_->ResetTargetViewIfEquals(child);
-}
-
-void WidgetGtk::NotifyAccessibilityEvent(
- View* view,
- ui::AccessibilityTypes::Event event_type,
- bool send_native_event) {
- // Send the notification to the delegate.
- if (ViewsDelegate::views_delegate)
- ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type);
-
- // In the future if we add native GTK accessibility support, the
- // notification should be sent here.
-}
-
void WidgetGtk::ClearNativeFocus() {
DCHECK(!child_);
if (!GetNativeView()) {
@@ -552,7 +517,7 @@ void WidgetGtk::ClearNativeFocus() {
}
bool WidgetGtk::HandleKeyboardEvent(const KeyEvent& key) {
- if (!GetFocusManager())
+ if (!GetWidget()->GetFocusManager())
return false;
const int key_code = key.key_code();
@@ -569,7 +534,7 @@ bool WidgetGtk::HandleKeyboardEvent(const KeyEvent& key) {
// VKEY_MENU is triggered by key release event.
// FocusManager::OnKeyEvent() returns false when the key has been consumed.
if (key_code != ui::VKEY_MENU)
- handled = !GetFocusManager()->OnKeyEvent(key);
+ handled = !GetWidget()->GetFocusManager()->OnKeyEvent(key);
else
should_handle_menu_key_release_ = true;
} else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ &&
@@ -577,7 +542,7 @@ bool WidgetGtk::HandleKeyboardEvent(const KeyEvent& key) {
// Trigger VKEY_MENU when only this key is pressed and released, and both
// press and release events are not handled by others.
Accelerator accelerator(ui::VKEY_MENU, false, false, false);
- handled = GetFocusManager()->ProcessAccelerator(accelerator);
+ handled = GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator);
}
return handled;
@@ -626,10 +591,10 @@ void WidgetGtk::RegisterChildExposeHandler(GtkWidget* child) {
////////////////////////////////////////////////////////////////////////////////
// WidgetGtk, NativeWidget implementation:
-void WidgetGtk::InitNativeWidget(const InitParams& params) {
+void WidgetGtk::InitNativeWidget(const Widget::InitParams& params) {
SetInitParams(params);
- InitParams modified_params = params;
+ Widget::InitParams modified_params = params;
gfx::NativeView parent = params.parent;
if (params.parent_widget) {
WidgetGtk* parent_gtk =
@@ -766,7 +731,32 @@ void WidgetGtk::InitNativeWidget(const InitParams& params) {
}
Widget* WidgetGtk::GetWidget() {
- return this;
+ return delegate_->AsWidget();
+}
+
+const Widget* WidgetGtk::GetWidget() const {
+ return delegate_->AsWidget();
+}
+
+gfx::NativeView WidgetGtk::GetNativeView() const {
+ return widget_;
+}
+
+gfx::NativeWindow WidgetGtk::GetNativeWindow() const {
+ return child_ ? NULL : GTK_WINDOW(widget_);
+}
+
+Window* WidgetGtk::GetContainingWindow() {
+ return GetWindowImpl(widget_);
+}
+
+const Window* WidgetGtk::GetContainingWindow() const {
+ return GetWindowImpl(widget_);
+}
+
+void WidgetGtk::ViewRemoved(View* view) {
+ if (drop_target_.get())
+ drop_target_->ResetTargetViewIfEquals(view);
}
void WidgetGtk::SetNativeWindowProperty(const char* name, void* value) {
@@ -785,6 +775,13 @@ bool WidgetGtk::IsScreenReaderActive() const {
return false;
}
+void WidgetGtk::SendNativeAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) {
+ // In the future if we add native GTK accessibility support, the
+ // notification should be sent here.
+}
+
void WidgetGtk::SetMouseCapture() {
DCHECK(!HasMouseCapture());
gtk_grab_add(window_contents_);
@@ -801,6 +798,18 @@ bool WidgetGtk::HasMouseCapture() const {
return GTK_WIDGET_HAS_GRAB(window_contents_);
}
+bool WidgetGtk::IsMouseButtonDown() const {
+ bool button_pressed = false;
+ GdkEvent* event = gtk_get_current_event();
+ if (event) {
+ button_pressed = event->type == GDK_BUTTON_PRESS ||
+ event->type == GDK_2BUTTON_PRESS ||
+ event->type == GDK_3BUTTON_PRESS;
+ gdk_event_free(event);
+ }
+ return button_pressed;
+}
+
InputMethod* WidgetGtk::GetInputMethodNative() {
return input_method_.get();
}
@@ -1018,7 +1027,7 @@ void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) {
// preferred size for these would prevents us from setting smaller window
// sizes.
if (child_) {
- gfx::Size size(GetRootView()->GetPreferredSize());
+ gfx::Size size(GetWidget()->GetRootView()->GetPreferredSize());
requisition->width = size.width();
requisition->height = size.height();
}
@@ -1153,7 +1162,7 @@ gboolean WidgetGtk::OnDragMotion(GtkWidget* widget,
gint y,
guint time) {
if (!drop_target_.get())
- drop_target_.reset(new DropTargetGtk(GetRootView(), context));
+ drop_target_.reset(new DropTargetGtk(GetWidget()->GetRootView(), context));
return drop_target_->OnDragMotion(context, x, y, time);
}
@@ -1164,7 +1173,8 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) {
return false;
}
- if (!last_mouse_event_was_move_ && !is_mouse_button_pressed_) {
+ if (!GetWidget()->last_mouse_event_was_move_ &&
+ !GetWidget()->is_mouse_button_pressed_) {
// When a mouse button is pressed gtk generates a leave, enter, press.
// RootView expects to get a mouse move before a press, otherwise enter is
// not set. So we generate a move here.
@@ -1180,13 +1190,13 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) {
MouseEvent mouse_event(TransformEvent(&motion));
delegate_->OnMouseEvent(mouse_event);
}
-
return false;
}
gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) {
- last_mouse_event_was_move_ = false;
- if (!HasMouseCapture() && !is_mouse_button_pressed_) {
+ GetWidget()->ResetLastMouseMoveFlag();
+
+ if (!HasMouseCapture() && !GetWidget()->is_mouse_button_pressed_) {
MouseEvent mouse_event(TransformEvent(event));
delegate_->OnMouseEvent(mouse_event);
}
@@ -1346,10 +1356,6 @@ void WidgetGtk::HandleGtkGrabBroke() {
////////////////////////////////////////////////////////////////////////////////
// WidgetGtk, private:
-RootView* WidgetGtk::CreateRootView() {
- return new RootView(this);
-}
-
gfx::AcceleratedWidget WidgetGtk::GetAcceleratedWidget() {
DCHECK(window_contents_ && window_contents_->window);
return GDK_WINDOW_XID(window_contents_->window);
@@ -1392,28 +1398,24 @@ void WidgetGtk::DispatchKeyEventPostIME(const KeyEvent& key) {
gtk_bindings_activate_event(GTK_OBJECT(widget_), event);
}
-void WidgetGtk::SetInitParams(const InitParams& params) {
+void WidgetGtk::SetInitParams(const Widget::InitParams& params) {
DCHECK(!GetNativeView());
delete_on_destroy_ = params.delete_on_destroy;
child_ = params.child;
+ // TODO(beng): The secondary checks here actually obviate the need for
+ // params.transient but that's only because WidgetGtk considers
+ // any top-level widget to be a transient widget. We will probably
+ // want to ammend this assumption at some point.
+ if (params.transient || params.parent || params.parent_widget)
+ transient_to_parent_ = true;
if (params.transparent)
MakeTransparent();
if (!params.accept_events && !child_)
ignore_events_ = true;
if (params.double_buffer)
EnableDoubleBuffer(true);
-
- if (params.type == InitParams::TYPE_MENU) {
- GdkEvent* event = gtk_get_current_event();
- if (event) {
- is_mouse_button_pressed_ = event->type == GDK_BUTTON_PRESS ||
- event->type == GDK_2BUTTON_PRESS ||
- event->type == GDK_3BUTTON_PRESS;
- gdk_event_free(event);
- }
- }
}
gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) {
@@ -1460,13 +1462,13 @@ Window* WidgetGtk::GetWindowImpl(GtkWidget* widget) {
WidgetGtk* widget_gtk = static_cast<WidgetGtk*>(
NativeWidget::GetNativeWidgetForNativeView(parent));
if (widget_gtk && widget_gtk->is_window_)
- return static_cast<WindowGtk*>(widget_gtk);
+ return static_cast<WindowGtk*>(widget_gtk)->GetWindow();
parent = gtk_widget_get_parent(parent);
}
return NULL;
}
-void WidgetGtk::CreateGtkWidget(const InitParams& params) {
+void WidgetGtk::CreateGtkWidget(const Widget::InitParams& params) {
// We turn off double buffering for two reasons:
// 1. We draw to a canvas then composite to the screen, which means we're
// doing our own double buffering already.
@@ -1520,8 +1522,8 @@ void WidgetGtk::CreateGtkWidget(const InitParams& params) {
} else {
// Use our own window class to override GtkWindow's move_focus method.
widget_ = gtk_views_window_new(
- params.type == InitParams::TYPE_WINDOW ? GTK_WINDOW_TOPLEVEL
- : GTK_WINDOW_POPUP);
+ params.type == Widget::InitParams::TYPE_WINDOW ? GTK_WINDOW_TOPLEVEL
+ : GTK_WINDOW_POPUP);
gtk_widget_set_name(widget_, "views-gtkwidget-window");
if (transient_to_parent_) {
gtk_window_set_transient_for(GTK_WINDOW(widget_),
@@ -1560,7 +1562,7 @@ void WidgetGtk::CreateGtkWidget(const InitParams& params) {
gtk_container_add(GTK_CONTAINER(widget_), window_contents_);
gtk_widget_show(window_contents_);
g_object_set_data(G_OBJECT(window_contents_), kNativeWidgetKey,
- static_cast<Widget*>(this));
+ static_cast<WidgetGtk*>(this));
if (transparent_)
ConfigureWidgetForTransparentBackground(NULL);
@@ -1643,11 +1645,6 @@ void WidgetGtk::DrawTransparentBackground(GtkWidget* widget,
// Widget, public:
// static
-Widget* Widget::CreateWidget() {
- return new WidgetGtk();
-}
-
-// static
void Widget::NotifyLocaleChanged() {
GList *window_list = gtk_window_list_toplevels();
for (GList* element = window_list; element; element = g_list_next(element)) {
@@ -1660,6 +1657,22 @@ void Widget::NotifyLocaleChanged() {
}
// static
+void Widget::CloseAllSecondaryWidgets() {
+ GList* windows = gtk_window_list_toplevels();
+ for (GList* window = windows; window;
+ window = g_list_next(window)) {
+ NativeWidget* native_widget = NativeWidget::GetNativeWidgetForNativeView(
+ GTK_WIDGET(window->data));
+ if (native_widget) {
+ Widget* widget = native_widget->GetWidget();
+ if (widget->is_secondary_widget())
+ widget->Close();
+ }
+ }
+ g_list_free(windows);
+}
+
+// static
bool Widget::ConvertRect(const Widget* source,
const Widget* target,
gfx::Rect* rect) {
@@ -1689,6 +1702,12 @@ bool Widget::ConvertRect(const Widget* source,
// NativeWidget, public:
// static
+NativeWidget* NativeWidget::CreateNativeWidget(
+ internal::NativeWidgetDelegate* delegate) {
+ return new WidgetGtk(delegate);
+}
+
+// static
NativeWidget* NativeWidget::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
if (!native_view)
@@ -1740,4 +1759,40 @@ void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view,
reinterpret_cast<gpointer>(children));
}
+// static
+void NativeWidget::ReparentNativeView(gfx::NativeView native_view,
+ gfx::NativeView new_parent) {
+ if (!native_view)
+ return;
+
+ gfx::NativeView previous_parent = gtk_widget_get_parent(native_view);
+ if (previous_parent == new_parent)
+ return;
+
+ NativeWidgets widgets;
+ GetAllNativeWidgets(native_view, &widgets);
+
+ // First notify all the widgets that they are being disassociated
+ // from their previous parent.
+ for (NativeWidgets::iterator it = widgets.begin();
+ it != widgets.end(); ++it) {
+ // TODO(beng): Rename this notification to NotifyNativeViewChanging()
+ // and eliminate the bool parameter.
+ (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(false,
+ previous_parent);
+ }
+
+ if (gtk_widget_get_parent(native_view))
+ gtk_widget_reparent(native_view, new_parent);
+ else
+ gtk_container_add(GTK_CONTAINER(new_parent), native_view);
+
+ // And now, notify them that they have a brand new parent.
+ for (NativeWidgets::iterator it = widgets.begin();
+ it != widgets.end(); ++it) {
+ (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true,
+ new_parent);
+ }
+}
+
} // namespace views
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index eaa29cd..54acfa6 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -41,25 +41,13 @@ class NativeWidgetDelegate;
}
// Widget implementation for GTK.
-class WidgetGtk : public Widget,
- public NativeWidget,
+class WidgetGtk : public NativeWidget,
public ui::ActiveWindowWatcherX::Observer,
public internal::InputMethodDelegate {
public:
- WidgetGtk();
+ explicit WidgetGtk(internal::NativeWidgetDelegate* delegate);
virtual ~WidgetGtk();
- // Marks this window as transient to its parent. A window that is transient
- // to its parent results in the parent rendering active when the child is
- // active.
- // This must be invoked before Init. This is only used for types other than
- // TYPE_CHILD. The default is false.
- // See gtk_window_set_transient_for for details.
- void make_transient_to_parent() {
- DCHECK(!widget_);
- transient_to_parent_ = true;
- }
-
// Returns the transient parent. See make_transient_to_parent for details on
// what the transient parent is.
GtkWindow* GetTransientParent() const;
@@ -123,19 +111,6 @@ class WidgetGtk : public Widget,
// Overridden from ui::ActiveWindowWatcherX::Observer.
virtual void ActiveWindowChanged(GdkWindow* active_window);
- // Overridden from Widget:
- virtual gfx::NativeView GetNativeView() const;
- virtual gfx::NativeWindow GetNativeWindow() const;
- virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
- virtual Window* GetWindow();
- virtual const Window* GetWindow() const;
- virtual void ViewHierarchyChanged(bool is_add, View *parent,
- View *child);
- virtual void NotifyAccessibilityEvent(
- View* view,
- ui::AccessibilityTypes::Event event_type,
- bool send_native_event);
-
// Clears the focus on the native widget having the focus.
virtual void ClearNativeFocus();
@@ -168,16 +143,30 @@ class WidgetGtk : public Widget,
// detached widget.
static void RegisterChildExposeHandler(GtkWidget* widget);
+ void set_focus_on_creation(bool focus_on_creation) {
+ focus_on_creation_ = focus_on_creation;
+ }
+
// Overridden from NativeWidget:
- virtual void InitNativeWidget(const InitParams& params) OVERRIDE;
+ virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual Widget* GetWidget() OVERRIDE;
+ virtual const Widget* GetWidget() const OVERRIDE;
+ virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
+ virtual Window* GetContainingWindow() OVERRIDE;
+ virtual const Window* GetContainingWindow() const OVERRIDE;
+ virtual void ViewRemoved(View* view) OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual bool IsScreenReaderActive() const OVERRIDE;
+ virtual void SendNativeAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) OVERRIDE;
virtual void SetMouseCapture() OVERRIDE;
virtual void ReleaseMouseCapture() OVERRIDE;
virtual bool HasMouseCapture() const OVERRIDE;
+ virtual bool IsMouseButtonDown() const OVERRIDE;
virtual InputMethod* GetInputMethodNative() OVERRIDE;
virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
@@ -268,16 +257,13 @@ class WidgetGtk : public Widget,
class DropObserver;
friend class DropObserver;
- // Overridden from Widget
- virtual RootView* CreateRootView() OVERRIDE;
-
// Overridden from NativeWidget
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
// Overridden from internal::InputMethodDelegate
virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
- void SetInitParams(const InitParams& params);
+ void SetInitParams(const Widget::InitParams& params);
// This is called only when the window is transparent.
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*);
@@ -291,7 +277,7 @@ class WidgetGtk : public Widget,
static Window* GetWindowImpl(GtkWidget* widget);
// Creates the GtkWidget.
- void CreateGtkWidget(const InitParams& params);
+ void CreateGtkWidget(const Widget::InitParams& params);
// Invoked from create widget to enable the various bits needed for a
// transparent background. This is only invoked if MakeTransparent has been
@@ -307,6 +293,7 @@ class WidgetGtk : public Widget,
GdkEventExpose* event);
// A delegate implementation that handles events received here.
+ // See class documentation for Widget in widget.h for a note about ownership.
internal::NativeWidgetDelegate* delegate_;
// Our native views. If we're a window/popup, then widget_ is the window and
@@ -333,7 +320,7 @@ class WidgetGtk : public Widget,
// The following factory is used to delay destruction.
ScopedRunnableMethodFactory<WidgetGtk> close_widget_factory_;
- // See description above setter.
+ // See class documentation for Widget in widget.h for a note about ownership.
bool delete_on_destroy_;
// See description above make_transparent for details.
@@ -385,6 +372,10 @@ class WidgetGtk : public Widget,
// this to determine whether we should process the event.
bool has_focus_;
+ // Whether we should SetFocus() on a newly created window after
+ // Init(). Defaults to true.
+ bool focus_on_creation_;
+
// If true, the window stays on top of the screen. This is only used
// for types other than TYPE_CHILD.
bool always_on_top_;
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index a5d2044..67166ff 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -132,8 +132,8 @@ bool WidgetWin::screen_reader_active_ = false;
////////////////////////////////////////////////////////////////////////////////
// WidgetWin, public:
-WidgetWin::WidgetWin()
- : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
+WidgetWin::WidgetWin(internal::NativeWidgetDelegate* delegate)
+ : delegate_(delegate),
close_widget_factory_(this),
active_mouse_tracking_flags_(0),
use_layered_buffer_(false),
@@ -147,14 +147,14 @@ WidgetWin::WidgetWin()
accessibility_view_events_(kMaxAccessibilityViewEvents),
previous_cursor_(NULL),
is_input_method_win_(false) {
- set_native_widget(this);
}
WidgetWin::~WidgetWin() {
// We need to delete the input method before calling DestroyRootView(),
// because it'll set focus_manager_ to NULL.
input_method_.reset();
- DestroyRootView();
+ if (delete_on_destroy_)
+ delete delegate_;
}
// static
@@ -192,7 +192,24 @@ void WidgetWin::ClearAccessibilityViewEvent(View* view) {
}
////////////////////////////////////////////////////////////////////////////////
-// WidgetWin, Widget implementation:
+// WidgetWin, NativeWidget implementation:
+
+void WidgetWin::InitNativeWidget(const Widget::InitParams& params) {
+ SetInitParams(params);
+
+ // Create the window.
+ gfx::NativeView parent = params.parent_widget ?
+ params.parent_widget->GetNativeView() : params.parent;
+ WindowImpl::Init(parent, params.bounds);
+}
+
+Widget* WidgetWin::GetWidget() {
+ return delegate_->AsWidget();
+}
+
+const Widget* WidgetWin::GetWidget() const {
+ return delegate_->AsWidget();
+}
gfx::NativeView WidgetWin::GetNativeView() const {
return WindowImpl::hwnd();
@@ -202,42 +219,19 @@ gfx::NativeWindow WidgetWin::GetNativeWindow() const {
return WindowImpl::hwnd();
}
-bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
- return false;
-}
-
-Window* WidgetWin::GetWindow() {
+Window* WidgetWin::GetContainingWindow() {
return GetWindowImpl(hwnd());
}
-const Window* WidgetWin::GetWindow() const {
+const Window* WidgetWin::GetContainingWindow() const {
return GetWindowImpl(hwnd());
}
-void WidgetWin::ViewHierarchyChanged(bool is_add, View* parent,
- View* child) {
- Widget::ViewHierarchyChanged(is_add, parent, child);
+void WidgetWin::ViewRemoved(View* view) {
if (drop_target_.get())
- drop_target_->ResetTargetViewIfEquals(child);
+ drop_target_->ResetTargetViewIfEquals(view);
- if (!is_add)
- ClearAccessibilityViewEvent(child);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// WidgetWin, NativeWidget implementation:
-
-void WidgetWin::InitNativeWidget(const Widget::InitParams& params) {
- SetInitParams(params);
-
- // Create the window.
- gfx::NativeView parent = params.parent_widget ?
- params.parent_widget->GetNativeView() : params.parent;
- WindowImpl::Init(parent, params.bounds);
-}
-
-Widget* WidgetWin::GetWidget() {
- return this;
+ ClearAccessibilityViewEvent(view);
}
void WidgetWin::SetNativeWindowProperty(const char* name, void* value) {
@@ -265,6 +259,19 @@ bool WidgetWin::IsScreenReaderActive() const {
return screen_reader_active_;
}
+void WidgetWin::SendNativeAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) {
+ // Now call the Windows-specific method to notify MSAA clients of this
+ // event. The widget gives us a temporary unique child ID to associate
+ // with this view so that clients can call get_accChild in
+ // NativeViewAccessibilityWin to retrieve the IAccessible associated
+ // with this view.
+ int child_id = AddAccessibilityViewEvent(view);
+ ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type),
+ GetNativeView(), OBJID_CLIENT, child_id);
+}
+
void WidgetWin::SetMouseCapture() {
DCHECK(!HasMouseCapture());
SetCapture(hwnd());
@@ -278,6 +285,14 @@ bool WidgetWin::HasMouseCapture() const {
return GetCapture() == hwnd();
}
+bool WidgetWin::IsMouseButtonDown() const {
+ return (GetKeyState(VK_LBUTTON) & 0x80) ||
+ (GetKeyState(VK_RBUTTON) & 0x80) ||
+ (GetKeyState(VK_MBUTTON) & 0x80) ||
+ (GetKeyState(VK_XBUTTON1) & 0x80) ||
+ (GetKeyState(VK_XBUTTON2) & 0x80);
+}
+
InputMethod* WidgetWin::GetInputMethodNative() {
return input_method_.get();
}
@@ -447,26 +462,6 @@ void WidgetWin::SetCursor(gfx::NativeCursor cursor) {
}
}
-void WidgetWin::NotifyAccessibilityEvent(
- View* view,
- ui::AccessibilityTypes::Event event_type,
- bool send_native_event) {
- // Send the notification to the delegate.
- if (ViewsDelegate::views_delegate)
- ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type);
-
- // Now call the Windows-specific method to notify MSAA clients of this
- // event. The widget gives us a temporary unique child ID to associate
- // with this view so that clients can call get_accChild in
- // NativeViewAccessibilityWin to retrieve the IAccessible associated
- // with this view.
- if (send_native_event) {
- int child_id = AddAccessibilityViewEvent(view);
- ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type),
- GetNativeView(), OBJID_CLIENT, child_id);
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
// WidgetWin, MessageLoop::Observer implementation:
@@ -507,7 +502,7 @@ LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) {
PostProcessActivateMessage(this, LOWORD(w_param));
if (message == WM_ENABLE && restore_focus_when_enabled_) {
restore_focus_when_enabled_ = false;
- GetFocusManager()->RestoreFocusedView();
+ GetWidget()->GetFocusManager()->RestoreFocusedView();
}
return result;
}
@@ -558,7 +553,7 @@ LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) {
props_.push_back(SetWindowSupportsRerouteMouseWheel(hwnd()));
- drop_target_ = new DropTargetWin(GetRootView());
+ drop_target_ = new DropTargetWin(GetWidget()->GetRootView());
// We need to add ourselves as a message loop observer so that we can repaint
// aggressively if the contents of our window become invalid. Unfortunately
@@ -569,10 +564,10 @@ LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) {
// Windows special DWM window frame requires a special tooltip manager so
// that window controls in Chrome windows don't flicker when you move your
// mouse over them. See comment in aero_tooltip_manager.h.
- if (GetThemeProvider()->ShouldUseNativeFrame()) {
- tooltip_manager_.reset(new AeroTooltipManager(this));
+ if (GetWidget()->GetThemeProvider()->ShouldUseNativeFrame()) {
+ tooltip_manager_.reset(new AeroTooltipManager(GetWidget()));
} else {
- tooltip_manager_.reset(new TooltipManagerWin(this));
+ tooltip_manager_.reset(new TooltipManagerWin(GetWidget()));
}
// This message initializes the window so that focus border are shown for
@@ -612,8 +607,8 @@ void WidgetWin::OnDestroy() {
}
void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
- if (widget_delegate())
- widget_delegate()->OnDisplayChanged();
+ if (GetWidget()->widget_delegate())
+ GetWidget()->widget_delegate()->OnDisplayChanged();
}
LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg,
@@ -651,7 +646,8 @@ LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) {
if (OBJID_CLIENT == l_param) {
// Retrieve MSAA dispatch object for the root view.
base::win::ScopedComPtr<IAccessible> root(
- NativeViewAccessibilityWin::GetAccessibleForView(GetRootView()));
+ NativeViewAccessibilityWin::GetAccessibleForView(
+ GetWidget()->GetRootView()));
// Create a reference that MSAA will marshall to the client.
reference_result = LresultFromObject(IID_IAccessible, w_param,
@@ -789,14 +785,16 @@ LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) {
}
void WidgetWin::OnMove(const CPoint& point) {
- if (widget_delegate())
- widget_delegate()->OnWidgetMove();
+ // TODO(beng): move to Widget.
+ if (GetWidget()->widget_delegate())
+ GetWidget()->widget_delegate()->OnWidgetMove();
SetMsgHandled(FALSE);
}
void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
- if (widget_delegate())
- widget_delegate()->OnWidgetMove();
+ // TODO(beng): move to Widget.
+ if (GetWidget()->widget_delegate())
+ GetWidget()->widget_delegate()->OnWidgetMove();
}
LRESULT WidgetWin::OnNCActivate(BOOL active) {
@@ -893,8 +891,9 @@ LRESULT WidgetWin::OnSetText(const wchar_t* text) {
}
void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
- if (flags == SPI_SETWORKAREA && widget_delegate())
- widget_delegate()->OnWorkAreaChanged();
+ // TODO(beng): move to Widget.
+ if (flags == SPI_SETWORKAREA && GetWidget()->widget_delegate())
+ GetWidget()->widget_delegate()->OnWorkAreaChanged();
SetMsgHandled(FALSE);
}
@@ -961,8 +960,9 @@ void WidgetWin::OnScreenReaderDetected() {
}
void WidgetWin::SetInitialFocus() {
- View* v = widget_delegate() ?
- widget_delegate()->GetInitiallyFocusedView() : NULL;
+ // TODO(beng): move to Widget.
+ View* v = GetWidget()->widget_delegate() ?
+ GetWidget()->widget_delegate()->GetInitiallyFocusedView() : NULL;
if (v)
v->RequestFocus();
}
@@ -979,7 +979,7 @@ Window* WidgetWin::GetWindowImpl(HWND hwnd) {
WidgetWin* widget =
reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent));
if (widget && widget->is_window_)
- return static_cast<WindowWin*>(widget);
+ return static_cast<WindowWin*>(widget)->GetWindow();
parent = ::GetParent(parent);
}
return NULL;
@@ -1016,7 +1016,7 @@ void WidgetWin::PostProcessActivateMessage(WidgetWin* widget,
}
}
-void WidgetWin::SetInitParams(const InitParams& params) {
+void WidgetWin::SetInitParams(const Widget::InitParams& params) {
// Set non-style attributes.
delete_on_destroy_ = params.delete_on_destroy;
@@ -1044,21 +1044,15 @@ void WidgetWin::SetInitParams(const InitParams& params) {
// Set type-dependent style attributes.
switch (params.type) {
- case InitParams::TYPE_WINDOW:
- case InitParams::TYPE_CONTROL:
+ case Widget::InitParams::TYPE_WINDOW:
+ case Widget::InitParams::TYPE_CONTROL:
break;
- case InitParams::TYPE_POPUP:
+ case Widget::InitParams::TYPE_POPUP:
style |= WS_POPUP;
ex_style |= WS_EX_TOOLWINDOW;
break;
- case InitParams::TYPE_MENU:
+ case Widget::InitParams::TYPE_MENU:
style |= WS_POPUP;
- is_mouse_button_pressed_ =
- ((GetKeyState(VK_LBUTTON) & 0x80) ||
- (GetKeyState(VK_RBUTTON) & 0x80) ||
- (GetKeyState(VK_MBUTTON) & 0x80) ||
- (GetKeyState(VK_XBUTTON1) & 0x80) ||
- (GetKeyState(VK_XBUTTON2) & 0x80));
break;
default:
NOTREACHED();
@@ -1089,7 +1083,7 @@ void WidgetWin::RedrawLayeredWindowContents() {
layered_window_invalid_rect_.y(),
layered_window_invalid_rect_.width(),
layered_window_invalid_rect_.height());
- GetRootView()->Paint(layered_window_contents_.get());
+ GetWidget()->GetRootView()->Paint(layered_window_contents_.get());
layered_window_contents_->restore();
RECT wr;
@@ -1107,7 +1101,7 @@ void WidgetWin::RedrawLayeredWindowContents() {
void WidgetWin::ClientAreaSizeChanged() {
RECT r;
- if (GetThemeProvider()->ShouldUseNativeFrame() || IsZoomed())
+ if (GetWidget()->GetThemeProvider()->ShouldUseNativeFrame() || IsZoomed())
GetClientRect(&r);
else
GetWindowRect(&r);
@@ -1133,13 +1127,26 @@ void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) {
// Widget, public:
// static
-Widget* Widget::CreateWidget() {
- return new WidgetWin;
+void Widget::NotifyLocaleChanged() {
+ NOTIMPLEMENTED();
}
+namespace {
+BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) {
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeView(hwnd);
+ if (native_widget) {
+ Widget* widget = native_widget->GetWidget();
+ if (widget->is_secondary_widget())
+ widget->Close();
+ }
+ return TRUE;
+}
+} // namespace
+
// static
-void Widget::NotifyLocaleChanged() {
- NOTIMPLEMENTED();
+void Widget::CloseAllSecondaryWidgets() {
+ EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0);
}
bool Widget::ConvertRect(const Widget* source,
@@ -1167,17 +1174,26 @@ bool Widget::ConvertRect(const Widget* source,
////////////////////////////////////////////////////////////////////////////////
// NativeWidget, public:
+// static
+NativeWidget* NativeWidget::CreateNativeWidget(
+ internal::NativeWidgetDelegate* delegate) {
+ return new WidgetWin(delegate);
+}
+
+// static
NativeWidget* NativeWidget::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
return reinterpret_cast<WidgetWin*>(
ViewProp::GetValue(native_view, kNativeWidgetKey));
}
+// static
NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) {
return GetNativeWidgetForNativeView(native_window);
}
+// static
NativeWidget* NativeWidget::GetTopLevelNativeWidget(
gfx::NativeView native_view) {
if (!native_view)
@@ -1206,6 +1222,7 @@ NativeWidget* NativeWidget::GetTopLevelNativeWidget(
return widget;
}
+// static
void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view,
NativeWidgets* children) {
if (!native_view)
@@ -1218,6 +1235,7 @@ void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view,
reinterpret_cast<LPARAM>(children));
}
+// static
void NativeWidget::ReparentNativeView(gfx::NativeView native_view,
gfx::NativeView new_parent) {
if (!native_view)
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 3c2974b..d013ddb 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -23,7 +23,6 @@
#include "views/ime/input_method_delegate.h"
#include "views/layout/layout_manager.h"
#include "views/widget/native_widget.h"
-#include "views/widget/widget.h"
namespace ui {
class ViewProp;
@@ -45,8 +44,6 @@ namespace internal {
class NativeWidgetDelegate;
}
-RootView* GetRootViewForHWND(HWND hwnd);
-
// A Windows message reflected from other windows. This message is sent
// with the following arguments:
// hWnd - Target window
@@ -80,12 +77,11 @@ const int WM_NCUAHDRAWFRAME = 0xAF;
//
///////////////////////////////////////////////////////////////////////////////
class WidgetWin : public ui::WindowImpl,
- public Widget,
public NativeWidget,
public MessageLoopForUI::Observer,
public internal::InputMethodDelegate {
public:
- WidgetWin();
+ explicit WidgetWin(internal::NativeWidgetDelegate* delegate);
virtual ~WidgetWin();
// Returns true if we are on Windows Vista or greater and composition is
@@ -113,20 +109,6 @@ class WidgetWin : public ui::WindowImpl,
// Clear a view that has recently been removed on a hierarchy change.
void ClearAccessibilityViewEvent(View* view);
- // Overridden from Widget:
- virtual gfx::NativeView GetNativeView() const OVERRIDE;
- virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
- virtual bool GetAccelerator(int cmd_id,
- ui::Accelerator* accelerator) OVERRIDE;
- virtual Window* GetWindow() OVERRIDE;
- virtual const Window* GetWindow() const OVERRIDE;
- virtual void ViewHierarchyChanged(bool is_add, View *parent,
- View *child) OVERRIDE;
- virtual void NotifyAccessibilityEvent(
- View* view,
- ui::AccessibilityTypes::Event event_type,
- bool send_native_event);
-
BOOL IsWindow() const {
return ::IsWindow(GetNativeView());
}
@@ -183,24 +165,26 @@ class WidgetWin : public ui::WindowImpl,
return ::GetClientRect(GetNativeView(), rect);
}
- // Resets the last move flag so that we can go around the optimization
- // that disregards duplicate mouse moves when ending animation requires
- // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation
- // to cause the close button to highlight.
- void ResetLastMouseMoveFlag() {
- last_mouse_event_was_move_ = false;
- }
-
// Overridden from NativeWidget:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual Widget* GetWidget() OVERRIDE;
+ virtual const Widget* GetWidget() const OVERRIDE;
+ virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
+ virtual Window* GetContainingWindow() OVERRIDE;
+ virtual const Window* GetContainingWindow() const OVERRIDE;
+ virtual void ViewRemoved(View* view) OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual bool IsScreenReaderActive() const OVERRIDE;
+ virtual void SendNativeAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) OVERRIDE;
virtual void SetMouseCapture() OVERRIDE;
virtual void ReleaseMouseCapture() OVERRIDE;
virtual bool HasMouseCapture() const OVERRIDE;
+ virtual bool IsMouseButtonDown() const OVERRIDE;
virtual InputMethod* GetInputMethodNative() OVERRIDE;
virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
@@ -443,6 +427,7 @@ class WidgetWin : public ui::WindowImpl,
virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
// A delegate implementation that handles events received here.
+ // See class documentation for Widget in widget.h for a note about ownership.
internal::NativeWidgetDelegate* delegate_;
// The following factory is used for calls to close the WidgetWin
@@ -481,8 +466,7 @@ class WidgetWin : public ui::WindowImpl,
// A factory that allows us to schedule a redraw for layered windows.
ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_;
- // Whether or not the window should delete itself when it is destroyed.
- // Set this to false via its setter for stack allocated instances.
+ // See class documentation for Widget in widget.h for a note about ownership.
bool delete_on_destroy_;
// True if we are allowed to update the layered window from the DIB backing
diff --git a/views/widget/widget_win_unittest.cc b/views/widget/widget_win_unittest.cc
index 3c13138..c9a33e8 100644
--- a/views/widget/widget_win_unittest.cc
+++ b/views/widget/widget_win_unittest.cc
@@ -43,7 +43,7 @@ class WidgetWinTest : public testing::Test {
};
WidgetWin* WidgetWinTest::CreateWidgetWin() {
- scoped_ptr<Widget> widget(Widget::CreateWidget());
+ scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
params.delete_on_destroy = false;
params.bounds = gfx::Rect(50, 50, 650, 650);
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index e86cd10..305eae1 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -236,7 +236,7 @@ gfx::Size CustomFrameView::GetPreferredSize() {
void CustomFrameView::ButtonPressed(Button* sender, const views::Event& event) {
if (sender == close_button_)
- frame_->CloseWindow();
+ frame_->Close();
else if (sender == minimize_button_)
frame_->Minimize();
else if (sender == maximize_button_)
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index e2cc5ef..b3b5c9a 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -541,7 +541,7 @@ DialogDelegate* DialogClientView::GetDialogDelegate() const {
}
void DialogClientView::Close() {
- window()->CloseWindow();
+ window()->Close();
GetDialogDelegate()->OnClose();
}
diff --git a/views/window/native_frame_view.cc b/views/window/native_frame_view.cc
index 397b6f3..c78d6d1 100644
--- a/views/window/native_frame_view.cc
+++ b/views/window/native_frame_view.cc
@@ -4,14 +4,16 @@
#include "views/window/native_frame_view.h"
-#include "views/window/window_win.h"
+#include "views/widget/widget_win.h"
+#include "views/window/native_window.h"
+#include "views/window/window.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// NativeFrameView, public:
-NativeFrameView::NativeFrameView(WindowWin* frame)
+NativeFrameView::NativeFrameView(Window* frame)
: NonClientFrameView(),
frame_(frame) {
}
@@ -29,8 +31,10 @@ gfx::Rect NativeFrameView::GetBoundsForClientView() const {
gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
RECT rect = client_bounds.ToRECT();
- AdjustWindowRectEx(&rect, frame_->window_style(), FALSE,
- frame_->window_ex_style());
+ WidgetWin* widget_win =
+ static_cast<WidgetWin*>(frame_->native_window()->AsNativeWidget());
+ AdjustWindowRectEx(&rect, widget_win->window_style(), FALSE,
+ widget_win->window_ex_style());
return gfx::Rect(rect);
}
diff --git a/views/window/native_frame_view.h b/views/window/native_frame_view.h
index ac68ddf..9bc943f 100644
--- a/views/window/native_frame_view.h
+++ b/views/window/native_frame_view.h
@@ -10,11 +10,11 @@
namespace views {
-class WindowWin;
+class Window;
class NativeFrameView : public NonClientFrameView {
public:
- explicit NativeFrameView(WindowWin* frame);
+ explicit NativeFrameView(Window* frame);
virtual ~NativeFrameView();
// NonClientFrameView overrides:
@@ -33,7 +33,7 @@ class NativeFrameView : public NonClientFrameView {
private:
// Our containing frame.
- WindowWin* frame_;
+ Window* frame_;
DISALLOW_COPY_AND_ASSIGN(NativeFrameView);
};
diff --git a/views/window/native_window.h b/views/window/native_window.h
index 63da12a..0e83f30 100644
--- a/views/window/native_window.h
+++ b/views/window/native_window.h
@@ -37,9 +37,13 @@ class NativeWindow {
virtual ~NativeWindow() {}
- static Window* CreateNativeWindow();
+ // Creates an appropriate default NativeWindow implementation for the current
+ // OS/circumstance.
+ static NativeWindow* CreateNativeWindow(
+ internal::NativeWindowDelegate* delegate);
virtual Window* GetWindow() = 0;
+ virtual const Window* GetWindow() const = 0;
virtual NativeWidget* AsNativeWidget() = 0;
virtual const NativeWidget* AsNativeWidget() const = 0;
@@ -100,7 +104,6 @@ class NativeWindow {
virtual void SetFullscreen(bool fullscreen) = 0;
virtual bool IsFullscreen() const = 0;
virtual void SetAlwaysOnTop(bool always_on_top) = 0;
- virtual bool IsAppWindow() const = 0;
virtual void SetUseDragFrame(bool use_drag_frame) = 0;
virtual NonClientFrameView* CreateFrameViewForWindow() = 0;
virtual void UpdateFrameAfterFrameChange() = 0;
diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h
index 23705a5..c88924b 100644
--- a/views/window/native_window_delegate.h
+++ b/views/window/native_window_delegate.h
@@ -6,6 +6,10 @@
#define VIEWS_WIDGET_NATIVE_WINDOW_DELEGATE_H_
#pragma once
+namespace ui {
+class ThemeProvider;
+}
+
namespace views {
namespace internal {
@@ -64,6 +68,12 @@ class NativeWindowDelegate {
// Called when the native window's position or size has changed.
virtual void OnNativeWindowBoundsChanged() = 0;
+
+ //
+ virtual Window* AsWindow() = 0;
+
+ //
+ virtual NativeWidgetDelegate* AsNativeWidgetDelegate() = 0;
};
} // namespace internal
diff --git a/views/window/window.cc b/views/window/window.cc
index 13f2515..efc9f15 100644
--- a/views/window/window.cc
+++ b/views/window/window.cc
@@ -47,7 +47,7 @@ Window::~Window() {
Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
const gfx::Rect& bounds,
WindowDelegate* window_delegate) {
- Window* window = NativeWindow::CreateNativeWindow();
+ Window* window = new Window;
Window::InitParams params(window_delegate);
params.parent_window = parent;
params.widget_init_params.bounds = bounds;
@@ -74,34 +74,24 @@ gfx::Size Window::GetLocalizedContentsSize(int col_resource_id,
GetLocalizedContentsHeight(row_resource_id));
}
-// static
-void Window::CloseSecondaryWidget(Widget* widget) {
- if (!widget)
- return;
-
- // Close widget if it's identified as a secondary window.
- Window* window = widget->GetWindow();
- if (window) {
- if (!window->IsAppWindow())
- window->CloseWindow();
- } else {
- // If it's not a Window, then close it anyway since it probably is
- // secondary.
- widget->Close();
- }
-}
-
void Window::InitWindow(const InitParams& params) {
window_delegate_ = params.window_delegate;
AsWidget()->set_widget_delegate(window_delegate_);
DCHECK(window_delegate_);
DCHECK(!window_delegate_->window_);
window_delegate_->window_ = this;
+ set_widget_delegate(window_delegate_);
+ native_window_ =
+ params.native_window ? params.native_window
+ : NativeWindow::CreateNativeWindow(this);
// If frame_view was set already, don't replace it with default one.
if (!non_client_view()->frame_view())
non_client_view()->SetFrameView(CreateFrameViewForWindow());
- AsWidget()->Init(params.widget_init_params);
- OnNativeWindowCreated(params.widget_init_params.bounds);
+ InitParams modified_params = params;
+ modified_params.widget_init_params.native_widget =
+ native_window_->AsNativeWidget();
+ Init(modified_params.widget_init_params);
+ OnNativeWindowCreated(modified_params.widget_init_params.bounds);
}
gfx::Rect Window::GetBounds() const {
@@ -149,7 +139,7 @@ void Window::Deactivate() {
native_window_->Deactivate();
}
-void Window::CloseWindow() {
+void Window::Close() {
if (window_closed_) {
// It appears we can hit this code path if you close a modal dialog then
// close the last browser before the destructor is hit, which triggers
@@ -159,9 +149,7 @@ void Window::CloseWindow() {
if (non_client_view_->CanClose()) {
SaveWindowPosition();
- // TODO(beng): This can be simplified to Widget::Close() once Window
- // subclasses Widget.
- native_window_->AsNativeWidget()->GetWidget()->Close();
+ Widget::Close();
window_closed_ = true;
}
}
@@ -206,10 +194,6 @@ void Window::SetUseDragFrame(bool use_drag_frame) {
native_window_->SetUseDragFrame(use_drag_frame);
}
-bool Window::IsAppWindow() const {
- return native_window_->IsAppWindow();
-}
-
void Window::EnableClose(bool enable) {
non_client_view_->EnableClose(enable);
native_window_->EnableClose(enable);
@@ -261,21 +245,6 @@ void Window::FrameTypeChanged() {
native_window_->FrameTypeChanged();
}
-Widget* Window::AsWidget() {
- return const_cast<Widget*>(const_cast<const Window*>(this)->AsWidget());
-}
-
-const Widget* Window::AsWidget() const {
- return native_window_->AsNativeWidget()->GetWidget();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Window, protected:
-
-void Window::SetNativeWindow(NativeWindow* native_window) {
- native_window_ = native_window;
-}
-
////////////////////////////////////////////////////////////////////////////////
// Window, internal::NativeWindowDelegate implementation:
@@ -364,6 +333,14 @@ void Window::OnNativeWindowBoundsChanged() {
SaveWindowPosition();
}
+Window* Window::AsWindow() {
+ return this;
+}
+
+internal::NativeWidgetDelegate* Window::AsNativeWidgetDelegate() {
+ return this;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Window, private:
diff --git a/views/window/window.h b/views/window/window.h
index 76fdb76..191aba4 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -39,7 +39,8 @@ class WindowDelegate;
// implementation. Multiple inheritance is required for this
// transitional step.
//
-class Window : public internal::NativeWindowDelegate {
+class Window : public Widget,
+ public internal::NativeWindowDelegate {
public:
struct InitParams {
// |window_delegate| cannot be NULL.
@@ -71,16 +72,6 @@ class Window : public internal::NativeWindowDelegate {
static gfx::Size GetLocalizedContentsSize(int col_resource_id,
int row_resource_id);
- // Closes all windows that aren't identified as "app windows" via
- // IsAppWindow. Called during application shutdown when the last "app window"
- // is closed.
- static void CloseAllSecondaryWindows();
-
- // Used by |CloseAllSecondaryWindows|. If |widget|'s window is a secondary
- // window, the window is closed. If |widget| has no window, it is closed.
- // Does nothing if |widget| is null.
- static void CloseSecondaryWidget(Widget* widget);
-
// Initializes the window. Must be called before any post-configuration
// operations are performed.
void InitWindow(const InitParams& params);
@@ -124,7 +115,7 @@ class Window : public internal::NativeWindowDelegate {
// Closes the window, ultimately destroying it. The window hides immediately,
// and is destroyed after a return to the message loop. Close() can be called
// multiple times.
- void CloseWindow();
+ virtual void Close() OVERRIDE;
// Maximizes/minimizes/restores the window.
void Maximize();
@@ -138,7 +129,7 @@ class Window : public internal::NativeWindowDelegate {
bool IsVisible() const;
// Whether or not the window is maximized or minimized.
- bool IsMaximized() const;
+ virtual bool IsMaximized() const;
bool IsMinimized() const;
// Accessors for fullscreen state.
@@ -149,11 +140,6 @@ class Window : public internal::NativeWindowDelegate {
// frame" - slightly transparent and without the standard window controls.
void SetUseDragFrame(bool use_drag_frame);
- // Returns true if the Window is considered to be an "app window" - i.e.
- // any window which when it is the last of its type closed causes the
- // application to exit.
- virtual bool IsAppWindow() const;
-
// Toggles the enable state for the Close button (and the Close menu item in
// the system menu).
void EnableClose(bool enable);
@@ -182,10 +168,6 @@ class Window : public internal::NativeWindowDelegate {
// Tell the window that something caused the frame type to change.
void FrameTypeChanged();
- // TODO(beng): remove once Window subclasses Widget.
- Widget* AsWidget();
- const Widget* AsWidget() const;
-
WindowDelegate* window_delegate() {
return const_cast<WindowDelegate*>(
const_cast<const Window*>(this)->window_delegate());
@@ -213,10 +195,6 @@ class Window : public internal::NativeWindowDelegate {
NativeWindow* native_window() { return native_window_; }
protected:
- // TODO(beng): Temporarily provided as a way to associate the subclass'
- // implementation of NativeWidget with this.
- void SetNativeWindow(NativeWindow* native_window);
-
// Overridden from NativeWindowDelegate:
virtual bool CanActivate() const OVERRIDE;
virtual bool IsInactiveRenderingDisabled() const OVERRIDE;
@@ -234,6 +212,8 @@ class Window : public internal::NativeWindowDelegate {
virtual void OnNativeWindowDestroying() OVERRIDE;
virtual void OnNativeWindowDestroyed() OVERRIDE;
virtual void OnNativeWindowBoundsChanged() OVERRIDE;
+ virtual Window* AsWindow() OVERRIDE;
+ virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE;
private:
// Sizes and positions the window just after it is created.
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 0e7a6f2..5d72ed8 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -79,37 +79,17 @@ GdkCursorType HitTestCodeToGdkCursorType(int hittest_code) {
namespace views {
-WindowGtk::WindowGtk()
- : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
+WindowGtk::WindowGtk(internal::NativeWindowDelegate* delegate)
+ : WidgetGtk(delegate->AsNativeWidgetDelegate()),
+ delegate_(delegate),
window_state_(GDK_WINDOW_STATE_WITHDRAWN),
window_closed_(false) {
- SetNativeWindow(this);
is_window_ = true;
}
WindowGtk::~WindowGtk() {
}
-// static
-void Window::CloseAllSecondaryWindows() {
- GList* windows = gtk_window_list_toplevels();
- for (GList* window = windows; window;
- window = g_list_next(window)) {
- Window::CloseSecondaryWidget(
- NativeWidget::GetNativeWidgetForNativeView(
- GTK_WIDGET(window->data))->GetWidget());
- }
- g_list_free(windows);
-}
-
-Window* WindowGtk::AsWindow() {
- return this;
-}
-
-const Window* WindowGtk::AsWindow() const {
- return this;
-}
-
////////////////////////////////////////////////////////////////////////////////
// WindowGtk, WidgetGtk overrides:
@@ -129,7 +109,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
if (event->type == GDK_BUTTON_PRESS &&
!mouse_event.IsOnlyRightMouseButton()) {
gfx::Point screen_point(event->x, event->y);
- View::ConvertPointToScreen(GetRootView(), &screen_point);
+ View::ConvertPointToScreen(GetWindow()->GetRootView(), &screen_point);
gtk_window_begin_move_drag(GetNativeWindow(), event->button,
screen_point.x(), screen_point.y(),
event->time);
@@ -147,7 +127,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
case HTTOPLEFT:
case HTTOPRIGHT: {
gfx::Point screen_point(event->x, event->y);
- View::ConvertPointToScreen(GetRootView(), &screen_point);
+ View::ConvertPointToScreen(GetWindow()->GetRootView(), &screen_point);
// TODO(beng): figure out how to get a good minimum size.
gtk_widget_set_size_request(GetNativeView(), 100, 100);
gtk_window_begin_resize_drag(GetNativeWindow(),
@@ -221,9 +201,6 @@ void WindowGtk::IsActiveChanged() {
}
void WindowGtk::InitNativeWidget(const Widget::InitParams& params) {
- if (params.parent)
- make_transient_to_parent();
-
WidgetGtk::InitNativeWidget(params);
g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event",
@@ -310,7 +287,11 @@ void WindowGtk::SetAccessibleState(ui::AccessibilityTypes::State state) {
}
Window* WindowGtk::GetWindow() {
- return this;
+ return delegate_->AsWindow();
+}
+
+const Window* WindowGtk::GetWindow() const {
+ return delegate_->AsWindow();
}
void WindowGtk::SetWindowBounds(const gfx::Rect& bounds,
@@ -320,7 +301,7 @@ void WindowGtk::SetWindowBounds(const gfx::Rect& bounds,
}
void WindowGtk::HideWindow() {
- Hide();
+ GetWindow()->Hide();
}
void WindowGtk::Activate() {
@@ -379,18 +360,12 @@ void WindowGtk::SetUseDragFrame(bool use_drag_frame) {
NOTIMPLEMENTED();
}
-void WindowGtk::SetAlwaysOnTop(bool always_on_top) {
- gtk_window_set_keep_above(GetNativeWindow(), always_on_top);
-}
-
-bool WindowGtk::IsAppWindow() const {
- return false;
+NonClientFrameView* WindowGtk::CreateFrameViewForWindow() {
+ return new CustomFrameView(delegate_->AsWindow());
}
-NonClientFrameView* WindowGtk::CreateFrameViewForWindow() {
- // TODO(erg): Always use a custom frame view? Are there cases where we let
- // the window manager deal with the X11 equivalent of the "non-client" area?
- return new CustomFrameView(this);
+void WindowGtk::SetAlwaysOnTop(bool always_on_top) {
+ gtk_window_set_keep_above(GetNativeWindow(), always_on_top);
}
void WindowGtk::UpdateFrameAfterFrameChange() {
@@ -410,8 +385,8 @@ bool WindowGtk::ShouldUseNativeFrame() const {
void WindowGtk::FrameTypeChanged() {
// This is called when the Theme has changed, so forward the event to the root
// widget.
- ThemeChanged();
- GetRootView()->SchedulePaint();
+ GetWidget()->ThemeChanged();
+ GetWidget()->GetRootView()->SchedulePaint();
}
////////////////////////////////////////////////////////////////////////////////
@@ -437,7 +412,9 @@ void WindowGtk::SaveWindowPosition() {
return;
bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
- GetWindow()->window_delegate()->SaveWindowPlacement(GetBounds(), maximized);
+ GetWindow()->window_delegate()->SaveWindowPlacement(
+ GetWidget()->GetWindowScreenBounds(),
+ maximized);
}
void WindowGtk::OnDestroy(GtkWidget* widget) {
@@ -450,8 +427,10 @@ void WindowGtk::OnDestroy(GtkWidget* widget) {
// NativeWindow, public:
// static
-Window* NativeWindow::CreateNativeWindow() {
- return new WindowGtk;
+NativeWindow* NativeWindow::CreateNativeWindow(
+ internal::NativeWindowDelegate* delegate) {
+ return new WindowGtk(delegate);
}
} // namespace views
+
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index e659e4a..b235349 100644
--- a/views/window/window_gtk.h
+++ b/views/window/window_gtk.h
@@ -25,13 +25,13 @@ class Client;
class WindowDelegate;
// Window implementation for GTK.
-class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
+class WindowGtk : public WidgetGtk, public NativeWindow {
public:
- WindowGtk();
+ explicit WindowGtk(internal::NativeWindowDelegate* delegate);
virtual ~WindowGtk();
- virtual Window* AsWindow();
- virtual const Window* AsWindow() const;
+ virtual Window* GetWindow() OVERRIDE;
+ virtual const Window* GetWindow() const OVERRIDE;
// Overridden from WidgetGtk:
virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event);
@@ -63,7 +63,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
virtual void SetAccessibleName(const std::wstring& name) OVERRIDE;
virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE;
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
- virtual Window* GetWindow() OVERRIDE;
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) OVERRIDE;
virtual void HideWindow() OVERRIDE;
@@ -79,7 +78,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
- virtual bool IsAppWindow() const OVERRIDE;
virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index d421647..621af5a 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -233,6 +233,30 @@ class WindowWin::ScopedRedrawLock {
////////////////////////////////////////////////////////////////////////////////
// WindowWin, public:
+WindowWin::WindowWin(internal::NativeWindowDelegate* delegate)
+ : WidgetWin(delegate->AsNativeWidgetDelegate()),
+ delegate_(delegate),
+ focus_on_creation_(true),
+ restored_enabled_(false),
+ fullscreen_(false),
+ is_active_(false),
+ lock_updates_(false),
+ saved_window_style_(0),
+ ignore_window_pos_changes_(false),
+ ignore_pos_changes_factory_(this),
+ force_hidden_count_(0),
+ is_right_mouse_pressed_on_caption_(false),
+ last_monitor_(NULL),
+ is_in_size_move_(false) {
+ is_window_ = true;
+ // Initialize these values to 0 so that subclasses can override the default
+ // behavior before calling Init.
+ set_window_style(0);
+ set_window_ex_style(0);
+}
+
+
+
WindowWin::~WindowWin() {
}
@@ -283,28 +307,6 @@ gfx::Font WindowWin::GetWindowTitleFont() {
///////////////////////////////////////////////////////////////////////////////
// WindowWin, protected:
-WindowWin::WindowWin()
- : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
- focus_on_creation_(true),
- restored_enabled_(false),
- fullscreen_(false),
- is_active_(false),
- lock_updates_(false),
- saved_window_style_(0),
- ignore_window_pos_changes_(false),
- ignore_pos_changes_factory_(this),
- force_hidden_count_(0),
- is_right_mouse_pressed_on_caption_(false),
- last_monitor_(NULL),
- is_in_size_move_(false) {
- SetNativeWindow(this);
- is_window_ = true;
- // Initialize these values to 0 so that subclasses can override the default
- // behavior before calling Init.
- set_window_style(0);
- set_window_ex_style(0);
-}
-
gfx::Insets WindowWin::GetClientAreaInsets() const {
// Returning an empty Insets object causes the default handling in
// WidgetWin::OnNCCalcSize() to be invoked.
@@ -371,7 +373,7 @@ LRESULT WindowWin::OnAppCommand(HWND window, short app_command, WORD device,
}
void WindowWin::OnClose() {
- GetWindow()->CloseWindow();
+ GetWindow()->Close();
}
void WindowWin::OnCommand(UINT notification_code, int command_id, HWND window) {
@@ -412,7 +414,7 @@ void WindowWin::OnExitSizeMove() {
WidgetWin::OnExitSizeMove();
delegate_->OnNativeWindowEndUserBoundsChange();
- if (!GetThemeProvider()->ShouldUseNativeFrame()) {
+ if (!ShouldUseNativeFrame()) {
// Sending SWP_FRAMECHANGED forces a non-client repaint, which fixes the
// glitch in rendering the bottom pixel of the window caused by us
// offsetting the client rect there (See comment in GetClientAreaInsets()).
@@ -773,7 +775,8 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) {
!!(GetKeyState(VK_SHIFT) & 0x8000),
!!(GetKeyState(VK_CONTROL) & 0x8000),
false);
- GetFocusManager()->ProcessAccelerator(accelerator);
+ AsNativeWidget()->GetWidget()->GetFocusManager()->
+ ProcessAccelerator(accelerator);
return;
}
@@ -892,6 +895,14 @@ void WindowWin::SetInitialFocus() {
////////////////////////////////////////////////////////////////////////////////
// WindowWin, NativeWindow implementation:
+Window* WindowWin::GetWindow() {
+ return delegate_->AsWindow();
+}
+
+const Window* WindowWin::GetWindow() const {
+ return delegate_->AsWindow();
+}
+
NativeWidget* WindowWin::AsNativeWidget() {
return this;
}
@@ -1163,10 +1174,6 @@ void WindowWin::SetAlwaysOnTop(bool always_on_top) {
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
-bool WindowWin::IsAppWindow() const {
- return false;
-}
-
void WindowWin::SetUseDragFrame(bool use_drag_frame) {
if (use_drag_frame) {
// Make the frame slightly transparent during the drag operation.
@@ -1187,8 +1194,8 @@ void WindowWin::SetUseDragFrame(bool use_drag_frame) {
NonClientFrameView* WindowWin::CreateFrameViewForWindow() {
if (ShouldUseNativeFrame())
- return new NativeFrameView(this);
- return new CustomFrameView(this);
+ return new NativeFrameView(GetWindow());
+ return new CustomFrameView(GetWindow());
}
void WindowWin::UpdateFrameAfterFrameChange() {
@@ -1201,10 +1208,7 @@ gfx::NativeWindow WindowWin::GetNativeWindow() const {
}
bool WindowWin::ShouldUseNativeFrame() const {
- ui::ThemeProvider* tp = GetThemeProvider();
- if (!tp)
- return WidgetWin::IsAeroGlassEnabled();
- return tp->ShouldUseNativeFrame();
+ return WidgetWin::IsAeroGlassEnabled();
}
void WindowWin::FrameTypeChanged() {
@@ -1344,26 +1348,13 @@ void WindowWin::ExecuteSystemMenuCommand(int command) {
SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
}
-namespace {
-BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) {
- NativeWidget* native_widget =
- NativeWidget::GetNativeWidgetForNativeView(hwnd);
- if (native_widget)
- Window::CloseSecondaryWidget(native_widget->GetWidget());
- return TRUE;
-}
-} // namespace
-
-void Window::CloseAllSecondaryWindows() {
- EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0);
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWindow, public:
// static
-Window* NativeWindow::CreateNativeWindow() {
- return new WindowWin;
+NativeWindow* NativeWindow::CreateNativeWindow(
+ internal::NativeWindowDelegate* delegate) {
+ return new WindowWin(delegate);
}
} // namespace views
diff --git a/views/window/window_win.h b/views/window/window_win.h
index 5ade949..71f2273 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -41,10 +41,9 @@ class WindowDelegate;
//
///////////////////////////////////////////////////////////////////////////////
class WindowWin : public WidgetWin,
- public NativeWindow,
- public Window {
+ public NativeWindow {
public:
- WindowWin();
+ explicit WindowWin(internal::NativeWindowDelegate* delegate);
virtual ~WindowWin();
// Show the window with the specified show command.
@@ -67,6 +66,10 @@ class WindowWin : public WidgetWin,
// Returns the system set window title font.
static gfx::Font GetWindowTitleFont();
+ // Overridden from NativeWindow:
+ virtual Window* GetWindow() OVERRIDE;
+ virtual const Window* GetWindow() const OVERRIDE;
+
protected:
friend Window;
@@ -123,8 +126,6 @@ class WindowWin : public WidgetWin,
virtual void OnSize(UINT size_param, const CSize& new_size) OVERRIDE;
virtual void OnSysCommand(UINT notification_code, CPoint click) OVERRIDE;
virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE;
- virtual Window* GetWindow() OVERRIDE { return this; }
- virtual const Window* GetWindow() const OVERRIDE { return this; }
virtual void Close() OVERRIDE;
virtual void SetInitialFocus() OVERRIDE;
@@ -159,7 +160,6 @@ class WindowWin : public WidgetWin,
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
- virtual bool IsAppWindow() const OVERRIDE;
virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;