| 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/bindings_utils.h" | 5 #include "chrome/renderer/extensions/bindings_utils.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return NULL; | 58 return NULL; |
| 59 | 59 |
| 60 return extensions->GetByURL(url); | 60 return extensions->GetByURL(url); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool ExtensionBase::CheckPermissionForCurrentContext( | 63 bool ExtensionBase::CheckPermissionForCurrentContext( |
| 64 const std::string& function_name) const { | 64 const std::string& function_name) const { |
| 65 const ::Extension* extension = GetExtensionForCurrentContext(); | 65 const ::Extension* extension = GetExtensionForCurrentContext(); |
| 66 if (extension && | 66 if (extension && |
| 67 extension_dispatcher_->IsExtensionActive(extension->id()) && | 67 extension_dispatcher_->IsExtensionActive(extension->id()) && |
| 68 extension->HasApiPermission(function_name)) | 68 extension->HasAPIPermission(function_name)) |
| 69 return true; | 69 return true; |
| 70 | 70 |
| 71 static const char kMessage[] = | 71 static const char kMessage[] = |
| 72 "You do not have permission to use '%s'. Be sure to declare" | 72 "You do not have permission to use '%s'. Be sure to declare" |
| 73 " in your manifest what permissions you need."; | 73 " in your manifest what permissions you need."; |
| 74 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 74 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 75 | 75 |
| 76 v8::ThrowException(v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 76 v8::ThrowException(v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 77 return false; | 77 return false; |
| 78 } | 78 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 214 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 215 if (!function.IsEmpty()) | 215 if (!function.IsEmpty()) |
| 216 return function->Call(v8::Object::New(), argc, argv); | 216 return function->Call(v8::Object::New(), argc, argv); |
| 217 | 217 |
| 218 return v8::Undefined(); | 218 return v8::Undefined(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace bindings_utils | 221 } // namespace bindings_utils |
| OLD | NEW |