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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 317 } |
318 | 318 |
319 // Decodes supplied JPEG byte array to image pixel array. | 319 // Decodes supplied JPEG byte array to image pixel array. |
320 static v8::Handle<v8::Value> DecodeJPEG(const v8::Arguments& args) { | 320 static v8::Handle<v8::Value> DecodeJPEG(const v8::Arguments& args) { |
321 static const char* kAllowedIds[] = { | 321 static const char* kAllowedIds[] = { |
322 "haiffjcadagjlijoggckpgfnoeiflnem", | 322 "haiffjcadagjlijoggckpgfnoeiflnem", |
323 "gnedhmakppccajfpfiihfcdlnpgomkcf", | 323 "gnedhmakppccajfpfiihfcdlnpgomkcf", |
324 "fjcibdnjlbfnbfdjneajpipnlcppleek", | 324 "fjcibdnjlbfnbfdjneajpipnlcppleek", |
325 "oflbaaikkabfdfkimeclgkackhdkpnip" // Testing extension. | 325 "oflbaaikkabfdfkimeclgkackhdkpnip" // Testing extension. |
326 }; | 326 }; |
327 static const std::vector<std::string> allowed_ids( | |
328 kAllowedIds, kAllowedIds + arraysize(kAllowedIds)); | |
329 | 327 |
330 ExtensionImpl* v8_extension = GetFromArguments<ExtensionImpl>(args); | 328 ExtensionImpl* v8_extension = GetFromArguments<ExtensionImpl>(args); |
331 const ::Extension* extension = | 329 const ::Extension* extension = |
332 v8_extension->GetExtensionForCurrentRenderView(); | 330 v8_extension->GetExtensionForCurrentRenderView(); |
333 if (!extension) | 331 if (!extension) |
334 return v8::Undefined(); | 332 return v8::Undefined(); |
335 if (allowed_ids.end() == std::find( | 333 if (kAllowedIds + arraysize(kAllowedIds) == std::find( |
336 allowed_ids.begin(), allowed_ids.end(), extension->id())) { | 334 kAllowedIds, kAllowedIds + arraysize(kAllowedIds), extension->id())) { |
337 return v8::Undefined(); | 335 return v8::Undefined(); |
338 } | 336 } |
339 | 337 |
340 DCHECK(args.Length() == 1); | 338 DCHECK(args.Length() == 1); |
341 DCHECK(args[0]->IsArray()); | 339 DCHECK(args[0]->IsArray()); |
342 v8::Local<v8::Object> jpeg_array = args[0]->ToObject(); | 340 v8::Local<v8::Object> jpeg_array = args[0]->ToObject(); |
343 size_t jpeg_length = | 341 size_t jpeg_length = |
344 jpeg_array->Get(v8::String::New("length"))->Int32Value(); | 342 jpeg_array->Get(v8::String::New("length"))->Int32Value(); |
345 | 343 |
346 // Put input JPEG array into string for DecodeImage(). | 344 // Put input JPEG array into string for DecodeImage(). |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 const std::string& extension_id) { | 686 const std::string& extension_id) { |
689 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); | 687 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); |
690 it != g_pending_requests.Get().end(); ++it) { | 688 it != g_pending_requests.Get().end(); ++it) { |
691 if (it->second->extension_id == extension_id) | 689 if (it->second->extension_id == extension_id) |
692 return true; | 690 return true; |
693 } | 691 } |
694 return false; | 692 return false; |
695 } | 693 } |
696 | 694 |
697 } // namespace | 695 } // namespace |
OLD | NEW |