| 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 #ifndef CHROME_BROWSER_UI_WEBUI_TAB_MODAL_CONFIRM_DIALOG_WEBUI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_TAB_MODAL_CONFIRM_DIALOG_WEBUI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_TAB_MODAL_CONFIRM_DIALOG_WEBUI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_TAB_MODAL_CONFIRM_DIALOG_WEBUI_H_ |
| 7 | 7 |
| 8 #if !(defined(USE_AURA) || defined(OS_CHROMEOS)) | 8 #if !(defined(USE_AURA) || defined(OS_CHROMEOS)) |
| 9 #error Tab-modal confirm dialog should be shown with native UI. | 9 #error Tab-modal confirm dialog should be shown with native UI. |
| 10 #endif | 10 #endif |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 15 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
| 16 #include "ui/web_dialogs/web_dialog_delegate.h" | 16 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 17 | 17 |
| 18 namespace ui { | |
| 19 class ConstrainedWebDialogDelegate; | 18 class ConstrainedWebDialogDelegate; |
| 20 } | |
| 21 | 19 |
| 22 // Displays a tab-modal dialog, i.e. a dialog that will block the current page | 20 // Displays a tab-modal dialog, i.e. a dialog that will block the current page |
| 23 // but still allow the user to switch to a different page. | 21 // but still allow the user to switch to a different page. |
| 24 // To display the dialog, allocate this object on the heap. It will open the | 22 // To display the dialog, allocate this object on the heap. It will open the |
| 25 // dialog from its constructor and then delete itself when the user dismisses | 23 // dialog from its constructor and then delete itself when the user dismisses |
| 26 // the dialog. | 24 // the dialog. |
| 27 class TabModalConfirmDialogWebUI : public TabModalConfirmDialog, | 25 class TabModalConfirmDialogWebUI : public TabModalConfirmDialog, |
| 28 public ui::WebDialogDelegate { | 26 public ui::WebDialogDelegate { |
| 29 public: | 27 public: |
| 30 TabModalConfirmDialogWebUI( | 28 TabModalConfirmDialogWebUI( |
| 31 TabModalConfirmDialogDelegate* dialog_delegate, | 29 TabModalConfirmDialogDelegate* dialog_delegate, |
| 32 TabContents* tab_contents); | 30 TabContents* tab_contents); |
| 33 | 31 |
| 34 // ui::WebDialogDelegate implementation. | 32 // ui::WebDialogDelegate implementation. |
| 35 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 33 virtual ui::ModalType GetDialogModalType() const OVERRIDE; |
| 36 virtual string16 GetDialogTitle() const OVERRIDE; | 34 virtual string16 GetDialogTitle() const OVERRIDE; |
| 37 virtual GURL GetDialogContentURL() const OVERRIDE; | 35 virtual GURL GetDialogContentURL() const OVERRIDE; |
| 38 virtual void GetWebUIMessageHandlers( | 36 virtual void GetWebUIMessageHandlers( |
| 39 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; | 37 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; |
| 40 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 38 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
| 41 virtual std::string GetDialogArgs() const OVERRIDE; | 39 virtual std::string GetDialogArgs() const OVERRIDE; |
| 42 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 40 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
| 43 virtual void OnCloseContents(content::WebContents* source, | 41 virtual void OnCloseContents(content::WebContents* source, |
| 44 bool* out_close_dialog) OVERRIDE; | 42 bool* out_close_dialog) OVERRIDE; |
| 45 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 43 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
| 46 | 44 |
| 47 ui::ConstrainedWebDialogDelegate* constrained_web_dialog_delegate() { | 45 ConstrainedWebDialogDelegate* constrained_web_dialog_delegate() { |
| 48 return constrained_web_dialog_delegate_; | 46 return constrained_web_dialog_delegate_; |
| 49 } | 47 } |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 virtual ~TabModalConfirmDialogWebUI(); | 50 virtual ~TabModalConfirmDialogWebUI(); |
| 53 | 51 |
| 54 // TabModalConfirmDialog: | 52 // TabModalConfirmDialog: |
| 55 virtual void AcceptTabModalDialog() OVERRIDE; | 53 virtual void AcceptTabModalDialog() OVERRIDE; |
| 56 virtual void CancelTabModalDialog() OVERRIDE; | 54 virtual void CancelTabModalDialog() OVERRIDE; |
| 57 | 55 |
| 58 scoped_ptr<TabModalConfirmDialogDelegate> delegate_; | 56 scoped_ptr<TabModalConfirmDialogDelegate> delegate_; |
| 59 | 57 |
| 60 // Deletes itself. | 58 // Deletes itself. |
| 61 ui::ConstrainedWebDialogDelegate* constrained_web_dialog_delegate_; | 59 ConstrainedWebDialogDelegate* constrained_web_dialog_delegate_; |
| 62 | 60 |
| 63 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogWebUI); | 61 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogWebUI); |
| 64 }; | 62 }; |
| 65 | 63 |
| 66 #endif // CHROME_BROWSER_UI_WEBUI_TAB_MODAL_CONFIRM_DIALOG_WEBUI_H_ | 64 #endif // CHROME_BROWSER_UI_WEBUI_TAB_MODAL_CONFIRM_DIALOG_WEBUI_H_ |
| OLD | NEW |