| 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_HTML_DIALOG_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "content/browser/webui/web_ui.h" | 13 #include "content/browser/webui/web_ui.h" |
| 14 #include "content/public/browser/web_ui_controller.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
| 16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 17 | 18 |
| 18 struct ContextMenuParams; | 19 struct ContextMenuParams; |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class ListValue; | 22 class ListValue; |
| 22 template<class T> class PropertyAccessor; | 23 template<class T> class PropertyAccessor; |
| 23 } | 24 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Displays file URL contents inside a modal HTML dialog. | 89 // Displays file URL contents inside a modal HTML dialog. |
| 89 // | 90 // |
| 90 // This application really should not use WebContents + WebUI. It should instead | 91 // This application really should not use WebContents + WebUI. It should instead |
| 91 // just embed a RenderView in a dialog and be done with it. | 92 // just embed a RenderView in a dialog and be done with it. |
| 92 // | 93 // |
| 93 // Before loading a URL corresponding to this WebUI, the caller should set its | 94 // Before loading a URL corresponding to this WebUI, the caller should set its |
| 94 // delegate as a property on the WebContents. This WebUI will pick it up from | 95 // delegate as a property on the WebContents. This WebUI will pick it up from |
| 95 // there and call it back. This is a bit of a hack to allow the dialog to pass | 96 // there and call it back. This is a bit of a hack to allow the dialog to pass |
| 96 // its delegate to the Web UI without having nasty accessors on the WebContents. | 97 // its delegate to the Web UI without having nasty accessors on the WebContents. |
| 97 // The correct design using RVH directly would avoid all of this. | 98 // The correct design using RVH directly would avoid all of this. |
| 98 class HtmlDialogUI : public WebUI { | 99 class HtmlDialogUI : public WebUI, public content::WebUIController { |
| 99 public: | 100 public: |
| 100 struct HtmlDialogParams { | 101 struct HtmlDialogParams { |
| 101 // The URL for the content that will be loaded in the dialog. | 102 // The URL for the content that will be loaded in the dialog. |
| 102 GURL url; | 103 GURL url; |
| 103 // Width of the dialog. | 104 // Width of the dialog. |
| 104 int width; | 105 int width; |
| 105 // Height of the dialog. | 106 // Height of the dialog. |
| 106 int height; | 107 int height; |
| 107 // The JSON input to pass to the dialog when showing it. | 108 // The JSON input to pass to the dialog when showing it. |
| 108 std::string json_input; | 109 std::string json_input; |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 // When created, the property should already be set on the WebContents. | 112 // When created, the property should already be set on the WebContents. |
| 112 explicit HtmlDialogUI(content::WebContents* web_contents); | 113 explicit HtmlDialogUI(content::WebContents* web_contents); |
| 113 virtual ~HtmlDialogUI(); | 114 virtual ~HtmlDialogUI(); |
| 114 | 115 |
| 115 // Close the dialog, passing the specified arguments to the close handler. | 116 // Close the dialog, passing the specified arguments to the close handler. |
| 116 void CloseDialog(const base::ListValue* args); | 117 void CloseDialog(const base::ListValue* args); |
| 117 | 118 |
| 118 // Returns the PropertyBag accessor object used to write the delegate pointer | 119 // Returns the PropertyBag accessor object used to write the delegate pointer |
| 119 // into the WebContents (see class-level comment above). | 120 // into the WebContents (see class-level comment above). |
| 120 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); | 121 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); |
| 121 | 122 |
| 122 private: | 123 private: |
| 123 // WebUI | 124 // WebUIController |
| 124 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 125 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 125 | 126 |
| 126 // JS message handler. | 127 // JS message handler. |
| 127 void OnDialogClosed(const base::ListValue* args); | 128 void OnDialogClosed(const base::ListValue* args); |
| 128 | 129 |
| 129 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); | 130 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 // Displays external URL contents inside a modal HTML dialog. | 133 // Displays external URL contents inside a modal HTML dialog. |
| 133 // | 134 // |
| 134 // Intended to be the place to collect the settings and lockdowns | 135 // Intended to be the place to collect the settings and lockdowns |
| 135 // necessary for running external UI components securely (e.g., the | 136 // necessary for running external UI components securely (e.g., the |
| 136 // cloud print dialog). | 137 // cloud print dialog). |
| 137 class ExternalHtmlDialogUI : public HtmlDialogUI { | 138 class ExternalHtmlDialogUI : public HtmlDialogUI { |
| 138 public: | 139 public: |
| 139 explicit ExternalHtmlDialogUI(content::WebContents* web_contents); | 140 explicit ExternalHtmlDialogUI(content::WebContents* web_contents); |
| 140 virtual ~ExternalHtmlDialogUI(); | 141 virtual ~ExternalHtmlDialogUI(); |
| 141 }; | 142 }; |
| 142 | 143 |
| 143 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ | 144 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
| OLD | NEW |