diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-18 03:04:29 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-18 03:04:29 +0000 |
commit | 1a4efd1aef0d481a670c929e280c581f897031a1 (patch) | |
tree | 4e3550e46338b07d5dcfadeeaf3cbafe91c0e227 /chrome/common | |
parent | c94eafc52c38a0a331fc0dc0a652dea37b3773b0 (diff) | |
download | chromium_src-1a4efd1aef0d481a670c929e280c581f897031a1.zip chromium_src-1a4efd1aef0d481a670c929e280c581f897031a1.tar.gz chromium_src-1a4efd1aef0d481a670c929e280c581f897031a1.tar.bz2 |
Revert 137794 - Add schema chrome-extension-resource:// for extension resources. It may be used for bundle JS libraries in future
like Google Analytics JS library.
BUG=122987
TEST=unit_tests --gtest_filter=ExtensionFileUtil.*
TEST=browser_tests --gtest_filter=ExtensionResourceRequestPolicyTest*
Review URL: https://chromiumcodereview.appspot.com/9909019
TBR=penghuang@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10409019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/chrome_content_client.cc | 2 | ||||
-rw-r--r-- | chrome/common/chrome_paths.cc | 6 | ||||
-rw-r--r-- | chrome/common/chrome_paths.h | 1 | ||||
-rw-r--r-- | chrome/common/extensions/csp_validator.cc | 5 | ||||
-rw-r--r-- | chrome/common/extensions/csp_validator_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/extension.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/extension_file_util.cc | 19 | ||||
-rw-r--r-- | chrome/common/extensions/extension_file_util.h | 4 | ||||
-rw-r--r-- | chrome/common/extensions/extension_file_util_unittest.cc | 70 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 1 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 4 |
11 files changed, 5 insertions, 111 deletions
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc index edb2e1c..369bc0a 100644 --- a/chrome/common/chrome_content_client.cc +++ b/chrome/common/chrome_content_client.cc @@ -379,8 +379,6 @@ void ChromeContentClient::AddAdditionalSchemes( std::vector<std::string>* savable_schemes) { standard_schemes->push_back(kExtensionScheme); savable_schemes->push_back(kExtensionScheme); - standard_schemes->push_back(kExtensionResourceScheme); - savable_schemes->push_back(kExtensionResourceScheme); #if defined(OS_CHROMEOS) standard_schemes->push_back(kCrosScheme); #endif diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index edeb082..4bd6bf0 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -307,12 +307,6 @@ bool PathProvider(int key, FilePath* result) { return false; cur = cur.Append(FILE_PATH_LITERAL("resources.pak")); break; - case chrome::DIR_RESOURCES_EXTENSION: - if (!PathService::Get(base::DIR_MODULE, &cur)) - return false; - cur = cur.Append(FILE_PATH_LITERAL("resources")) - .Append(FILE_PATH_LITERAL("extension")); - break; #if defined(OS_CHROMEOS) case chrome::FILE_CHROMEOS_API: if (!PathService::Get(base::DIR_MODULE, &cur)) diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h index a3991c6..61fa4f6f 100644 --- a/chrome/common/chrome_paths.h +++ b/chrome/common/chrome_paths.h @@ -96,7 +96,6 @@ enum { FILE_RESOURCES_PACK, // Full path to the .pak file containing // binary data (e.g., html files and images // used by interal pages). - DIR_RESOURCES_EXTENSION, // Full path to extension resources. #if defined(OS_CHROMEOS) FILE_CHROMEOS_API, // Full path to chrome os api shared object. #endif diff --git a/chrome/common/extensions/csp_validator.cc b/chrome/common/extensions/csp_validator.cc index 7b28bdf..e80468b 100644 --- a/chrome/common/extensions/csp_validator.cc +++ b/chrome/common/extensions/csp_validator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -43,8 +43,7 @@ bool HasOnlySecureTokens(StringTokenizer& tokenizer) { source == "'none'" || StartsWithASCII(source, "https://", true) || StartsWithASCII(source, "chrome://", true) || - StartsWithASCII(source, "chrome-extension://", true) || - StartsWithASCII(source, "chrome-extension-resource:", true)) { + StartsWithASCII(source, "chrome-extension://", true)) { continue; } diff --git a/chrome/common/extensions/csp_validator_unittest.cc b/chrome/common/extensions/csp_validator_unittest.cc index 5b9bfbe..b7fa4da 100644 --- a/chrome/common/extensions/csp_validator_unittest.cc +++ b/chrome/common/extensions/csp_validator_unittest.cc @@ -60,8 +60,6 @@ TEST(ExtensionCSPValidator, IsSecure) { "default-src 'self' chrome://resources")); EXPECT_TRUE(ContentSecurityPolicyIsSecure( "default-src 'self' chrome-extension://aabbcc")); - EXPECT_TRUE(ContentSecurityPolicyIsSecure( - "default-src 'self' chrome-extension-resource://aabbcc")); EXPECT_FALSE(ContentSecurityPolicyIsSecure( "default-src 'self' https:")); EXPECT_FALSE(ContentSecurityPolicyIsSecure( diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 91c21df..7799938 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -76,7 +76,7 @@ const char kPrivate[] = "PRIVATE"; const int kRSAKeySize = 1024; const char kDefaultContentSecurityPolicy[] = - "script-src 'self' chrome-extension-resource:; object-src 'self'"; + "script-src 'self'; object-src 'self'"; // 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 diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index 848625e..3f9a9b9 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -635,25 +635,6 @@ FilePath ExtensionURLToRelativeFilePath(const GURL& url) { return path; } -FilePath ExtensionResourceURLToFilePath(const GURL& url, const FilePath& root) { - std::string host = net::UnescapeURLComponent(url.host(), - net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); - if (host.empty()) - return FilePath(); - - FilePath relative_path = ExtensionURLToRelativeFilePath(url); - if (relative_path.empty()) - return FilePath(); - - FilePath path = root.AppendASCII(host).Append(relative_path); - if (!file_util::PathExists(path) || - !file_util::AbsolutePath(&path) || - !root.IsParent(path)) { - return FilePath(); - } - return path; -} - FilePath GetUserDataTempDir() { // We do file IO in this function, but only when the current profile's // Temp directory has never been used before, or in a rare error case. diff --git a/chrome/common/extensions/extension_file_util.h b/chrome/common/extensions/extension_file_util.h index 1ad1120..1ab3f07 100644 --- a/chrome/common/extensions/extension_file_util.h +++ b/chrome/common/extensions/extension_file_util.h @@ -100,10 +100,6 @@ bool CheckForIllegalFilenames(const FilePath& extension_path, // Get a relative file path from a chrome-extension:// URL. FilePath ExtensionURLToRelativeFilePath(const GURL& url); -// Get a full file path from a chrome-extension-resource:// URL, If the URL -// points a file outside of root, this function will return empty FilePath. -FilePath ExtensionResourceURLToFilePath(const GURL& url, const FilePath& root); - // Get a path to a temp directory for unpacking an extension. // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), // with a histogram that allows us to understand why it is failing. diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc index eef0a63..e2d1066 100644 --- a/chrome/common/extensions/extension_file_util_unittest.cc +++ b/chrome/common/extensions/extension_file_util_unittest.cc @@ -215,8 +215,9 @@ TEST(ExtensionFileUtil, FailLoadingNonUTF8Scripts) { "It isn't UTF-8 encoded.", error.c_str()); } -TEST(ExtensionFileUtil, ExtensionURLToRelativeFilePath) { #define URL_PREFIX "chrome-extension://extension-id/" + +TEST(ExtensionFileUtil, ExtensionURLToRelativeFilePath) { struct TestCase { const char* url; const char* expected_relative_path; @@ -242,7 +243,6 @@ TEST(ExtensionFileUtil, ExtensionURLToRelativeFilePath) { { URL_PREFIX "\\\\foo\\simple.html", "foo/simple.html" }, }; -#undef URL_PREFIX for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { GURL url(test_cases[i].url); @@ -261,72 +261,6 @@ TEST(ExtensionFileUtil, ExtensionURLToRelativeFilePath) { } } -TEST(ExtensionFileUtil, ExtensionResourceURLToFilePath) { - // Setup filesystem for testing. - FilePath root_path; - ASSERT_TRUE(file_util::CreateNewTempDirectory( - FILE_PATH_LITERAL(""), &root_path)); - ASSERT_TRUE(file_util::AbsolutePath(&root_path)); - - FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); - ASSERT_TRUE(file_util::CreateDirectory(api_path)); - - const char data[] = "Test Data"; - FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); - ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); - resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); - ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); - -#ifdef FILE_PATH_USES_WIN_SEPARATORS -#define SEP "\\" -#else -#define SEP "/" -#endif -#define URL_PREFIX "chrome-extension-resource://" - struct TestCase { - const char* url; - const FilePath::CharType* expected_path; - } test_cases[] = { - { URL_PREFIX "apiname/test.js", - FILE_PATH_LITERAL("test.js") }, - { URL_PREFIX "/apiname/test.js", - FILE_PATH_LITERAL("test.js") }, - // Test % escape - { URL_PREFIX "apiname/%74%65st.js", - FILE_PATH_LITERAL("test.js") }, - { URL_PREFIX "apiname/escape%20spaces.js", - FILE_PATH_LITERAL("escape spaces.js") }, - // Test file does not exist. - { URL_PREFIX "apiname/directory/to/file.js", - NULL }, - // Test apiname/../../test.js - { URL_PREFIX "apiname/../../test.js", - FILE_PATH_LITERAL("test.js") }, - { URL_PREFIX "apiname/..%2F../test.js", - NULL }, - { URL_PREFIX "apiname/f/../../../test.js", - FILE_PATH_LITERAL("test.js") }, - { URL_PREFIX "apiname/f%2F..%2F..%2F../test.js", - NULL }, - }; -#undef SEP -#undef URL_PREFIX - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { - GURL url(test_cases[i].url); - FilePath expected_path; - if (test_cases[i].expected_path) - expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( - test_cases[i].expected_path); - FilePath actual_path = - extension_file_util::ExtensionResourceURLToFilePath(url, root_path); - EXPECT_EQ(expected_path.value(), actual_path.value()) << - " For the path " << url; - } - // Remove temp files. - ASSERT_TRUE(file_util::Delete(root_path, true)); -} - static scoped_refptr<Extension> LoadExtensionManifest( DictionaryValue* manifest, const FilePath& manifest_dir, diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index b00a417..3df1a91 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -426,6 +426,5 @@ const char* const kChromeDebugURLs[] = { int kNumberOfChromeDebugURLs = static_cast<int>(arraysize(kChromeDebugURLs)); const char kExtensionScheme[] = "chrome-extension"; -const char kExtensionResourceScheme[] = "chrome-extension-resource"; } // namespace chrome diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index d97ce50..b451e5c 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -352,10 +352,6 @@ extern int kNumberOfChromeDebugURLs; // Canonical schemes you can use as input to GURL.SchemeIs(). extern const char kExtensionScheme[]; - -// Canonical schemes you can use as input to GURL.SchemeIs(). -extern const char kExtensionResourceScheme[]; - #if defined(OS_CHROMEOS) extern const char kDriveScheme[]; #endif |