| 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/custom_bindings_util.h" | 5 #include "chrome/renderer/extensions/custom_bindings_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/common/extensions/api/extension_api.h" |
| 11 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 13 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 13 #include "chrome/renderer/extensions/chrome_private_custom_bindings.h" | 14 #include "chrome/renderer/extensions/chrome_private_custom_bindings.h" |
| 14 #include "chrome/renderer/extensions/context_menus_custom_bindings.h" | 15 #include "chrome/renderer/extensions/context_menus_custom_bindings.h" |
| 15 #include "chrome/renderer/extensions/experimental.socket_custom_bindings.h" | 16 #include "chrome/renderer/extensions/experimental.socket_custom_bindings.h" |
| 16 #include "chrome/renderer/extensions/extension_custom_bindings.h" | 17 #include "chrome/renderer/extensions/extension_custom_bindings.h" |
| 17 #include "chrome/renderer/extensions/extension_dispatcher.h" | 18 #include "chrome/renderer/extensions/extension_dispatcher.h" |
| 18 #include "chrome/renderer/extensions/file_browser_handler_custom_bindings.h" | 19 #include "chrome/renderer/extensions/file_browser_handler_custom_bindings.h" |
| 19 #include "chrome/renderer/extensions/file_browser_private_custom_bindings.h" | 20 #include "chrome/renderer/extensions/file_browser_private_custom_bindings.h" |
| 20 #include "chrome/renderer/extensions/page_actions_custom_bindings.h" | 21 #include "chrome/renderer/extensions/page_actions_custom_bindings.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 next_to_upper = false; | 138 next_to_upper = false; |
| 138 } else { | 139 } else { |
| 139 camelcase.push_back(*it); | 140 camelcase.push_back(*it); |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 | 143 |
| 143 return camelcase; | 144 return camelcase; |
| 144 } | 145 } |
| 145 | 146 |
| 146 bool AllowAPIInjection(const std::string& api_name, | 147 bool AllowAPIInjection(const std::string& api_name, |
| 147 const Extension& extension) { | 148 const Extension& extension, |
| 149 bool is_content_script) { |
| 148 CHECK(api_name != ""); | 150 CHECK(api_name != ""); |
| 149 | 151 |
| 150 // As in ExtensionAPI::GetSchemasForExtension, we need to allow any bindings | 152 // As in ExtensionAPI::GetSchemasForExtension, we need to allow any bindings |
| 151 // for an API that the extension *might* have permission to use. | 153 // for an API that the extension *might* have permission to use. |
| 152 return extension.required_permission_set()->HasAnyAccessToAPI(api_name) || | 154 bool allowed = |
| 153 extension.optional_permission_set()->HasAnyAccessToAPI(api_name); | 155 extension.required_permission_set()->HasAnyAccessToAPI(api_name) || |
| 156 extension.optional_permission_set()->HasAnyAccessToAPI(api_name); |
| 157 |
| 158 if (allowed && is_content_script) |
| 159 allowed = !ExtensionAPI::GetInstance()->IsWholeAPIPrivileged(api_name); |
| 160 |
| 161 return allowed; |
| 154 } | 162 } |
| 155 | 163 |
| 156 } // namespace custom_bindings_util | 164 } // namespace custom_bindings_util |
| 157 | 165 |
| 158 } // namespace extensions | 166 } // namespace extensions |
| OLD | NEW |