| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return v8::FunctionTemplate::New(SetIconCommon, | 196 return v8::FunctionTemplate::New(SetIconCommon, |
| 197 v8::External::New(this)); | 197 v8::External::New(this)); |
| 198 } else if (name->Equals(v8::String::New("GetUniqueSubEventName"))) { | 198 } else if (name->Equals(v8::String::New("GetUniqueSubEventName"))) { |
| 199 return v8::FunctionTemplate::New(GetUniqueSubEventName); | 199 return v8::FunctionTemplate::New(GetUniqueSubEventName); |
| 200 } else if (name->Equals(v8::String::New("GetLocalFileSystem"))) { | 200 } else if (name->Equals(v8::String::New("GetLocalFileSystem"))) { |
| 201 return v8::FunctionTemplate::New(GetLocalFileSystem); | 201 return v8::FunctionTemplate::New(GetLocalFileSystem); |
| 202 } else if (name->Equals(v8::String::New("DecodeJPEG"))) { | 202 } else if (name->Equals(v8::String::New("DecodeJPEG"))) { |
| 203 return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); | 203 return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); |
| 204 } else if (name->Equals(v8::String::New("CreateBlob"))) { | 204 } else if (name->Equals(v8::String::New("CreateBlob"))) { |
| 205 return v8::FunctionTemplate::New(CreateBlob, v8::External::New(this)); | 205 return v8::FunctionTemplate::New(CreateBlob, v8::External::New(this)); |
| 206 } else if (name->Equals(v8::String::New("SendResponseAck"))) { |
| 207 return v8::FunctionTemplate::New(SendResponseAck, |
| 208 v8::External::New(this)); |
| 206 } | 209 } |
| 207 | 210 |
| 208 return ChromeV8Extension::GetNativeFunction(name); | 211 return ChromeV8Extension::GetNativeFunction(name); |
| 209 } | 212 } |
| 210 | 213 |
| 211 private: | 214 private: |
| 212 static v8::Handle<v8::Value> GetExtensionAPIDefinition( | 215 static v8::Handle<v8::Value> GetExtensionAPIDefinition( |
| 213 const v8::Arguments& args) { | 216 const v8::Arguments& args) { |
| 214 return v8::String::NewExternal( | 217 return v8::String::NewExternal( |
| 215 new StaticV8ExternalAsciiStringResource( | 218 new StaticV8ExternalAsciiStringResource( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 static v8::Handle<v8::Value> CreateBlob(const v8::Arguments& args) { | 369 static v8::Handle<v8::Value> CreateBlob(const v8::Arguments& args) { |
| 367 CHECK(args.Length() == 2); | 370 CHECK(args.Length() == 2); |
| 368 CHECK(args[0]->IsString()); | 371 CHECK(args[0]->IsString()); |
| 369 CHECK(args[1]->IsInt32()); | 372 CHECK(args[1]->IsInt32()); |
| 370 WebKit::WebString path(UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); | 373 WebKit::WebString path(UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); |
| 371 WebKit::WebBlob blob = | 374 WebKit::WebBlob blob = |
| 372 WebKit::WebBlob::createFromFile(path, args[1]->Int32Value()); | 375 WebKit::WebBlob::createFromFile(path, args[1]->Int32Value()); |
| 373 return blob.toV8Value(); | 376 return blob.toV8Value(); |
| 374 } | 377 } |
| 375 | 378 |
| 379 static v8::Handle<v8::Value> SendResponseAck(const v8::Arguments& args) { |
| 380 CHECK(args.Length() == 1); |
| 381 CHECK(args[0]->IsInt32()); |
| 382 |
| 383 content::RenderView* render_view = GetCurrentRenderView(); |
| 384 if (render_view) { |
| 385 render_view->Send(new ExtensionHostMsg_ResponseAck( |
| 386 render_view->GetRoutingId(), args[0]->Int32Value())); |
| 387 } |
| 388 return v8::Undefined(); |
| 389 } |
| 390 |
| 376 // Creates a new messaging channel to the tab with the given ID. | 391 // Creates a new messaging channel to the tab with the given ID. |
| 377 static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) { | 392 static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) { |
| 378 // Get the current RenderView so that we can send a routed IPC message from | 393 // Get the current RenderView so that we can send a routed IPC message from |
| 379 // the correct source. | 394 // the correct source. |
| 380 content::RenderView* renderview = GetCurrentRenderView(); | 395 content::RenderView* renderview = GetCurrentRenderView(); |
| 381 if (!renderview) | 396 if (!renderview) |
| 382 return v8::Undefined(); | 397 return v8::Undefined(); |
| 383 | 398 |
| 384 if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() && | 399 if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() && |
| 385 args[2]->IsString()) { | 400 args[2]->IsString()) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // static | 671 // static |
| 657 bool ExtensionProcessBindings::HasPendingRequests( | 672 bool ExtensionProcessBindings::HasPendingRequests( |
| 658 const std::string& extension_id) { | 673 const std::string& extension_id) { |
| 659 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); | 674 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); |
| 660 it != g_pending_requests.Get().end(); ++it) { | 675 it != g_pending_requests.Get().end(); ++it) { |
| 661 if (it->second->extension_id == extension_id) | 676 if (it->second->extension_id == extension_id) |
| 662 return true; | 677 return true; |
| 663 } | 678 } |
| 664 return false; | 679 return false; |
| 665 } | 680 } |
| OLD | NEW |