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 #include "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 }; | 243 }; |
244 const size_t Extension::kNumHostedAppPermissions = | 244 const size_t Extension::kNumHostedAppPermissions = |
245 arraysize(Extension::kHostedAppPermissionNames); | 245 arraysize(Extension::kHostedAppPermissionNames); |
246 | 246 |
247 // We purposefully don't put this into kPermissionNames. | 247 // We purposefully don't put this into kPermissionNames. |
248 const char Extension::kOldUnlimitedStoragePermission[] = "unlimited_storage"; | 248 const char Extension::kOldUnlimitedStoragePermission[] = "unlimited_storage"; |
249 | 249 |
250 const int Extension::kValidWebExtentSchemes = | 250 const int Extension::kValidWebExtentSchemes = |
251 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; | 251 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; |
252 | 252 |
| 253 const int Extension::kValidHostPermissionSchemes = |
| 254 (UserScript::kValidUserScriptSchemes | |
| 255 URLPattern::SCHEME_CHROMEUI) & ~URLPattern::SCHEME_FILE; |
| 256 |
253 // | 257 // |
254 // Extension | 258 // Extension |
255 // | 259 // |
256 | 260 |
257 // static | 261 // static |
258 scoped_refptr<Extension> Extension::Create(const FilePath& path, | 262 scoped_refptr<Extension> Extension::Create(const FilePath& path, |
259 Location location, | 263 Location location, |
260 const DictionaryValue& value, | 264 const DictionaryValue& value, |
261 bool require_key, | 265 bool require_key, |
262 std::string* error) { | 266 std::string* error) { |
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 } else { | 1738 } else { |
1735 // Hosted apps only get access to a subset of the valid permissions. | 1739 // Hosted apps only get access to a subset of the valid permissions. |
1736 if (IsHostedAppPermission(permission_str)) { | 1740 if (IsHostedAppPermission(permission_str)) { |
1737 api_permissions_.insert(permission_str); | 1741 api_permissions_.insert(permission_str); |
1738 continue; | 1742 continue; |
1739 } | 1743 } |
1740 } | 1744 } |
1741 | 1745 |
1742 // Check if it's a host pattern permission. | 1746 // Check if it's a host pattern permission. |
1743 URLPattern pattern = URLPattern(CanExecuteScriptEverywhere() ? | 1747 URLPattern pattern = URLPattern(CanExecuteScriptEverywhere() ? |
1744 URLPattern::SCHEME_ALL : | 1748 URLPattern::SCHEME_ALL : kValidHostPermissionSchemes); |
1745 (UserScript::kValidUserScriptSchemes | | 1749 |
1746 URLPattern::SCHEME_CHROMEUI) & ~URLPattern::SCHEME_FILE); | |
1747 | 1750 |
1748 if (URLPattern::PARSE_SUCCESS == pattern.Parse(permission_str)) { | 1751 if (URLPattern::PARSE_SUCCESS == pattern.Parse(permission_str)) { |
1749 if (!CanSpecifyHostPermission(pattern)) { | 1752 if (!CanSpecifyHostPermission(pattern)) { |
1750 *error = ExtensionErrorUtils::FormatErrorMessage( | 1753 *error = ExtensionErrorUtils::FormatErrorMessage( |
1751 errors::kInvalidPermissionScheme, base::IntToString(i)); | 1754 errors::kInvalidPermissionScheme, base::IntToString(i)); |
1752 return false; | 1755 return false; |
1753 } | 1756 } |
1754 | 1757 |
1755 // The path component is not used for host permissions, so we force it | 1758 // The path component is not used for host permissions, so we force it |
1756 // to match all paths. | 1759 // to match all paths. |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 UninstalledExtensionInfo::UninstalledExtensionInfo( | 2236 UninstalledExtensionInfo::UninstalledExtensionInfo( |
2234 const Extension& extension) | 2237 const Extension& extension) |
2235 : extension_id(extension.id()), | 2238 : extension_id(extension.id()), |
2236 extension_api_permissions(extension.api_permissions()), | 2239 extension_api_permissions(extension.api_permissions()), |
2237 is_theme(extension.is_theme()), | 2240 is_theme(extension.is_theme()), |
2238 is_app(extension.is_app()), | 2241 is_app(extension.is_app()), |
2239 converted_from_user_script(extension.converted_from_user_script()), | 2242 converted_from_user_script(extension.converted_from_user_script()), |
2240 update_url(extension.update_url()) {} | 2243 update_url(extension.update_url()) {} |
2241 | 2244 |
2242 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2245 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
OLD | NEW |