| 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 UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 6 #define UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "content/public/browser/web_ui_controller.h" | 9 #include "content/public/browser/web_ui_controller.h" |
| 10 #include "ui/web_dialogs/web_dialogs_export.h" | |
| 11 | 10 |
| 12 class ConstrainedWindow; | 11 class ConstrainedWindow; |
| 13 class Profile; | 12 class Profile; |
| 14 class TabContents; | 13 class TabContents; |
| 15 | 14 |
| 16 namespace content { | 15 namespace content { |
| 17 class RenderViewHost; | 16 class RenderViewHost; |
| 18 class WebContents; | 17 class WebContents; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace ui { | 20 namespace ui { |
| 22 class WebDialogDelegate; | 21 class WebDialogDelegate; |
| 23 class WebDialogWebContentsDelegate; | 22 class WebDialogWebContentsDelegate; |
| 23 } |
| 24 | 24 |
| 25 class WEB_DIALOGS_EXPORT ConstrainedWebDialogDelegate { | 25 class ConstrainedWebDialogDelegate { |
| 26 public: | 26 public: |
| 27 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; | 27 virtual const ui::WebDialogDelegate* GetWebDialogDelegate() const = 0; |
| 28 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; | 28 virtual ui::WebDialogDelegate* GetWebDialogDelegate() = 0; |
| 29 | 29 |
| 30 // Called when the dialog is being closed in response to a "DialogClose" | 30 // Called when the dialog is being closed in response to a "DialogClose" |
| 31 // message from WebUI. | 31 // message from WebUI. |
| 32 virtual void OnDialogCloseFromWebUI() = 0; | 32 virtual void OnDialogCloseFromWebUI() = 0; |
| 33 | 33 |
| 34 // If called, on dialog closure, the dialog will release its WebContents | 34 // If called, on dialog closure, the dialog will release its TabContents |
| 35 // instead of destroying it. After which point, the caller will own the | 35 // instead of destroying it. After which point, the caller will own the |
| 36 // released WebContents. | 36 // released TabContents. |
| 37 virtual void ReleaseTabContentsOnDialogClose() = 0; | 37 virtual void ReleaseTabContentsOnDialogClose() = 0; |
| 38 | 38 |
| 39 // Returns the ConstrainedWindow. | 39 // Returns the ConstrainedWindow. |
| 40 // TODO: fix this function name and the one below to conform to the style | 40 // TODO: fix this function name and the one below to conform to the style |
| 41 // guide (i.e. GetWindow, GetTab). | 41 // guide (i.e. GetWindow, GetTab). |
| 42 virtual ConstrainedWindow* window() = 0; | 42 virtual ConstrainedWindow* window() = 0; |
| 43 | 43 |
| 44 // Returns the TabContents owned by the constrained window. | 44 // Returns the TabContents owned by the constrained window. |
| 45 virtual TabContents* tab() = 0; | 45 virtual TabContents* tab() = 0; |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 virtual ~ConstrainedWebDialogDelegate() {} | 48 virtual ~ConstrainedWebDialogDelegate() {} |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // ConstrainedWebDialogUI is a facility to show HTML WebUI content | 51 // ConstrainedWebDialogUI is a facility to show HTML WebUI content |
| 52 // in a tab-modal constrained dialog. It is implemented as an adapter | 52 // in a tab-modal constrained dialog. It is implemented as an adapter |
| 53 // between an WebDialogUI object and a ConstrainedWindow object. | 53 // between an WebDialogUI object and a ConstrainedWindow object. |
| 54 // | 54 // |
| 55 // Since ConstrainedWindow requires platform-specific delegate | 55 // Since ConstrainedWindow requires platform-specific delegate |
| 56 // implementations, this class is just a factory stub. | 56 // implementations, this class is just a factory stub. |
| 57 // TODO(thestig) Refactor the platform-independent code out of the | 57 // TODO(thestig): Refactor the platform-independent code out of the |
| 58 // platform-specific implementations. | 58 // platform-specific implementations. |
| 59 class WEB_DIALOGS_EXPORT ConstrainedWebDialogUI | 59 class ConstrainedWebDialogUI |
| 60 : public content::WebUIController { | 60 : public content::WebUIController { |
| 61 public: | 61 public: |
| 62 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); | 62 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); |
| 63 virtual ~ConstrainedWebDialogUI(); | 63 virtual ~ConstrainedWebDialogUI(); |
| 64 | 64 |
| 65 // WebUIController implementation: | 65 // WebUIController implementation: |
| 66 virtual void RenderViewCreated( | 66 virtual void RenderViewCreated( |
| 67 content::RenderViewHost* render_view_host) OVERRIDE; | 67 content::RenderViewHost* render_view_host) OVERRIDE; |
| 68 | 68 |
| 69 // Sets the delegate on the WebContents. | 69 // Sets the delegate on the WebContents. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 87 // ConstrainedWebDialogUI object. | 87 // ConstrainedWebDialogUI object. |
| 88 // |profile| is used to construct the constrained HTML dialog's WebContents. | 88 // |profile| is used to construct the constrained HTML dialog's WebContents. |
| 89 // |delegate| controls the behavior of the dialog. | 89 // |delegate| controls the behavior of the dialog. |
| 90 // |tab_delegate| is optional, pass one in to use a custom | 90 // |tab_delegate| is optional, pass one in to use a custom |
| 91 // WebDialogWebContentsDelegate with the dialog, or NULL to | 91 // WebDialogWebContentsDelegate with the dialog, or NULL to |
| 92 // use the default one. The dialog takes ownership of | 92 // use the default one. The dialog takes ownership of |
| 93 // |tab_delegate|. | 93 // |tab_delegate|. |
| 94 // |overshadowed| is the tab being overshadowed by the dialog. | 94 // |overshadowed| is the tab being overshadowed by the dialog. |
| 95 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 95 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
| 96 Profile* profile, | 96 Profile* profile, |
| 97 WebDialogDelegate* delegate, | 97 ui::WebDialogDelegate* delegate, |
| 98 WebDialogWebContentsDelegate* tab_delegate, | 98 ui::WebDialogWebContentsDelegate* tab_delegate, |
| 99 TabContents* overshadowed); | 99 content::WebContents* overshadowed); |
| 100 | 100 |
| 101 } // namespace ui | 101 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 102 | |
| 103 #endif // UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ | |
| OLD | NEW |