tab_modal_confirm_dialog_views.h revision a36e5920737c6adbddd3e43b760e5de8431db6e0
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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_VIEWS_TAB_MODAL_CONFIRM_DIALOG_VIEWS_H_ 6#define CHROME_BROWSER_UI_VIEWS_TAB_MODAL_CONFIRM_DIALOG_VIEWS_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "chrome/browser/ui/tab_modal_confirm_dialog.h" 11#include "ui/gfx/native_widget_types.h" 12#include "ui/views/controls/link_listener.h" 13#include "ui/views/window/dialog_delegate.h" 14 15namespace content { 16class WebContents; 17class BrowserContext; 18} 19 20namespace views { 21class MessageBoxView; 22class Widget; 23} 24 25// Displays a tab-modal dialog, i.e. a dialog that will block the current page 26// but still allow the user to switch to a different page. 27// To display the dialog, allocate this object on the heap. It will open the 28// dialog from its constructor and then delete itself when the user dismisses 29// the dialog. 30class TabModalConfirmDialogViews : public TabModalConfirmDialog, 31 public views::DialogDelegate, 32 public views::LinkListener { 33 public: 34 TabModalConfirmDialogViews(TabModalConfirmDialogDelegate* delegate, 35 content::WebContents* web_contents); 36 37 // views::DialogDelegate: 38 virtual string16 GetWindowTitle() const OVERRIDE; 39 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 40 virtual bool Cancel() OVERRIDE; 41 virtual bool Accept() OVERRIDE; 42 virtual bool Close() OVERRIDE; 43 44 // views::WidgetDelegate: 45 virtual views::View* GetContentsView() OVERRIDE; 46 virtual views::NonClientFrameView* CreateNonClientFrameView( 47 views::Widget* widget) OVERRIDE; 48 virtual views::Widget* GetWidget() OVERRIDE; 49 virtual const views::Widget* GetWidget() const OVERRIDE; 50 virtual void DeleteDelegate() OVERRIDE; 51 virtual ui::ModalType GetModalType() const OVERRIDE; 52 53 private: 54 virtual ~TabModalConfirmDialogViews(); 55 56 // TabModalConfirmDialog: 57 virtual void AcceptTabModalDialog() OVERRIDE; 58 virtual void CancelTabModalDialog() OVERRIDE; 59 60 // TabModalConfirmDialogCloseDelegate: 61 virtual void CloseDialog() OVERRIDE; 62 63 // views::LinkListener: 64 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 65 66 scoped_ptr<TabModalConfirmDialogDelegate> delegate_; 67 68 // The message box view whose commands we handle. 69 views::MessageBoxView* message_box_view_; 70 71 views::Widget* dialog_; 72 content::BrowserContext* browser_context_; 73 74 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogViews); 75}; 76 77#endif // CHROME_BROWSER_UI_VIEWS_TAB_MODAL_CONFIRM_DIALOG_VIEWS_H_ 78