Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
| 8 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
| 9 | 9 |
| 10 using content::WebContents; | 10 using content::WebContents; |
| 11 | 11 |
| 12 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate() | 12 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate() |
| 13 : operations_delegate_(NULL), | 13 : operations_delegate_(NULL), |
| 14 closing_(false) { | 14 closing_(false) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() { | 17 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() { |
| 18 // 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 |
| 19 // it again. | 19 // it again. |
| 20 operations_delegate_ = NULL; | 20 operations_delegate_ = NULL; |
| 21 // Make sure everything is cleaned up. | 21 // Make sure everything is cleaned up. |
| 22 Cancel(); | 22 Cancel(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void TabModalConfirmDialogDelegate::Cancel() { | 25 bool TabModalConfirmDialogDelegate::Cancel() { |
| 26 if (closing_) | 26 if (closing_) |
| 27 return; | 27 return false; |
| 28 // Make sure we won't do anything when |Cancel()| or |Accept()| is called | 28 // Make sure we won't do anything when another action occurs. |
| 29 // again. | |
| 30 closing_ = true; | 29 closing_ = true; |
| 31 OnCanceled(); | 30 OnCanceled(); |
| 32 CloseDialog(); | 31 CloseDialog(); |
| 32 return true; | |
| 33 } | 33 } |
| 34 | 34 |
| 35 void TabModalConfirmDialogDelegate::Accept() { | 35 bool TabModalConfirmDialogDelegate::Accept() { |
| 36 if (closing_) | 36 if (closing_) |
| 37 return; | 37 return false; |
| 38 // Make sure we won't do anything when |Cancel()| or |Accept()| is called | 38 // Make sure we won't do anything when another action occurs. |
| 39 // again. | |
| 40 closing_ = true; | 39 closing_ = true; |
| 41 OnAccepted(); | 40 OnAccepted(); |
| 42 CloseDialog(); | 41 CloseDialog(); |
| 42 return true; | |
| 43 } | 43 } |
| 44 | 44 |
| 45 void TabModalConfirmDialogDelegate::LinkClicked( | 45 bool TabModalConfirmDialogDelegate::LinkClicked( |
| 46 WindowOpenDisposition disposition) { | 46 WindowOpenDisposition disposition) { |
| 47 if (closing_) | 47 if (closing_) |
| 48 return; | 48 return false; |
| 49 // Make sure we won't do anything when another action occurs. | 49 // Make sure we won't do anything when another action occurs. |
| 50 closing_ = true; | 50 closing_ = true; |
| 51 OnLinkClicked(disposition); | 51 OnLinkClicked(disposition); |
| 52 CloseDialog(); | 52 CloseDialog(); |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 bool TabModalConfirmDialogDelegate::Close() { | |
| 57 if (closing_) | |
| 58 return false; | |
| 59 // Make sure we won't do anything when another action occurs. | |
| 60 closing_ = true; | |
| 61 OnClosed(); | |
| 62 CloseDialog(); | |
|
fdoray
2013/07/24 20:21:07
For Views, calling CloseDialog() in Cancel(), Acce
| |
| 63 return true; | |
| 53 } | 64 } |
| 54 | 65 |
| 55 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { | 66 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { |
| 56 return NULL; | 67 return NULL; |
| 57 } | 68 } |
| 58 | 69 |
| 59 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() { | 70 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() { |
| 60 return l10n_util::GetStringUTF16(IDS_OK); | 71 return l10n_util::GetStringUTF16(IDS_OK); |
| 61 } | 72 } |
| 62 | 73 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 79 void TabModalConfirmDialogDelegate::OnAccepted() { | 90 void TabModalConfirmDialogDelegate::OnAccepted() { |
| 80 } | 91 } |
| 81 | 92 |
| 82 void TabModalConfirmDialogDelegate::OnCanceled() { | 93 void TabModalConfirmDialogDelegate::OnCanceled() { |
| 83 } | 94 } |
| 84 | 95 |
| 85 void TabModalConfirmDialogDelegate::OnLinkClicked( | 96 void TabModalConfirmDialogDelegate::OnLinkClicked( |
| 86 WindowOpenDisposition disposition) { | 97 WindowOpenDisposition disposition) { |
| 87 } | 98 } |
| 88 | 99 |
| 100 void TabModalConfirmDialogDelegate::OnClosed() { | |
| 101 } | |
| 102 | |
| 89 void TabModalConfirmDialogDelegate::CloseDialog() { | 103 void TabModalConfirmDialogDelegate::CloseDialog() { |
| 90 if (operations_delegate_) | 104 if (operations_delegate_) |
| 91 operations_delegate_->CloseDialog(); | 105 operations_delegate_->CloseDialog(); |
| 92 } | 106 } |
| OLD | NEW |