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

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

Issue 672403002: Cleanup: Remove most enable_extensions logic in extensions code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android Created 6 years, 1 month 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/renderer/dom_activity_logger.cc ('k') | extensions/shell/BUILD.gn » ('j') | 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/messaging_bindings.h" 5 #include "extensions/renderer/messaging_bindings.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "content/public/renderer/render_thread.h" 16 #include "content/public/renderer/render_thread.h"
17 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
18 #include "content/public/renderer/v8_value_converter.h" 18 #include "content/public/renderer/v8_value_converter.h"
19 #include "extensions/common/api/messaging/message.h" 19 #include "extensions/common/api/messaging/message.h"
20 #include "extensions/common/extension_messages.h" 20 #include "extensions/common/extension_messages.h"
21 #include "extensions/common/manifest_handlers/externally_connectable.h"
21 #include "extensions/renderer/dispatcher.h" 22 #include "extensions/renderer/dispatcher.h"
22 #include "extensions/renderer/event_bindings.h" 23 #include "extensions/renderer/event_bindings.h"
23 #include "extensions/renderer/object_backed_native_handler.h" 24 #include "extensions/renderer/object_backed_native_handler.h"
24 #include "extensions/renderer/scoped_persistent.h" 25 #include "extensions/renderer/scoped_persistent.h"
25 #include "extensions/renderer/script_context.h" 26 #include "extensions/renderer/script_context.h"
26 #include "extensions/renderer/script_context_set.h" 27 #include "extensions/renderer/script_context_set.h"
27 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" 28 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
28 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" 29 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
29 #include "third_party/WebKit/public/web/WebScopedWindowFocusAllowedIndicator.h" 30 #include "third_party/WebKit/public/web/WebScopedWindowFocusAllowedIndicator.h"
30 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 31 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
31 #include "v8/include/v8.h" 32 #include "v8/include/v8.h"
32 33
33 // TODO(thestig): Remove #ifdef from this file when extensions are no longer
34 // used on mobile.
35 #if defined(ENABLE_EXTENSIONS)
36 #include "extensions/common/manifest_handlers/externally_connectable.h"
37 #endif
38
39 // Message passing API example (in a content script): 34 // Message passing API example (in a content script):
40 // var extension = 35 // var extension =
41 // new chrome.Extension('00123456789abcdef0123456789abcdef0123456'); 36 // new chrome.Extension('00123456789abcdef0123456789abcdef0123456');
42 // var port = runtime.connect(); 37 // var port = runtime.connect();
43 // port.postMessage('Can you hear me now?'); 38 // port.postMessage('Can you hear me now?');
44 // port.onmessage.addListener(function(msg, port) { 39 // port.onmessage.addListener(function(msg, port) {
45 // alert('response=' + msg); 40 // alert('response=' + msg);
46 // port.postMessage('I got your reponse'); 41 // port.postMessage('I got your reponse');
47 // }); 42 // });
48 43
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 std::string target_extension_id = script_context->GetExtensionID(); 254 std::string target_extension_id = script_context->GetExtensionID();
260 const Extension* extension = script_context->extension(); 255 const Extension* extension = script_context->extension();
261 256
262 v8::Handle<v8::Value> tab = v8::Null(isolate); 257 v8::Handle<v8::Value> tab = v8::Null(isolate);
263 v8::Handle<v8::Value> tls_channel_id_value = v8::Undefined(isolate); 258 v8::Handle<v8::Value> tls_channel_id_value = v8::Undefined(isolate);
264 259
265 if (extension) { 260 if (extension) {
266 if (!source_tab->empty() && !extension->is_platform_app()) 261 if (!source_tab->empty() && !extension->is_platform_app())
267 tab = converter->ToV8Value(source_tab, script_context->v8_context()); 262 tab = converter->ToV8Value(source_tab, script_context->v8_context());
268 263
269 #if defined(ENABLE_EXTENSIONS)
270 ExternallyConnectableInfo* externally_connectable = 264 ExternallyConnectableInfo* externally_connectable =
271 ExternallyConnectableInfo::Get(extension); 265 ExternallyConnectableInfo::Get(extension);
272 if (externally_connectable && 266 if (externally_connectable &&
273 externally_connectable->accepts_tls_channel_id) { 267 externally_connectable->accepts_tls_channel_id) {
274 tls_channel_id_value = v8::String::NewFromUtf8(isolate, 268 tls_channel_id_value = v8::String::NewFromUtf8(isolate,
275 tls_channel_id.c_str(), 269 tls_channel_id.c_str(),
276 v8::String::kNormalString, 270 v8::String::kNormalString,
277 tls_channel_id.size()); 271 tls_channel_id.size());
278 } 272 }
279 #endif
280 } 273 }
281 274
282 v8::Handle<v8::Value> arguments[] = { 275 v8::Handle<v8::Value> arguments[] = {
283 // portId 276 // portId
284 v8::Integer::New(isolate, target_port_id), 277 v8::Integer::New(isolate, target_port_id),
285 // channelName 278 // channelName
286 v8::String::NewFromUtf8(isolate, 279 v8::String::NewFromUtf8(isolate,
287 channel_name.c_str(), 280 channel_name.c_str(),
288 v8::String::kNormalString, 281 v8::String::kNormalString,
289 channel_name.size()), 282 channel_name.size()),
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 const ScriptContextSet& context_set, 418 const ScriptContextSet& context_set,
426 int port_id, 419 int port_id,
427 const std::string& error_message, 420 const std::string& error_message,
428 content::RenderView* restrict_to_render_view) { 421 content::RenderView* restrict_to_render_view) {
429 context_set.ForEach( 422 context_set.ForEach(
430 restrict_to_render_view, 423 restrict_to_render_view,
431 base::Bind(&DispatchOnDisconnectToScriptContext, port_id, error_message)); 424 base::Bind(&DispatchOnDisconnectToScriptContext, port_id, error_message));
432 } 425 }
433 426
434 } // namespace extensions 427 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dom_activity_logger.cc ('k') | extensions/shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698