OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_process_bindings.h" | 5 #include "chrome/renderer/extensions/extension_process_bindings.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 if (!v8_extension->CheckPermissionForCurrentContext(name)) | 409 if (!v8_extension->CheckPermissionForCurrentContext(name)) |
410 return v8::Undefined(); | 410 return v8::Undefined(); |
411 | 411 |
412 GURL source_url; | 412 GURL source_url; |
413 WebFrame* webframe = WebFrame::frameForCurrentContext(); | 413 WebFrame* webframe = WebFrame::frameForCurrentContext(); |
414 if (webframe) | 414 if (webframe) |
415 source_url = webframe->url(); | 415 source_url = webframe->url(); |
416 | 416 |
417 int request_id = args[2]->Int32Value(); | 417 int request_id = args[2]->Int32Value(); |
418 bool has_callback = args[3]->BooleanValue(); | 418 bool has_callback = args[3]->BooleanValue(); |
| 419 bool for_io_thread = args[4]->BooleanValue(); |
419 | 420 |
420 v8::Persistent<v8::Context> current_context = | 421 v8::Persistent<v8::Context> current_context = |
421 v8::Persistent<v8::Context>::New(v8::Context::GetCurrent()); | 422 v8::Persistent<v8::Context>::New(v8::Context::GetCurrent()); |
422 DCHECK(!current_context.IsEmpty()); | 423 DCHECK(!current_context.IsEmpty()); |
423 GetPendingRequestMap()[request_id].reset(new PendingRequest( | 424 GetPendingRequestMap()[request_id].reset(new PendingRequest( |
424 current_context, name)); | 425 current_context, name)); |
425 | 426 |
426 ExtensionHostMsg_Request_Params params; | 427 ExtensionHostMsg_Request_Params params; |
427 params.name = name; | 428 params.name = name; |
428 params.arguments.Swap(value_args); | 429 params.arguments.Swap(value_args); |
429 params.source_url = source_url; | 430 params.source_url = source_url; |
430 params.request_id = request_id; | 431 params.request_id = request_id; |
431 params.has_callback = has_callback; | 432 params.has_callback = has_callback; |
432 params.user_gesture = webframe->isProcessingUserGesture(); | 433 params.user_gesture = webframe->isProcessingUserGesture(); |
433 renderview->Send(new ExtensionHostMsg_Request( | 434 if (for_io_thread) { |
434 renderview->routing_id(), params)); | 435 renderview->Send(new ExtensionHostMsg_RequestForIOThread( |
| 436 renderview->routing_id(), params)); |
| 437 } else { |
| 438 renderview->Send(new ExtensionHostMsg_Request( |
| 439 renderview->routing_id(), params)); |
| 440 } |
435 | 441 |
436 return v8::Undefined(); | 442 return v8::Undefined(); |
437 } | 443 } |
438 | 444 |
439 // Starts an API request to the browser, with an optional callback. The | 445 // Starts an API request to the browser, with an optional callback. The |
440 // callback will be dispatched to EventBindings::HandleResponse. | 446 // callback will be dispatched to EventBindings::HandleResponse. |
441 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { | 447 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { |
442 std::string str_args = *v8::String::Utf8Value(args[1]); | 448 std::string str_args = *v8::String::Utf8Value(args[1]); |
443 base::JSONReader reader; | 449 base::JSONReader reader; |
444 scoped_ptr<Value> value_args; | 450 scoped_ptr<Value> value_args; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 580 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
575 std::string error = *v8::String::AsciiValue(retval); | 581 std::string error = *v8::String::AsciiValue(retval); |
576 DCHECK(false) << error; | 582 DCHECK(false) << error; |
577 } | 583 } |
578 #endif | 584 #endif |
579 | 585 |
580 request->second->context.Dispose(); | 586 request->second->context.Dispose(); |
581 request->second->context.Clear(); | 587 request->second->context.Clear(); |
582 pending_requests.erase(request); | 588 pending_requests.erase(request); |
583 } | 589 } |
OLD | NEW |