summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-28 10:52:48 +0000
committerwittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-28 10:52:48 +0000
commit295a6d6b5b54a8c3007b415dd82d3bd5b2f5c7de (patch)
tree469f23ce9943b8833d3023641b83542ee79cb7c1
parent8fa1a2e9e17f2813b3d1bff2dae70948f3a85a5d (diff)
downloadchromium_src-295a6d6b5b54a8c3007b415dd82d3bd5b2f5c7de.zip
chromium_src-295a6d6b5b54a8c3007b415dd82d3bd5b2f5c7de.tar.gz
chromium_src-295a6d6b5b54a8c3007b415dd82d3bd5b2f5c7de.tar.bz2
Remove uses of ConstrainedWindowViews within Views dialogs
This change moves towards the elimination of the ConstrainedWindowViews type by replacing ConstrainedWindowViews-specific functions with their Widget-based equivalents, removing the ConstrainedWindowViews-specific functions, and updating web contents modal dialog users to reference the window via the views::Widget type. Still remaining to be done for Views is the removal of the ConstrainedWindowViews::Create factory function. Patch set 1 is the removal of the ConstrainedWindowViews-specific functions BUG=157161 Review URL: https://chromiumcodereview.appspot.com/12389003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185216 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.cc7
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.h5
-rw-r--r--chrome/browser/ui/views/collected_cookies_views.cc2
-rw-r--r--chrome/browser/ui/views/collected_cookies_views.h4
-rw-r--r--chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc18
-rw-r--r--chrome/browser/ui/views/constrained_window_views.cc44
-rw-r--r--chrome/browser/ui/views/constrained_window_views.h11
-rw-r--r--chrome/browser/ui/views/constrained_window_views_browsertest.cc14
-rw-r--r--chrome/browser/ui/views/extensions/media_galleries_dialog_views.h7
-rw-r--r--chrome/browser/ui/views/login_prompt_views.cc8
-rw-r--r--chrome/browser/ui/views/ssl_client_certificate_selector.cc4
-rw-r--r--chrome/browser/ui/views/ssl_client_certificate_selector.h4
-rw-r--r--chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc2
-rw-r--r--chrome/browser/ui/views/tab_modal_confirm_dialog_views.h5
-rw-r--r--chrome/browser/ui/views/web_contents_modal_dialog_manager_views.cc35
15 files changed, 67 insertions, 103 deletions
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index 7514da8..9c4a06f 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -442,9 +442,8 @@ void AutofillDialogViews::Show() {
UpdateAccountChooser();
UpdateNotificationArea();
- // Ownership of |contents_| is handed off by this call. The
- // ConstrainedWindowViews will take care of deleting itself after calling
- // DeleteDelegate().
+ // 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);
focus_manager_ = window_->GetFocusManager();
focus_manager_->AddFocusChangeListener(this);
@@ -452,7 +451,7 @@ void AutofillDialogViews::Show() {
void AutofillDialogViews::Hide() {
if (window_)
- window_->CloseWebContentsModalDialog();
+ window_->Close();
}
void AutofillDialogViews::UpdateAccountChooser() {
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h
index 3d57426..bca7df9 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h
@@ -17,8 +17,6 @@
#include "ui/views/focus/focus_manager.h"
#include "ui/views/window/dialog_delegate.h"
-class ConstrainedWindowViews;
-
namespace content {
class KeyboardListener;
}
@@ -39,6 +37,7 @@ class MenuRunner;
class TextButton;
class Textfield;
class WebView;
+class Widget;
}
namespace ui {
@@ -345,7 +344,7 @@ class AutofillDialogViews : public AutofillDialogView,
// The window that displays |contents_|. Weak pointer; may be NULL when the
// dialog is closing.
- ConstrainedWindowViews* window_;
+ views::Widget* window_;
// The top-level View for the dialog. Owned by the constrained window.
views::View* contents_;
diff --git a/chrome/browser/ui/views/collected_cookies_views.cc b/chrome/browser/ui/views/collected_cookies_views.cc
index f5eb858..5f2bafb 100644
--- a/chrome/browser/ui/views/collected_cookies_views.cc
+++ b/chrome/browser/ui/views/collected_cookies_views.cc
@@ -510,5 +510,5 @@ void CollectedCookiesViews::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
- window_->CloseWebContentsModalDialog();
+ window_->Close();
}
diff --git a/chrome/browser/ui/views/collected_cookies_views.h b/chrome/browser/ui/views/collected_cookies_views.h
index ea21fa5..285d978 100644
--- a/chrome/browser/ui/views/collected_cookies_views.h
+++ b/chrome/browser/ui/views/collected_cookies_views.h
@@ -14,7 +14,6 @@
#include "ui/views/controls/tree/tree_view_controller.h"
#include "ui/views/window/dialog_delegate.h"
-class ConstrainedWindowViews;
class CookieInfoView;
class CookiesTreeModel;
class InfobarView;
@@ -27,6 +26,7 @@ namespace views {
class Label;
class TextButton;
class TreeView;
+class Widget;
}
// This is the Views implementation of the collected cookies dialog.
@@ -89,7 +89,7 @@ class CollectedCookiesViews : public views::DialogDelegateView,
content::NotificationRegistrar registrar_;
- ConstrainedWindowViews* window_;
+ views::Widget* window_;
// The web contents.
content::WebContents* web_contents_;
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 5eeb9b5..c3f0dbd 100644
--- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
+++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
@@ -38,7 +38,7 @@ class ConstrainedWebDialogDelegateViews
// WebDialogWebContentsDelegate interface.
virtual void CloseContents(WebContents* source) OVERRIDE {
- window_->CloseWebContentsModalDialog();
+ window_->Close();
}
// contents::WebContentsDelegate
@@ -54,15 +54,15 @@ class ConstrainedWebDialogDelegateViews
return window_->GetNativeView();
}
- void set_window(ConstrainedWindowViews* window) { window_ = window; }
- ConstrainedWindowViews* window() const { return window_; }
+ void set_window(views::Widget* window) { window_ = window; }
+ views::Widget* window() const { return window_; }
private:
// Converts keyboard events on the WebContents to accelerators.
UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
views::WebView* view_;
- ConstrainedWindowViews* window_;
+ views::Widget* window_;
DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViews);
};
@@ -95,7 +95,7 @@ class ConstrainedWebDialogDelegateViewViews
return impl_->ReleaseWebContentsOnDialogClose();
}
virtual NativeWebContentsModalDialog GetNativeDialog() OVERRIDE {
- return impl_->window()->GetNativeDialog();
+ return impl_->window()->GetNativeView();
}
virtual WebContents* GetWebContents() OVERRIDE {
return impl_->GetWebContents();
@@ -148,7 +148,7 @@ class ConstrainedWebDialogDelegateViewViews
const ui::Accelerator& accelerator) OVERRIDE {
// Pressing ESC closes the dialog.
DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
- impl_->window()->CloseWebContentsModalDialog();
+ impl_->window()->Close();
return true;
}
virtual gfx::Size GetPreferredSize() OVERRIDE {
@@ -162,11 +162,11 @@ class ConstrainedWebDialogDelegateViewViews
return gfx::Size();
}
- void SetWindow(ConstrainedWindowViews* window) {
+ void SetWindow(views::Widget* window) {
impl_->set_window(window);
}
- ConstrainedWindowViews* GetWindow() {
+ views::Widget* GetWindow() {
return impl_->window();
}
@@ -201,7 +201,7 @@ ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
ConstrainedWebDialogDelegateViewViews* constrained_delegate =
new ConstrainedWebDialogDelegateViewViews(
browser_context, delegate, tab_delegate);
- ConstrainedWindowViews* window =
+ views::Widget* window =
ConstrainedWindowViews::Create(web_contents, constrained_delegate);
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 8b0c79b..82fa413 100644
--- a/chrome/browser/ui/views/constrained_window_views.cc
+++ b/chrome/browser/ui/views/constrained_window_views.cc
@@ -171,7 +171,7 @@ gfx::ImageSkia* VistaWindowResources::images_[];
class ConstrainedWindowFrameView : public views::NonClientFrameView,
public views::ButtonListener {
public:
- ConstrainedWindowFrameView(ConstrainedWindowViews* container,
+ ConstrainedWindowFrameView(views::Widget* container,
bool browser_is_off_the_record);
virtual ~ConstrainedWindowFrameView();
@@ -238,7 +238,7 @@ class ConstrainedWindowFrameView : public views::NonClientFrameView,
// Loads the appropriate set of WindowResources for the frame view.
void InitWindowResources();
- ConstrainedWindowViews* container_;
+ views::Widget* container_;
bool browser_is_off_the_record_;
@@ -291,7 +291,7 @@ const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0);
} // namespace
ConstrainedWindowFrameView::ConstrainedWindowFrameView(
- ConstrainedWindowViews* container, bool browser_is_off_the_record)
+ views::Widget* container, bool browser_is_off_the_record)
: NonClientFrameView(),
container_(container),
browser_is_off_the_record_(browser_is_off_the_record),
@@ -390,7 +390,7 @@ void ConstrainedWindowFrameView::OnThemeChanged() {
void ConstrainedWindowFrameView::ButtonPressed(
views::Button* sender, const ui::Event& event) {
if (sender == close_button_)
- container_->CloseWebContentsModalDialog();
+ container_->Close();
}
int ConstrainedWindowFrameView::NonClientBorderThickness() const {
@@ -548,7 +548,7 @@ class ConstrainedWindowFrameViewAsh : public ash::CustomFrameViewAsh {
container_(NULL) {
}
- void Init(ConstrainedWindowViews* container) {
+ void Init(views::Widget* container) {
container_ = container;
ash::CustomFrameViewAsh::Init(container);
// Always use "active" look.
@@ -559,11 +559,11 @@ class ConstrainedWindowFrameViewAsh : public ash::CustomFrameViewAsh {
virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE {
if (sender == close_button())
- container_->CloseWebContentsModalDialog();
+ container_->Close();
}
private:
- ConstrainedWindowViews* container_; // not owned
+ views::Widget* container_; // not owned
DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh);
};
#endif // defined(USE_ASH)
@@ -590,38 +590,12 @@ ConstrainedWindowViews::ConstrainedWindowViews(
ConstrainedWindowViews::~ConstrainedWindowViews() {
}
-void ConstrainedWindowViews::ShowWebContentsModalDialog() {
- Show();
- FocusWebContentsModalDialog();
-}
-
-void ConstrainedWindowViews::CloseWebContentsModalDialog() {
- Close();
-}
-
-void ConstrainedWindowViews::FocusWebContentsModalDialog() {
- if (widget_delegate() && widget_delegate()->GetInitiallyFocusedView())
- widget_delegate()->GetInitiallyFocusedView()->RequestFocus();
-#if defined(USE_ASH)
- // We don't necessarily have a RootWindow yet.
- if (GetNativeView()->GetRootWindow())
- GetNativeView()->Focus();
-#endif
-}
-
-void ConstrainedWindowViews::PulseWebContentsModalDialog() {
-}
-
-NativeWebContentsModalDialog ConstrainedWindowViews::GetNativeDialog() {
- return GetNativeView();
-}
-
-ConstrainedWindowViews* ConstrainedWindowViews::Create(
+views::Widget* ConstrainedWindowViews::Create(
content::WebContents* web_contents,
views::WidgetDelegate* widget_delegate) {
WebContentsModalDialogManager* manager =
WebContentsModalDialogManager::FromWebContents(web_contents);
- ConstrainedWindowViews* dialog = new ConstrainedWindowViews(
+ views::Widget* dialog = new ConstrainedWindowViews(
web_contents->GetView()->GetNativeView(),
web_contents->GetBrowserContext()->IsOffTheRecord(),
widget_delegate);
diff --git a/chrome/browser/ui/views/constrained_window_views.h b/chrome/browser/ui/views/constrained_window_views.h
index 8041849..e687857 100644
--- a/chrome/browser/ui/views/constrained_window_views.h
+++ b/chrome/browser/ui/views/constrained_window_views.h
@@ -37,16 +37,9 @@ class ConstrainedWindowViews : public views::Widget {
views::WidgetDelegate* widget_delegate);
virtual ~ConstrainedWindowViews();
- // TODO(wittman): Remove in favor of native equivalents.
- void ShowWebContentsModalDialog();
- void CloseWebContentsModalDialog();
- void FocusWebContentsModalDialog();
- void PulseWebContentsModalDialog();
- NativeWebContentsModalDialog GetNativeDialog();
-
// Factory function for the class (temporary).
- static ConstrainedWindowViews* Create(content::WebContents* web_contents,
- views::WidgetDelegate* widget_delegate);
+ static views::Widget* Create(content::WebContents* web_contents,
+ views::WidgetDelegate* widget_delegate);
private:
// Overridden from views::Widget:
diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc
index 5af7531..9d5541f 100644
--- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc
+++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc
@@ -137,7 +137,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) {
// Create a constrained dialog. It will attach itself to web_contents.
scoped_ptr<TestConstrainedDialog> test_dialog1(new TestConstrainedDialog);
- ConstrainedWindowViews* window1 = ConstrainedWindowViews::Create(
+ views::Widget* window1 = ConstrainedWindowViews::Create(
web_contents, test_dialog1.get());
views::FocusManager* focus_manager = window1->GetFocusManager();
@@ -151,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) {
// web_contents, but will remain hidden since the test_dialog1 is still
// showing.
scoped_ptr<TestConstrainedDialog> test_dialog2(new TestConstrainedDialog);
- ConstrainedWindowViews* window2 = ConstrainedWindowViews::Create(
+ views::Widget* window2 = ConstrainedWindowViews::Create(
web_contents, test_dialog2.get());
// Should be the same focus_manager.
ASSERT_EQ(focus_manager, window2->GetFocusManager());
@@ -233,7 +233,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabSwitchTest) {
// Create a constrained dialog. It will attach itself to web_contents.
scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog);
- ConstrainedWindowViews* window = ConstrainedWindowViews::Create(
+ views::Widget* window = ConstrainedWindowViews::Create(
web_contents, test_dialog.get());
EXPECT_TRUE(window->IsVisible());
@@ -343,11 +343,9 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest,
NULL,
web_contents);
- ConstrainedWindowViews* cwv =
- static_cast<ConstrainedWindowViews*>(
- views::Widget::GetWidgetForNativeView(cwdd->GetNativeDialog()));
- views::test::TestWidgetObserver observer(cwv);
- cwv->FocusWebContentsModalDialog();
+ views::Widget* widget =
+ views::Widget::GetWidgetForNativeView(cwdd->GetNativeDialog());
+ views::test::TestWidgetObserver observer(widget);
content::RenderViewHost* render_view_host =
cwdd->GetWebContents()->GetRenderViewHost();
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 8429f54..5149996 100644
--- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.h
+++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.h
@@ -12,11 +12,10 @@
#include "ui/views/controls/button/button.h"
#include "ui/views/window/dialog_delegate.h"
-class ConstrainedWindowViews;
-
namespace views {
class Checkbox;
class TextButton;
+class Widget;
}
namespace chrome {
@@ -65,8 +64,8 @@ class MediaGalleriesDialogViews : public MediaGalleriesDialog,
MediaGalleriesDialogController* controller_;
- // The constrained window (a weak pointer).
- ConstrainedWindowViews* window_;
+ // The containing window (a weak pointer).
+ views::Widget* window_;
// The contents of the dialog. Owned by |window_|'s RootView.
views::View* contents_;
diff --git a/chrome/browser/ui/views/login_prompt_views.cc b/chrome/browser/ui/views/login_prompt_views.cc
index 3488cbb..b0c0152 100644
--- a/chrome/browser/ui/views/login_prompt_views.cc
+++ b/chrome/browser/ui/views/login_prompt_views.cc
@@ -73,7 +73,7 @@ class LoginHandlerViews : public LoginHandler,
virtual void DeleteDelegate() OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // The constrained window is going to delete itself; clear our pointer.
+ // The widget is going to delete itself; clear our pointer.
dialog_ = NULL;
SetModel(NULL);
@@ -141,9 +141,9 @@ class LoginHandlerViews : public LoginHandler,
}
virtual void CloseDialog() OVERRIDE {
- // The hosting ConstrainedWindowViews may have been freed.
+ // The hosting widget may have been freed.
if (dialog_)
- dialog_->CloseWebContentsModalDialog();
+ dialog_->Close();
}
private:
@@ -155,7 +155,7 @@ class LoginHandlerViews : public LoginHandler,
// The LoginView that contains the user's login information
LoginView* login_view_;
- ConstrainedWindowViews* dialog_;
+ views::Widget* dialog_;
DISALLOW_COPY_AND_ASSIGN(LoginHandlerViews);
};
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.cc b/chrome/browser/ui/views/ssl_client_certificate_selector.cc
index 8bf49b0..cf58804 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector.cc
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector.cc
@@ -160,7 +160,7 @@ net::X509Certificate* SSLClientCertificateSelector::GetSelectedCert() const {
void SSLClientCertificateSelector::OnCertSelectedByNotification() {
DVLOG(1) << __FUNCTION__;
DCHECK(window_);
- window_->CloseWebContentsModalDialog();
+ window_->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -247,7 +247,7 @@ void SSLClientCertificateSelector::OnSelectionChanged() {
void SSLClientCertificateSelector::OnDoubleClick() {
if (Accept())
- window_->CloseWebContentsModalDialog();
+ window_->Close();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.h b/chrome/browser/ui/views/ssl_client_certificate_selector.h
index 3cd00d7..fea735f 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector.h
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector.h
@@ -30,10 +30,10 @@ class X509Certificate;
namespace views {
class TableView;
class TextButton;
+class Widget;
}
class CertificateSelectorTableModel;
-class ConstrainedWindowViews;
class SSLClientCertificateSelector : public SSLClientAuthObserver,
public views::DialogDelegateView,
@@ -80,7 +80,7 @@ class SSLClientCertificateSelector : public SSLClientAuthObserver,
content::WebContents* web_contents_;
- ConstrainedWindowViews* window_;
+ views::Widget* window_;
views::TableView* table_;
views::TextButton* view_cert_button_;
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 dd62b1d..7feea81 100644
--- a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
+++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
@@ -50,7 +50,7 @@ void TabModalConfirmDialogViews::CancelTabModalDialog() {
}
void TabModalConfirmDialogViews::CloseDialog() {
- dialog_->CloseWebContentsModalDialog();
+ dialog_->Close();
}
//////////////////////////////////////////////////////////////////////////////
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 0fd23d1..b786194 100644
--- a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h
+++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h
@@ -11,14 +11,13 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/views/window/dialog_delegate.h"
-class ConstrainedWindowViews;
-
namespace content {
class WebContents;
}
namespace views {
class MessageBoxView;
+class Widget;
}
// Displays a tab-modal dialog, i.e. a dialog that will block the current page
@@ -60,7 +59,7 @@ class TabModalConfirmDialogViews : public TabModalConfirmDialog,
// The message box view whose commands we handle.
views::MessageBoxView* message_box_view_;
- ConstrainedWindowViews* dialog_;
+ views::Widget* dialog_;
DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogViews);
};
diff --git a/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.cc b/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.cc
index 0591d31..e2938a9 100644
--- a/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.cc
+++ b/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/ui/views/constrained_window_views.h"
#include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_observer.h"
#if defined(USE_AURA)
@@ -75,30 +76,37 @@ class NativeWebContentsModalDialogManagerViews
}
virtual void ShowDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
- return GetConstrainedWindowViews(dialog)->ShowWebContentsModalDialog();
+ GetWidget(dialog)->Show();
+ FocusDialog(dialog);
}
virtual void CloseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
- views::Widget* widget = GetWidget(dialog);
-#if defined(USE_ASH)
- gfx::NativeView view = platform_util::GetParent(widget->GetNativeView());
- // Allow the parent to animate again.
- if (view && view->parent())
- view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey);
-#endif
- widget->Close();
+ GetWidget(dialog)->Close();
}
virtual void FocusDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
- return GetConstrainedWindowViews(dialog)->FocusWebContentsModalDialog();
+ views::Widget* widget = GetWidget(dialog);
+ if (widget->widget_delegate() &&
+ widget->widget_delegate()->GetInitiallyFocusedView())
+ widget->widget_delegate()->GetInitiallyFocusedView()->RequestFocus();
+#if defined(USE_ASH)
+ // We don't necessarily have a RootWindow yet.
+ if (widget->GetNativeView()->GetRootWindow())
+ widget->GetNativeView()->Focus();
+#endif
}
virtual void PulseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
- return GetConstrainedWindowViews(dialog)->PulseWebContentsModalDialog();
}
// views::WidgetObserver overrides
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE {
+#if defined(USE_ASH)
+ gfx::NativeView view = platform_util::GetParent(widget->GetNativeView());
+ // Allow the parent to animate again.
+ if (view && view->parent())
+ view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey);
+#endif
native_delegate_->WillClose(widget->GetNativeView());
observed_widgets_.erase(widget);
}
@@ -110,11 +118,6 @@ class NativeWebContentsModalDialogManagerViews
return widget;
}
- static ConstrainedWindowViews* GetConstrainedWindowViews(
- NativeWebContentsModalDialog dialog) {
- return static_cast<ConstrainedWindowViews*>(GetWidget(dialog));
- }
-
NativeWebContentsModalDialogManagerDelegate* native_delegate_;
std::set<views::Widget*> observed_widgets_;