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 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "content/public/browser/web_ui_controller.h" | 12 #include "content/public/browser/web_ui_controller.h" |
11 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
12 | 14 |
13 namespace gfx { | 15 namespace gfx { |
14 class Size; | 16 class Size; |
15 } | 17 } |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 class BrowserContext; | 20 class BrowserContext; |
19 class WebContents; | 21 class WebContents; |
20 } | 22 } |
21 | 23 |
22 namespace ui { | 24 namespace ui { |
23 class WebDialogDelegate; | 25 class WebDialogDelegate; |
24 } | 26 } |
25 | 27 |
26 class ConstrainedWebDialogDelegate { | 28 class ConstrainedWebDialogDelegate { |
27 public: | 29 public: |
28 virtual const ui::WebDialogDelegate* GetWebDialogDelegate() const = 0; | 30 virtual const ui::WebDialogDelegate* GetWebDialogDelegate() const = 0; |
29 virtual ui::WebDialogDelegate* GetWebDialogDelegate() = 0; | 31 virtual ui::WebDialogDelegate* GetWebDialogDelegate() = 0; |
30 | 32 |
31 // Called when the dialog is being closed in response to a "dialogClose" | 33 // Called when the dialog is being closed in response to a "dialogClose" |
32 // message from WebUI. | 34 // message from WebUI. |
33 virtual void OnDialogCloseFromWebUI() = 0; | 35 virtual void OnDialogCloseFromWebUI() = 0; |
34 | 36 |
35 // If called, on dialog closure, the dialog will release its WebContents | 37 // If called, the dialog will release the ownership of its WebContents. |
36 // instead of destroying it. After which point, the caller will own the | 38 // The dialog will continue to use it until it is destroyed. |
37 // released WebContents. | 39 virtual std::unique_ptr<content::WebContents> ReleaseWebContents() = 0; |
38 virtual void ReleaseWebContentsOnDialogClose() = 0; | |
39 | 40 |
40 // Returns the WebContents owned by the constrained window. | 41 // Returns the WebContents owned by the constrained window. |
41 virtual content::WebContents* GetWebContents() = 0; | 42 virtual content::WebContents* GetWebContents() = 0; |
42 | 43 |
43 // Returns the native type used to display the dialog. | 44 // Returns the native type used to display the dialog. |
44 virtual gfx::NativeWindow GetNativeDialog() = 0; | 45 virtual gfx::NativeWindow GetNativeDialog() = 0; |
45 | 46 |
46 // Returns the minimum size for the dialog. | 47 // Returns the minimum size for the dialog. |
47 virtual gfx::Size GetMinimumSize() const = 0; | 48 virtual gfx::Size GetMinimumSize() const = 0; |
48 | 49 |
(...skipping 18 matching lines...) Expand all Loading... |
67 public: | 68 public: |
68 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); | 69 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); |
69 ~ConstrainedWebDialogUI() override; | 70 ~ConstrainedWebDialogUI() override; |
70 | 71 |
71 // WebUIController implementation: | 72 // WebUIController implementation: |
72 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | 73 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
73 | 74 |
74 // Sets the delegate on the WebContents. | 75 // Sets the delegate on the WebContents. |
75 static void SetConstrainedDelegate(content::WebContents* web_contents, | 76 static void SetConstrainedDelegate(content::WebContents* web_contents, |
76 ConstrainedWebDialogDelegate* delegate); | 77 ConstrainedWebDialogDelegate* delegate); |
| 78 static void ClearConstrainedDelegate(content::WebContents* web_contents); |
77 | 79 |
78 protected: | 80 protected: |
79 // Returns the ConstrainedWebDialogDelegate saved with the WebContents. | 81 // Returns the ConstrainedWebDialogDelegate saved with the WebContents. |
80 // Returns NULL if no such delegate is set. | 82 // Returns NULL if no such delegate is set. |
81 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); | 83 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); |
82 | 84 |
83 private: | 85 private: |
84 // JS Message Handler | 86 // JS Message Handler |
85 void OnDialogCloseMessage(const base::ListValue* args); | 87 void OnDialogCloseMessage(const base::ListValue* args); |
86 | 88 |
(...skipping 21 matching lines...) Expand all Loading... |
108 // |min_size| is the minimum size of the dialog. | 110 // |min_size| is the minimum size of the dialog. |
109 // |max_size| is the maximum size of the dialog. | 111 // |max_size| is the maximum size of the dialog. |
110 ConstrainedWebDialogDelegate* ShowConstrainedWebDialogWithAutoResize( | 112 ConstrainedWebDialogDelegate* ShowConstrainedWebDialogWithAutoResize( |
111 content::BrowserContext* browser_context, | 113 content::BrowserContext* browser_context, |
112 ui::WebDialogDelegate* delegate, | 114 ui::WebDialogDelegate* delegate, |
113 content::WebContents* overshadowed, | 115 content::WebContents* overshadowed, |
114 const gfx::Size& min_size, | 116 const gfx::Size& min_size, |
115 const gfx::Size& max_size); | 117 const gfx::Size& max_size); |
116 | 118 |
117 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ | 119 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
OLD | NEW |