| 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 UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ | 6 #define UI_WEB_DIALOGS_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 #include "ui/web_dialogs/web_dialogs_export.h" |
| 11 | 12 |
| 12 class ConstrainedWindow; | 13 class ConstrainedWindow; |
| 13 class Profile; | 14 class Profile; |
| 14 class TabContentsWrapper; | 15 class TabContentsWrapper; |
| 15 class WebDialogDelegate; | |
| 16 class WebDialogWebContentsDelegate; | 16 class WebDialogWebContentsDelegate; |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 template<class T> class PropertyAccessor; | 19 template<class T> class PropertyAccessor; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 class RenderViewHost; | 23 class RenderViewHost; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class ConstrainedWebDialogDelegate { | 26 namespace ui { |
| 27 class WebDialogDelegate; |
| 28 |
| 29 class WEB_DIALOGS_EXPORT ConstrainedWebDialogDelegate { |
| 27 public: | 30 public: |
| 28 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; | 31 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; |
| 29 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; | 32 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; |
| 30 | 33 |
| 31 // Called when the dialog is being closed in response to a "DialogClose" | 34 // Called when the dialog is being closed in response to a "DialogClose" |
| 32 // message from WebUI. | 35 // message from WebUI. |
| 33 virtual void OnDialogCloseFromWebUI() = 0; | 36 virtual void OnDialogCloseFromWebUI() = 0; |
| 34 | 37 |
| 35 // If called, on dialog closure, the dialog will release its WebContents | 38 // If called, on dialog closure, the dialog will release its WebContents |
| 36 // instead of destroying it. After which point, the caller will own the | 39 // instead of destroying it. After which point, the caller will own the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 // ConstrainedWebDialogUI is a facility to show HTML WebUI content | 53 // ConstrainedWebDialogUI is a facility to show HTML WebUI content |
| 51 // in a tab-modal constrained dialog. It is implemented as an adapter | 54 // in a tab-modal constrained dialog. It is implemented as an adapter |
| 52 // between an WebDialogUI object and a ConstrainedWindow object. | 55 // between an WebDialogUI object and a ConstrainedWindow object. |
| 53 // | 56 // |
| 54 // Since ConstrainedWindow requires platform-specific delegate | 57 // Since ConstrainedWindow requires platform-specific delegate |
| 55 // implementations, this class is just a factory stub. | 58 // implementations, this class is just a factory stub. |
| 56 // TODO(thestig) Refactor the platform-independent code out of the | 59 // TODO(thestig) Refactor the platform-independent code out of the |
| 57 // platform-specific implementations. | 60 // platform-specific implementations. |
| 58 class ConstrainedWebDialogUI : public content::WebUIController { | 61 class WEB_DIALOGS_EXPORT ConstrainedWebDialogUI |
| 62 : public content::WebUIController { |
| 59 public: | 63 public: |
| 60 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); | 64 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); |
| 61 virtual ~ConstrainedWebDialogUI(); | 65 virtual ~ConstrainedWebDialogUI(); |
| 62 | 66 |
| 63 // WebUIController implementation: | 67 // WebUIController implementation: |
| 64 virtual void RenderViewCreated( | 68 virtual void RenderViewCreated( |
| 65 content::RenderViewHost* render_view_host) OVERRIDE; | 69 content::RenderViewHost* render_view_host) OVERRIDE; |
| 66 | 70 |
| 67 // Create a constrained HTML dialog. The actual object that gets created | |
| 68 // is a ConstrainedWebDialogDelegate, which later triggers construction of a | |
| 69 // ConstrainedWebDialogUI object. | |
| 70 // |profile| is used to construct the constrained HTML dialog's WebContents. | |
| 71 // |delegate| controls the behavior of the dialog. | |
| 72 // |tab_delegate| is optional, pass one in to use a custom | |
| 73 // WebDialogWebContentsDelegate with the dialog, or NULL to | |
| 74 // use the default one. The dialog takes ownership of | |
| 75 // |tab_delegate|. | |
| 76 // |overshadowed| is the tab being overshadowed by the dialog. | |
| 77 static ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | |
| 78 Profile* profile, | |
| 79 WebDialogDelegate* delegate, | |
| 80 WebDialogWebContentsDelegate* tab_delegate, | |
| 81 TabContentsWrapper* overshadowed); | |
| 82 | |
| 83 // Returns a property accessor that can be used to set the | 71 // Returns a property accessor that can be used to set the |
| 84 // ConstrainedWebDialogDelegate property on a WebContents. | 72 // ConstrainedWebDialogDelegate property on a WebContents. |
| 85 static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& | 73 static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& |
| 86 GetPropertyAccessor(); | 74 GetPropertyAccessor(); |
| 87 | 75 |
| 88 protected: | 76 protected: |
| 89 // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. | 77 // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. |
| 90 // Returns NULL if that property is not set. | 78 // Returns NULL if that property is not set. |
| 91 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); | 79 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); |
| 92 | 80 |
| 93 private: | 81 private: |
| 94 // JS Message Handler | 82 // JS Message Handler |
| 95 void OnDialogCloseMessage(const base::ListValue* args); | 83 void OnDialogCloseMessage(const base::ListValue* args); |
| 96 | 84 |
| 97 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); | 85 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); |
| 98 }; | 86 }; |
| 99 | 87 |
| 100 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ | 88 // Create a constrained HTML dialog. The actual object that gets created |
| 89 // is a ConstrainedWebDialogDelegate, which later triggers construction of a |
| 90 // ConstrainedWebDialogUI object. |
| 91 // |profile| is used to construct the constrained HTML dialog's WebContents. |
| 92 // |delegate| controls the behavior of the dialog. |
| 93 // |tab_delegate| is optional, pass one in to use a custom |
| 94 // WebDialogWebContentsDelegate with the dialog, or NULL to |
| 95 // use the default one. The dialog takes ownership of |
| 96 // |tab_delegate|. |
| 97 // |overshadowed| is the tab being overshadowed by the dialog. |
| 98 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
| 99 Profile* profile, |
| 100 WebDialogDelegate* delegate, |
| 101 WebDialogWebContentsDelegate* tab_delegate, |
| 102 TabContentsWrapper* overshadowed); |
| 103 |
| 104 } // namespace ui |
| 105 |
| 106 #endif // UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ |
| OLD | NEW |