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

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

Issue 23057005: In extension messaging, use the sender frame's URL as the sender URL rather (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test, rebase Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // the correct source. 47 // the correct source.
48 content::RenderView* renderview = GetRenderView(); 48 content::RenderView* renderview = GetRenderView();
49 if (!renderview) 49 if (!renderview)
50 return; 50 return;
51 51
52 // The Javascript code should validate/fill the arguments. 52 // The Javascript code should validate/fill the arguments.
53 CHECK_EQ(2, args.Length()); 53 CHECK_EQ(2, args.Length());
54 CHECK(args[0]->IsString() && args[1]->IsString()); 54 CHECK(args[0]->IsString() && args[1]->IsString());
55 55
56 ExtensionMsg_ExternalConnectionInfo info; 56 ExtensionMsg_ExternalConnectionInfo info;
57 info.source_id = context()->extension() ? context()->extension()->id() : ""; 57 info.source_id = context()->GetExtensionID();
58 info.target_id = *v8::String::Utf8Value(args[0]->ToString()); 58 info.target_id = *v8::String::Utf8Value(args[0]->ToString());
59 info.source_url = renderview->GetWebView()->mainFrame()->document().url(); 59 info.source_url = context()->GetURL();
60 std::string channel_name = *v8::String::Utf8Value(args[1]->ToString()); 60 std::string channel_name = *v8::String::Utf8Value(args[1]->ToString());
61 int port_id = -1; 61 int port_id = -1;
62 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension( 62 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension(
63 renderview->GetRoutingID(), info, channel_name, &port_id)); 63 renderview->GetRoutingID(), info, channel_name, &port_id));
64 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); 64 args.GetReturnValue().Set(static_cast<int32_t>(port_id));
65 } 65 }
66 66
67 void RuntimeCustomBindings::OpenChannelToNativeApp( 67 void RuntimeCustomBindings::OpenChannelToNativeApp(
68 const v8::FunctionCallbackInfo<v8::Value>& args) { 68 const v8::FunctionCallbackInfo<v8::Value>& args) {
69 // Verify that the extension has permission to use native messaging. 69 // Verify that the extension has permission to use native messaging.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const v8::FunctionCallbackInfo<v8::Value>& args) { 107 const v8::FunctionCallbackInfo<v8::Value>& args) {
108 CHECK(context()->extension()); 108 CHECK(context()->extension());
109 109
110 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 110 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
111 args.GetReturnValue().Set( 111 args.GetReturnValue().Set(
112 converter->ToV8Value(context()->extension()->manifest()->value(), 112 converter->ToV8Value(context()->extension()->manifest()->value(),
113 context()->v8_context())); 113 context()->v8_context()));
114 } 114 }
115 115
116 } // namespace extensions 116 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698