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