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

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

Issue 21372006: Revert 212329 "Reland "Close web contents modal dialogs on conte..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | Annotate | Revision Log
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"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 13
14 using content::NavigationController; 14 using content::NavigationController;
15 using content::WebContents; 15 using content::WebContents;
16 16
17 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate( 17 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate(
18 WebContents* web_contents) 18 WebContents* web_contents)
19 : operations_delegate_(NULL), 19 : close_delegate_(NULL),
20 closing_(false) { 20 closing_(false) {
21 NavigationController* controller = &web_contents->GetController(); 21 NavigationController* controller = &web_contents->GetController();
22 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
23 content::Source<NavigationController>(controller));
22 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, 24 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
23 content::Source<NavigationController>(controller)); 25 content::Source<NavigationController>(controller));
24 } 26 }
25 27
26 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() { 28 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() {
27 // 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
28 // it again. 30 // it again.
29 operations_delegate_ = NULL; 31 close_delegate_ = NULL;
30 // Make sure everything is cleaned up. 32 // Make sure everything is cleaned up.
31 Cancel(); 33 Cancel();
32 } 34 }
33 35
34 void TabModalConfirmDialogDelegate::Cancel() { 36 void TabModalConfirmDialogDelegate::Cancel() {
35 if (closing_) 37 if (closing_)
36 return; 38 return;
37 // Make sure we won't do anything when |Cancel()| or |Accept()| is called 39 // Make sure we won't do anything when |Cancel()| or |Accept()| is called
38 // again. 40 // again.
39 closing_ = true; 41 closing_ = true;
(...skipping 18 matching lines...) Expand all
58 // Make sure we won't do anything when another action occurs. 60 // Make sure we won't do anything when another action occurs.
59 closing_ = true; 61 closing_ = true;
60 OnLinkClicked(disposition); 62 OnLinkClicked(disposition);
61 CloseDialog(); 63 CloseDialog();
62 } 64 }
63 65
64 void TabModalConfirmDialogDelegate::Observe( 66 void TabModalConfirmDialogDelegate::Observe(
65 int type, 67 int type,
66 const content::NotificationSource& source, 68 const content::NotificationSource& source,
67 const content::NotificationDetails& details) { 69 const content::NotificationDetails& details) {
68 // Close the dialog if the tab is closed. 70 // Close the dialog if we load a page (because the action might not apply to
69 if (type == chrome::NOTIFICATION_TAB_CLOSING) { 71 // the same page anymore) or if the tab is closed.
72 if (type == content::NOTIFICATION_LOAD_START ||
73 type == chrome::NOTIFICATION_TAB_CLOSING) {
70 Cancel(); 74 Cancel();
71 } else { 75 } else {
72 NOTREACHED(); 76 NOTREACHED();
73 } 77 }
74 } 78 }
75 79
76 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { 80 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() {
77 return NULL; 81 return NULL;
78 } 82 }
79 83
(...skipping 21 matching lines...) Expand all
101 } 105 }
102 106
103 void TabModalConfirmDialogDelegate::OnCanceled() { 107 void TabModalConfirmDialogDelegate::OnCanceled() {
104 } 108 }
105 109
106 void TabModalConfirmDialogDelegate::OnLinkClicked( 110 void TabModalConfirmDialogDelegate::OnLinkClicked(
107 WindowOpenDisposition disposition) { 111 WindowOpenDisposition disposition) {
108 } 112 }
109 113
110 void TabModalConfirmDialogDelegate::CloseDialog() { 114 void TabModalConfirmDialogDelegate::CloseDialog() {
111 if (operations_delegate_) 115 if (close_delegate_)
112 operations_delegate_->CloseDialog(); 116 close_delegate_->CloseDialog();
113 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698