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_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // the correct source. | 51 // the correct source. |
52 content::RenderView* renderview = GetRenderView(); | 52 content::RenderView* renderview = GetRenderView(); |
53 if (!renderview) | 53 if (!renderview) |
54 return; | 54 return; |
55 | 55 |
56 // The Javascript code should validate/fill the arguments. | 56 // The Javascript code should validate/fill the arguments. |
57 CHECK_EQ(args.Length(), 3); | 57 CHECK_EQ(args.Length(), 3); |
58 CHECK(args[0]->IsString() && args[1]->IsString() && args[2]->IsBoolean()); | 58 CHECK(args[0]->IsString() && args[1]->IsString() && args[2]->IsBoolean()); |
59 | 59 |
60 ExtensionMsg_ExternalConnectionInfo info; | 60 ExtensionMsg_ExternalConnectionInfo info; |
61 info.source_id = context()->GetExtensionID(); | 61 |
| 62 // For messaging APIs, hosted apps should be considered a web page so hide |
| 63 // its extension ID. |
| 64 const Extension* extension = context()->extension(); |
| 65 if (extension && !extension->is_hosted_app()) |
| 66 info.source_id = extension->id(); |
| 67 |
62 info.target_id = *v8::String::Utf8Value(args[0]->ToString()); | 68 info.target_id = *v8::String::Utf8Value(args[0]->ToString()); |
63 info.source_url = context()->GetURL(); | 69 info.source_url = context()->GetURL(); |
64 std::string channel_name = *v8::String::Utf8Value(args[1]->ToString()); | 70 std::string channel_name = *v8::String::Utf8Value(args[1]->ToString()); |
65 bool include_tls_channel_id = | 71 bool include_tls_channel_id = |
66 args.Length() > 2 ? args[2]->BooleanValue() : false; | 72 args.Length() > 2 ? args[2]->BooleanValue() : false; |
67 int port_id = -1; | 73 int port_id = -1; |
68 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension( | 74 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension( |
69 renderview->GetRoutingID(), info, channel_name, include_tls_channel_id, | 75 renderview->GetRoutingID(), info, channel_name, include_tls_channel_id, |
70 &port_id)); | 76 &port_id)); |
71 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); | 77 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 v8::Local<v8::Value> window = context->Global(); | 174 v8::Local<v8::Value> window = context->Global(); |
169 DCHECK(!window.IsEmpty()); | 175 DCHECK(!window.IsEmpty()); |
170 v8_views->Set(v8::Integer::New(args.GetIsolate(), v8_index++), window); | 176 v8_views->Set(v8::Integer::New(args.GetIsolate(), v8_index++), window); |
171 } | 177 } |
172 } | 178 } |
173 | 179 |
174 args.GetReturnValue().Set(v8_views); | 180 args.GetReturnValue().Set(v8_views); |
175 } | 181 } |
176 | 182 |
177 } // namespace extensions | 183 } // namespace extensions |
OLD | NEW |