From 689dfa60ce033bbba001df3aed52fc5e747f0e1f Mon Sep 17 00:00:00 2001 From: "wittman@chromium.org" Date: Sat, 2 Mar 2013 17:58:36 +0000 Subject: [PATCH] Remove the ConstrainedWindowViews class Move the responsibility for creating the constrained-style window frame to the widget delegates, removing the last reason for the ConstrainedWindowViews class. Move the web contents modal dialog factory function outside ConstrainedWindowViews and refactor to more closely match the Widget::CreateWindowWithParent interface. We can't use Widget::CreateWindowWithParent directly yet because we appear to be depending on setting params.child = true for proper window positioning, at least on Windows, and constructing with a gfx::NativeWindow parent results in strange test failures. Once the WCMD positioning interface is in place we should be able to investigate how to eliminate this function. Remove the ConstrainedWindowViews class. BUG=157161 Review URL: https://chromiumcodereview.appspot.com/12382038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185731 0039d316-1c4b-4281-b951-d872f2087c98 --- .../ui/views/autofill/autofill_dialog_views.cc | 20 +++++- .../ui/views/autofill/autofill_dialog_views.h | 2 + chrome/browser/ui/views/collected_cookies_views.cc | 18 ++++- chrome/browser/ui/views/collected_cookies_views.h | 2 + .../views/constrained_web_dialog_delegate_views.cc | 18 ++++- .../browser/ui/views/constrained_window_views.cc | 45 ++++-------- chrome/browser/ui/views/constrained_window_views.h | 81 ++++++++-------------- .../views/constrained_window_views_browsertest.cc | 28 +++++--- .../extensions/media_galleries_dialog_views.cc | 21 +++++- .../extensions/media_galleries_dialog_views.h | 2 + chrome/browser/ui/views/login_prompt_views.cc | 19 ++++- .../ui/views/ssl_client_certificate_selector.cc | 19 ++++- .../ui/views/ssl_client_certificate_selector.h | 2 + .../ui/views/tab_modal_confirm_dialog_views.cc | 21 +++++- .../ui/views/tab_modal_confirm_dialog_views.h | 4 ++ 15 files changed, 202 insertions(+), 100 deletions(-) rewrite chrome/browser/ui/views/constrained_window_views.h (70%) diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc index 5b78f663c7ce..d926e2a3cd93 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc @@ -11,9 +11,11 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" #include "chrome/browser/ui/views/constrained_window_views.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/theme_resources.h" #include "grit/ui_resources.h" #include "third_party/skia/include/core/SkColor.h" @@ -38,6 +40,7 @@ #include "ui/views/layout/fill_layout.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/layout/layout_constants.h" +#include "ui/views/widget/widget.h" namespace autofill { @@ -518,7 +521,13 @@ void AutofillDialogViews::Show() { // Ownership of |contents_| is handed off by this call. The widget will take // care of deleting itself after calling DeleteDelegate(). - window_ = ConstrainedWindowViews::Create(controller_->web_contents(), this); + window_ = CreateWebContentsModalDialogViews( + this, + controller_->web_contents()->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents( + controller_->web_contents()); + web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView()); focus_manager_ = window_->GetFocusManager(); focus_manager_->AddFocusChangeListener(this); } @@ -706,6 +715,15 @@ bool AutofillDialogViews::Accept() { return true; } +// TODO(wittman): Remove this override once we move to the new style frame view +// on all dialogs. +views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( + views::Widget* widget) { + return CreateConstrainedStyleNonClientFrameView( + widget, + controller_->web_contents()->GetBrowserContext()); +} + void AutofillDialogViews::ButtonPressed(views::Button* sender, const ui::Event& event) { if (sender == use_billing_for_shipping_) { diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h index 292c9d091955..e491118a4113 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h @@ -95,6 +95,8 @@ class AutofillDialogViews : public AutofillDialogView, virtual views::View* CreateFootnoteView() OVERRIDE; virtual bool Cancel() OVERRIDE; virtual bool Accept() OVERRIDE; + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE; // views::ButtonListener implementation: virtual void ButtonPressed(views::Button* sender, diff --git a/chrome/browser/ui/views/collected_cookies_views.cc b/chrome/browser/ui/views/collected_cookies_views.cc index 6394204f79d6..9aed03aeed5e 100644 --- a/chrome/browser/ui/views/collected_cookies_views.cc +++ b/chrome/browser/ui/views/collected_cookies_views.cc @@ -21,11 +21,13 @@ #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "chrome/browser/ui/views/constrained_window_views.h" #include "chrome/browser/ui/views/cookie_info_view.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" @@ -191,7 +193,12 @@ CollectedCookiesViews::CollectedCookiesViews(content::WebContents* web_contents) TabSpecificContentSettings::FromWebContents(web_contents); registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, content::Source(content_settings)); - window_ = ConstrainedWindowViews::Create(web_contents, this); + window_ = CreateWebContentsModalDialogViews( + this, + web_contents->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(web_contents); + web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView()); } /////////////////////////////////////////////////////////////////////////////// @@ -223,6 +230,15 @@ bool CollectedCookiesViews::Cancel() { return true; } +// TODO(wittman): Remove this override once we move to the new style frame view +// on all dialogs. +views::NonClientFrameView* CollectedCookiesViews::CreateNonClientFrameView( + views::Widget* widget) { + return CreateConstrainedStyleNonClientFrameView( + widget, + web_contents_->GetBrowserContext()); +} + ui::ModalType CollectedCookiesViews::GetModalType() const { #if defined(USE_ASH) return ui::MODAL_TYPE_CHILD; diff --git a/chrome/browser/ui/views/collected_cookies_views.h b/chrome/browser/ui/views/collected_cookies_views.h index d12f209c891e..439100abbe7d 100644 --- a/chrome/browser/ui/views/collected_cookies_views.h +++ b/chrome/browser/ui/views/collected_cookies_views.h @@ -50,6 +50,8 @@ class CollectedCookiesViews : public views::DialogDelegateView, virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; virtual void DeleteDelegate() OVERRIDE; virtual bool Cancel() OVERRIDE; + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE; virtual ui::ModalType GetModalType() const OVERRIDE; // views::ButtonListener: diff --git a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc index c3f0dbd849a7..cdbca59171ac 100644 --- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc +++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc @@ -7,11 +7,14 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/ui/views/constrained_window_views.h" #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ui/gfx/size.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/view.h" +#include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #include "ui/web_dialogs/web_dialog_delegate.h" #include "ui/web_dialogs/web_dialog_ui.h" @@ -123,6 +126,14 @@ class ConstrainedWebDialogDelegateViewViews virtual views::View* GetContentsView() OVERRIDE { return this; } + // TODO(wittman): Remove this override once we move to the new style frame + // view on all dialogs. + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE { + return CreateConstrainedStyleNonClientFrameView( + widget, + GetWebContents()->GetBrowserContext()); + } virtual ui::ModalType GetModalType() const OVERRIDE { #if defined(USE_ASH) @@ -202,7 +213,12 @@ ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( new ConstrainedWebDialogDelegateViewViews( browser_context, delegate, tab_delegate); views::Widget* window = - ConstrainedWindowViews::Create(web_contents, constrained_delegate); + CreateWebContentsModalDialogViews( + constrained_delegate, + web_contents->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(web_contents); + web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); constrained_delegate->SetWindow(window); return constrained_delegate; } diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc index 82fa41349ae8..fac53635c9a9 100644 --- a/chrome/browser/ui/views/constrained_window_views.cc +++ b/chrome/browser/ui/views/constrained_window_views.cc @@ -568,48 +568,31 @@ class ConstrainedWindowFrameViewAsh : public ash::CustomFrameViewAsh { }; #endif // defined(USE_ASH) -ConstrainedWindowViews::ConstrainedWindowViews( - gfx::NativeView parent, - bool off_the_record, - views::WidgetDelegate* widget_delegate) - : off_the_record_(off_the_record) { - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); +views::Widget* CreateWebContentsModalDialogViews( + views::WidgetDelegate* widget_delegate, + gfx::NativeView parent) { + views::Widget* dialog = new views::Widget; + + views::Widget::InitParams params; params.delegate = widget_delegate; params.child = true; - params.parent = parent; -#if defined(USE_ASH) - // Ash window headers can be transparent. - params.transparent = true; -#endif - - Init(params); -} - -ConstrainedWindowViews::~ConstrainedWindowViews() { -} + dialog->Init(params); -views::Widget* ConstrainedWindowViews::Create( - content::WebContents* web_contents, - views::WidgetDelegate* widget_delegate) { - WebContentsModalDialogManager* manager = - WebContentsModalDialogManager::FromWebContents(web_contents); - views::Widget* dialog = new ConstrainedWindowViews( - web_contents->GetView()->GetNativeView(), - web_contents->GetBrowserContext()->IsOffTheRecord(), - widget_delegate); - manager->ShowDialog(dialog->GetNativeView()); return dialog; } -views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() { +views::NonClientFrameView* CreateConstrainedStyleNonClientFrameView( + views::Widget* widget, + content::BrowserContext* browser_context) { if (views::DialogDelegate::UseNewStyle()) - return views::DialogDelegate::CreateNewStyleFrameView(this); + return views::DialogDelegate::CreateNewStyleFrameView(widget); #if defined(USE_ASH) ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; - frame->Init(this); + frame->Init(widget); return frame; #endif - return new ConstrainedWindowFrameView(this, off_the_record_); + return new ConstrainedWindowFrameView(widget, + browser_context->IsOffTheRecord()); } diff --git a/chrome/browser/ui/views/constrained_window_views.h b/chrome/browser/ui/views/constrained_window_views.h dissimilarity index 70% index e687857f6ac1..c95290f05252 100644 --- a/chrome/browser/ui/views/constrained_window_views.h +++ b/chrome/browser/ui/views/constrained_window_views.h @@ -1,53 +1,28 @@ -// Copyright (c) 2012 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_CONSTRAINED_WINDOW_VIEWS_H_ -#define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ - -#include "base/compiler_specific.h" -#include "chrome/browser/ui/native_web_contents_modal_dialog.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/rect.h" -#include "ui/views/widget/widget.h" - -namespace content { -class WebContents; -} -namespace views { -namespace internal { -class NativeWidgetDelegate; -} -class NativeWidget; -class NonClientFrameView; -class WidgetDelegate; -} - -/////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowViews -// -// A web contents modal dialog that implements the dialog as a child HWND with -// a custom window frame. The ConstrainedWindowViews owns itself and will be -// deleted soon after being closed. -// -class ConstrainedWindowViews : public views::Widget { - public: - ConstrainedWindowViews(gfx::NativeView parent, - bool off_the_record, - views::WidgetDelegate* widget_delegate); - virtual ~ConstrainedWindowViews(); - - // Factory function for the class (temporary). - static views::Widget* Create(content::WebContents* web_contents, - views::WidgetDelegate* widget_delegate); - - private: - // Overridden from views::Widget: - virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; - - bool off_the_record_; - - DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowViews); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ +// Copyright (c) 2012 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_CONSTRAINED_WINDOW_VIEWS_H_ +#define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ + +#include "ui/gfx/native_widget_types.h" + +namespace content { +class WebContents; +class BrowserContext; +} +namespace views { +class NonClientFrameView; +class WidgetDelegate; +class Widget; +} + +views::Widget* CreateWebContentsModalDialogViews( + views::WidgetDelegate* widget_delegate, + gfx::NativeView parent); + +views::NonClientFrameView* CreateConstrainedStyleNonClientFrameView( + views::Widget* widget, + content::BrowserContext* browser_context); + +#endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_VIEWS_H_ diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc index 9d5541f809c5..a50ec56da999 100644 --- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc +++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc @@ -17,6 +17,8 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "ipc/ipc_message.h" #include "ui/base/accelerators/accelerator.h" #include "ui/views/controls/textfield/textfield.h" @@ -137,8 +139,10 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) { // Create a constrained dialog. It will attach itself to web_contents. scoped_ptr test_dialog1(new TestConstrainedDialog); - views::Widget* window1 = ConstrainedWindowViews::Create( - web_contents, test_dialog1.get()); + views::Widget* window1 = CreateWebContentsModalDialogViews( + test_dialog1.get(), + web_contents->GetView()->GetNativeView()); + web_contents_modal_dialog_manager->ShowDialog(window1->GetNativeView()); views::FocusManager* focus_manager = window1->GetFocusManager(); ASSERT_TRUE(focus_manager); @@ -151,8 +155,10 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) { // web_contents, but will remain hidden since the test_dialog1 is still // showing. scoped_ptr test_dialog2(new TestConstrainedDialog); - views::Widget* window2 = ConstrainedWindowViews::Create( - web_contents, test_dialog2.get()); + views::Widget* window2 = CreateWebContentsModalDialogViews( + test_dialog2.get(), + web_contents->GetView()->GetNativeView()); + web_contents_modal_dialog_manager->ShowDialog(window2->GetNativeView()); // Should be the same focus_manager. ASSERT_EQ(focus_manager, window2->GetFocusManager()); @@ -212,8 +218,10 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) { // Create a constrained dialog. It will attach itself to web_contents. scoped_ptr test_dialog(new TestConstrainedDialog); - ConstrainedWindowViews::Create( - web_contents, test_dialog.get()); + views::Widget* window = CreateWebContentsModalDialogViews( + test_dialog.get(), + web_contents->GetView()->GetNativeView()); + web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); bool closed = browser()->tab_strip_model()->CloseWebContentsAt( @@ -233,8 +241,12 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabSwitchTest) { // Create a constrained dialog. It will attach itself to web_contents. scoped_ptr test_dialog(new TestConstrainedDialog); - views::Widget* window = ConstrainedWindowViews::Create( - web_contents, test_dialog.get()); + views::Widget* window = CreateWebContentsModalDialogViews( + test_dialog.get(), + web_contents->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(web_contents); + web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); EXPECT_TRUE(window->IsVisible()); // Open a new tab. The constrained window should hide itself. diff --git a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc index c5fce121ce25..00d27a1661c8 100644 --- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc +++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc @@ -5,6 +5,9 @@ #include "chrome/browser/ui/views/extensions/media_galleries_dialog_views.h" #include "chrome/browser/ui/views/constrained_window_views.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_util.h" @@ -16,6 +19,7 @@ #include "ui/views/layout/grid_layout.h" #include "ui/views/layout/layout_constants.h" #include "ui/views/view.h" +#include "ui/views/widget/widget.h" #include "ui/views/window/dialog_client_view.h" @@ -37,7 +41,13 @@ MediaGalleriesDialogViews::MediaGalleriesDialogViews( // Ownership of |contents_| is handed off by this call. |window_| will take // care of deleting itself after calling DeleteDelegate(). - window_ = ConstrainedWindowViews::Create(controller->web_contents(), this); + window_ = CreateWebContentsModalDialogViews( + this, + controller->web_contents()->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents( + controller->web_contents()); + web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView()); } MediaGalleriesDialogViews::~MediaGalleriesDialogViews() {} @@ -203,6 +213,15 @@ bool MediaGalleriesDialogViews::Accept() { return true; } +// TODO(wittman): Remove this override once we move to the new style frame view +// on all dialogs. +views::NonClientFrameView* MediaGalleriesDialogViews::CreateNonClientFrameView( + views::Widget* widget) { + return CreateConstrainedStyleNonClientFrameView( + widget, + controller_->web_contents()->GetBrowserContext()); +} + void MediaGalleriesDialogViews::ButtonPressed(views::Button* sender, const ui::Event& event) { confirm_available_ = true; diff --git a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.h b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.h index 9a3d211f786e..cf68da69b460 100644 --- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.h +++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.h @@ -48,6 +48,8 @@ class MediaGalleriesDialogViews : public MediaGalleriesDialog, virtual views::View* CreateExtraView() OVERRIDE; virtual bool Cancel() OVERRIDE; virtual bool Accept() OVERRIDE; + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE; // views::ButtonListener implementation: virtual void ButtonPressed(views::Button* sender, diff --git a/chrome/browser/ui/views/login_prompt_views.cc b/chrome/browser/ui/views/login_prompt_views.cc index b0c0152e8eda..2365d3d11d76 100644 --- a/chrome/browser/ui/views/login_prompt_views.cc +++ b/chrome/browser/ui/views/login_prompt_views.cc @@ -10,13 +10,16 @@ #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/views/constrained_window_views.h" #include "chrome/browser/ui/views/login_view.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "net/url_request/url_request.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/views/widget/widget.h" #include "ui/views/window/dialog_delegate.h" using content::BrowserThread; @@ -102,6 +105,15 @@ class LoginHandlerViews : public LoginHandler, return true; } + // TODO(wittman): Remove this override once we move to the new style frame + // view on all dialogs. + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE { + return CreateConstrainedStyleNonClientFrameView( + widget, + GetWebContentsForLogin()->GetBrowserContext()); + } + virtual views::View* GetInitiallyFocusedView() OVERRIDE { return login_view_->GetInitiallyFocusedView(); } @@ -136,7 +148,12 @@ class LoginHandlerViews : public LoginHandler, // will occur via an InvokeLater on the UI thread, which is guaranteed // to happen after this is called (since this was InvokeLater'd first). WebContents* requesting_contents = GetWebContentsForLogin(); - dialog_ = ConstrainedWindowViews::Create(requesting_contents, this); + dialog_ = CreateWebContentsModalDialogViews( + this, + requesting_contents->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(requesting_contents); + web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); NotifyAuthNeeded(); } diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.cc b/chrome/browser/ui/views/ssl_client_certificate_selector.cc index 009dca9774b3..3dda77ca2c83 100644 --- a/chrome/browser/ui/views/ssl_client_certificate_selector.cc +++ b/chrome/browser/ui/views/ssl_client_certificate_selector.cc @@ -10,6 +10,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/certificate_viewer.h" #include "chrome/browser/ui/views/constrained_window_views.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" @@ -25,6 +26,7 @@ #include "ui/views/controls/table/table_view.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/layout/layout_constants.h" +#include "ui/views/widget/widget.h" #include "ui/views/window/dialog_client_view.h" using content::BrowserThread; @@ -138,7 +140,12 @@ void SSLClientCertificateSelector::Init() { StartObserving(); - window_ = ConstrainedWindowViews::Create(web_contents_, this); + window_ = CreateWebContentsModalDialogViews( + this, + web_contents_->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(web_contents_); + web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView()); // Select the first row automatically. This must be done after the dialog has // been created. @@ -206,6 +213,16 @@ bool SSLClientCertificateSelector::Accept() { return false; } +// TODO(wittman): Remove this override once we move to the new style frame view +// on all dialogs. +views::NonClientFrameView* + SSLClientCertificateSelector::CreateNonClientFrameView( + views::Widget* widget) { + return CreateConstrainedStyleNonClientFrameView( + widget, + web_contents_->GetBrowserContext()); +} + views::View* SSLClientCertificateSelector::GetInitiallyFocusedView() { return table_; } diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.h b/chrome/browser/ui/views/ssl_client_certificate_selector.h index f38f443bb15b..e4033d7d0530 100644 --- a/chrome/browser/ui/views/ssl_client_certificate_selector.h +++ b/chrome/browser/ui/views/ssl_client_certificate_selector.h @@ -61,6 +61,8 @@ class SSLClientCertificateSelector : public SSLClientAuthObserver, virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; virtual bool Cancel() OVERRIDE; virtual bool Accept() OVERRIDE; + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE; virtual views::View* GetInitiallyFocusedView() OVERRIDE; virtual views::View* CreateExtraView() OVERRIDE; virtual ui::ModalType GetModalType() const OVERRIDE; diff --git a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc index 7feea81b6754..3ea5b5bb05ad 100644 --- a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc +++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc @@ -10,10 +10,14 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" #include "chrome/browser/ui/views/constrained_window_views.h" +#include "chrome/browser/ui/web_contents_modal_dialog_manager.h" #include "chrome/common/chrome_switches.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/views/controls/message_box_view.h" +#include "ui/views/widget/widget.h" #include "ui/views/window/dialog_client_view.h" // static @@ -33,8 +37,14 @@ TabModalConfirmDialogViews::TabModalConfirmDialogViews( : delegate_(delegate), message_box_view_(new views::MessageBoxView( views::MessageBoxView::InitParams(delegate->GetMessage()))), - dialog_(NULL) { - dialog_ = ConstrainedWindowViews::Create(web_contents, this); + dialog_(NULL), + browser_context_(web_contents->GetBrowserContext()) { + dialog_ = CreateWebContentsModalDialogViews( + this, + web_contents->GetView()->GetNativeView()); + WebContentsModalDialogManager* web_contents_modal_dialog_manager = + WebContentsModalDialogManager::FromWebContents(web_contents); + web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); delegate_->set_close_delegate(this); } @@ -86,6 +96,13 @@ views::View* TabModalConfirmDialogViews::GetContentsView() { return message_box_view_; } +// TODO(wittman): Remove this override once we move to the new style frame view +// on all dialogs. +views::NonClientFrameView* TabModalConfirmDialogViews::CreateNonClientFrameView( + views::Widget* widget) { + return CreateConstrainedStyleNonClientFrameView(widget, browser_context_); +} + views::Widget* TabModalConfirmDialogViews::GetWidget() { return message_box_view_->GetWidget(); } diff --git a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h index b78619439dc8..a67c5cef9944 100644 --- a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h +++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h @@ -13,6 +13,7 @@ namespace content { class WebContents; +class BrowserContext; } namespace views { @@ -39,6 +40,8 @@ class TabModalConfirmDialogViews : public TabModalConfirmDialog, // views::WidgetDelegate: virtual views::View* GetContentsView() OVERRIDE; + virtual views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) OVERRIDE; virtual views::Widget* GetWidget() OVERRIDE; virtual const views::Widget* GetWidget() const OVERRIDE; virtual void DeleteDelegate() OVERRIDE; @@ -60,6 +63,7 @@ class TabModalConfirmDialogViews : public TabModalConfirmDialog, views::MessageBoxView* message_box_view_; views::Widget* dialog_; + content::BrowserContext* browser_context_; DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogViews); }; -- 2.11.4.GIT