Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_WEB_DIALOGS_WEB_DIALOG_UI_H_ | |
| 6 #define UI_WEB_DIALOGS_WEB_DIALOG_UI_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/string16.h" | |
| 13 #include "content/public/browser/web_contents_delegate.h" | |
| 14 #include "content/public/browser/web_ui_controller.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 #include "ui/base/ui_base_types.h" | |
| 17 #include "ui/web_dialogs/web_dialogs_export.h" | |
| 18 | |
| 19 | |
| 20 namespace base { | |
| 21 class ListValue; | |
| 22 template<class T> class PropertyAccessor; | |
| 23 } | |
| 24 | |
| 25 namespace content { | |
| 26 class WebContents; | |
| 27 class WebUIMessageHandler; | |
| 28 struct ContextMenuParams; | |
| 29 } | |
| 30 | |
| 31 namespace gfx { | |
| 32 class Size; | |
| 33 } | |
| 34 | |
| 35 namespace web_dialogs { | |
|
tfarina
2012/05/04 18:12:21
Just to note, web_dialogs seems not a good namespa
| |
| 36 | |
| 37 class WebDialogDelegate; | |
| 38 | |
| 39 // Displays file URL contents inside a modal web dialog. | |
| 40 // | |
| 41 // This application really should not use WebContents + WebUI. It should instead | |
| 42 // just embed a RenderView in a dialog and be done with it. | |
| 43 // | |
| 44 // Before loading a URL corresponding to this WebUI, the caller should set its | |
| 45 // delegate as a property on the WebContents. This WebUI will pick it up from | |
| 46 // there and call it back. This is a bit of a hack to allow the dialog to pass | |
| 47 // its delegate to the Web UI without having nasty accessors on the WebContents. | |
| 48 // The correct design using RVH directly would avoid all of this. | |
| 49 class WEB_DIALOGS_EXPORT WebDialogUI : public content::WebUIController { | |
| 50 public: | |
| 51 struct WebDialogParams { | |
| 52 // The URL for the content that will be loaded in the dialog. | |
| 53 GURL url; | |
| 54 // Width of the dialog. | |
| 55 int width; | |
| 56 // Height of the dialog. | |
| 57 int height; | |
| 58 // The JSON input to pass to the dialog when showing it. | |
| 59 std::string json_input; | |
| 60 }; | |
| 61 | |
| 62 // When created, the property should already be set on the WebContents. | |
| 63 explicit WebDialogUI(content::WebUI* web_ui); | |
| 64 virtual ~WebDialogUI(); | |
| 65 | |
| 66 // Close the dialog, passing the specified arguments to the close handler. | |
| 67 void CloseDialog(const base::ListValue* args); | |
| 68 | |
| 69 // Returns the PropertyBag accessor object used to write the delegate pointer | |
| 70 // into the WebContents (see class-level comment above). | |
| 71 static base::PropertyAccessor<WebDialogDelegate*>& GetPropertyAccessor(); | |
| 72 | |
| 73 private: | |
| 74 // WebUIController | |
| 75 virtual void RenderViewCreated( | |
| 76 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 77 | |
| 78 // JS message handler. | |
| 79 void OnDialogClosed(const base::ListValue* args); | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(WebDialogUI); | |
| 82 }; | |
| 83 | |
| 84 } // namespace web_dialogs | |
| 85 #endif // UI_WEB_DIALOGS_WEB_DIALOG_UI_H_ | |
| OLD | NEW |