| 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/runtime_custom_bindings.h" | 5 #include "chrome/renderer/extensions/runtime_custom_bindings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Get the current RenderView so that we can send a routed IPC message from | 62 // Get the current RenderView so that we can send a routed IPC message from |
| 63 // the correct source. | 63 // the correct source. |
| 64 content::RenderView* renderview = GetCurrentRenderView(); | 64 content::RenderView* renderview = GetCurrentRenderView(); |
| 65 if (!renderview) | 65 if (!renderview) |
| 66 return v8::Undefined(); | 66 return v8::Undefined(); |
| 67 | 67 |
| 68 // The Javascript code should validate/fill the arguments. | 68 // The Javascript code should validate/fill the arguments. |
| 69 CHECK(args.Length() >= 3 && | 69 CHECK(args.Length() >= 3 && |
| 70 args[0]->IsString() && | 70 args[0]->IsString() && |
| 71 args[1]->IsString() && | 71 args[1]->IsString() && |
| 72 args[2]->IsString() && | 72 args[2]->IsString()); |
| 73 args[3]->IsString()); | |
| 74 | 73 |
| 75 std::string extension_id = *v8::String::Utf8Value(args[0]->ToString()); | 74 std::string extension_id = *v8::String::Utf8Value(args[0]->ToString()); |
| 76 std::string native_app_name = *v8::String::Utf8Value(args[1]->ToString()); | 75 std::string native_app_name = *v8::String::Utf8Value(args[1]->ToString()); |
| 77 std::string channel_name = *v8::String::Utf8Value(args[2]->ToString()); | 76 std::string channel_name = *v8::String::Utf8Value(args[2]->ToString()); |
| 78 std::string connect_message = *v8::String::Utf8Value(args[3]->ToString()); | |
| 79 | 77 |
| 80 int port_id = -1; | 78 int port_id = -1; |
| 81 renderview->Send(new ExtensionHostMsg_OpenChannelToNativeApp( | 79 renderview->Send(new ExtensionHostMsg_OpenChannelToNativeApp( |
| 82 renderview->GetRoutingID(), | 80 renderview->GetRoutingID(), |
| 83 extension_id, | 81 extension_id, |
| 84 native_app_name, | 82 native_app_name, |
| 85 channel_name, | 83 channel_name, |
| 86 connect_message, | |
| 87 &port_id)); | 84 &port_id)); |
| 88 return v8::Integer::New(port_id); | 85 return v8::Integer::New(port_id); |
| 89 } | 86 } |
| 90 | 87 |
| 91 v8::Handle<v8::Value> RuntimeCustomBindings::GetManifest( | 88 v8::Handle<v8::Value> RuntimeCustomBindings::GetManifest( |
| 92 const v8::Arguments& args) { | 89 const v8::Arguments& args) { |
| 93 CHECK(context_->extension()); | 90 CHECK(context_->extension()); |
| 94 | 91 |
| 95 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 92 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 96 return converter->ToV8Value(context_->extension()->manifest()->value(), | 93 return converter->ToV8Value(context_->extension()->manifest()->value(), |
| 97 context_->v8_context()); | 94 context_->v8_context()); |
| 98 } | 95 } |
| 99 | 96 |
| 100 } // extensions | 97 } // extensions |
| OLD | NEW |