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/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" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 user_gesture); | 272 user_gesture); |
273 } | 273 } |
274 | 274 |
275 void ExtensionHelper::OnExtensionDispatchOnConnect( | 275 void ExtensionHelper::OnExtensionDispatchOnConnect( |
276 int target_port_id, | 276 int target_port_id, |
277 const std::string& channel_name, | 277 const std::string& channel_name, |
278 const base::DictionaryValue& source_tab, | 278 const base::DictionaryValue& source_tab, |
279 const ExtensionMsg_ExternalConnectionInfo& info, | 279 const ExtensionMsg_ExternalConnectionInfo& info, |
280 const std::string& tls_channel_id) { | 280 const std::string& tls_channel_id) { |
281 MessagingBindings::DispatchOnConnect( | 281 MessagingBindings::DispatchOnConnect( |
282 dispatcher_->v8_context_set().GetAll(), | 282 dispatcher_->script_context_set().GetAll(), |
283 target_port_id, channel_name, source_tab, | 283 target_port_id, |
284 info.source_id, info.target_id, info.source_url, | 284 channel_name, |
285 tls_channel_id, render_view()); | 285 source_tab, |
286 info.source_id, | |
287 info.target_id, | |
288 info.source_url, | |
289 tls_channel_id, | |
290 render_view()); | |
286 } | 291 } |
287 | 292 |
288 void ExtensionHelper::OnExtensionDeliverMessage(int target_id, | 293 void ExtensionHelper::OnExtensionDeliverMessage(int target_id, |
289 const Message& message) { | 294 const Message& message) { |
290 MessagingBindings::DeliverMessage(dispatcher_->v8_context_set().GetAll(), | 295 MessagingBindings::DeliverMessage(dispatcher_->script_context_set().GetAll(), |
291 target_id, | 296 target_id, |
292 message, | 297 message, |
293 render_view()); | 298 render_view()); |
294 } | 299 } |
295 | 300 |
296 void ExtensionHelper::OnExtensionDispatchOnDisconnect( | 301 void ExtensionHelper::OnExtensionDispatchOnDisconnect( |
297 int port_id, | 302 int port_id, |
298 const std::string& error_message) { | 303 const std::string& error_message) { |
299 MessagingBindings::DispatchOnDisconnect( | 304 MessagingBindings::DispatchOnDisconnect( |
300 dispatcher_->v8_context_set().GetAll(), | 305 dispatcher_->script_context_set().GetAll(), |
301 port_id, error_message, | 306 port_id, |
307 error_message, | |
302 render_view()); | 308 render_view()); |
303 } | 309 } |
304 | 310 |
305 void ExtensionHelper::OnExecuteCode( | 311 void ExtensionHelper::OnExecuteCode( |
306 const ExtensionMsg_ExecuteCode_Params& params) { | 312 const ExtensionMsg_ExecuteCode_Params& params) { |
307 WebView* webview = render_view()->GetWebView(); | 313 WebView* webview = render_view()->GetWebView(); |
308 WebFrame* main_frame = webview->mainFrame(); | 314 WebFrame* main_frame = webview->mainFrame(); |
309 if (!main_frame) { | 315 if (!main_frame) { |
310 base::ListValue val; | 316 base::ListValue val; |
311 Send(new ExtensionHostMsg_ExecuteCodeFinished(routing_id(), | 317 Send(new ExtensionHostMsg_ExecuteCodeFinished(routing_id(), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 browser_window_id_ = window_id; | 367 browser_window_id_ = window_id; |
362 } | 368 } |
363 | 369 |
364 void ExtensionHelper::OnAddMessageToConsole(ConsoleMessageLevel level, | 370 void ExtensionHelper::OnAddMessageToConsole(ConsoleMessageLevel level, |
365 const std::string& message) { | 371 const std::string& message) { |
366 console::AddMessage(render_view(), level, message); | 372 console::AddMessage(render_view(), level, message); |
367 } | 373 } |
368 | 374 |
369 void ExtensionHelper::OnAppWindowClosed() { | 375 void ExtensionHelper::OnAppWindowClosed() { |
370 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 376 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
371 v8::Handle<v8::Context> script_context = | 377 v8::Handle<v8::Context> v8_context = |
372 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 378 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); |
373 ChromeV8Context* chrome_v8_context = | 379 ScriptContext* script_context = |
374 dispatcher_->v8_context_set().GetByV8Context(script_context); | 380 dispatcher_->script_context_set().GetByV8Context(v8_context); |
375 if (!chrome_v8_context) | 381 if (!script_context) |
376 return; | 382 return; |
377 chrome_v8_context->module_system()->CallModuleMethod( | 383 script_context->module_system()->CallModuleMethod("app.window", |
378 "app.window", "onAppWindowClosed"); | 384 "onAppWindowClosed"); |
not at google - send to devlin
2014/04/17 15:11:10
this method looks unnecessary. it doesn't even nee
koz (OOO until 15th September)
2014/04/22 00:13:38
I think it's good to move away from calling JS met
not at google - send to devlin
2014/04/22 00:15:38
That makes sense.
| |
379 } | 385 } |
380 | 386 |
381 } // namespace extensions | 387 } // namespace extensions |
OLD | NEW |