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

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

Issue 15855010: Make ExtensionMsg_MessageInvoke run a module system function rather than a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: go Created 7 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 | 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/extension_helper.h" 5 #include "chrome/renderer/extensions/extension_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/extension_messages.h" 16 #include "chrome/common/extensions/extension_messages.h"
16 #include "chrome/common/render_messages.h" 17 #include "chrome/common/render_messages.h"
17 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
18 #include "chrome/renderer/extensions/chrome_v8_context.h" 19 #include "chrome/renderer/extensions/chrome_v8_context.h"
19 #include "chrome/renderer/extensions/console.h" 20 #include "chrome/renderer/extensions/console.h"
20 #include "chrome/renderer/extensions/dispatcher.h" 21 #include "chrome/renderer/extensions/dispatcher.h"
21 #include "chrome/renderer/extensions/miscellaneous_bindings.h" 22 #include "chrome/renderer/extensions/miscellaneous_bindings.h"
22 #include "chrome/renderer/extensions/user_script_scheduler.h" 23 #include "chrome/renderer/extensions/user_script_scheduler.h"
23 #include "chrome/renderer/extensions/user_script_slave.h" 24 #include "chrome/renderer/extensions/user_script_slave.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 bool success, 244 bool success,
244 const base::ListValue& response, 245 const base::ListValue& response,
245 const std::string& error) { 246 const std::string& error) {
246 dispatcher_->OnExtensionResponse(request_id, 247 dispatcher_->OnExtensionResponse(request_id,
247 success, 248 success,
248 response, 249 response,
249 error); 250 error);
250 } 251 }
251 252
252 void ExtensionHelper::OnExtensionMessageInvoke(const std::string& extension_id, 253 void ExtensionHelper::OnExtensionMessageInvoke(const std::string& extension_id,
254 const std::string& module_name,
253 const std::string& function_name, 255 const std::string& function_name,
254 const base::ListValue& args, 256 const base::ListValue& args,
255 bool user_gesture) { 257 bool user_gesture) {
256 scoped_ptr<WebScopedUserGesture> web_user_gesture; 258 scoped_ptr<WebScopedUserGesture> web_user_gesture;
257 if (user_gesture) { 259 if (user_gesture)
258 web_user_gesture.reset(new WebScopedUserGesture); 260 web_user_gesture.reset(new WebScopedUserGesture);
259 } 261 dispatcher_->v8_context_set().ForEach(
koz (OOO until 15th September) 2013/05/31 04:28:44 It feels a little weird to have to pass Dispatcher
not at google - send to devlin 2013/05/31 22:47:07 I had decided to do it this way because there were
260 262 extension_id,
261 dispatcher_->v8_context_set().DispatchChromeHiddenMethod( 263 render_view(),
262 extension_id, function_name, args, render_view()); 264 base::Bind(&Dispatcher::CallModuleMethod,
265 module_name,
266 function_name,
267 &args));
263 } 268 }
264 269
265 void ExtensionHelper::OnExtensionDispatchOnConnect( 270 void ExtensionHelper::OnExtensionDispatchOnConnect(
266 int target_port_id, 271 int target_port_id,
267 const std::string& channel_name, 272 const std::string& channel_name,
268 const base::DictionaryValue& source_tab, 273 const base::DictionaryValue& source_tab,
269 const ExtensionMsg_ExternalConnectionInfo& info) { 274 const ExtensionMsg_ExternalConnectionInfo& info) {
270 MiscellaneousBindings::DispatchOnConnect( 275 MiscellaneousBindings::DispatchOnConnect(
271 dispatcher_->v8_context_set().GetAll(), 276 dispatcher_->v8_context_set().GetAll(),
272 target_port_id, channel_name, source_tab, 277 target_port_id, channel_name, source_tab,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 362 }
358 363
359 void ExtensionHelper::OnAppWindowClosed() { 364 void ExtensionHelper::OnAppWindowClosed() {
360 v8::HandleScope scope; 365 v8::HandleScope scope;
361 v8::Handle<v8::Context> script_context = 366 v8::Handle<v8::Context> script_context =
362 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); 367 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext();
363 ChromeV8Context* chrome_v8_context = 368 ChromeV8Context* chrome_v8_context =
364 dispatcher_->v8_context_set().GetByV8Context(script_context); 369 dispatcher_->v8_context_set().GetByV8Context(script_context);
365 if (!chrome_v8_context) 370 if (!chrome_v8_context)
366 return; 371 return;
367 chrome_v8_context->CallChromeHiddenMethod("OnAppWindowClosed", 0, NULL, NULL); 372 chrome_v8_context->module_system()->CallModuleMethod(
373 "app.window", "onAppWindowClosed");
368 } 374 }
369 375
370 } // namespace extensions 376 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698