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 #include "chrome/renderer/extensions/tabs_custom_bindings.h" | 5 #include "chrome/renderer/extensions/tabs_custom_bindings.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "content/public/renderer/render_frame.h" | 12 #include "content/public/renderer/render_frame.h" |
13 #include "extensions/common/extension_messages.h" | 13 #include "extensions/common/extension_messages.h" |
14 #include "extensions/renderer/script_context.h" | 14 #include "extensions/renderer/script_context.h" |
15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 TabsCustomBindings::TabsCustomBindings(ScriptContext* context) | 19 TabsCustomBindings::TabsCustomBindings(ScriptContext* context) |
20 : ObjectBackedNativeHandler(context) { | 20 : ObjectBackedNativeHandler(context) { |
21 RouteFunction("OpenChannelToTab", | 21 RouteFunction("OpenChannelToTab", "tabs", |
22 base::Bind(&TabsCustomBindings::OpenChannelToTab, | 22 base::Bind(&TabsCustomBindings::OpenChannelToTab, |
23 base::Unretained(this))); | 23 base::Unretained(this))); |
24 } | 24 } |
25 | 25 |
26 void TabsCustomBindings::OpenChannelToTab( | 26 void TabsCustomBindings::OpenChannelToTab( |
27 const v8::FunctionCallbackInfo<v8::Value>& args) { | 27 const v8::FunctionCallbackInfo<v8::Value>& args) { |
28 content::RenderFrame* render_frame = context()->GetRenderFrame(); | 28 content::RenderFrame* render_frame = context()->GetRenderFrame(); |
29 if (!render_frame) | 29 if (!render_frame) |
30 return; | 30 return; |
31 | 31 |
32 // tabs_custom_bindings.js unwraps arguments to tabs.connect/sendMessage and | 32 // tabs_custom_bindings.js unwraps arguments to tabs.connect/sendMessage and |
33 // passes them to OpenChannelToTab, in the following order: | 33 // passes them to OpenChannelToTab, in the following order: |
(...skipping 14 matching lines...) Expand all Loading... |
48 std::string extension_id = *v8::String::Utf8Value(args[2]); | 48 std::string extension_id = *v8::String::Utf8Value(args[2]); |
49 std::string channel_name = *v8::String::Utf8Value(args[3]); | 49 std::string channel_name = *v8::String::Utf8Value(args[3]); |
50 int port_id = -1; | 50 int port_id = -1; |
51 render_frame->Send(new ExtensionHostMsg_OpenChannelToTab( | 51 render_frame->Send(new ExtensionHostMsg_OpenChannelToTab( |
52 render_frame->GetRoutingID(), info, extension_id, channel_name, | 52 render_frame->GetRoutingID(), info, extension_id, channel_name, |
53 &port_id)); | 53 &port_id)); |
54 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); | 54 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); |
55 } | 55 } |
56 | 56 |
57 } // namespace extensions | 57 } // namespace extensions |
OLD | NEW |