| 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 void TabModalConfirmDialogDelegate::Cancel() { |
| 26 if (closing_) | 26 if (closing_) |
| 27 return; | 27 return; |
| 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(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void TabModalConfirmDialogDelegate::Accept() { | 34 void TabModalConfirmDialogDelegate::Accept() { |
| 36 if (closing_) | 35 if (closing_) |
| 37 return; | 36 return; |
| 38 // Make sure we won't do anything when |Cancel()| or |Accept()| is called | 37 // Make sure we won't do anything when another action occurs. |
| 39 // again. | |
| 40 closing_ = true; | 38 closing_ = true; |
| 41 OnAccepted(); | 39 OnAccepted(); |
| 42 CloseDialog(); | 40 CloseDialog(); |
| 43 } | 41 } |
| 44 | 42 |
| 45 void TabModalConfirmDialogDelegate::LinkClicked( | 43 void TabModalConfirmDialogDelegate::LinkClicked( |
| 46 WindowOpenDisposition disposition) { | 44 WindowOpenDisposition disposition) { |
| 47 if (closing_) | 45 if (closing_) |
| 48 return; | 46 return; |
| 49 // Make sure we won't do anything when another action occurs. | 47 // Make sure we won't do anything when another action occurs. |
| 50 closing_ = true; | 48 closing_ = true; |
| 51 OnLinkClicked(disposition); | 49 OnLinkClicked(disposition); |
| 52 CloseDialog(); | 50 CloseDialog(); |
| 53 } | 51 } |
| 54 | 52 |
| 53 void TabModalConfirmDialogDelegate::Close() { |
| 54 if (closing_) |
| 55 return; |
| 56 // Make sure we won't do anything when another action occurs. |
| 57 closing_ = true; |
| 58 OnClosed(); |
| 59 CloseDialog(); |
| 60 } |
| 61 |
| 55 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { | 62 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { |
| 56 return NULL; | 63 return NULL; |
| 57 } | 64 } |
| 58 | 65 |
| 59 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() { | 66 string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() { |
| 60 return l10n_util::GetStringUTF16(IDS_OK); | 67 return l10n_util::GetStringUTF16(IDS_OK); |
| 61 } | 68 } |
| 62 | 69 |
| 63 string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() { | 70 string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() { |
| 64 return l10n_util::GetStringUTF16(IDS_CANCEL); | 71 return l10n_util::GetStringUTF16(IDS_CANCEL); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 void TabModalConfirmDialogDelegate::OnAccepted() { | 86 void TabModalConfirmDialogDelegate::OnAccepted() { |
| 80 } | 87 } |
| 81 | 88 |
| 82 void TabModalConfirmDialogDelegate::OnCanceled() { | 89 void TabModalConfirmDialogDelegate::OnCanceled() { |
| 83 } | 90 } |
| 84 | 91 |
| 85 void TabModalConfirmDialogDelegate::OnLinkClicked( | 92 void TabModalConfirmDialogDelegate::OnLinkClicked( |
| 86 WindowOpenDisposition disposition) { | 93 WindowOpenDisposition disposition) { |
| 87 } | 94 } |
| 88 | 95 |
| 96 void TabModalConfirmDialogDelegate::OnClosed() { |
| 97 } |
| 98 |
| 89 void TabModalConfirmDialogDelegate::CloseDialog() { | 99 void TabModalConfirmDialogDelegate::CloseDialog() { |
| 90 if (operations_delegate_) | 100 if (operations_delegate_) |
| 91 operations_delegate_->CloseDialog(); | 101 operations_delegate_->CloseDialog(); |
| 92 } | 102 } |
| OLD | NEW |