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

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

Issue 15841013: Make miscellaneous_bindings and event_bindings Required as needed. Previously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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(
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,
273 info.source_id, info.target_id, info.source_url, 278 info.source_id, info.target_id, info.source_url,
274 render_view()); 279 render_view());
275 } 280 }
276 281
277 void ExtensionHelper::OnExtensionDeliverMessage(int target_id, 282 void ExtensionHelper::OnExtensionDeliverMessage(
278 const std::string& message) { 283 int target_id,
284 const base::ListValue& message) {
279 MiscellaneousBindings::DeliverMessage(dispatcher_->v8_context_set().GetAll(), 285 MiscellaneousBindings::DeliverMessage(dispatcher_->v8_context_set().GetAll(),
280 target_id, 286 target_id,
281 message, 287 message,
282 render_view()); 288 render_view());
283 } 289 }
284 290
285 void ExtensionHelper::OnExtensionDispatchOnDisconnect( 291 void ExtensionHelper::OnExtensionDispatchOnDisconnect(
286 int port_id, 292 int port_id,
287 const std::string& error_message) { 293 const std::string& error_message) {
288 MiscellaneousBindings::DispatchOnDisconnect( 294 MiscellaneousBindings::DispatchOnDisconnect(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 362 }
357 363
358 void ExtensionHelper::OnAppWindowClosed() { 364 void ExtensionHelper::OnAppWindowClosed() {
359 v8::HandleScope scope; 365 v8::HandleScope scope;
360 v8::Handle<v8::Context> script_context = 366 v8::Handle<v8::Context> script_context =
361 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); 367 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext();
362 ChromeV8Context* chrome_v8_context = 368 ChromeV8Context* chrome_v8_context =
363 dispatcher_->v8_context_set().GetByV8Context(script_context); 369 dispatcher_->v8_context_set().GetByV8Context(script_context);
364 if (!chrome_v8_context) 370 if (!chrome_v8_context)
365 return; 371 return;
366 chrome_v8_context->CallChromeHiddenMethod("OnAppWindowClosed", 0, NULL, NULL); 372 chrome_v8_context->module_system()->CallModuleMethod(
373 "app.window", "onAppWindowClosed");
367 } 374 }
368 375
369 } // namespace extensions 376 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_helper.h ('k') | chrome/renderer/extensions/miscellaneous_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698