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.
5 #ifndef CONTENT_RENDERER_WEB_UI_BINDINGS_H_
6 #define CONTENT_RENDERER_WEB_UI_BINDINGS_H_
8 #include "content/common/content_export.h"
9 #include "ipc/ipc_sender.h"
10 #include "webkit/glue/cpp_bound_class.h"
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
{
17 CONTENT_EXPORT
DOMBoundBrowserObject();
18 CONTENT_EXPORT
virtual ~DOMBoundBrowserObject();
20 // Sets a property with the given name and value.
21 void SetProperty(const std::string
& name
, const std::string
& value
);
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_
;
29 DISALLOW_COPY_AND_ASSIGN(DOMBoundBrowserObject
);
32 // WebUIBindings is the class backing the "chrome" object accessible
33 // from Javascript from privileged pages.
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
39 class WebUIBindings
: public DOMBoundBrowserObject
{
41 WebUIBindings(IPC::Sender
* sender
, int routing_id
);
42 virtual ~WebUIBindings();
45 // The send() function provided to Javascript.
46 void Send(const webkit_glue::CppArgumentList
& args
,
47 webkit_glue::CppVariant
* result
);
52 DISALLOW_COPY_AND_ASSIGN(WebUIBindings
);
55 #endif // CONTENT_RENDERER_WEB_UI_BINDINGS_H_