Chromium Code Reviews| Index: chrome/common/extensions/extension.cc |
| diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc |
| index 46735554511590bc563763c622081a8a6a97fc3e..c77e496edebc4c1424fb237579715f8a9ed9d141 100644 |
| --- a/chrome/common/extensions/extension.cc |
| +++ b/chrome/common/extensions/extension.cc |
| @@ -33,7 +33,6 @@ |
| #include "chrome/common/extensions/api/themes/theme_handler.h" |
| #include "chrome/common/extensions/background_info.h" |
| #include "chrome/common/extensions/csp_handler.h" |
| -#include "chrome/common/extensions/csp_validator.h" |
| #include "chrome/common/extensions/extension_manifest_constants.h" |
| #include "chrome/common/extensions/feature_switch.h" |
| #include "chrome/common/extensions/features/base_feature_provider.h" |
| @@ -45,6 +44,7 @@ |
| #include "chrome/common/extensions/permissions/api_permission_set.h" |
| #include "chrome/common/extensions/permissions/permission_set.h" |
| #include "chrome/common/extensions/permissions/permissions_info.h" |
| +#include "chrome/common/extensions/sandboxed_page_info.h" |
| #include "chrome/common/extensions/user_script.h" |
| #include "chrome/common/url_constants.h" |
| #include "crypto/sha2.h" |
| @@ -66,9 +66,6 @@ namespace values = extension_manifest_values; |
| namespace errors = extension_manifest_errors; |
| namespace info_keys = extension_info_keys; |
| -using extensions::csp_validator::ContentSecurityPolicyIsLegal; |
| -using extensions::csp_validator::ContentSecurityPolicyIsSandboxed; |
| - |
| namespace extensions { |
| namespace { |
| @@ -89,9 +86,6 @@ const char kPrivate[] = "PRIVATE"; |
| const int kRSAKeySize = 1024; |
| -const char kDefaultSandboxedPageContentSecurityPolicy[] = |
| - "sandbox allow-scripts allow-forms allow-popups"; |
| - |
| // Converts a normal hexadecimal string into the alphabet used by extensions. |
| // We use the characters 'a'-'p' instead of '0'-'f' to avoid ever having a |
| // completely numeric host, since some software interprets that as an IP |
| @@ -371,14 +365,10 @@ bool Extension::ResourceMatches(const URLPatternSet& pattern_set, |
| return pattern_set.MatchesURL(extension_url_.Resolve(resource)); |
| } |
| -bool Extension::IsSandboxedPage(const std::string& relative_path) const { |
| - return ResourceMatches(sandboxed_pages_, relative_path); |
| -} |
| - |
| std::string Extension::GetResourceContentSecurityPolicy( |
|
Yoyo Zhou
2013/03/25 17:16:01
Can this function be moved to CSPInfo? I think it
Devlin
2013/03/26 23:00:15
Done.
|
| const std::string& relative_path) const { |
| - return IsSandboxedPage(relative_path) ? |
| - sandboxed_pages_content_security_policy_ : |
| + return SandboxedPageInfo::IsSandboxedPage(this, relative_path) ? |
| + SandboxedPageInfo::GetContentSecurityPolicy(this) : |
| CSPInfo::GetContentSecurityPolicy(this); |
| } |
| @@ -1749,7 +1739,6 @@ bool Extension::LoadSharedFeatures(string16* error) { |
| if (!LoadDescription(error) || |
| !ManifestHandler::ParseExtension(this, error) || |
| !LoadNaClModules(error) || |
| - !LoadSandboxedPages(error) || |
| !LoadRequirements(error) || |
| !LoadKioskEnabled(error) || |
| !LoadOfflineEnabled(error)) |
| @@ -1833,58 +1822,6 @@ bool Extension::LoadNaClModules(string16* error) { |
| return true; |
| } |
| -bool Extension::LoadSandboxedPages(string16* error) { |
| - if (!manifest_->HasPath(keys::kSandboxedPages)) |
| - return true; |
| - |
| - const ListValue* list_value = NULL; |
| - if (!manifest_->GetList(keys::kSandboxedPages, &list_value)) { |
| - *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesList); |
| - return false; |
| - } |
| - for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| - std::string relative_path; |
| - if (!list_value->GetString(i, &relative_path)) { |
| - *error = ErrorUtils::FormatErrorMessageUTF16( |
| - errors::kInvalidSandboxedPage, base::IntToString(i)); |
| - return false; |
| - } |
| - URLPattern pattern(URLPattern::SCHEME_EXTENSION); |
| - if (pattern.Parse(extension_url_.spec()) != URLPattern::PARSE_SUCCESS) { |
| - *error = ErrorUtils::FormatErrorMessageUTF16( |
| - errors::kInvalidURLPatternError, extension_url_.spec()); |
| - return false; |
| - } |
| - while (relative_path[0] == '/') |
| - relative_path = relative_path.substr(1, relative_path.length() - 1); |
| - pattern.SetPath(pattern.path() + relative_path); |
| - sandboxed_pages_.AddPattern(pattern); |
| - } |
| - |
| - if (manifest_->HasPath(keys::kSandboxedPagesCSP)) { |
| - if (!manifest_->GetString( |
| - keys::kSandboxedPagesCSP, &sandboxed_pages_content_security_policy_)) { |
| - *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesCSP); |
| - return false; |
| - } |
| - |
| - if (!ContentSecurityPolicyIsLegal( |
| - sandboxed_pages_content_security_policy_) || |
| - !ContentSecurityPolicyIsSandboxed( |
| - sandboxed_pages_content_security_policy_, GetType())) { |
| - *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesCSP); |
| - return false; |
| - } |
| - } else { |
| - sandboxed_pages_content_security_policy_ = |
| - kDefaultSandboxedPageContentSecurityPolicy; |
| - CHECK(ContentSecurityPolicyIsSandboxed( |
| - sandboxed_pages_content_security_policy_, GetType())); |
| - } |
| - |
| - return true; |
| -} |
| - |
| bool Extension::LoadRequirements(string16* error) { |
| // Before parsing requirements from the manifest, automatically default the |
| // NPAPI plugin requirement based on whether it includes NPAPI plugins. |