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