diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 09:16:47 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 09:16:47 +0000 |
commit | 3d00e87205a8050aade92ca20f1d87c45032d03a (patch) | |
tree | f445ab86c35cfd8a198b16cda83972f0d3e848f4 /chrome/browser | |
parent | 661ed097db8294f6a10e2f1006dc34a325ea549a (diff) | |
download | chromium_src-3d00e87205a8050aade92ca20f1d87c45032d03a.zip chromium_src-3d00e87205a8050aade92ca20f1d87c45032d03a.tar.gz chromium_src-3d00e87205a8050aade92ca20f1d87c45032d03a.tar.bz2 |
Make BubbleWindow a Widget override with a BubbleFrameView.
Eliminate NativeWidgetGtk specifics, remove extra files.
This supersedes http://codereview.chromium.org/8811001/
This supersedes http://codereview.chromium.org/8774022/
See Issue 106230 for a list of some BubbleWindow users.
The save and open SelectFileExtensionDialog instances look good.
Bookmark All Tabs dialog looks good on non-aura, blocked on aura by crbug.com/106474.
BUG=106230
TEST=BubbleWindows look the same on CrOS, and now similar on Aura. Ensure no regressions of crosbug.com/9065, crosbug.com/8538.
Review URL: http://codereview.chromium.org/8800032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_frame_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_frame_view.h | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_window.cc | 37 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_window.h | 48 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_window_gtk.cc | 64 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_window_style.cc | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_window_style.h | 17 | ||||
-rw-r--r-- | chrome/browser/ui/views/extensions/extension_dialog.cc | 29 | ||||
-rw-r--r-- | chrome/browser/ui/views/extensions/extension_dialog.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/views/window.cc | 12 |
10 files changed, 65 insertions, 179 deletions
diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc index 9aaad38..55607a6 100644 --- a/chrome/browser/chromeos/frame/bubble_frame_view.cc +++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc @@ -42,11 +42,9 @@ const int kTitleFontSizeDelta = 1; namespace chromeos { -BubbleFrameView::BubbleFrameView(views::Widget* frame, - views::WidgetDelegate* widget_delegate, +BubbleFrameView::BubbleFrameView(views::WidgetDelegate* widget_delegate, DialogStyle style) - : frame_(frame), - style_(style), + : style_(style), title_(NULL), close_button_(NULL), throbber_(NULL) { @@ -90,7 +88,7 @@ void BubbleFrameView::StopThrobber() { DCHECK(throbber_ != NULL); throbber_->Stop(); if (title_) - title_->SetText(frame_->widget_delegate()->GetWindowTitle()); + title_->SetText(GetWidget()->widget_delegate()->GetWindowTitle()); } gfx::Rect BubbleFrameView::GetBoundsForClientView() const { @@ -149,9 +147,9 @@ gfx::Insets BubbleFrameView::GetInsets() const { } gfx::Size BubbleFrameView::GetPreferredSize() { - gfx::Size pref = frame_->client_view()->GetPreferredSize(); + gfx::Size pref = GetWidget()->client_view()->GetPreferredSize(); gfx::Rect bounds(0, 0, pref.width(), pref.height()); - return frame_->non_client_view()->GetWindowBoundsForClientBounds( + return GetWidget()->non_client_view()->GetWindowBoundsForClientBounds( bounds).size(); } @@ -239,7 +237,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_->Close(); + GetWidget()->Close(); } } // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.h b/chrome/browser/chromeos/frame/bubble_frame_view.h index 87f4636..63b7192 100644 --- a/chrome/browser/chromeos/frame/bubble_frame_view.h +++ b/chrome/browser/chromeos/frame/bubble_frame_view.h @@ -31,8 +31,7 @@ namespace chromeos { class BubbleFrameView : public views::NonClientFrameView, public views::ButtonListener { public: - BubbleFrameView(views::Widget* frame, - views::WidgetDelegate* widget_delegate, + BubbleFrameView(views::WidgetDelegate* widget_delegate, DialogStyle style); virtual ~BubbleFrameView(); @@ -60,9 +59,6 @@ class BubbleFrameView : public views::NonClientFrameView, void StopThrobber(); private: - // The window that owns this view. - views::Widget* frame_; - // Allows to tweak appearance of the view. DialogStyle style_; diff --git a/chrome/browser/chromeos/frame/bubble_window.cc b/chrome/browser/chromeos/frame/bubble_window.cc new file mode 100644 index 0000000..82f2e79 --- /dev/null +++ b/chrome/browser/chromeos/frame/bubble_window.cc @@ -0,0 +1,37 @@ +// 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/chromeos/frame/bubble_window.h" + +#include "chrome/browser/chromeos/frame/bubble_frame_view.h" + +namespace chromeos { + +// static +const SkColor kBubbleWindowBackgroundColor = SK_ColorWHITE; + +views::Widget* BubbleWindow::Create( + gfx::NativeWindow parent, + DialogStyle style, + views::WidgetDelegate* widget_delegate) { + BubbleWindow* window = new BubbleWindow(style); + views::Widget::InitParams params; + params.delegate = widget_delegate; + params.parent = reinterpret_cast<gfx::NativeView>(parent); + window->Init(params); + return window; +} + +BubbleWindow::~BubbleWindow() { +} + +views::NonClientFrameView* BubbleWindow::CreateNonClientFrameView() { + return new BubbleFrameView(widget_delegate(), style_); +} + +BubbleWindow::BubbleWindow(DialogStyle style) + : style_(style) { +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_window.h b/chrome/browser/chromeos/frame/bubble_window.h index 0405ebf..4a3bf94 100644 --- a/chrome/browser/chromeos/frame/bubble_window.h +++ b/chrome/browser/chromeos/frame/bubble_window.h @@ -6,42 +6,28 @@ #define CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_WINDOW_H_ #pragma once -#include "chrome/browser/chromeos/frame/bubble_window_style.h" #include "chrome/browser/ui/dialog_style.h" +#include "ui/views/widget/widget.h" -#if defined(TOOLKIT_USES_GTK) -// TODO(msw): While I dislike the includes and code to be mixed into the same -// preprocessor conditional, this seems okay as I can hopefully fix this up -// in a matter of days / crbug.com/98322. -#include "ui/views/widget/native_widget_gtk.h" -#else // TOOLKIT_USES_GTK -#include "ui/views/view.h" -#endif - -namespace views { -class WidgetDelegate; -} - -#if defined(TOOLKIT_USES_GTK) -// TODO(msw): To fix as explained above (crbug.com/98322). namespace chromeos { +extern const SkColor kBubbleWindowBackgroundColor; + // A window that uses BubbleFrameView as its frame. -class BubbleWindow : public views::NativeWidgetGtk { +class BubbleWindow : public views::Widget { public: static views::Widget* Create(gfx::NativeWindow parent, DialogStyle style, views::WidgetDelegate* widget_delegate); - protected: - BubbleWindow(views::Widget* window, DialogStyle style); + virtual ~BubbleWindow(); - // Overridden from views::NativeWidgetGtk: - virtual void InitNativeWidget( - const views::Widget::InitParams& params) OVERRIDE; + // Overridden from views::Widget: virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; private: + explicit BubbleWindow(DialogStyle style); + DialogStyle style_; DISALLOW_COPY_AND_ASSIGN(BubbleWindow); @@ -49,22 +35,4 @@ class BubbleWindow : public views::NativeWidgetGtk { } // namespace chromeos -#else // TOOLKIT_USES_GTK - -namespace chromeos { - -class BubbleWindow { - public: - static views::Widget* Create(gfx::NativeWindow parent, - DialogStyle style, - views::WidgetDelegate* widget_delegate) { - NOTIMPLEMENTED(); - return NULL; - } -}; - -} // namespace chromeos - -#endif // TOOLKIT_USES_GTK - #endif // CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_WINDOW_H_ diff --git a/chrome/browser/chromeos/frame/bubble_window_gtk.cc b/chrome/browser/chromeos/frame/bubble_window_gtk.cc deleted file mode 100644 index 67846e6..0000000 --- a/chrome/browser/chromeos/frame/bubble_window_gtk.cc +++ /dev/null @@ -1,64 +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/chromeos/frame/bubble_window.h" - -#include <gtk/gtk.h> - -#include "chrome/browser/chromeos/frame/bubble_frame_view.h" -#include "ui/gfx/skia_utils_gtk.h" -#include "ui/views/window/non_client_view.h" - -namespace chromeos { - -BubbleWindow::BubbleWindow(views::Widget* window, - DialogStyle style) - : views::NativeWidgetGtk(window), - style_(style) { -} - -void BubbleWindow::InitNativeWidget(const views::Widget::InitParams& params) { - views::NativeWidgetGtk::InitNativeWidget(params); - - // Turn on double buffering so that the hosted GtkWidgets does not - // flash as in http://crosbug.com/9065. - EnableDoubleBuffer(true); - - GdkColor background_color = - gfx::SkColorToGdkColor(kBubbleWindowBackgroundColor); - gtk_widget_modify_bg(GetNativeView(), GTK_STATE_NORMAL, &background_color); - - // A work-around for http://crosbug.com/8538. All GdkWindow of top-level - // GtkWindow should participate _NET_WM_SYNC_REQUEST protocol and window - // manager should only show the window after getting notified. And we - // should only notify window manager after at least one paint is done. - // TODO(xiyuan): Figure out the right fix. - gtk_widget_realize(GetNativeView()); - gdk_window_set_back_pixmap(GetNativeView()->window, NULL, FALSE); - gtk_widget_realize(window_contents()); - gdk_window_set_back_pixmap(window_contents()->window, NULL, FALSE); -} - -views::NonClientFrameView* BubbleWindow::CreateNonClientFrameView() { - views::Widget* window = GetWidget(); - return new BubbleFrameView(window, window->widget_delegate(), style_); -} - -views::Widget* BubbleWindow::Create( - gfx::NativeWindow parent, - DialogStyle style, - views::WidgetDelegate* widget_delegate) { - views::Widget* window = new views::Widget; - BubbleWindow* bubble_window = new BubbleWindow(window, style); - views::Widget::InitParams params; - params.delegate = widget_delegate; - params.native_widget = bubble_window; - params.parent = GTK_WIDGET(parent); - params.bounds = gfx::Rect(); - window->Init(params); - - return window; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_window_style.cc b/chrome/browser/chromeos/frame/bubble_window_style.cc deleted file mode 100644 index 1b94d8b..0000000 --- a/chrome/browser/chromeos/frame/bubble_window_style.cc +++ /dev/null @@ -1,12 +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/chromeos/frame/bubble_window_style.h" - -namespace chromeos { - -// static -const SkColor kBubbleWindowBackgroundColor = SK_ColorWHITE; - -} // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_window_style.h b/chrome/browser/chromeos/frame/bubble_window_style.h deleted file mode 100644 index 3bfdb45..0000000 --- a/chrome/browser/chromeos/frame/bubble_window_style.h +++ /dev/null @@ -1,17 +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_CHROMEOS_FRAME_BUBBLE_WINDOW_STYLE_H_ -#define CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_WINDOW_STYLE_H_ -#pragma once - -#include "third_party/skia/include/core/SkColor.h" - -namespace chromeos { - -extern const SkColor kBubbleWindowBackgroundColor; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_WINDOW_STYLE_H_ diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index 41e8cdd..53c74ed1 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc @@ -21,28 +21,6 @@ #include "googleurl/src/gurl.h" #include "ui/views/widget/widget.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/frame/bubble_window.h" -#endif - -namespace { - -views::Widget* CreateWindow(gfx::NativeWindow parent, - views::WidgetDelegate* delegate) { -#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) - // TODO(msw): revert to BubbleWindow for all ChromeOS cases when CL - // for crbug.com/98322 is landed. - // On Chrome OS we need to override the style to suppress padding around - // the borders. - return chromeos::BubbleWindow::Create(parent, - STYLE_FLUSH, delegate); -#else - return browser::CreateViewsWindow(parent, delegate, STYLE_GENERIC); -#endif -} - -} // namespace - ExtensionDialog::ExtensionDialog(ExtensionHost* host, ExtensionDialogObserver* observer) : window_(NULL), @@ -94,7 +72,12 @@ ExtensionHost* ExtensionDialog::CreateExtensionHost(const GURL& url, void ExtensionDialog::InitWindow(Browser* browser, int width, int height) { gfx::NativeWindow parent = browser->window()->GetNativeHandle(); - window_ = CreateWindow(parent, this /* views::WidgetDelegate */); +#if defined(OS_CHROMEOS) + DialogStyle style = STYLE_FLUSH; +#else + DialogStyle style = STYLE_GENERIC; +#endif + window_ = browser::CreateViewsWindow(parent, this, style); // Center the window over the browser. gfx::Point center = browser->window()->GetBounds().CenterPoint(); diff --git a/chrome/browser/ui/views/extensions/extension_dialog.h b/chrome/browser/ui/views/extensions/extension_dialog.h index e80f0a9..8686e2a 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.h +++ b/chrome/browser/ui/views/extensions/extension_dialog.h @@ -17,11 +17,6 @@ class ExtensionHost; class GURL; class TabContents; -namespace views { -class View; -class Widget; -} - // Modal dialog containing contents provided by an extension. // Dialog is automatically centered in the browser window and has fixed size. // For example, used by the Chrome OS file browser. diff --git a/chrome/browser/ui/views/window.cc b/chrome/browser/ui/views/window.cc index 49e6cc7..3827a1d 100644 --- a/chrome/browser/ui/views/window.cc +++ b/chrome/browser/ui/views/window.cc @@ -7,20 +7,22 @@ #include "ui/views/bubble/bubble_delegate.h" #include "ui/views/widget/widget.h" -#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) +#if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/frame/bubble_window.h" + +#if defined(TOOLKIT_USES_GTK) #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" -#endif +#endif // TOOLKIT_USES_GTK + +#endif // OS_CHROMEOS namespace browser { views::Widget* CreateViewsWindow(gfx::NativeWindow parent, views::WidgetDelegate* delegate, DialogStyle style) { -#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) - // TODO(msw): revert to BubbleWindow for all ChromeOS cases when CL - // for crbug.com/98322 is landed. +#if defined(OS_CHROMEOS) return chromeos::BubbleWindow::Create(parent, style, delegate); #else return views::Widget::CreateWindowWithParent(delegate, parent); |