| 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_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 11 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 11 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 12 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" | 12 #include "chrome/browser/ui/webui/chrome_web_dialog_web_contents_delegate.h" |
| 13 #include "chrome/browser/ui/webui/web_dialog_ui.h" | 13 #include "ui/web_dialogs/web_dialog_ui.h" |
| 14 | 14 |
| 15 // Platform-agnostic base implementation of ConstrainedWebDialogDelegate. | 15 // Platform-agnostic base implementation of ConstrainedWebDialogDelegate. |
| 16 class ConstrainedWebDialogDelegateBase | 16 class ConstrainedWebDialogDelegateBase |
| 17 : public ConstrainedWebDialogDelegate, | 17 : public ConstrainedWebDialogDelegate, |
| 18 public WebDialogWebContentsDelegate { | 18 public ChromeWebDialogWebContentsDelegate { |
| 19 public: | 19 public: |
| 20 ConstrainedWebDialogDelegateBase( | 20 ConstrainedWebDialogDelegateBase( |
| 21 Profile* profile, | 21 Profile* profile, |
| 22 WebDialogDelegate* delegate, | 22 views::WebDialogDelegate* delegate, |
| 23 WebDialogWebContentsDelegate* tab_delegate); | 23 WebDialogWebContentsDelegate* tab_delegate); |
| 24 virtual ~ConstrainedWebDialogDelegateBase(); | 24 virtual ~ConstrainedWebDialogDelegateBase(); |
| 25 | 25 |
| 26 void set_window(ConstrainedWindow* window); | 26 void set_window(ConstrainedWindow* window); |
| 27 bool closed_via_webui() const; | 27 bool closed_via_webui() const; |
| 28 | 28 |
| 29 // ConstrainedWebDialogDelegate interface. | 29 // ConstrainedWebDialogDelegate interface. |
| 30 virtual const WebDialogDelegate* | 30 virtual const views::WebDialogDelegate* |
| 31 GetWebDialogDelegate() const OVERRIDE; | 31 GetWebDialogDelegate() const OVERRIDE; |
| 32 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE; | 32 virtual views::WebDialogDelegate* GetWebDialogDelegate() OVERRIDE; |
| 33 virtual void OnDialogCloseFromWebUI() OVERRIDE; | 33 virtual void OnDialogCloseFromWebUI() OVERRIDE; |
| 34 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; | 34 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; |
| 35 virtual ConstrainedWindow* window() OVERRIDE; | 35 virtual ConstrainedWindow* window() OVERRIDE; |
| 36 virtual TabContentsWrapper* tab() OVERRIDE; | 36 virtual TabContentsWrapper* tab() OVERRIDE; |
| 37 | 37 |
| 38 // WebDialogWebContentsDelegate interface. | 38 // WebDialogWebContentsDelegate interface. |
| 39 virtual void HandleKeyboardEvent( | 39 virtual void HandleKeyboardEvent( |
| 40 const NativeWebKeyboardEvent& event) OVERRIDE; | 40 const NativeWebKeyboardEvent& event) OVERRIDE; |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 void set_override_tab_delegate( | 43 void set_override_tab_delegate( |
| 44 WebDialogWebContentsDelegate* override_tab_delegate); | 44 views::WebDialogWebContentsDelegate* override_tab_delegate); |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 WebDialogDelegate* web_dialog_delegate_; | 47 views::WebDialogDelegate* web_dialog_delegate_; |
| 48 | 48 |
| 49 // The constrained window that owns |this|. Saved so we can close it later. | 49 // The constrained window that owns |this|. Saved so we can close it later. |
| 50 ConstrainedWindow* window_; | 50 ConstrainedWindow* window_; |
| 51 | 51 |
| 52 // Holds the HTML to display in the constrained dialog. | 52 // Holds the HTML to display in the constrained dialog. |
| 53 scoped_ptr<TabContentsWrapper> tab_; | 53 scoped_ptr<TabContentsWrapper> tab_; |
| 54 | 54 |
| 55 // Was the dialog closed from WebUI (in which case |web_dialog_delegate_|'s | 55 // Was the dialog closed from WebUI (in which case |web_dialog_delegate_|'s |
| 56 // OnDialogClosed() method has already been called)? | 56 // OnDialogClosed() method has already been called)? |
| 57 bool closed_via_webui_; | 57 bool closed_via_webui_; |
| 58 | 58 |
| 59 // If true, release |tab_| on close instead of destroying it. | 59 // If true, release |tab_| on close instead of destroying it. |
| 60 bool release_tab_on_close_; | 60 bool release_tab_on_close_; |
| 61 | 61 |
| 62 scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_; | 62 scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateBase); | 64 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateBase); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ | 67 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ |
| OLD | NEW |