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