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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 | 260 |
261 const int Extension::kPageActionIconMaxSize = 19; | 261 const int Extension::kPageActionIconMaxSize = 19; |
262 const int Extension::kBrowserActionIconMaxSize = 19; | 262 const int Extension::kBrowserActionIconMaxSize = 19; |
263 | 263 |
264 const int Extension::kValidWebExtentSchemes = | 264 const int Extension::kValidWebExtentSchemes = |
265 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; | 265 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; |
266 | 266 |
267 const int Extension::kValidHostPermissionSchemes = | 267 const int Extension::kValidHostPermissionSchemes = |
268 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; | 268 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; |
269 | 269 |
270 Extension::Requirements::Requirements() | |
271 : webgl(false), | |
272 css3d(false), | |
273 plugins(false) { | |
274 } | |
275 | |
276 Extension::Requirements::~Requirements() {} | |
277 | |
270 Extension::InputComponentInfo::InputComponentInfo() | 278 Extension::InputComponentInfo::InputComponentInfo() |
271 : type(INPUT_COMPONENT_TYPE_NONE), | 279 : type(INPUT_COMPONENT_TYPE_NONE), |
272 shortcut_alt(false), | 280 shortcut_alt(false), |
273 shortcut_ctrl(false), | 281 shortcut_ctrl(false), |
274 shortcut_shift(false) { | 282 shortcut_shift(false) { |
275 } | 283 } |
276 | 284 |
277 Extension::InputComponentInfo::~InputComponentInfo() {} | 285 Extension::InputComponentInfo::~InputComponentInfo() {} |
278 | 286 |
279 Extension::TtsVoice::TtsVoice() {} | 287 Extension::TtsVoice::TtsVoice() {} |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1315 string16* error) { | 1323 string16* error) { |
1316 if (!LoadDescription(error) || | 1324 if (!LoadDescription(error) || |
1317 !LoadHomepageURL(error) || | 1325 !LoadHomepageURL(error) || |
1318 !LoadUpdateURL(error) || | 1326 !LoadUpdateURL(error) || |
1319 !LoadIcons(error) || | 1327 !LoadIcons(error) || |
1320 !LoadCommands(error) || | 1328 !LoadCommands(error) || |
1321 !LoadPlugins(error) || | 1329 !LoadPlugins(error) || |
1322 !LoadNaClModules(error) || | 1330 !LoadNaClModules(error) || |
1323 !LoadWebAccessibleResources(error) || | 1331 !LoadWebAccessibleResources(error) || |
1324 !LoadSandboxedPages(error) || | 1332 !LoadSandboxedPages(error) || |
1325 !CheckRequirements(error) || | 1333 !LoadRequirements(error) || |
1326 !LoadDefaultLocale(error) || | 1334 !LoadDefaultLocale(error) || |
1327 !LoadOfflineEnabled(error) || | 1335 !LoadOfflineEnabled(error) || |
1328 !LoadOptionsPage(error) || | 1336 !LoadOptionsPage(error) || |
1329 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). | 1337 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). |
1330 !LoadBackgroundScripts(error) || | 1338 !LoadBackgroundScripts(error) || |
1331 !LoadBackgroundPage(api_permissions, error) || | 1339 !LoadBackgroundPage(api_permissions, error) || |
1332 !LoadBackgroundPersistent(api_permissions, error) || | 1340 !LoadBackgroundPersistent(api_permissions, error) || |
1333 !LoadBackgroundAllowJSAccess(api_permissions, error) || | 1341 !LoadBackgroundAllowJSAccess(api_permissions, error) || |
1334 !LoadWebIntentServices(error) || | 1342 !LoadWebIntentServices(error) || |
1335 !LoadOAuth2Info(error)) | 1343 !LoadOAuth2Info(error)) |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1687 } else { | 1695 } else { |
1688 sandboxed_pages_content_security_policy_ = | 1696 sandboxed_pages_content_security_policy_ = |
1689 kDefaultSandboxedPageContentSecurityPolicy; | 1697 kDefaultSandboxedPageContentSecurityPolicy; |
1690 CHECK(ContentSecurityPolicyIsSandboxed( | 1698 CHECK(ContentSecurityPolicyIsSandboxed( |
1691 sandboxed_pages_content_security_policy_, GetType())); | 1699 sandboxed_pages_content_security_policy_, GetType())); |
1692 } | 1700 } |
1693 | 1701 |
1694 return true; | 1702 return true; |
1695 } | 1703 } |
1696 | 1704 |
1697 // These are not actually persisted (they're only used by the store), but | 1705 bool Extension::LoadRequirements(string16* error) { |
1698 // still validated. | |
1699 bool Extension::CheckRequirements(string16* error) { | |
1700 if (!manifest_->HasKey(keys::kRequirements)) | 1706 if (!manifest_->HasKey(keys::kRequirements)) |
1701 return true; | 1707 return true; |
1702 DictionaryValue* requirements_value = NULL; | 1708 DictionaryValue* requirements_value = NULL; |
1703 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) { | 1709 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) { |
1704 *error = ASCIIToUTF16(errors::kInvalidRequirements); | 1710 *error = ASCIIToUTF16(errors::kInvalidRequirements); |
1705 return false; | 1711 return false; |
1706 } | 1712 } |
1707 | 1713 |
1708 for (DictionaryValue::key_iterator it = requirements_value->begin_keys(); | 1714 for (DictionaryValue::key_iterator it = requirements_value->begin_keys(); |
1709 it != requirements_value->end_keys(); ++it) { | 1715 it != requirements_value->end_keys(); ++it) { |
1710 DictionaryValue* requirement_value; | 1716 DictionaryValue* requirement_value; |
1711 if (!requirements_value->GetDictionaryWithoutPathExpansion( | 1717 if (!requirements_value->GetDictionaryWithoutPathExpansion( |
1712 *it, &requirement_value)) { | 1718 *it, |
1719 &requirement_value)) { | |
Aaron Boodman
2012/08/06 20:36:07
nit: previous indentation style was fine.
eaugusti
2012/08/17 23:25:01
Done.
| |
1713 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 1720 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
1714 errors::kInvalidRequirement, *it); | 1721 errors::kInvalidRequirement, *it); |
1715 return false; | 1722 return false; |
1716 } | 1723 } |
1724 | |
1725 if (*it == "plugins") { | |
1726 requirements_.plugins = true; | |
1727 } else if (*it == "3D") { | |
1728 ListValue* features; | |
Aaron Boodman
2012/08/06 20:36:07
= NULL;
eaugusti
2012/08/17 23:25:01
Done.
| |
1729 if (!requirement_value->GetListWithoutPathExpansion("features", | |
1730 &features) || | |
1731 !features) { | |
1732 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | |
1733 errors::kInvalidRequirement, *it); | |
1734 return false; | |
1735 } | |
1736 | |
1737 for (base::ListValue::iterator feature_it = features->begin(); | |
1738 feature_it != features->end(); | |
1739 ++feature_it) { | |
1740 std::string feature; | |
1741 if ((*feature_it)->GetAsString(&feature)) { | |
1742 if (feature == "webgl") { | |
1743 requirements_.webgl = true; | |
1744 } else if (feature == "css3d") { | |
1745 requirements_.css3d = true; | |
1746 } else { | |
1747 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | |
1748 errors::kInvalidRequirement, *it); | |
1749 return false; | |
1750 } | |
1751 } | |
1752 } | |
1753 } else { | |
1754 *error = ASCIIToUTF16(errors::kInvalidRequirements); | |
1755 return false; | |
1756 } | |
1717 } | 1757 } |
1718 return true; | 1758 return true; |
1719 } | 1759 } |
1720 | 1760 |
1721 bool Extension::LoadDefaultLocale(string16* error) { | 1761 bool Extension::LoadDefaultLocale(string16* error) { |
1722 if (!manifest_->HasKey(keys::kDefaultLocale)) | 1762 if (!manifest_->HasKey(keys::kDefaultLocale)) |
1723 return true; | 1763 return true; |
1724 if (!manifest_->GetString(keys::kDefaultLocale, &default_locale_) || | 1764 if (!manifest_->GetString(keys::kDefaultLocale, &default_locale_) || |
1725 !l10n_util::IsValidLocaleSyntax(default_locale_)) { | 1765 !l10n_util::IsValidLocaleSyntax(default_locale_)) { |
1726 *error = ASCIIToUTF16(errors::kInvalidDefaultLocale); | 1766 *error = ASCIIToUTF16(errors::kInvalidDefaultLocale); |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3912 | 3952 |
3913 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3953 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3914 const Extension* extension, | 3954 const Extension* extension, |
3915 const PermissionSet* permissions, | 3955 const PermissionSet* permissions, |
3916 Reason reason) | 3956 Reason reason) |
3917 : reason(reason), | 3957 : reason(reason), |
3918 extension(extension), | 3958 extension(extension), |
3919 permissions(permissions) {} | 3959 permissions(permissions) {} |
3920 | 3960 |
3921 } // namespace extensions | 3961 } // namespace extensions |
OLD | NEW |