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

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

Issue 18786005: Cleanup: remove redundant tab close observation from TabModalConfirmDialogDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 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
« no previous file with comments | « chrome/browser/ui/tab_modal_confirm_dialog_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_source.h"
10 #include "content/public/browser/web_contents.h"
11 #include "grit/generated_resources.h" 7 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h" 8 #include "ui/base/l10n/l10n_util.h"
13 9
14 using content::NavigationController;
15 using content::WebContents; 10 using content::WebContents;
16 11
17 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate( 12 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate()
18 WebContents* web_contents)
19 : operations_delegate_(NULL), 13 : operations_delegate_(NULL),
20 closing_(false) { 14 closing_(false) {
21 NavigationController* controller = &web_contents->GetController();
22 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
23 content::Source<NavigationController>(controller));
24 } 15 }
25 16
26 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() { 17 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() {
27 // If we end up here, the window has been closed, so make sure we don't close 18 // If we end up here, the window has been closed, so make sure we don't close
28 // it again. 19 // it again.
29 operations_delegate_ = NULL; 20 operations_delegate_ = NULL;
30 // Make sure everything is cleaned up. 21 // Make sure everything is cleaned up.
31 Cancel(); 22 Cancel();
32 } 23 }
33 24
(...skipping 20 matching lines...) Expand all
54 void TabModalConfirmDialogDelegate::LinkClicked( 45 void TabModalConfirmDialogDelegate::LinkClicked(
55 WindowOpenDisposition disposition) { 46 WindowOpenDisposition disposition) {
56 if (closing_) 47 if (closing_)
57 return; 48 return;
58 // Make sure we won't do anything when another action occurs. 49 // Make sure we won't do anything when another action occurs.
59 closing_ = true; 50 closing_ = true;
60 OnLinkClicked(disposition); 51 OnLinkClicked(disposition);
61 CloseDialog(); 52 CloseDialog();
62 } 53 }
63 54
64 void TabModalConfirmDialogDelegate::Observe(
65 int type,
66 const content::NotificationSource& source,
67 const content::NotificationDetails& details) {
68 // Close the dialog if the tab is closed.
69 if (type == chrome::NOTIFICATION_TAB_CLOSING) {
70 Cancel();
71 } else {
72 NOTREACHED();
73 }
74 }
75
76 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { 55 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() {
77 return NULL; 56 return NULL;
78 } 57 }
79 58
80 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() { 59 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() {
81 return l10n_util::GetStringUTF16(IDS_OK); 60 return l10n_util::GetStringUTF16(IDS_OK);
82 } 61 }
83 62
84 string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() { 63 string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() {
85 return l10n_util::GetStringUTF16(IDS_CANCEL); 64 return l10n_util::GetStringUTF16(IDS_CANCEL);
(...skipping 18 matching lines...) Expand all
104 } 83 }
105 84
106 void TabModalConfirmDialogDelegate::OnLinkClicked( 85 void TabModalConfirmDialogDelegate::OnLinkClicked(
107 WindowOpenDisposition disposition) { 86 WindowOpenDisposition disposition) {
108 } 87 }
109 88
110 void TabModalConfirmDialogDelegate::CloseDialog() { 89 void TabModalConfirmDialogDelegate::CloseDialog() {
111 if (operations_delegate_) 90 if (operations_delegate_)
112 operations_delegate_->CloseDialog(); 91 operations_delegate_->CloseDialog();
113 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_modal_confirm_dialog_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698