| 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 CONTENT_RENDERER_WEB_UI_BINDINGS_H_ | |
| 6 #define CONTENT_RENDERER_WEB_UI_BINDINGS_H_ | |
| 7 | |
| 8 #include "content/common/content_export.h" | |
| 9 #include "ipc/ipc_sender.h" | |
| 10 #include "webkit/glue/cpp_bound_class.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 // A DOMBoundBrowserObject is a backing for some object bound to the window | |
| 15 // in JS that knows how to dispatch messages to an associated c++ object living | |
| 16 // in the browser process. | |
| 17 class DOMBoundBrowserObject : public webkit_glue::CppBoundClass { | |
| 18 public: | |
| 19 CONTENT_EXPORT DOMBoundBrowserObject(); | |
| 20 CONTENT_EXPORT virtual ~DOMBoundBrowserObject(); | |
| 21 | |
| 22 // Sets a property with the given name and value. | |
| 23 void SetProperty(const std::string& name, const std::string& value); | |
| 24 | |
| 25 private: | |
| 26 // The list of properties that have been set. We keep track of this so we | |
| 27 // can free them on destruction. | |
| 28 typedef std::vector<webkit_glue::CppVariant*> PropertyList; | |
| 29 PropertyList properties_; | |
| 30 | |
| 31 DISALLOW_COPY_AND_ASSIGN(DOMBoundBrowserObject); | |
| 32 }; | |
| 33 | |
| 34 // WebUIBindings is the class backing the "chrome" object accessible | |
| 35 // from Javascript from privileged pages. | |
| 36 // | |
| 37 // We expose one function, for sending a message to the browser: | |
| 38 // send(String name, Object argument); | |
| 39 // It's plumbed through to the OnWebUIMessage callback on RenderViewHost | |
| 40 // delegate. | |
| 41 class WebUIBindings : public DOMBoundBrowserObject { | |
| 42 public: | |
| 43 WebUIBindings(IPC::Sender* sender, int routing_id); | |
| 44 virtual ~WebUIBindings(); | |
| 45 | |
| 46 private: | |
| 47 // The send() function provided to Javascript. | |
| 48 void Send(const webkit_glue::CppArgumentList& args, | |
| 49 webkit_glue::CppVariant* result); | |
| 50 | |
| 51 IPC::Sender* sender_; | |
| 52 int routing_id_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(WebUIBindings); | |
| 55 }; | |
| 56 | |
| 57 } // namespace content | |
| 58 | |
| 59 #endif // CONTENT_RENDERER_WEB_UI_BINDINGS_H_ | |
| OLD | NEW |