| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Generates an extension ID from arbitrary input. The same input string will | 243 // Generates an extension ID from arbitrary input. The same input string will |
| 244 // always generate the same output ID. | 244 // always generate the same output ID. |
| 245 static bool GenerateId(const std::string& input, std::string* output); | 245 static bool GenerateId(const std::string& input, std::string* output); |
| 246 | 246 |
| 247 // Expects base64 encoded |input| and formats into |output| including | 247 // Expects base64 encoded |input| and formats into |output| including |
| 248 // the appropriate header & footer. | 248 // the appropriate header & footer. |
| 249 static bool FormatPEMForFileOutput(const std::string input, | 249 static bool FormatPEMForFileOutput(const std::string input, |
| 250 std::string* output, bool is_public); | 250 std::string* output, bool is_public); |
| 251 | 251 |
| 252 // Determine whether |new_extension| has increased privileges compared to | 252 // Determine whether |new_extension| has increased privileges compared to |
| 253 // |old_extension|. | 253 // |old_extension| and its previous |granted_apis| and |granted_extent|. |
| 254 static bool IsPrivilegeIncrease(const Extension* old_extension, | 254 // If |old_extension| is NULL, then new_extension is only compared against |
| 255 // |granted_apis| and |granted_extent|. |
| 256 static bool IsPrivilegeIncrease(const std::set<std::string>& granted_apis, |
| 257 const ExtensionExtent& granted_extent, |
| 258 const Extension* old_extension, |
| 255 const Extension* new_extension); | 259 const Extension* new_extension); |
| 256 | 260 |
| 257 // Given an extension and icon size, read it if present and decode it into | 261 // Given an extension and icon size, read it if present and decode it into |
| 258 // result. In the browser process, this will DCHECK if not called on the | 262 // result. In the browser process, this will DCHECK if not called on the |
| 259 // file thread. To easily load extension images on the UI thread, see | 263 // file thread. To easily load extension images on the UI thread, see |
| 260 // ImageLoadingTracker. | 264 // ImageLoadingTracker. |
| 261 static void DecodeIcon(const Extension* extension, | 265 static void DecodeIcon(const Extension* extension, |
| 262 Icons icon_size, | 266 Icons icon_size, |
| 263 scoped_ptr<SkBitmap>* result); | 267 scoped_ptr<SkBitmap>* result); |
| 264 | 268 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 294 UserScript* script, | 298 UserScript* script, |
| 295 std::string* error); | 299 std::string* error); |
| 296 | 300 |
| 297 // Adds an extension to the scripting whitelist. Used for testing only. | 301 // Adds an extension to the scripting whitelist. Used for testing only. |
| 298 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); | 302 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); |
| 299 | 303 |
| 300 // Returns true if the extension has the specified API permission. | 304 // Returns true if the extension has the specified API permission. |
| 301 static bool HasApiPermission(const std::set<std::string>& api_permissions, | 305 static bool HasApiPermission(const std::set<std::string>& api_permissions, |
| 302 const std::string& function_name); | 306 const std::string& function_name); |
| 303 | 307 |
| 308 // Whether the |effective_host_permissions| and |api_permissions| include |
| 309 // effective access to all hosts. See the non-static version of the method |
| 310 // for more details. |
| 311 static bool HasEffectiveAccessToAllHosts( |
| 312 const ExtensionExtent& effective_host_permissions, |
| 313 const std::set<std::string>& api_permissions); |
| 314 |
| 304 bool HasApiPermission(const std::string& function_name) const { | 315 bool HasApiPermission(const std::string& function_name) const { |
| 305 return HasApiPermission(this->api_permissions(), function_name); | 316 return HasApiPermission(this->api_permissions(), function_name); |
| 306 } | 317 } |
| 307 | 318 |
| 308 const ExtensionExtent& GetEffectiveHostPermissions() const { | 319 const ExtensionExtent& GetEffectiveHostPermissions() const { |
| 309 return effective_host_permissions_; | 320 return effective_host_permissions_; |
| 310 } | 321 } |
| 311 | 322 |
| 312 // Whether or not the extension is allowed permission for a URL pattern from | 323 // Whether or not the extension is allowed permission for a URL pattern from |
| 313 // the manifest. http, https, and chrome://favicon/ is allowed for all | 324 // the manifest. http, https, and chrome://favicon/ is allowed for all |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 std::set<std::string> extension_api_permissions; | 694 std::set<std::string> extension_api_permissions; |
| 684 // TODO(akalin): Once we have a unified ExtensionType, replace the | 695 // TODO(akalin): Once we have a unified ExtensionType, replace the |
| 685 // below member variables with a member of that type. | 696 // below member variables with a member of that type. |
| 686 bool is_theme; | 697 bool is_theme; |
| 687 bool is_app; | 698 bool is_app; |
| 688 bool converted_from_user_script; | 699 bool converted_from_user_script; |
| 689 GURL update_url; | 700 GURL update_url; |
| 690 }; | 701 }; |
| 691 | 702 |
| 692 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 703 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |