| Index: chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
|
| diff --git a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..abcd55d412ef27601938d4d258f08c57cc83f821
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
|
| @@ -0,0 +1,90 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h"
|
| +
|
| +#include "base/utf_string_conversions.h"
|
| +#include "chrome/browser/ui/browser_dialogs.h"
|
| +#include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| +#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
|
| +#include "chrome/browser/ui/views/constrained_window_views.h"
|
| +#include "content/browser/tab_contents/navigation_controller.h"
|
| +#include "content/browser/tab_contents/tab_contents.h"
|
| +#include "grit/generated_resources.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/views/controls/message_box_view.h"
|
| +
|
| +namespace browser {
|
| +
|
| +// Declared in browser_dialogs.h so others don't have to depend on our header.
|
| +void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate,
|
| + TabContentsWrapper* wrapper) {
|
| + new TabModalConfirmDialogViews(delegate, wrapper);
|
| +}
|
| +
|
| +} // namespace browser
|
| +
|
| +//////////////////////////////////////////////////////////////////////////////
|
| +// TabModalConfirmDialogViews, constructor & destructor:
|
| +
|
| +TabModalConfirmDialogViews::TabModalConfirmDialogViews(
|
| + TabModalConfirmDialogDelegate* delegate,
|
| + TabContentsWrapper* wrapper)
|
| + : delegate_(delegate),
|
| + message_box_view_(new views::MessageBoxView(
|
| + views::MessageBoxView::NO_OPTIONS,
|
| + delegate->GetMessage(),
|
| + string16())) {
|
| + delegate_->set_window(new ConstrainedWindowViews(wrapper, this));
|
| +}
|
| +
|
| +TabModalConfirmDialogViews::~TabModalConfirmDialogViews() {
|
| +}
|
| +
|
| +//////////////////////////////////////////////////////////////////////////////
|
| +// TabModalConfirmDialogViews, views::DialogDelegate implementation:
|
| +
|
| +string16 TabModalConfirmDialogViews::GetWindowTitle() const {
|
| + return delegate_->GetTitle();
|
| +}
|
| +
|
| +string16 TabModalConfirmDialogViews::GetDialogButtonLabel(
|
| + ui::DialogButton button) const {
|
| + if (button == ui::DIALOG_BUTTON_OK)
|
| + return delegate_->GetAcceptButtonTitle();
|
| + if (button == ui::DIALOG_BUTTON_CANCEL)
|
| + return delegate_->GetCancelButtonTitle();
|
| + return string16();
|
| +}
|
| +
|
| +bool TabModalConfirmDialogViews::Cancel() {
|
| + delegate_->Cancel();
|
| + return true;
|
| +}
|
| +
|
| +bool TabModalConfirmDialogViews::Accept() {
|
| + delegate_->Accept();
|
| + return true;
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// TabModalConfirmDialogViews, views::WidgetDelegate implementation:
|
| +
|
| +views::View* TabModalConfirmDialogViews::GetContentsView() {
|
| + return message_box_view_;
|
| +}
|
| +
|
| +views::Widget* TabModalConfirmDialogViews::GetWidget() {
|
| + return message_box_view_->GetWidget();
|
| +}
|
| +
|
| +const views::Widget* TabModalConfirmDialogViews::GetWidget() const {
|
| + return message_box_view_->GetWidget();
|
| +}
|
| +
|
| +void TabModalConfirmDialogViews::DeleteDelegate() {
|
| + delete this;
|
| +}
|
|
|