| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/runtime_custom_bindings.h" | 5 #include "extensions/renderer/runtime_custom_bindings.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 CHECK(args[0]->IsString()); | 80 CHECK(args[0]->IsString()); |
| 81 | 81 |
| 82 // Verify that the extension has permission to use native messaging. | 82 // Verify that the extension has permission to use native messaging. |
| 83 if (!context()->GetAvailability("runtime.connectNative").is_available()) | 83 if (!context()->GetAvailability("runtime.connectNative").is_available()) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 content::RenderFrame* render_frame = context()->GetRenderFrame(); | 86 content::RenderFrame* render_frame = context()->GetRenderFrame(); |
| 87 if (!render_frame) | 87 if (!render_frame) |
| 88 return; | 88 return; |
| 89 | 89 |
| 90 const std::string& extension_id = context()->GetExtensionID(); | |
| 91 // Should be caught by JS. | |
| 92 CHECK(!extension_id.empty()); | |
| 93 | |
| 94 std::string native_app_name = *v8::String::Utf8Value(args[0]); | 90 std::string native_app_name = *v8::String::Utf8Value(args[0]); |
| 95 | 91 |
| 96 int port_id = -1; | 92 int port_id = -1; |
| 97 render_frame->Send(new ExtensionHostMsg_OpenChannelToNativeApp( | 93 render_frame->Send(new ExtensionHostMsg_OpenChannelToNativeApp( |
| 98 render_frame->GetRoutingID(), extension_id, native_app_name, &port_id)); | 94 render_frame->GetRoutingID(), native_app_name, &port_id)); |
| 99 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); | 95 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); |
| 100 } | 96 } |
| 101 | 97 |
| 102 void RuntimeCustomBindings::GetManifest( | 98 void RuntimeCustomBindings::GetManifest( |
| 103 const v8::FunctionCallbackInfo<v8::Value>& args) { | 99 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 104 CHECK(context()->extension()); | 100 CHECK(context()->extension()); |
| 105 | 101 |
| 106 std::unique_ptr<content::V8ValueConverter> converter( | 102 std::unique_ptr<content::V8ValueConverter> converter( |
| 107 content::V8ValueConverter::create()); | 103 content::V8ValueConverter::create()); |
| 108 args.GetReturnValue().Set(converter->ToV8Value( | 104 args.GetReturnValue().Set(converter->ToV8Value( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 v8::Maybe<bool> maybe = | 167 v8::Maybe<bool> maybe = |
| 172 v8_views->CreateDataProperty(v8_context, v8_index++, window); | 168 v8_views->CreateDataProperty(v8_context, v8_index++, window); |
| 173 CHECK(maybe.IsJust() && maybe.FromJust()); | 169 CHECK(maybe.IsJust() && maybe.FromJust()); |
| 174 } | 170 } |
| 175 } | 171 } |
| 176 | 172 |
| 177 args.GetReturnValue().Set(v8_views); | 173 args.GetReturnValue().Set(v8_views); |
| 178 } | 174 } |
| 179 | 175 |
| 180 } // namespace extensions | 176 } // namespace extensions |
| OLD | NEW |