OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "chrome/renderer/extensions/extension_process_bindings.h" | 10 #include "chrome/renderer/extensions/extension_process_bindings.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 | 409 |
410 return StartRequestCommon(args, value_args); | 410 return StartRequestCommon(args, value_args); |
411 } | 411 } |
412 | 412 |
413 // A special request for setting the extension action icon. This function | 413 // A special request for setting the extension action icon. This function |
414 // accepts a canvas ImageData object, so it needs to do extra processing | 414 // accepts a canvas ImageData object, so it needs to do extra processing |
415 // before sending the request to the browser. | 415 // before sending the request to the browser. |
416 static v8::Handle<v8::Value> SetExtensionActionIcon(const v8::Arguments& args)
{ | 416 static v8::Handle<v8::Value> SetExtensionActionIcon(const v8::Arguments& args)
{ |
417 v8::Local<v8::Object> details = args[1]->ToObject(); | 417 v8::Local<v8::Object> details = args[1]->ToObject(); |
418 int tab_id = details->Get(v8::String::New("tabId"))->Int32Value(); | |
419 v8::Local<v8::Object> image_data = | 418 v8::Local<v8::Object> image_data = |
420 details->Get(v8::String::New("imageData"))->ToObject(); | 419 details->Get(v8::String::New("imageData"))->ToObject(); |
421 v8::Local<v8::Object> data = | 420 v8::Local<v8::Object> data = |
422 image_data->Get(v8::String::New("data"))->ToObject(); | 421 image_data->Get(v8::String::New("data"))->ToObject(); |
423 int width = image_data->Get(v8::String::New("width"))->Int32Value(); | 422 int width = image_data->Get(v8::String::New("width"))->Int32Value(); |
424 int height = image_data->Get(v8::String::New("height"))->Int32Value(); | 423 int height = image_data->Get(v8::String::New("height"))->Int32Value(); |
425 | 424 |
426 int data_length = data->Get(v8::String::New("length"))->Int32Value(); | 425 int data_length = data->Get(v8::String::New("length"))->Int32Value(); |
427 if (data_length != 4 * width * height) { | 426 if (data_length != 4 * width * height) { |
428 NOTREACHED() << "Invalid argument to setIcon. Expecting ImageData."; | 427 NOTREACHED() << "Invalid argument to setIcon. Expecting ImageData."; |
(...skipping 16 matching lines...) Expand all Loading... |
445 } | 444 } |
446 | 445 |
447 // Construct the Value object. | 446 // Construct the Value object. |
448 IPC::Message bitmap_pickle; | 447 IPC::Message bitmap_pickle; |
449 IPC::WriteParam(&bitmap_pickle, bitmap); | 448 IPC::WriteParam(&bitmap_pickle, bitmap); |
450 Value* bitmap_value = BinaryValue::CreateWithCopiedBuffer( | 449 Value* bitmap_value = BinaryValue::CreateWithCopiedBuffer( |
451 static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size()); | 450 static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size()); |
452 | 451 |
453 DictionaryValue* dict = new DictionaryValue(); | 452 DictionaryValue* dict = new DictionaryValue(); |
454 dict->Set(L"imageData", bitmap_value); | 453 dict->Set(L"imageData", bitmap_value); |
455 dict->SetInteger(L"tabId", tab_id); | 454 |
| 455 if (details->Has(v8::String::New("tabId"))) { |
| 456 dict->SetInteger(L"tabId", |
| 457 details->Get(v8::String::New("tabId"))->Int32Value()); |
| 458 } |
456 | 459 |
457 return StartRequestCommon(args, dict); | 460 return StartRequestCommon(args, dict); |
458 } | 461 } |
459 | 462 |
460 static v8::Handle<v8::Value> GetRenderViewId(const v8::Arguments& args) { | 463 static v8::Handle<v8::Value> GetRenderViewId(const v8::Arguments& args) { |
461 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); | 464 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); |
462 if (!renderview) | 465 if (!renderview) |
463 return v8::Undefined(); | 466 return v8::Undefined(); |
464 return v8::Integer::New(renderview->routing_id()); | 467 return v8::Integer::New(renderview->routing_id()); |
465 } | 468 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 return; | 609 return; |
607 | 610 |
608 v8::HandleScope handle_scope; | 611 v8::HandleScope handle_scope; |
609 WebFrame* frame = view->mainFrame(); | 612 WebFrame* frame = view->mainFrame(); |
610 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); | 613 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
611 v8::Handle<v8::Value> argv[1]; | 614 v8::Handle<v8::Value> argv[1]; |
612 argv[0] = v8::String::New(type_str); | 615 argv[0] = v8::String::New(type_str); |
613 bindings_utils::CallFunctionInContext(context, "setViewType", | 616 bindings_utils::CallFunctionInContext(context, "setViewType", |
614 arraysize(argv), argv); | 617 arraysize(argv), argv); |
615 } | 618 } |
OLD | NEW |