| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" |
| 6 |
| 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser_dialogs.h" |
| 9 #include "chrome/browser/ui/browser_list.h" |
| 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 12 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 13 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 14 #include "content/browser/tab_contents/navigation_controller.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" |
| 16 #include "grit/generated_resources.h" |
| 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/views/controls/message_box_view.h" |
| 19 |
| 20 namespace browser { |
| 21 |
| 22 // Declared in browser_dialogs.h so others don't have to depend on our header. |
| 23 void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate, |
| 24 TabContentsWrapper* wrapper) { |
| 25 new TabModalConfirmDialogViews(delegate, wrapper); |
| 26 } |
| 27 |
| 28 } // namespace browser |
| 29 |
| 30 ////////////////////////////////////////////////////////////////////////////// |
| 31 // TabModalConfirmDialogViews, constructor & destructor: |
| 32 |
| 33 TabModalConfirmDialogViews::TabModalConfirmDialogViews( |
| 34 TabModalConfirmDialogDelegate* delegate, |
| 35 TabContentsWrapper* wrapper) |
| 36 : delegate_(delegate), |
| 37 message_box_view_(new views::MessageBoxView( |
| 38 views::MessageBoxView::NO_OPTIONS, |
| 39 delegate->GetMessage(), |
| 40 string16())) { |
| 41 delegate_->set_window(new ConstrainedWindowViews(wrapper, this)); |
| 42 } |
| 43 |
| 44 TabModalConfirmDialogViews::~TabModalConfirmDialogViews() { |
| 45 } |
| 46 |
| 47 ////////////////////////////////////////////////////////////////////////////// |
| 48 // TabModalConfirmDialogViews, views::DialogDelegate implementation: |
| 49 |
| 50 string16 TabModalConfirmDialogViews::GetWindowTitle() const { |
| 51 return delegate_->GetTitle(); |
| 52 } |
| 53 |
| 54 string16 TabModalConfirmDialogViews::GetDialogButtonLabel( |
| 55 ui::DialogButton button) const { |
| 56 if (button == ui::DIALOG_BUTTON_OK) |
| 57 return delegate_->GetAcceptButtonTitle(); |
| 58 if (button == ui::DIALOG_BUTTON_CANCEL) |
| 59 return delegate_->GetCancelButtonTitle(); |
| 60 return string16(); |
| 61 } |
| 62 |
| 63 bool TabModalConfirmDialogViews::Cancel() { |
| 64 delegate_->Cancel(); |
| 65 return true; |
| 66 } |
| 67 |
| 68 bool TabModalConfirmDialogViews::Accept() { |
| 69 delegate_->Accept(); |
| 70 return true; |
| 71 } |
| 72 |
| 73 /////////////////////////////////////////////////////////////////////////////// |
| 74 // TabModalConfirmDialogViews, views::WidgetDelegate implementation: |
| 75 |
| 76 views::View* TabModalConfirmDialogViews::GetContentsView() { |
| 77 return message_box_view_; |
| 78 } |
| 79 |
| 80 views::Widget* TabModalConfirmDialogViews::GetWidget() { |
| 81 return message_box_view_->GetWidget(); |
| 82 } |
| 83 |
| 84 const views::Widget* TabModalConfirmDialogViews::GetWidget() const { |
| 85 return message_box_view_->GetWidget(); |
| 86 } |
| 87 |
| 88 void TabModalConfirmDialogViews::DeleteDelegate() { |
| 89 delete this; |
| 90 } |
| OLD | NEW |