| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_v8_extension.h" | 5 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 static const char kMessage[] = | 97 static const char kMessage[] = |
| 98 "You do not have permission to use '%s'. Be sure to declare" | 98 "You do not have permission to use '%s'. Be sure to declare" |
| 99 " in your manifest what permissions you need."; | 99 " in your manifest what permissions you need."; |
| 100 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 100 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 101 v8::ThrowException( | 101 v8::ThrowException( |
| 102 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 102 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 if (!extension_dispatcher_->IsExtensionActive(extension->id()) && | 106 if (!extension_dispatcher_->IsExtensionActive(extension->id()) && |
| 107 ExtensionAPI::GetInstance()->IsPrivileged(function_name)) { | 107 ExtensionAPI::GetSharedInstance()->IsPrivileged(function_name)) { |
| 108 static const char kMessage[] = | 108 static const char kMessage[] = |
| 109 "%s can only be used in an extension process."; | 109 "%s can only be used in an extension process."; |
| 110 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 110 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 111 v8::ThrowException( | 111 v8::ThrowException( |
| 112 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 112 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 return true; | 116 return true; |
| 117 } | 117 } |
| OLD | NEW |