diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 17:43:05 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 17:43:05 +0000 |
commit | af1fde05ba3696986ba28445ea0c74f96d456ebb (patch) | |
tree | 8986d27bfec650d279fa085767279a59442c6eaf /chrome/browser | |
parent | a6ea9c6010cfa383356c3e84c2976132ce22c9d1 (diff) | |
download | chromium_src-af1fde05ba3696986ba28445ea0c74f96d456ebb.zip chromium_src-af1fde05ba3696986ba28445ea0c74f96d456ebb.tar.gz chromium_src-af1fde05ba3696986ba28445ea0c74f96d456ebb.tar.bz2 |
Rework the way Widget::Init works:
- Remove SetCreateParams from the public Widget API.
- Add parent/bounds fields to CreateParams
- Make Widget::Init be the canonical init method (vs. WidgetWin/Gtk Init) and have it take a CreateParams.
- NativeWidget now has a InitNativeWidget method, which subclasses can override. Everyone must call Widget::Init via Widget* (not WidgetWin* as this will be ambiguous to WindowImpl::Init).
BUG=72040
TEST=none
Review URL: http://codereview.chromium.org/6881107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
45 files changed, 214 insertions, 194 deletions
diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc index 6294f2e..cff8723 100644 --- a/chrome/browser/chromeos/frame/panel_controller.cc +++ b/chrome/browser/chromeos/frame/panel_controller.cc @@ -141,10 +141,11 @@ void PanelController::Init(bool initial_focus, WmIpcPanelUserResizeType resize_type) { gfx::Rect title_bounds(0, 0, window_bounds.width(), kTitleHeight); + title_window_ = views::Widget::CreateWidget(); views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); params.transparent = true; - title_window_ = views::Widget::CreateWidget(params); - title_window_->Init(NULL, title_bounds); + params.bounds = title_bounds; + title_window_->Init(params); gtk_widget_set_size_request(title_window_->GetNativeView(), title_bounds.width(), title_bounds.height()); title_ = title_window_->GetNativeView(); diff --git a/chrome/browser/chromeos/input_method/candidate_window.cc b/chrome/browser/chromeos/input_method/candidate_window.cc index 9199ecc..dc693ca 100644 --- a/chrome/browser/chromeos/input_method/candidate_window.cc +++ b/chrome/browser/chromeos/input_method/candidate_window.cc @@ -1282,10 +1282,10 @@ bool CandidateWindowController::Impl::Init() { void CandidateWindowController::Impl::CreateView() { // Create a non-decorated frame. - frame_.reset(views::Widget::CreateWidget( - views::Widget::CreateParams(views::Widget::CreateParams::TYPE_POPUP))); + frame_.reset(views::Widget::CreateWidget()); // The size is initially zero. - frame_->Init(NULL, gfx::Rect(0, 0)); + frame_->Init( + views::Widget::CreateParams(views::Widget::CreateParams::TYPE_POPUP)); // Create the candidate window. candidate_window_ = new CandidateWindowView(frame_.get()); diff --git a/chrome/browser/chromeos/login/background_view.cc b/chrome/browser/chromeos/login/background_view.cc index cd7bc58..17a5714 100644 --- a/chrome/browser/chromeos/login/background_view.cc +++ b/chrome/browser/chromeos/login/background_view.cc @@ -169,9 +169,10 @@ views::Widget* BackgroundView::CreateWindowContainingView( BackgroundView** view) { ResetXCursor(); - Widget* window = Widget::CreateWidget( - Widget::CreateParams(Widget::CreateParams::TYPE_WINDOW)); - window->Init(NULL, bounds); + Widget* window = Widget::CreateWidget(); + Widget::CreateParams params(Widget::CreateParams::TYPE_WINDOW); + params.bounds = bounds; + window->Init(params); *view = new BackgroundView(); (*view)->Init(background_url); diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc index 3dd8b01..f9e7919 100644 --- a/chrome/browser/chromeos/login/helper.cc +++ b/chrome/browser/chromeos/login/helper.cc @@ -109,13 +109,16 @@ void ThrobberHostView::StartThrobber() { throbber->set_stop_delay_ms(0); gfx::Rect throbber_bounds = CalculateThrobberBounds(throbber); - views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); - params.transparent = true; - throbber_widget_ = views::Widget::CreateWidget(params); - static_cast<views::WidgetGtk*>(throbber_widget_)->make_transient_to_parent(); + throbber_widget_ = views::Widget::CreateWidget(); + static_cast<views::WidgetGtk*>(throbber_widget_->native_widget())-> + make_transient_to_parent(); throbber_bounds.Offset(host_view_->GetScreenBounds().origin()); - throbber_widget_->Init(host_gtk_window, throbber_bounds); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); + params.transparent = true; + params.bounds = throbber_bounds; + params.parent = host_gtk_window; + throbber_widget_->Init(params); throbber_widget_->SetContentsView(throbber); // This keeps the window from flashing at startup. gdk_window_set_back_pixmap( diff --git a/chrome/browser/chromeos/login/message_bubble.cc b/chrome/browser/chromeos/login/message_bubble.cc index e7a099c..25ebd7b 100644 --- a/chrome/browser/chromeos/login/message_bubble.cc +++ b/chrome/browser/chromeos/login/message_bubble.cc @@ -21,7 +21,7 @@ namespace chromeos { static const int kBorderSize = 4; static const int kMaxLabelWidth = 250; -MessageBubble::MessageBubble(views::WidgetGtk::Type type, +MessageBubble::MessageBubble(views::Widget::CreateParams::Type type, views::Widget* parent, SkBitmap* image, const std::wstring& text, @@ -114,7 +114,8 @@ MessageBubble* MessageBubble::Show(views::Widget* parent, MessageBubbleDelegate* delegate) { // The bubble will be destroyed when it is closed. MessageBubble* bubble = new MessageBubble( - views::WidgetGtk::TYPE_WINDOW, parent, image, text, help, true, delegate); + views::Widget::CreateParams::TYPE_WINDOW, parent, image, text, help, + true, delegate); bubble->InitBubble(parent, position_relative_to, arrow_location, bubble->text_->parent(), delegate); return bubble; @@ -131,7 +132,8 @@ MessageBubble* MessageBubble::ShowNoGrab( MessageBubbleDelegate* delegate) { // The bubble will be destroyed when it is closed. MessageBubble* bubble = new MessageBubble( - views::WidgetGtk::TYPE_CHILD, parent, image, text, help, false, delegate); + views::Widget::CreateParams::TYPE_CONTROL, parent, image, text, help, + false, delegate); bubble->InitBubble(parent, position_relative_to, arrow_location, bubble->text_->parent(), delegate); return bubble; diff --git a/chrome/browser/chromeos/login/message_bubble.h b/chrome/browser/chromeos/login/message_bubble.h index 0b22697..d734c70 100644 --- a/chrome/browser/chromeos/login/message_bubble.h +++ b/chrome/browser/chromeos/login/message_bubble.h @@ -77,7 +77,7 @@ class MessageBubble : public Bubble, virtual void SetMouseCapture(); private: - MessageBubble(views::WidgetGtk::Type type, + MessageBubble(views::Widget::CreateParams::Type type, views::Widget* parent, SkBitmap* image, const std::wstring& text, diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index 2e79b6f..195d50a 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -198,9 +198,7 @@ static base::LazyInstance<ScreenLockObserver> g_screen_lock_observer( // focus/events inside the grab widget. class LockWindow : public views::WidgetGtk { public: - LockWindow() - : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), - toplevel_focus_widget_(NULL) { + LockWindow() : toplevel_focus_widget_(NULL) { EnableDoubleBuffer(true); } @@ -284,8 +282,7 @@ class GrabWidgetRootView class GrabWidget : public views::WidgetGtk { public: explicit GrabWidget(chromeos::ScreenLocker* screen_locker) - : views::WidgetGtk(views::WidgetGtk::TYPE_CHILD), - screen_locker_(screen_locker), + : screen_locker_(screen_locker), ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), grab_failure_count_(0), kbd_grab_status_(GDK_GRAB_INVALID_TIME), @@ -478,7 +475,7 @@ class ScreenLockerBackgroundView : public chromeos::BackgroundView, public chromeos::ScreenLocker::ScreenLockViewContainer { public: - ScreenLockerBackgroundView(views::WidgetGtk* lock_widget, + ScreenLockerBackgroundView(views::Widget* lock_widget, views::View* screen_lock_view) : lock_widget_(lock_widget), screen_lock_view_(screen_lock_view) { @@ -511,7 +508,7 @@ class ScreenLockerBackgroundView } private: - views::WidgetGtk* lock_widget_; + views::Widget* lock_widget_; views::View* screen_lock_view_; @@ -688,7 +685,9 @@ void ScreenLocker::Init() { LockWindow* lock_window = new LockWindow(); lock_window_ = lock_window; - lock_window_->Init(NULL, init_bounds); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); + params.bounds = init_bounds; + lock_window_->Init(params); g_signal_connect(lock_window_->GetNativeView(), "client-event", G_CALLBACK(OnClientEventThunk), this); @@ -710,8 +709,11 @@ void ScreenLocker::Init() { // namespace feels a bit ugly.) GrabWidget* cast_lock_widget = new GrabWidget(this); lock_widget_ = cast_lock_widget; - lock_widget_->MakeTransparent(); - lock_widget_->InitWithWidget(lock_window_, gfx::Rect()); + views::Widget::CreateParams lock_params( + views::Widget::CreateParams::TYPE_CONTROL); + lock_params.transparent = true; + lock_params.parent_widget = lock_window_; + lock_widget_->Init(lock_params); if (screen_lock_view_) { GrabWidgetRootView* root_view = new GrabWidgetRootView(screen_lock_view_); grab_container_ = root_view; @@ -762,7 +764,9 @@ void ScreenLocker::Init() { NULL, false); gdk_window_set_back_pixmap(lock_widget_->GetNativeView()->window, NULL, false); - lock_window->set_toplevel_focus_widget(lock_widget_->window_contents()); + lock_window->set_toplevel_focus_widget( + static_cast<views::WidgetGtk*>(lock_widget_->native_widget())-> + window_contents()); // Create the SystemKeyEventListener so it can listen for system keyboard // messages regardless of focus while screen locked. diff --git a/chrome/browser/chromeos/login/screen_locker.h b/chrome/browser/chromeos/login/screen_locker.h index 9ef42d0..23d2afc 100644 --- a/chrome/browser/chromeos/login/screen_locker.h +++ b/chrome/browser/chromeos/login/screen_locker.h @@ -168,10 +168,10 @@ class ScreenLocker : public LoginStatusConsumer, CHROMEGTK_CALLBACK_1(ScreenLocker, void, OnClientEvent, GdkEventClient*); // The screen locker window. - views::WidgetGtk* lock_window_; + views::Widget* lock_window_; - // TYPE_CHILD widget to grab the keyboard/mouse input. - views::WidgetGtk* lock_widget_; + // Child widget to grab the keyboard/mouse input. + views::Widget* lock_widget_; // A view that accepts password. ScreenLockView* screen_lock_view_; diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc index ef97ebd0..208321f 100644 --- a/chrome/browser/chromeos/login/user_controller.cc +++ b/chrome/browser/chromeos/login/user_controller.cc @@ -419,10 +419,11 @@ void UserController::CreateBorderWindow(int index, height += 2 * kBorderSize + kUserImageSize + kVerticalIntervalSize; } + border_window_ = Widget::CreateWidget(); Widget::CreateParams params(Widget::CreateParams::TYPE_WINDOW); params.transparent = true; - border_window_ = Widget::CreateWidget(params); - border_window_->Init(NULL, gfx::Rect(0, 0, width, height)); + params.bounds = gfx::Rect(0, 0, width, height); + border_window_->Init(params); if (!is_new_user_) { views::View* background_view = new views::View(); views::Painter* painter = CreateWizardPainter( diff --git a/chrome/browser/chromeos/login/user_controller_gtk.cc b/chrome/browser/chromeos/login/user_controller_gtk.cc index 2b7717e..bcd5023 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() : WidgetGtk(WidgetGtk::TYPE_WINDOW) { + ControlsWidget() { } private: @@ -38,8 +38,7 @@ class ControlsWidget : public WidgetGtk { class ClickNotifyingWidget : public WidgetGtk { public: explicit ClickNotifyingWidget(UserController* controller) - : WidgetGtk(WidgetGtk::TYPE_WINDOW), - controller_(controller) { + : controller_(controller) { } private: @@ -55,9 +54,11 @@ class ClickNotifyingWidget : public WidgetGtk { DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); }; -WidgetGtk* InitWidget(WidgetGtk* widget, const gfx::Rect& bounds) { - widget->MakeTransparent(); - widget->Init(NULL, bounds); +views::Widget* InitWidget(views::Widget* widget, const gfx::Rect& bounds) { + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); + params.transparent = true; + params.bounds = bounds; + widget->Init(params); GdkWindow* gdk_window = widget->GetNativeView()->window; gdk_window_set_back_pixmap(gdk_window, NULL, false); return widget; diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 0d8c162..258908b 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -596,18 +596,19 @@ void WizardController::InitiateOOBEUpdate() { views::Widget* WizardController::CreateScreenWindow( const gfx::Rect& bounds, bool initial_show) { - views::Widget::CreateParams widget_params( - views::Widget::CreateParams::TYPE_WINDOW); - widget_params.transparent = true; - widget_ = views::Widget::CreateWidget(widget_params); + widget_ = views::Widget::CreateWidget(); // Window transparency makes background flicker through controls that // are constantly updating its contents (like image view with video // stream). Hence enabling double buffer. static_cast<views::WidgetGtk*>(widget_)->EnableDoubleBuffer(true); - widget_->Init(NULL, bounds); + views::Widget::CreateParams widget_params( + views::Widget::CreateParams::TYPE_WINDOW); + widget_params.transparent = true; + widget_params.bounds = bounds; + widget_->Init(widget_params); std::vector<int> params; // For initial show WM would animate background window. - // Otherwise it stays unchaged. + // Otherwise it stays unchanged. params.push_back(initial_show); chromeos::WmIpc::instance()->SetWindowType( widget_->GetNativeView(), diff --git a/chrome/browser/chromeos/notifications/balloon_view.cc b/chrome/browser/chromeos/notifications/balloon_view.cc index 6246e51..89317af 100644 --- a/chrome/browser/chromeos/notifications/balloon_view.cc +++ b/chrome/browser/chromeos/notifications/balloon_view.cc @@ -267,19 +267,19 @@ 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()); + static_cast<views::WidgetGtk*>(control_view_host_.get())-> + EnableDoubleBuffer(true); views::Widget::CreateParams params( views::Widget::CreateParams::TYPE_CONTROL); params.delete_on_destroy = false; - control_view_host_.reset(views::Widget::CreateWidget(params)); - static_cast<views::WidgetGtk*>(control_view_host_.get())-> - EnableDoubleBuffer(true); - control_view_host_->Init(GetParentNativeView(), gfx::Rect()); + params.parent = GetParentNativeView(); + control_view_host_->Init(params); NotificationControlView* control = new NotificationControlView(this); control_view_host_->SetContentsView(control); } - if (!is_add && this == child && control_view_host_.get() && controls_) { + if (!is_add && this == child && control_view_host_.get() && controls_) control_view_host_.release()->CloseNow(); - } } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/chromeos/notifications/notification_panel.cc b/chrome/browser/chromeos/notifications/notification_panel.cc index c6b311c..1724b56 100644 --- a/chrome/browser/chromeos/notifications/notification_panel.cc +++ b/chrome/browser/chromeos/notifications/notification_panel.cc @@ -73,8 +73,7 @@ chromeos::BalloonViewImpl* GetBalloonViewOf(const Balloon* balloon) { class ViewportWidget : public views::WidgetGtk { public: explicit ViewportWidget(chromeos::NotificationPanel* panel) - : WidgetGtk(views::WidgetGtk::TYPE_CHILD), - panel_(panel) { + : panel_(panel) { } void UpdateControl() { @@ -415,18 +414,18 @@ NotificationPanel::~NotificationPanel() { void NotificationPanel::Show() { if (!panel_widget_) { - // TODO(oshima): Using window because Popup widget behaves weird - // when resizing. This needs to be investigated. - views::WidgetGtk* widget_gtk = - new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); + panel_widget_ = views::Widget::CreateWidget(); // Enable double buffering because the panel has both pure views // control and native controls (scroll bar). - widget_gtk->EnableDoubleBuffer(true); - panel_widget_ = widget_gtk; + static_cast<views::WidgetGtk*>(panel_widget_->native_widget())-> + EnableDoubleBuffer(true); gfx::Rect bounds = GetPreferredBounds(); bounds = bounds.Union(min_bounds_); - panel_widget_->Init(NULL, bounds); + views::Widget::CreateParams params( + views::Widget::CreateParams::TYPE_WINDOW); + params.bounds = bounds; + panel_widget_->Init(params); // Set minimum bounds so that it can grow freely. gtk_widget_set_size_request(GTK_WIDGET(panel_widget_->GetNativeView()), min_bounds_.width(), min_bounds_.height()); @@ -439,7 +438,8 @@ void NotificationPanel::Show() { // Add the view port after scroll_view is attached to the panel widget. ViewportWidget* widget = new ViewportWidget(this); container_host_ = widget; - container_host_->Init(NULL, gfx::Rect()); + container_host_->Init( + views::Widget::CreateParams(views::Widget::CreateParams::TYPE_CONTROL)); container_host_->SetContentsView(balloon_container_.get()); // The window_contents_ is onwed by the WidgetGtk. Increase ref count // so that window_contents does not get deleted when detached. diff --git a/chrome/browser/chromeos/panels/panel_scroller.cc b/chrome/browser/chromeos/panels/panel_scroller.cc index 70e72e9..9572a19 100644 --- a/chrome/browser/chromeos/panels/panel_scroller.cc +++ b/chrome/browser/chromeos/panels/panel_scroller.cc @@ -80,9 +80,10 @@ PanelScroller::~PanelScroller() { // static PanelScroller* PanelScroller::CreateWindow() { - views::Widget* widget = views::Widget::CreateWidget( - views::Widget::CreateParams(views::Widget::CreateParams::TYPE_WINDOW)); - widget->Init(NULL, gfx::Rect(0, 0, 100, 800)); + views::Widget* widget = views::Widget::CreateWidget(); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); + params.bounds = gfx::Rect(0, 0, 100, 800); + widget->Init(params); PanelScroller* scroller = new PanelScroller(); widget->SetContentsView(scroller); diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 5c7ec31..6e86bb5 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -134,7 +134,10 @@ bool ExternalTabContainer::Init(Profile* profile, route_all_top_level_navigations_ = route_all_top_level_navigations; set_window_style(WS_POPUP | WS_CLIPCHILDREN); - views::WidgetWin::Init(NULL, bounds); + + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); + params.bounds = bounds; + GetWidget()->Init(params); if (!IsWindow()) { NOTREACHED(); return false; diff --git a/chrome/browser/first_run/try_chrome_dialog_view.cc b/chrome/browser/first_run/try_chrome_dialog_view.cc index d9b3d88..47c9996 100644 --- a/chrome/browser/first_run/try_chrome_dialog_view.cc +++ b/chrome/browser/first_run/try_chrome_dialog_view.cc @@ -65,16 +65,16 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal( gfx::Size icon_size = icon->GetPreferredSize(); // An approximate window size. After Layout() we'll get better bounds. - views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); - params.can_activate = true; - popup_ = views::Widget::CreateWidget(params); + popup_ = views::Widget::CreateWidget(); if (!popup_) { NOTREACHED(); return DIALOG_ERROR; } - gfx::Rect pos(310, 160); - popup_->Init(NULL, pos); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); + params.can_activate = true; + params.bounds = gfx::Rect(310, 160); + popup_->Init(params); views::RootView* root_view = popup_->GetRootView(); // The window color is a tiny bit off-white. @@ -194,8 +194,8 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal( // account the differences between XP and Vista fonts and buttons. layout->Layout(root_view); gfx::Size preferred = layout->GetPreferredSize(root_view); - pos = ComputeWindowPosition(preferred.width(), preferred.height(), - base::i18n::IsRTL()); + gfx::Rect pos = ComputeWindowPosition(preferred.width(), preferred.height(), + base::i18n::IsRTL()); popup_->SetBounds(pos); // Carve the toast shape into the window. 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 0648704..0529dad 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc @@ -332,8 +332,9 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() { views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.can_activate = false; params.transparent = true; - popup_->SetCreateParams(params); - popup_->Init(location_bar_->GetWidget()->GetNativeView(), GetPopupBounds()); + params.parent = location_bar_->GetWidget()->GetNativeView(); + params.bounds = GetPopupBounds(); + popup_->GetWidget()->Init(params); popup_->SetContentsView(this); popup_->MoveAbove(popup_->GetRelativeWindowForPopup( edit_view_->GetNativeView())); diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc index 9796e77..d0299a8 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.cc @@ -9,8 +9,7 @@ //////////////////////////////////////////////////////////////////////////////// // AutocompletePopupGtk, public: -AutocompletePopupGtk::AutocompletePopupGtk() - : WidgetGtk(WidgetGtk::TYPE_POPUP) { +AutocompletePopupGtk::AutocompletePopupGtk() { } AutocompletePopupGtk::~AutocompletePopupGtk() { diff --git a/chrome/browser/ui/views/browser_bubble_gtk.cc b/chrome/browser/ui/views/browser_bubble_gtk.cc index 8195220..fdf2654 100644 --- a/chrome/browser/ui/views/browser_bubble_gtk.cc +++ b/chrome/browser/ui/views/browser_bubble_gtk.cc @@ -23,8 +23,7 @@ namespace { class BubbleWidget : public views::WidgetGtk { public: explicit BubbleWidget(BrowserBubble* bubble) - : views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW), - bubble_(bubble), + : bubble_(bubble), border_contents_(new BorderContents) { border_contents_->Init(); } @@ -95,7 +94,9 @@ void BrowserBubble::InitPopup() { BubbleWidget* pop = new BubbleWidget(this); pop->MakeTransparent(); pop->make_transient_to_parent(); - pop->Init(frame_->GetNativeView(), gfx::Rect()); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); + params.parent = frame_->GetNativeView(); + pop->Init(params); #if defined(OS_CHROMEOS) { vector<int> params; diff --git a/chrome/browser/ui/views/browser_bubble_win.cc b/chrome/browser/ui/views/browser_bubble_win.cc index 8392bd381..16b4266 100644 --- a/chrome/browser/ui/views/browser_bubble_win.cc +++ b/chrome/browser/ui/views/browser_bubble_win.cc @@ -109,16 +109,19 @@ void BrowserBubble::InitPopup() { // 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; BorderWidgetWin* border_widget = pop->border_widget(); - border_widget->Init(new BorderContents, frame_->GetNativeView()); + border_widget->InitBorderWidgetWin(new BorderContents, + frame_->GetNativeView()); // We make the BorderWidgetWin the owner of the Bubble HWND, so that the // latter is displayed on top of the former. - pop->Init(border_widget->GetNativeView(), gfx::Rect()); - pop->SetContentsView(view_); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); + params.parent = border_widget->GetNativeView(); + popup_->Init(params); + popup_->SetContentsView(view_); - popup_ = pop; ResizeToView(); Reposition(); diff --git a/chrome/browser/ui/views/bubble/border_widget_win.cc b/chrome/browser/ui/views/bubble/border_widget_win.cc index 0c71bee..e43558d 100644 --- a/chrome/browser/ui/views/bubble/border_widget_win.cc +++ b/chrome/browser/ui/views/bubble/border_widget_win.cc @@ -10,15 +10,18 @@ BorderWidgetWin::BorderWidgetWin() : border_contents_(NULL) { - set_window_style(WS_POPUP); - set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED); } -void BorderWidgetWin::Init(BorderContents* border_contents, HWND owner) { +void BorderWidgetWin::InitBorderWidgetWin(BorderContents* border_contents, + HWND owner) { DCHECK(!border_contents_); border_contents_ = border_contents; border_contents_->Init(); - WidgetWin::Init(owner, gfx::Rect()); + + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); + params.transparent = true; + params.parent = owner; + GetWidget()->Init(params); SetContentsView(border_contents_); SetWindowPos(owner, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOREDRAW); diff --git a/chrome/browser/ui/views/bubble/border_widget_win.h b/chrome/browser/ui/views/bubble/border_widget_win.h index e087163..a6f9256 100644 --- a/chrome/browser/ui/views/bubble/border_widget_win.h +++ b/chrome/browser/ui/views/bubble/border_widget_win.h @@ -22,7 +22,7 @@ class BorderWidgetWin : public views::WidgetWin { virtual ~BorderWidgetWin() { } // Initializes the BrowserWidget making |owner| its owning window. - void Init(BorderContents* border_contents, HWND owner); + void InitBorderWidgetWin(BorderContents* border_contents, HWND owner); // Given the size of the contained contents (without margins), and the rect // (in screen coordinates) to point to, sets the border window positions and diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc index 49b8d59..29ea30a 100644 --- a/chrome/browser/ui/views/bubble/bubble.cc +++ b/chrome/browser/ui/views/bubble/bubble.cc @@ -69,7 +69,7 @@ Bubble* Bubble::ShowFocusless( views::View* contents, BubbleDelegate* delegate, bool show_while_screen_is_locked) { - Bubble* bubble = new Bubble(views::WidgetGtk::TYPE_POPUP, + Bubble* bubble = new Bubble(views::Widget::CreateParams::TYPE_POPUP, show_while_screen_is_locked); bubble->InitBubble(parent, position_relative_to, arrow_location, contents, delegate); @@ -122,7 +122,6 @@ void Bubble::AnimationProgressed(const ui::Animation* animation) { Bubble::Bubble() : #if defined(OS_LINUX) - WidgetGtk(TYPE_WINDOW), border_contents_(NULL), #elif defined(OS_WIN) border_(NULL), @@ -131,6 +130,7 @@ Bubble::Bubble() show_status_(kOpen), fade_away_on_close_(false), #if defined(OS_CHROMEOS) + type_(views::Widget::CreateParams::TYPE_WINDOW), show_while_screen_is_locked_(false), #endif arrow_location_(BubbleBorder::NONE), @@ -138,12 +138,13 @@ Bubble::Bubble() } #if defined(OS_CHROMEOS) -Bubble::Bubble(views::WidgetGtk::Type type, bool show_while_screen_is_locked) - : WidgetGtk(type), - border_contents_(NULL), +Bubble::Bubble(views::Widget::CreateParams::Type type, + bool show_while_screen_is_locked) + : border_contents_(NULL), delegate_(NULL), show_status_(kOpen), fade_away_on_close_(false), + type_(type), show_while_screen_is_locked_(show_while_screen_is_locked), arrow_location_(BubbleBorder::NONE), contents_(NULL) { @@ -185,18 +186,21 @@ void Bubble::InitBubble(views::Widget* parent, SetOpacity(0); } - border_->Init(CreateBorderContents(), parent->GetNativeView()); + border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView()); border_->border_contents()->SetBackgroundColor(kBackgroundColor); // We make the BorderWidgetWin the owner of the Bubble HWND, so that the // latter is displayed on top of the former. - WidgetWin::Init(border_->GetNativeView(), gfx::Rect()); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); + params.parent = border_->GetNativeView(); + GetWidget()->Init(params); SetWindowText(GetNativeView(), delegate_->accessible_name().c_str()); #elif defined(OS_LINUX) - MakeTransparent(); - make_transient_to_parent(); - WidgetGtk::InitWithWidget(parent, gfx::Rect()); + views::Widget::CreateParams params(type_); + params.transparent = true; + params.parent_widget = parent; + GetWidget()->Init(params); #if defined(OS_CHROMEOS) { vector<int> params; diff --git a/chrome/browser/ui/views/bubble/bubble.h b/chrome/browser/ui/views/bubble/bubble.h index 4c4f59c..3504ab9 100644 --- a/chrome/browser/ui/views/bubble/bubble.h +++ b/chrome/browser/ui/views/bubble/bubble.h @@ -135,7 +135,8 @@ class Bubble protected: Bubble(); #if defined(OS_CHROMEOS) - Bubble(views::WidgetGtk::Type type, bool show_while_screen_is_locked); + Bubble(views::Widget::CreateParams::Type type, + bool show_while_screen_is_locked); #endif virtual ~Bubble(); @@ -201,6 +202,8 @@ class Bubble bool fade_away_on_close_; #if defined(OS_CHROMEOS) + // Some callers want the bubble to be a child control instead of a window. + views::Widget::CreateParams::Type type_; // Should we set a property telling the window manager to show this window // onscreen even when the screen is locked? bool show_while_screen_is_locked_; diff --git a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc index ea48190..1b3855b 100644 --- a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc +++ b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc @@ -69,8 +69,7 @@ class ConstrainedHtmlDelegateGtk : public views::WidgetGtk, ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( Profile* profile, HtmlDialogUIDelegate* delegate) - : views::WidgetGtk(views::WidgetGtk::TYPE_CHILD), - HtmlDialogTabContentsDelegate(profile), + : HtmlDialogTabContentsDelegate(profile), html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), tab_container_(NULL), html_delegate_(delegate), @@ -85,7 +84,8 @@ ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( GURL(), PageTransition::START_PAGE); - Init(NULL, gfx::Rect()); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL); + GetWidget()->Init(params); tab_container_ = new TabContentsContainer; SetContentsView(tab_container_); diff --git a/chrome/browser/ui/views/dom_view_browsertest.cc b/chrome/browser/ui/views/dom_view_browsertest.cc index bd5dc14..2d5c3b9 100644 --- a/chrome/browser/ui/views/dom_view_browsertest.cc +++ b/chrome/browser/ui/views/dom_view_browsertest.cc @@ -14,10 +14,10 @@ using namespace views; class DOMViewTest : public InProcessBrowserTest { public: Widget* CreatePopupWindow() { + Widget* widget = Widget::CreateWidget(); Widget::CreateParams params(Widget::CreateParams::TYPE_POPUP); - params.mirror_origin_in_rtl = false; - Widget* widget = Widget::CreateWidget(params); - widget->Init(NULL, gfx::Rect(0, 0, 400, 400)); + params.bounds = gfx::Rect(0, 0, 400, 400); + widget->Init(params); return widget; } }; 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 602f8e7..e5a193b 100644 --- a/chrome/browser/ui/views/download/download_started_animation_win.cc +++ b/chrome/browser/ui/views/download/download_started_animation_win.cc @@ -101,13 +101,14 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( SetImage(kDownloadImage); - gfx::Rect rc(0, 0, 0, 0); + popup_ = views::Widget::CreateWidget(); + popup_->SetOpacity(0x00); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.transparent = true; params.accept_events = false; - popup_ = views::Widget::CreateWidget(params); - popup_->SetOpacity(0x00); - popup_->Init(tab_contents_->GetNativeView(), rc); + params.parent = tab_contents_->GetNativeView(); + popup_->Init(params); 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 a5ea1c7..d65ebda 100644 --- a/chrome/browser/ui/views/dropdown_bar_host.cc +++ b/chrome/browser/ui/views/dropdown_bar_host.cc @@ -54,8 +54,11 @@ void DropdownBarHost::Init(DropdownBarView* view) { view_ = view; // Initialize the host. - host_.reset(CreateHost()); - host_->InitWithWidget(browser_view_->GetWidget(), gfx::Rect()); + host_.reset(views::Widget::CreateWidget()); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL); + params.delete_on_destroy = false; + params.parent_widget = browser_view_->GetWidget(); + host_->Init(params); host_->SetContentsView(view_); // Start listening to focus changes, so we can register and unregister our diff --git a/chrome/browser/ui/views/dropdown_bar_host.h b/chrome/browser/ui/views/dropdown_bar_host.h index 27628c0..c53f40c 100644 --- a/chrome/browser/ui/views/dropdown_bar_host.h +++ b/chrome/browser/ui/views/dropdown_bar_host.h @@ -136,9 +136,6 @@ class DropdownBarHost : public views::AcceleratorTarget, // truncated to prevent from drawing onto Chrome's window border. void UpdateWindowEdges(const gfx::Rect& new_pos); - // Creates and returns the native Widget. - views::Widget* CreateHost(); - // Allows implementation to tweak widget position. void SetWidgetPositionNative(const gfx::Rect& new_pos, bool no_redraw); diff --git a/chrome/browser/ui/views/dropdown_bar_host_gtk.cc b/chrome/browser/ui/views/dropdown_bar_host_gtk.cc index a954f5d..32f6c99 100644 --- a/chrome/browser/ui/views/dropdown_bar_host_gtk.cc +++ b/chrome/browser/ui/views/dropdown_bar_host_gtk.cc @@ -15,13 +15,6 @@ #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" #endif -views::Widget* DropdownBarHost::CreateHost() { - views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL); - // We own the host. - params.delete_on_destroy = false; - return views::Widget::CreateWidget(params); -} - void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, bool no_redraw) { host_->SetBounds(new_pos); diff --git a/chrome/browser/ui/views/dropdown_bar_host_win.cc b/chrome/browser/ui/views/dropdown_bar_host_win.cc index 33e8a60..74190fd 100644 --- a/chrome/browser/ui/views/dropdown_bar_host_win.cc +++ b/chrome/browser/ui/views/dropdown_bar_host_win.cc @@ -22,16 +22,6 @@ NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( return NativeWebKeyboardEvent(hwnd, key_event.native_event().message, key, 0); } -views::Widget* DropdownBarHost::CreateHost() { - views::WidgetWin* widget = new views::WidgetWin(); - views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL); - // Don't let WidgetWin manage our lifetime. We want our lifetime to - // coincide with TabContents. - params.delete_on_destroy = false; - widget->SetCreateParams(params); - return widget; -} - void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, bool no_redraw) { gfx::Rect window_rect = host_->GetWindowScreenBounds(); diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index 5b0e94b..a3e93da 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -60,7 +60,7 @@ BrowserFrameWin::~BrowserFrameWin() { } void BrowserFrameWin::InitBrowserFrame() { - WindowWin::Init(NULL, gfx::Rect()); + GetWidget()->Init(views::Widget::WindowCreateParams()); } // static diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc index 3bd97a1..ebe4cb3 100644 --- a/chrome/browser/ui/views/frame/contents_container.cc +++ b/chrome/browser/ui/views/frame/contents_container.cc @@ -152,15 +152,17 @@ void ContentsContainer::Layout() { void ContentsContainer::CreateOverlay(int initial_opacity) { DCHECK(!active_overlay_); - views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); - params.transparent = true; - params.accept_events = false; - active_overlay_ = views::Widget::CreateWidget(params); + 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()); - active_overlay_->Init(active_->GetWidget()->GetNativeView(), overlay_bounds); + views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); + params.transparent = true; + params.accept_events = false; + params.parent = active_->GetWidget()->GetNativeView(); + params.bounds = overlay_bounds; + active_overlay_->Init(params); overlay_view_ = new OverlayContentView(this); overlay_view_->set_background( views::Background::CreateSolidBackground(SK_ColorWHITE)); diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble.cc b/chrome/browser/ui/views/fullscreen_exit_bubble.cc index 98bb8c5..9f79e5f 100644 --- a/chrome/browser/ui/views/fullscreen_exit_bubble.cc +++ b/chrome/browser/ui/views/fullscreen_exit_bubble.cc @@ -132,13 +132,15 @@ FullscreenExitBubble::FullscreenExitBubble( this, UTF16ToWideHack(accelerator.GetShortcutText())); // Initialize the popup. + popup_ = views::Widget::CreateWidget(); + popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity)); views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.transparent = true; params.can_activate = false; params.delete_on_destroy = false; - popup_ = views::Widget::CreateWidget(params); - popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity)); - popup_->Init(frame->GetNativeView(), GetPopupRect(false)); + params.parent = frame->GetNativeView(); + params.bounds = GetPopupRect(false); + popup_->Init(params); popup_->SetContentsView(view_); popup_->Show(); // This does not activate the popup. diff --git a/chrome/browser/ui/views/generic_info_view_unittest.cc b/chrome/browser/ui/views/generic_info_view_unittest.cc index bfefb72..a3c8f0f 100644 --- a/chrome/browser/ui/views/generic_info_view_unittest.cc +++ b/chrome/browser/ui/views/generic_info_view_unittest.cc @@ -23,11 +23,6 @@ using namespace views; class GenericInfoViewTest : public testing::Test { - public: - Widget* CreateWidget() { - return views::Widget::CreateWidget( - Widget::CreateParams(Widget::CreateParams::TYPE_POPUP)); - } private: MessageLoopForUI message_loop_; }; @@ -36,8 +31,10 @@ TEST_F(GenericInfoViewTest, GenericInfoView) { const string16 kName = ASCIIToUTF16("Name"); const string16 kValue = ASCIIToUTF16("Value"); - Widget* widget = CreateWidget(); - widget->Init(NULL, gfx::Rect(0, 0, 100, 100)); + Widget* widget = Widget::CreateWidget(); + Widget::CreateParams params(Widget::CreateParams::TYPE_POPUP); + params.bounds = gfx::Rect(0, 0, 100, 100); + widget->Init(params); RootView* root_view = widget->GetRootView(); GenericInfoView* view1 = new GenericInfoView(1); diff --git a/chrome/browser/ui/views/native_constrained_window_win.cc b/chrome/browser/ui/views/native_constrained_window_win.cc index 96facbe..dc1b7d6 100644 --- a/chrome/browser/ui/views/native_constrained_window_win.cc +++ b/chrome/browser/ui/views/native_constrained_window_win.cc @@ -19,10 +19,6 @@ class NativeConstrainedWindowWin : public NativeConstrainedWindow, views::WindowDelegate* window_delegate) : WindowWin(window_delegate), delegate_(delegate) { - views::Widget::CreateParams params( - views::Widget::CreateParams::TYPE_WINDOW); - params.child = true; - SetCreateParams(params); } virtual ~NativeConstrainedWindowWin() { @@ -31,7 +27,11 @@ class NativeConstrainedWindowWin : public NativeConstrainedWindow, private: // Overridden from NativeConstrainedWindow: virtual void InitNativeConstrainedWindow(gfx::NativeView parent) OVERRIDE { - WindowWin::Init(parent, gfx::Rect()); + views::Widget::CreateParams params( + views::Widget::CreateParams::TYPE_WINDOW); + params.child = true; + params.parent = parent; + GetWidget()->Init(params); } virtual views::NativeWindow* AsNativeWindow() OVERRIDE { return this; diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc index cdd4a5a..c1827d3 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.cc +++ b/chrome/browser/ui/views/notifications/balloon_view.cc @@ -316,19 +316,20 @@ void BalloonViewImpl::Show(Balloon* balloon) { gfx::Rect contents_rect = GetContentsRectangle(); html_contents_.reset(new BalloonViewHost(balloon)); html_contents_->SetPreferredSize(gfx::Size(10000, 10000)); - Widget::CreateParams params(Widget::CreateParams::TYPE_POPUP); - params.mirror_origin_in_rtl = false; - html_container_ = Widget::CreateWidget(params); + html_container_ = Widget::CreateWidget(); html_container_->SetAlwaysOnTop(true); - html_container_->Init(NULL, contents_rect); + Widget::CreateParams params(Widget::CreateParams::TYPE_POPUP); + params.bounds = contents_rect; + html_container_->Init(params); html_container_->SetContentsView(html_contents_->view()); gfx::Rect balloon_rect(x(), y(), GetTotalWidth(), GetTotalHeight()); - params.transparent = true; - frame_container_ = Widget::CreateWidget(params); + frame_container_ = Widget::CreateWidget(); frame_container_->set_widget_delegate(this); frame_container_->SetAlwaysOnTop(true); - frame_container_->Init(NULL, balloon_rect); + params.transparent = true; + params.bounds = balloon_rect; + frame_container_->Init(params); frame_container_->SetContentsView(this); frame_container_->MoveAboveWidget(html_container_); diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index 6251845..ec387f0 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -559,18 +559,19 @@ StatusBubbleViews::~StatusBubbleViews() { void StatusBubbleViews::Init() { if (!popup_.get()) { - Widget::CreateParams params(Widget::CreateParams::TYPE_POPUP); - params.transparent = true; - params.accept_events = false; - params.delete_on_destroy = false; - popup_.reset(Widget::CreateWidget(params)); + popup_.reset(Widget::CreateWidget()); views::Widget* frame = base_view_->GetWidget(); if (!view_) view_ = new StatusView(this, popup_.get(), frame->GetThemeProvider()); if (!expand_view_.get()) expand_view_.reset(new StatusViewExpander(this, view_)); popup_->SetOpacity(0x00); - popup_->Init(frame->GetNativeView(), gfx::Rect()); + Widget::CreateParams params(Widget::CreateParams::TYPE_POPUP); + params.transparent = true; + params.accept_events = false; + params.delete_on_destroy = false; + params.parent = frame->GetNativeView(); + popup_->Init(params); popup_->SetContentsView(view_); Reposition(); popup_->Show(); 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 84625a1..566f9d0 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,9 +30,9 @@ HWND GetHiddenTabHostWindow() { static views::Widget* widget = NULL; if (!widget) { + widget = views::Widget::CreateWidget(); views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); - widget = views::Widget::CreateWidget(params); - widget->Init(NULL, gfx::Rect()); + widget->Init(params); // If a background window requests focus, the hidden tab host will // be activated to focus the tab. Use WS_DISABLED to prevent // this. @@ -72,8 +72,8 @@ void NativeTabContentsViewWin::EndDragging() { void NativeTabContentsViewWin::InitNativeTabContentsView() { views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL); params.delete_on_destroy = false; - SetCreateParams(params); - WidgetWin::Init(GetHiddenTabHostWindow(), gfx::Rect()); + params.parent = GetHiddenTabHostWindow(); + GetWidget()->Init(params); // Remove the root view drop target so we can register our own. RevokeDragDrop(GetNativeView()); 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 index 18f815c..20eff86 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc @@ -103,7 +103,6 @@ TabContentsView* TabContentsView::Create(TabContents* tab_contents) { TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents) : TabContentsView(tab_contents), - views::WidgetGtk(TYPE_CHILD), sad_tab_(NULL), ignore_next_char_event_(false) { drag_source_.reset(new TabContentsDragSource(this)); @@ -150,9 +149,10 @@ void TabContentsViewGtk::RemoveConstrainedWindow( } void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) { - set_delete_on_destroy(false); - WidgetGtk::Init(NULL, gfx::Rect(0, 0, initial_size.width(), - initial_size.height())); + views::Widget::CreateParams params(views::Widget::CreateParams::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())); diff --git a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc index fb8e74a..629368c 100644 --- a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc @@ -203,13 +203,14 @@ 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); // TODO(sky): This should "just work" on Gtk now. views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.transparent = true; params.keep_on_top = true; - popup_ = views::Widget::CreateWidget(params); - popup_->SetOpacity(0x00); - popup_->Init(NULL, info.GetPopupRect()); + params.bounds = info.GetPopupRect(); + popup_->Init(params); popup_->SetContentsView(new DockView(info.type())); if (info.in_enable_area()) animation_.Reset(1); diff --git a/chrome/browser/ui/views/tabs/dragged_tab_view.cc b/chrome/browser/ui/views/tabs/dragged_tab_view.cc index da99f34..18ca918 100644 --- a/chrome/browser/ui/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/ui/views/tabs/dragged_tab_view.cc @@ -39,11 +39,7 @@ DraggedTabView::DraggedTabView(const std::vector<views::View*>& renderers, contents_size_(contents_size) { set_parent_owned(false); - views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); - params.transparent = true; - params.keep_on_top = true; - params.delete_on_destroy = false; - container_.reset(views::Widget::CreateWidget(params)); + container_.reset(views::Widget::CreateWidget()); #if defined(OS_WIN) static_cast<views::WidgetWin*>(container_.get())-> set_can_update_layered_window(false); @@ -54,11 +50,15 @@ DraggedTabView::DraggedTabView(const std::vector<views::View*>& renderers, show_contents_on_drag_ = false; } #endif - gfx::Size container_size(PreferredContainerSize()); - container_->Init(NULL, gfx::Rect(gfx::Point(), container_size)); + views::Widget::CreateParams params(views::Widget::CreateParams::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(), container_size)); + container_->SetBounds(gfx::Rect(gfx::Point(), params.bounds.size())); } DraggedTabView::~DraggedTabView() { 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 124d8e2..cbd90e2 100644 --- a/chrome/browser/ui/views/tabs/native_view_photobooth_win.cc +++ b/chrome/browser/ui/views/tabs/native_view_photobooth_win.cc @@ -151,12 +151,13 @@ 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(); views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.transparent = true; - capture_window_ = views::Widget::CreateWidget(params); + params.bounds = capture_bounds; + capture_window_->Init(params); // If the capture window isn't visible, blitting from the TabContents' // HWND's DC to the capture bitmap produces blankness. - capture_window_->Init(NULL, capture_bounds); capture_window_->Show(); SetLayeredWindowAttributes( capture_window_->GetNativeView(), RGB(0xFF, 0xFF, 0xFF), 0xFF, LWA_ALPHA); diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 728f3ac..83b3e69 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -860,15 +860,14 @@ 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(); views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.keep_on_top = true; params.transparent = true; params.accept_events = false; params.can_activate = false; - arrow_window = views::Widget::CreateWidget(params); - arrow_window->Init( - NULL, - gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height)); + params.bounds = gfx::Rect(drop_indicator_width, drop_indicator_height); + arrow_window->Init(params); arrow_window->SetContentsView(arrow_view); } diff --git a/chrome/browser/ui/views/theme_install_bubble_view.cc b/chrome/browser/ui/views/theme_install_bubble_view.cc index a3136aa..f04ef8b 100644 --- a/chrome/browser/ui/views/theme_install_bubble_view.cc +++ b/chrome/browser/ui/views/theme_install_bubble_view.cc @@ -70,13 +70,13 @@ ThemeInstallBubbleView::ThemeInstallBubbleView(TabContents* tab_contents) NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, NotificationService::AllSources()); - gfx::Rect rc(0, 0, 0, 0); + popup_ = views::Widget::CreateWidget(); + popup_->SetOpacity(0xCC); views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); params.transparent = true; params.accept_events = false; - popup_ = views::Widget::CreateWidget(params); - popup_->SetOpacity(0xCC); - popup_->Init(tab_contents->GetNativeView(), rc); + params.parent = tab_contents->GetNativeView(); + popup_->Init(params); popup_->SetContentsView(this); Reposition(); popup_->Show(); |