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