Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc

Issue 18179004: Dismiss action in tab modal dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test for Mac Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 5 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "content/public/browser/navigation_controller.h" 8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_source.h" 9 #include "content/public/browser/notification_source.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 18 matching lines...) Expand all
29 // If we end up here, the window has been closed, so make sure we don't close 29 // If we end up here, the window has been closed, so make sure we don't close
30 // it again. 30 // it again.
31 close_delegate_ = NULL; 31 close_delegate_ = NULL;
32 // Make sure everything is cleaned up. 32 // Make sure everything is cleaned up.
33 Cancel(); 33 Cancel();
34 } 34 }
35 35
36 void TabModalConfirmDialogDelegate::Cancel() { 36 void TabModalConfirmDialogDelegate::Cancel() {
37 if (closing_) 37 if (closing_)
38 return; 38 return;
39 // Make sure we won't do anything when |Cancel()| or |Accept()| is called 39 // Make sure we won't do anything when another action occurs.
40 // again.
41 closing_ = true; 40 closing_ = true;
42 OnCanceled(); 41 OnCanceled();
43 CloseDialog(); 42 CloseDialog();
44 } 43 }
45 44
46 void TabModalConfirmDialogDelegate::Accept() { 45 void TabModalConfirmDialogDelegate::Accept() {
47 if (closing_) 46 if (closing_)
48 return; 47 return;
49 // Make sure we won't do anything when |Cancel()| or |Accept()| is called 48 // Make sure we won't do anything when another action occurs.
50 // again.
51 closing_ = true; 49 closing_ = true;
52 OnAccepted(); 50 OnAccepted();
53 CloseDialog(); 51 CloseDialog();
54 } 52 }
55 53
56 void TabModalConfirmDialogDelegate::LinkClicked( 54 void TabModalConfirmDialogDelegate::LinkClicked(
57 WindowOpenDisposition disposition) { 55 WindowOpenDisposition disposition) {
58 if (closing_) 56 if (closing_)
59 return; 57 return;
60 // Make sure we won't do anything when another action occurs. 58 // Make sure we won't do anything when another action occurs.
61 closing_ = true; 59 closing_ = true;
62 OnLinkClicked(disposition); 60 OnLinkClicked(disposition);
63 CloseDialog(); 61 CloseDialog();
64 } 62 }
65 63
66 void TabModalConfirmDialogDelegate::Observe( 64 void TabModalConfirmDialogDelegate::Observe(
67 int type, 65 int type,
68 const content::NotificationSource& source, 66 const content::NotificationSource& source,
69 const content::NotificationDetails& details) { 67 const content::NotificationDetails& details) {
70 // Close the dialog if we load a page (because the action might not apply to 68 // Close the dialog if we load a page (because the action might not apply to
71 // the same page anymore) or if the tab is closed. 69 // the same page anymore) or if the tab is closed.
72 if (type == content::NOTIFICATION_LOAD_START || 70 if (type == content::NOTIFICATION_LOAD_START ||
73 type == chrome::NOTIFICATION_TAB_CLOSING) { 71 type == chrome::NOTIFICATION_TAB_CLOSING) {
74 Cancel(); 72 Close();
75 } else { 73 } else {
76 NOTREACHED(); 74 NOTREACHED();
77 } 75 }
78 } 76 }
79 77
78 void TabModalConfirmDialogDelegate::Close() {
79 if (closing_)
80 return;
81 // Make sure we won't do anything when another action occurs.
82 closing_ = true;
83 OnClosed();
84 CloseDialog();
85 }
86
80 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { 87 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() {
81 return NULL; 88 return NULL;
82 } 89 }
83 90
84 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() { 91 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() {
85 return l10n_util::GetStringUTF16(IDS_OK); 92 return l10n_util::GetStringUTF16(IDS_OK);
86 } 93 }
87 94
88 string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() { 95 string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() {
89 return l10n_util::GetStringUTF16(IDS_CANCEL); 96 return l10n_util::GetStringUTF16(IDS_CANCEL);
(...skipping 14 matching lines...) Expand all
104 void TabModalConfirmDialogDelegate::OnAccepted() { 111 void TabModalConfirmDialogDelegate::OnAccepted() {
105 } 112 }
106 113
107 void TabModalConfirmDialogDelegate::OnCanceled() { 114 void TabModalConfirmDialogDelegate::OnCanceled() {
108 } 115 }
109 116
110 void TabModalConfirmDialogDelegate::OnLinkClicked( 117 void TabModalConfirmDialogDelegate::OnLinkClicked(
111 WindowOpenDisposition disposition) { 118 WindowOpenDisposition disposition) {
112 } 119 }
113 120
121 void TabModalConfirmDialogDelegate::OnClosed() {
122 }
123
114 void TabModalConfirmDialogDelegate::CloseDialog() { 124 void TabModalConfirmDialogDelegate::CloseDialog() {
115 if (close_delegate_) 125 if (close_delegate_)
116 close_delegate_->CloseDialog(); 126 close_delegate_->CloseDialog();
117 } 127 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_modal_confirm_dialog_delegate.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_editor_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698