summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorfdoray@chromium.org <fdoray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 05:46:18 +0000
committerfdoray@chromium.org <fdoray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 05:46:18 +0000
commitec35112f26c5d497489673b960c0f78dc1452d7c (patch)
tree9b34e3989d2bfd122dd8bfe165c63aa67832d3a7 /ui
parent4b1e6bef6d12091316f8c71162fe7c5920b61645 (diff)
downloadchromium_src-ec35112f26c5d497489673b960c0f78dc1452d7c.zip
chromium_src-ec35112f26c5d497489673b960c0f78dc1452d7c.tar.gz
chromium_src-ec35112f26c5d497489673b960c0f78dc1452d7c.tar.bz2
Dismiss action in tab modal dialogs.
See design document: https://docs.google.com/a/google.com/document/d/1i7V7rIcZiWRd9RqWDBC7bdtXeoT3ievSwgUOqrS1148/edit?usp=sharing TEST= 1. Sign in to Chromium. (Hot-dog menu > Sign in to Chromium...) 2. Sign out from Chromium. (Hot-dog menu > Settings, then click the "Disconnect your Google Account..." button) 3. Sign in to Chromium with a different account than the one used at step 1. 4. Do one of the following action once the email confirmation dialog appears: - Click the X on the top-left corner. - Close the parent tab. - Navigate to a different URL in the parent tab. Expected result: The dialog disappears and no action is performed (no Settings page is opened and the user is not signed in). BUG=175647 Review URL: https://chromiumcodereview.appspot.com/18179004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/window/dialog_client_view.cc29
-rw-r--r--ui/views/window/dialog_delegate.cc9
-rw-r--r--ui/views/window/dialog_delegate.h25
3 files changed, 39 insertions, 24 deletions
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 117ae62..d592292 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -55,10 +55,11 @@ void DialogClientView::AcceptWindow() {
}
void DialogClientView::CancelWindow() {
- // Call the standard Close handler, which checks with the delegate before
- // proceeding. This checking _isn't_ done here, but in the WM_CLOSE handler,
- // so that the close box on the window also shares this code path.
- Close();
+ // Only notify the delegate once. See |notified_delegate_|'s comment.
+ if (!notified_delegate_ && GetDialogDelegate()->Cancel()) {
+ notified_delegate_ = true;
+ Close();
+ }
}
void DialogClientView::UpdateDialogButtons() {
@@ -109,16 +110,14 @@ bool DialogClientView::CanClose() {
if (notified_delegate_)
return true;
- DialogDelegate* dialog = GetDialogDelegate();
- int buttons = dialog->GetDialogButtons();
- bool close = true;
- if ((buttons & ui::DIALOG_BUTTON_CANCEL) ||
- (buttons == ui::DIALOG_BUTTON_NONE))
- close = dialog->Cancel();
- else if (buttons & ui::DIALOG_BUTTON_OK)
- close = dialog->Accept(true);
- notified_delegate_ = close;
- return close;
+ // The dialog is closing but no Accept or Cancel action has been performed
+ // before: it's a Close action.
+ if (GetDialogDelegate()->Close()) {
+ notified_delegate_ = true;
+ GetDialogDelegate()->OnClosed();
+ return true;
+ }
+ return false;
}
DialogClientView* DialogClientView::AsDialogClientView() {
@@ -403,7 +402,7 @@ gfx::Insets DialogClientView::GetButtonRowInsets() const {
void DialogClientView::Close() {
GetWidget()->Close();
- GetDialogDelegate()->OnClose();
+ GetDialogDelegate()->OnClosed();
}
} // namespace views
diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc
index ef80f81..9291fc7 100644
--- a/ui/views/window/dialog_delegate.cc
+++ b/ui/views/window/dialog_delegate.cc
@@ -85,6 +85,15 @@ bool DialogDelegate::Accept() {
return true;
}
+bool DialogDelegate::Close() {
+ int buttons = GetDialogButtons();
+ if ((buttons & ui::DIALOG_BUTTON_CANCEL) ||
+ (buttons == ui::DIALOG_BUTTON_NONE)) {
+ return Cancel();
+ }
+ return Accept(true);
+}
+
base::string16 DialogDelegate::GetDialogLabel() const {
return base::string16();
}
diff --git a/ui/views/window/dialog_delegate.h b/ui/views/window/dialog_delegate.h
index bd59960..ed4e797 100644
--- a/ui/views/window/dialog_delegate.h
+++ b/ui/views/window/dialog_delegate.h
@@ -54,22 +54,29 @@ class VIEWS_EXPORT DialogDelegate : public ui::DialogModel,
virtual View* CreateFootnoteView();
// For Dialog boxes, if there is a "Cancel" button or no dialog button at all,
- // this is called when the user presses the "Cancel" button or the Close
- // button on the window or in the system menu, or presses the Esc key.
- // This function should return true if the window can be closed after it
- // returns, or false if it must remain open.
+ // this is called when the user presses the "Cancel" button or the Esc key.
+ // It can also be called on a close action if |Close| has not been
+ // overridden. This function should return true if the window can be closed
+ // after it returns, or false if it must remain open.
virtual bool Cancel();
// For Dialog boxes, this is called when the user presses the "OK" button,
- // or the Enter key. Can also be called on Esc key or close button
- // presses if there is no "Cancel" button. This function should return
- // true if the window can be closed after it returns, or false if it must
- // remain open. If |window_closing| is true, it means that this handler is
+ // or the Enter key. It can also be called on a close action if |Close|
+ // has not been overridden. This function should return true if the window
+ // can be closed after it returns, or false if it must remain open.
+ // If |window_closing| is true, it means that this handler is
// being called because the window is being closed (e.g. by Window::Close)
// and there is no Cancel handler, so Accept is being called instead.
virtual bool Accept(bool window_closing);
virtual bool Accept();
+ // Called when the user closes the window without selecting an option,
+ // e.g. by pressing the close button on the window or using a window manager
+ // gesture. By default, this calls Accept() if the only button in the dialog
+ // is Accept, Cancel() otherwise. This function should return true if the
+ // window can be closed after it returns, or false if it must remain open.
+ virtual bool Close();
+
// Overridden from ui::DialogModel:
virtual base::string16 GetDialogLabel() const OVERRIDE;
virtual base::string16 GetDialogTitle() const OVERRIDE;
@@ -101,7 +108,7 @@ class VIEWS_EXPORT DialogDelegate : public ui::DialogModel,
virtual bool UseNewStyleForThisDialog() const;
// Called when the window has been closed.
- virtual void OnClose() {}
+ virtual void OnClosed() {}
// A helper for accessing the DialogClientView object contained by this
// delegate's Window.