| 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_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "content/public/browser/web_ui_controller.h" | 10 #include "content/public/browser/web_ui_controller.h" |
| 11 | 11 |
| 12 class ConstrainedWindow; | 12 class ConstrainedWindow; |
| 13 class Profile; | 13 class Profile; |
| 14 class TabContentsWrapper; | 14 class TabContentsWrapper; |
| 15 |
| 16 namespace web_dialogs { |
| 15 class WebDialogDelegate; | 17 class WebDialogDelegate; |
| 16 class WebDialogWebContentsDelegate; | 18 } |
| 19 class ChromeWebDialogWebContentsDelegate; |
| 17 | 20 |
| 18 namespace base { | 21 namespace base { |
| 19 template<class T> class PropertyAccessor; | 22 template<class T> class PropertyAccessor; |
| 20 } | 23 } |
| 21 | 24 |
| 22 namespace content { | 25 namespace content { |
| 23 class RenderViewHost; | 26 class RenderViewHost; |
| 24 } | 27 } |
| 25 | 28 |
| 26 class ConstrainedWebDialogDelegate { | 29 class ConstrainedWebDialogDelegate { |
| 27 public: | 30 public: |
| 28 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; | 31 virtual const web_dialogs::WebDialogDelegate* |
| 29 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; | 32 GetWebDialogDelegate() const = 0; |
| 33 virtual web_dialogs::WebDialogDelegate* GetWebDialogDelegate() = 0; |
| 30 | 34 |
| 31 // Called when the dialog is being closed in response to a "DialogClose" | 35 // Called when the dialog is being closed in response to a "DialogClose" |
| 32 // message from WebUI. | 36 // message from WebUI. |
| 33 virtual void OnDialogCloseFromWebUI() = 0; | 37 virtual void OnDialogCloseFromWebUI() = 0; |
| 34 | 38 |
| 35 // If called, on dialog closure, the dialog will release its WebContents | 39 // If called, on dialog closure, the dialog will release its WebContents |
| 36 // instead of destroying it. After which point, the caller will own the | 40 // instead of destroying it. After which point, the caller will own the |
| 37 // released WebContents. | 41 // released WebContents. |
| 38 virtual void ReleaseTabContentsOnDialogClose() = 0; | 42 virtual void ReleaseTabContentsOnDialogClose() = 0; |
| 39 | 43 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 // ConstrainedWebDialogUI object. | 73 // ConstrainedWebDialogUI object. |
| 70 // |profile| is used to construct the constrained HTML dialog's WebContents. | 74 // |profile| is used to construct the constrained HTML dialog's WebContents. |
| 71 // |delegate| controls the behavior of the dialog. | 75 // |delegate| controls the behavior of the dialog. |
| 72 // |tab_delegate| is optional, pass one in to use a custom | 76 // |tab_delegate| is optional, pass one in to use a custom |
| 73 // WebDialogWebContentsDelegate with the dialog, or NULL to | 77 // WebDialogWebContentsDelegate with the dialog, or NULL to |
| 74 // use the default one. The dialog takes ownership of | 78 // use the default one. The dialog takes ownership of |
| 75 // |tab_delegate|. | 79 // |tab_delegate|. |
| 76 // |overshadowed| is the tab being overshadowed by the dialog. | 80 // |overshadowed| is the tab being overshadowed by the dialog. |
| 77 static ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 81 static ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
| 78 Profile* profile, | 82 Profile* profile, |
| 79 WebDialogDelegate* delegate, | 83 web_dialogs::WebDialogDelegate* delegate, |
| 80 WebDialogWebContentsDelegate* tab_delegate, | 84 ChromeWebDialogWebContentsDelegate* tab_delegate, |
| 81 TabContentsWrapper* overshadowed); | 85 TabContentsWrapper* overshadowed); |
| 82 | 86 |
| 83 // Returns a property accessor that can be used to set the | 87 // Returns a property accessor that can be used to set the |
| 84 // ConstrainedWebDialogDelegate property on a WebContents. | 88 // ConstrainedWebDialogDelegate property on a WebContents. |
| 85 static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& | 89 static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& |
| 86 GetPropertyAccessor(); | 90 GetPropertyAccessor(); |
| 87 | 91 |
| 88 protected: | 92 protected: |
| 89 // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. | 93 // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. |
| 90 // Returns NULL if that property is not set. | 94 // Returns NULL if that property is not set. |
| 91 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); | 95 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); |
| 92 | 96 |
| 93 private: | 97 private: |
| 94 // JS Message Handler | 98 // JS Message Handler |
| 95 void OnDialogCloseMessage(const base::ListValue* args); | 99 void OnDialogCloseMessage(const base::ListValue* args); |
| 96 | 100 |
| 97 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); | 101 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); |
| 98 }; | 102 }; |
| 99 | 103 |
| 100 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ | 104 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| OLD | NEW |