| OLD | NEW |
| 1 // Copyright (c) 2012 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_EXTENSIONS_MESSAGING_BINDINGS_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_MESSAGING_BINDINGS_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_MESSAGING_BINDINGS_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_MESSAGING_BINDINGS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/renderer/extensions/chrome_v8_context_set.h" | 10 #include "extensions/renderer/script_context_set.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class DictionaryValue; | 13 class DictionaryValue; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class RenderView; | 17 class RenderView; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace v8 { | 20 namespace v8 { |
| 21 class Extension; | 21 class Extension; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 class ChromeV8Extension; | |
| 26 class Dispatcher; | 25 class Dispatcher; |
| 27 struct Message; | 26 struct Message; |
| 27 class ObjectBackedNativeHandler; |
| 28 | 28 |
| 29 // Manually implements JavaScript bindings for extension messaging. | 29 // Manually implements JavaScript bindings for extension messaging. |
| 30 // | 30 // |
| 31 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings. | 31 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings. |
| 32 // If anything needs to be manual for some reason, it should be implemented in | 32 // If anything needs to be manual for some reason, it should be implemented in |
| 33 // its own class. | 33 // its own class. |
| 34 class MessagingBindings { | 34 class MessagingBindings { |
| 35 public: | 35 public: |
| 36 // Creates an instance of the extension. | 36 // Creates an instance of the extension. |
| 37 static ChromeV8Extension* Get(Dispatcher* dispatcher, | 37 static ObjectBackedNativeHandler* Get(Dispatcher* dispatcher, |
| 38 ChromeV8Context* context); | 38 ScriptContext* context); |
| 39 | 39 |
| 40 // Dispatches the onConnect content script messaging event to some contexts | 40 // Dispatches the onConnect content script messaging event to some contexts |
| 41 // in |contexts|. If |restrict_to_render_view| is specified, only contexts in | 41 // in |contexts|. If |restrict_to_render_view| is specified, only contexts in |
| 42 // that render view will receive the message. | 42 // that render view will receive the message. |
| 43 static void DispatchOnConnect( | 43 static void DispatchOnConnect(const ScriptContextSet::ContextSet& contexts, |
| 44 const ChromeV8ContextSet::ContextSet& contexts, | 44 int target_port_id, |
| 45 int target_port_id, | 45 const std::string& channel_name, |
| 46 const std::string& channel_name, | 46 const base::DictionaryValue& source_tab, |
| 47 const base::DictionaryValue& source_tab, | 47 const std::string& source_extension_id, |
| 48 const std::string& source_extension_id, | 48 const std::string& target_extension_id, |
| 49 const std::string& target_extension_id, | 49 const GURL& source_url, |
| 50 const GURL& source_url, | 50 const std::string& tls_channel_id, |
| 51 const std::string& tls_channel_id, | 51 content::RenderView* restrict_to_render_view); |
| 52 content::RenderView* restrict_to_render_view); | |
| 53 | 52 |
| 54 // Delivers a message sent using content script messaging to some of the | 53 // Delivers a message sent using content script messaging to some of the |
| 55 // contexts in |bindings_context_set|. If |restrict_to_render_view| is | 54 // contexts in |bindings_context_set|. If |restrict_to_render_view| is |
| 56 // specified, only contexts in that render view will receive the message. | 55 // specified, only contexts in that render view will receive the message. |
| 57 static void DeliverMessage( | 56 static void DeliverMessage(const ScriptContextSet::ContextSet& context_set, |
| 58 const ChromeV8ContextSet::ContextSet& context_set, | 57 int target_port_id, |
| 59 int target_port_id, | 58 const Message& message, |
| 60 const Message& message, | 59 content::RenderView* restrict_to_render_view); |
| 61 content::RenderView* restrict_to_render_view); | |
| 62 | 60 |
| 63 // Dispatches the onDisconnect event in response to the channel being closed. | 61 // Dispatches the onDisconnect event in response to the channel being closed. |
| 64 static void DispatchOnDisconnect( | 62 static void DispatchOnDisconnect( |
| 65 const ChromeV8ContextSet::ContextSet& context_set, | 63 const ScriptContextSet::ContextSet& context_set, |
| 66 int port_id, | 64 int port_id, |
| 67 const std::string& error_message, | 65 const std::string& error_message, |
| 68 content::RenderView* restrict_to_render_view); | 66 content::RenderView* restrict_to_render_view); |
| 69 }; | 67 }; |
| 70 | 68 |
| 71 } // namespace extensions | 69 } // namespace extensions |
| 72 | 70 |
| 73 #endif // CHROME_RENDERER_EXTENSIONS_MESSAGING_BINDINGS_H_ | 71 #endif // CHROME_RENDERER_EXTENSIONS_MESSAGING_BINDINGS_H_ |
| OLD | NEW |