| 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 UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 6 #define UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ | 6 #define UI_WEB_DIALOGS_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" | 10 #include "ui/web_dialogs/web_dialogs_export.h" |
| 11 | 11 |
| 12 class ConstrainedWindow; | 12 class ConstrainedWindow; |
| 13 class Profile; | 13 class Profile; |
| 14 class TabContents; | 14 class TabContents; |
| 15 | 15 |
| 16 namespace base { | |
| 17 template<class T> class PropertyAccessor; | |
| 18 } | |
| 19 | |
| 20 namespace content { | 16 namespace content { |
| 21 class RenderViewHost; | 17 class RenderViewHost; |
| 18 class WebContents; |
| 22 } | 19 } |
| 23 | 20 |
| 24 namespace ui { | 21 namespace ui { |
| 25 class WebDialogDelegate; | 22 class WebDialogDelegate; |
| 26 class WebDialogWebContentsDelegate; | 23 class WebDialogWebContentsDelegate; |
| 27 | 24 |
| 28 class WEB_DIALOGS_EXPORT ConstrainedWebDialogDelegate { | 25 class WEB_DIALOGS_EXPORT ConstrainedWebDialogDelegate { |
| 29 public: | 26 public: |
| 30 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; | 27 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; |
| 31 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; | 28 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 62 class WEB_DIALOGS_EXPORT ConstrainedWebDialogUI | 59 class WEB_DIALOGS_EXPORT ConstrainedWebDialogUI |
| 63 : public content::WebUIController { | 60 : public content::WebUIController { |
| 64 public: | 61 public: |
| 65 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); | 62 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); |
| 66 virtual ~ConstrainedWebDialogUI(); | 63 virtual ~ConstrainedWebDialogUI(); |
| 67 | 64 |
| 68 // WebUIController implementation: | 65 // WebUIController implementation: |
| 69 virtual void RenderViewCreated( | 66 virtual void RenderViewCreated( |
| 70 content::RenderViewHost* render_view_host) OVERRIDE; | 67 content::RenderViewHost* render_view_host) OVERRIDE; |
| 71 | 68 |
| 72 // Returns a property accessor that can be used to set the | 69 // Sets the delegate on the WebContents. |
| 73 // ConstrainedWebDialogDelegate property on a WebContents. | 70 static void SetConstrainedDelegate(content::WebContents* web_contents, |
| 74 static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& | 71 ConstrainedWebDialogDelegate* delegate); |
| 75 GetPropertyAccessor(); | |
| 76 | 72 |
| 77 protected: | 73 protected: |
| 78 // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. | 74 // Returns the ConstrainedWebDialogDelegate saved with the WebContents. |
| 79 // Returns NULL if that property is not set. | 75 // Returns NULL if no such delegate is set. |
| 80 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); | 76 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); |
| 81 | 77 |
| 82 private: | 78 private: |
| 83 // JS Message Handler | 79 // JS Message Handler |
| 84 void OnDialogCloseMessage(const base::ListValue* args); | 80 void OnDialogCloseMessage(const base::ListValue* args); |
| 85 | 81 |
| 86 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); | 82 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); |
| 87 }; | 83 }; |
| 88 | 84 |
| 89 // Create a constrained HTML dialog. The actual object that gets created | 85 // Create a constrained HTML dialog. The actual object that gets created |
| 90 // is a ConstrainedWebDialogDelegate, which later triggers construction of a | 86 // is a ConstrainedWebDialogDelegate, which later triggers construction of a |
| 91 // ConstrainedWebDialogUI object. | 87 // ConstrainedWebDialogUI object. |
| 92 // |profile| is used to construct the constrained HTML dialog's WebContents. | 88 // |profile| is used to construct the constrained HTML dialog's WebContents. |
| 93 // |delegate| controls the behavior of the dialog. | 89 // |delegate| controls the behavior of the dialog. |
| 94 // |tab_delegate| is optional, pass one in to use a custom | 90 // |tab_delegate| is optional, pass one in to use a custom |
| 95 // WebDialogWebContentsDelegate with the dialog, or NULL to | 91 // WebDialogWebContentsDelegate with the dialog, or NULL to |
| 96 // use the default one. The dialog takes ownership of | 92 // use the default one. The dialog takes ownership of |
| 97 // |tab_delegate|. | 93 // |tab_delegate|. |
| 98 // |overshadowed| is the tab being overshadowed by the dialog. | 94 // |overshadowed| is the tab being overshadowed by the dialog. |
| 99 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 95 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
| 100 Profile* profile, | 96 Profile* profile, |
| 101 WebDialogDelegate* delegate, | 97 WebDialogDelegate* delegate, |
| 102 WebDialogWebContentsDelegate* tab_delegate, | 98 WebDialogWebContentsDelegate* tab_delegate, |
| 103 TabContents* overshadowed); | 99 TabContents* overshadowed); |
| 104 | 100 |
| 105 } // namespace ui | 101 } // namespace ui |
| 106 | 102 |
| 107 #endif // UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ | 103 #endif // UI_WEB_DIALOGS_CONSTRAINED_WEB_DIALOG_UI_H_ |
| OLD | NEW |