| OLD | NEW |
| 1 // Copyright (c) 2011 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_RENDERER_EXTERNAL_HOST_BINDINGS_H_ | 5 #ifndef CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ |
| 6 #define CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ | 6 #define CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 #include "webkit/glue/cpp_bound_class.h" | 10 #include "webkit/glue/cpp_bound_class.h" |
| 11 | 11 |
| 12 // ExternalHostBindings is the class backing the "externalHost" object | 12 // ExternalHostBindings is the class backing the "externalHost" object |
| 13 // accessible from Javascript | 13 // accessible from Javascript |
| 14 // | 14 // |
| 15 // We expose one function, for sending a message to the external host: | 15 // We expose one function, for sending a message to the external host: |
| 16 // postMessage(String message[, String target]); | 16 // postMessage(String message[, String target]); |
| 17 class ExternalHostBindings : public CppBoundClass { | 17 class ExternalHostBindings : public webkit_glue::CppBoundClass { |
| 18 public: | 18 public: |
| 19 ExternalHostBindings(IPC::Message::Sender* sender, int routing_id); | 19 ExternalHostBindings(IPC::Message::Sender* sender, int routing_id); |
| 20 virtual ~ExternalHostBindings(); | 20 virtual ~ExternalHostBindings(); |
| 21 | 21 |
| 22 // Invokes the registered onmessage handler. | 22 // Invokes the registered onmessage handler. |
| 23 // Returns true on successful invocation. | 23 // Returns true on successful invocation. |
| 24 bool ForwardMessageFromExternalHost(const std::string& message, | 24 bool ForwardMessageFromExternalHost(const std::string& message, |
| 25 const std::string& origin, | 25 const std::string& origin, |
| 26 const std::string& target); | 26 const std::string& target); |
| 27 | 27 |
| 28 // Overridden to hold onto a pointer back to the web frame. | 28 // Overridden to hold onto a pointer back to the web frame. |
| 29 void BindToJavascript(WebKit::WebFrame* frame, const std::string& classname); | 29 void BindToJavascript(WebKit::WebFrame* frame, const std::string& classname); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 // Creates an uninitialized instance of a MessageEvent object. | 32 // Creates an uninitialized instance of a MessageEvent object. |
| 33 // This is equivalent to calling window.document.createEvent("MessageEvent") | 33 // This is equivalent to calling window.document.createEvent("MessageEvent") |
| 34 // in javascript. | 34 // in javascript. |
| 35 bool CreateMessageEvent(NPObject** message_event); | 35 bool CreateMessageEvent(NPObject** message_event); |
| 36 | 36 |
| 37 // The postMessage() function provided to Javascript. | 37 // The postMessage() function provided to Javascript. |
| 38 void PostMessage(const CppArgumentList& args, CppVariant* result); | 38 void PostMessage(const webkit_glue::CppArgumentList& args, |
| 39 webkit_glue::CppVariant* result); |
| 39 | 40 |
| 40 CppVariant on_message_handler_; | 41 webkit_glue::CppVariant on_message_handler_; |
| 41 WebKit::WebFrame* frame_; | 42 WebKit::WebFrame* frame_; |
| 42 IPC::Message::Sender* sender_; | 43 IPC::Message::Sender* sender_; |
| 43 int routing_id_; | 44 int routing_id_; |
| 44 | 45 |
| 45 DISALLOW_COPY_AND_ASSIGN(ExternalHostBindings); | 46 DISALLOW_COPY_AND_ASSIGN(ExternalHostBindings); |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 #endif // CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ | 49 #endif // CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ |
| OLD | NEW |