| 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/schema_generated_bindings.h" | 5 #include "chrome/renderer/extensions/schema_generated_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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return v8::FunctionTemplate::New(SetIconCommon, | 206 return v8::FunctionTemplate::New(SetIconCommon, |
| 207 v8::External::New(this)); | 207 v8::External::New(this)); |
| 208 } else if (name->Equals(v8::String::New("GetUniqueSubEventName"))) { | 208 } else if (name->Equals(v8::String::New("GetUniqueSubEventName"))) { |
| 209 return v8::FunctionTemplate::New(GetUniqueSubEventName); | 209 return v8::FunctionTemplate::New(GetUniqueSubEventName); |
| 210 } else if (name->Equals(v8::String::New("GetLocalFileSystem"))) { | 210 } else if (name->Equals(v8::String::New("GetLocalFileSystem"))) { |
| 211 return v8::FunctionTemplate::New(GetLocalFileSystem); | 211 return v8::FunctionTemplate::New(GetLocalFileSystem); |
| 212 } else if (name->Equals(v8::String::New("DecodeJPEG"))) { | 212 } else if (name->Equals(v8::String::New("DecodeJPEG"))) { |
| 213 return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); | 213 return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); |
| 214 } else if (name->Equals(v8::String::New("CreateBlob"))) { | 214 } else if (name->Equals(v8::String::New("CreateBlob"))) { |
| 215 return v8::FunctionTemplate::New(CreateBlob, v8::External::New(this)); | 215 return v8::FunctionTemplate::New(CreateBlob, v8::External::New(this)); |
| 216 } else if (name->Equals(v8::String::New("SendResponseAck"))) { |
| 217 return v8::FunctionTemplate::New(SendResponseAck, |
| 218 v8::External::New(this)); |
| 216 } | 219 } |
| 217 | 220 |
| 218 return ChromeV8Extension::GetNativeFunction(name); | 221 return ChromeV8Extension::GetNativeFunction(name); |
| 219 } | 222 } |
| 220 | 223 |
| 221 private: | 224 private: |
| 222 static v8::Handle<v8::Value> GetExtensionAPIDefinition( | 225 static v8::Handle<v8::Value> GetExtensionAPIDefinition( |
| 223 const v8::Arguments& args) { | 226 const v8::Arguments& args) { |
| 224 ExtensionImpl* self = GetFromArguments<ExtensionImpl>(args); | 227 ExtensionImpl* self = GetFromArguments<ExtensionImpl>(args); |
| 225 if (!self->extension_api_.IsEmpty()) | 228 if (!self->extension_api_.IsEmpty()) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 static v8::Handle<v8::Value> CreateBlob(const v8::Arguments& args) { | 393 static v8::Handle<v8::Value> CreateBlob(const v8::Arguments& args) { |
| 391 CHECK(args.Length() == 2); | 394 CHECK(args.Length() == 2); |
| 392 CHECK(args[0]->IsString()); | 395 CHECK(args[0]->IsString()); |
| 393 CHECK(args[1]->IsInt32()); | 396 CHECK(args[1]->IsInt32()); |
| 394 WebKit::WebString path(UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); | 397 WebKit::WebString path(UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); |
| 395 WebKit::WebBlob blob = | 398 WebKit::WebBlob blob = |
| 396 WebKit::WebBlob::createFromFile(path, args[1]->Int32Value()); | 399 WebKit::WebBlob::createFromFile(path, args[1]->Int32Value()); |
| 397 return blob.toV8Value(); | 400 return blob.toV8Value(); |
| 398 } | 401 } |
| 399 | 402 |
| 403 static v8::Handle<v8::Value> SendResponseAck(const v8::Arguments& args) { |
| 404 CHECK(args.Length() == 1); |
| 405 CHECK(args[0]->IsInt32()); |
| 406 |
| 407 content::RenderView* render_view = GetCurrentRenderView(); |
| 408 if (render_view) { |
| 409 render_view->Send(new ExtensionHostMsg_ResponseAck( |
| 410 render_view->GetRoutingId(), args[0]->Int32Value())); |
| 411 } |
| 412 return v8::Undefined(); |
| 413 } |
| 414 |
| 400 // Creates a new messaging channel to the tab with the given ID. | 415 // Creates a new messaging channel to the tab with the given ID. |
| 401 static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) { | 416 static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) { |
| 402 // Get the current RenderView so that we can send a routed IPC message from | 417 // Get the current RenderView so that we can send a routed IPC message from |
| 403 // the correct source. | 418 // the correct source. |
| 404 content::RenderView* renderview = GetCurrentRenderView(); | 419 content::RenderView* renderview = GetCurrentRenderView(); |
| 405 if (!renderview) | 420 if (!renderview) |
| 406 return v8::Undefined(); | 421 return v8::Undefined(); |
| 407 | 422 |
| 408 if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() && | 423 if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() && |
| 409 args[2]->IsString()) { | 424 args[2]->IsString()) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 const std::string& extension_id) { | 703 const std::string& extension_id) { |
| 689 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); | 704 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); |
| 690 it != g_pending_requests.Get().end(); ++it) { | 705 it != g_pending_requests.Get().end(); ++it) { |
| 691 if (it->second->extension_id == extension_id) | 706 if (it->second->extension_id == extension_id) |
| 692 return true; | 707 return true; |
| 693 } | 708 } |
| 694 return false; | 709 return false; |
| 695 } | 710 } |
| 696 | 711 |
| 697 } // namespace | 712 } // namespace |
| OLD | NEW |