Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: extensions/renderer/runtime_custom_bindings.cc

Issue 2006013002: [Extensions] Determine NativeMessaging ID solely on the browser process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ;; Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/extension_messages.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « extensions/common/extension_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698