diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 17:38:06 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 17:38:06 +0000 |
commit | 98901d9f7dc19e58a926970a26e31832d1377fa5 (patch) | |
tree | 83c516f48264356a6bd9df239b62ab3f412efa22 | |
parent | f0b9405a4617ecdffc9a4d8d616cf9bafc84ae9f (diff) | |
download | chromium_src-98901d9f7dc19e58a926970a26e31832d1377fa5.zip chromium_src-98901d9f7dc19e58a926970a26e31832d1377fa5.tar.gz chromium_src-98901d9f7dc19e58a926970a26e31832d1377fa5.tar.bz2 |
Revert 128753 - Add full support for filesystem URLs.
BUG=114484
TEST=existing filesystem tests don't break
Review URL: https://chromiumcodereview.appspot.com/7811006
TBR=ericu@google.com
Review URL: https://chromiumcodereview.appspot.com/9808101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128757 0039d316-1c4b-4281-b951-d872f2087c98
28 files changed, 118 insertions, 287 deletions
diff --git a/build/temp_gyp/googleurl.gyp b/build/temp_gyp/googleurl.gyp index 66665bb..3115ce6 100644 --- a/build/temp_gyp/googleurl.gyp +++ b/build/temp_gyp/googleurl.gyp @@ -23,7 +23,6 @@ '../../googleurl/src/url_canon.h', '../../googleurl/src/url_canon_etc.cc', '../../googleurl/src/url_canon_fileurl.cc', - '../../googleurl/src/url_canon_filesystemurl.cc', '../../googleurl/src/url_canon_host.cc', '../../googleurl/src/url_canon_icu.cc', '../../googleurl/src/url_canon_icu.h', @@ -52,9 +51,6 @@ '../..', ], }, - 'defines': [ - 'FULL_FILESYSTEM_URL_SUPPORT=1', - ], 'conditions': [ ['component=="shared_library"', { 'defines': [ @@ -86,9 +82,6 @@ '../../googleurl/src/url_test_utils.h', '../../googleurl/src/url_util_unittest.cc', ], - 'defines': [ - 'FULL_FILESYSTEM_URL_SUPPORT=1', - ], 'conditions': [ ['os_posix==1 and OS!="mac"', { 'conditions': [ diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 0efd16d..010617a 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -95,7 +95,6 @@ AutocompleteInput::AutocompleteInput(const string16& text, if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && canonicalized_url.is_valid() && (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || - canonicalized_url.SchemeIsFileSystem() || !canonicalized_url.host().empty())) canonicalized_url_ = canonicalized_url; @@ -167,14 +166,6 @@ AutocompleteInput::Type AutocompleteInput::Parse( return URL; } - if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileSystemScheme)) { - // This could theoretically be a strange search, but let's check. - // If it's got an inner_url with a scheme, it's a URL, whether it's valid or - // not. - if (parts->inner_parsed() && parts->inner_parsed()->scheme.is_valid()) - return URL; - } - // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it // well enough that we can fall through to the heuristics below. If it's // something else, we can just determine our action based on what we do with @@ -464,9 +455,6 @@ void AutocompleteInput::ParseForEmphasizeComponents( host->reset(); } } - } else if (LowerCaseEqualsASCII(scheme_str, chrome::kFileSystemScheme) && - parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) { - *host = parts.inner_parsed()->host; } } diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc index fbf4ad51..ed35f16 100644 --- a/chrome/browser/autocomplete/autocomplete_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_unittest.cc @@ -495,12 +495,6 @@ TEST_F(AutocompleteTest, InputType) { { ASCIIToUTF16("[2001:dB8::1]"), AutocompleteInput::URL }, { ASCIIToUTF16("192.168.0.256"), AutocompleteInput::QUERY }, { ASCIIToUTF16("[foo.com]"), AutocompleteInput::QUERY }, - { ASCIIToUTF16("filesystem:http://a.com/t/bar"), AutocompleteInput::URL }, - { ASCIIToUTF16("filesystem:http:foo"), AutocompleteInput::URL }, - { ASCIIToUTF16("filesystem:file://"), AutocompleteInput::URL }, - { ASCIIToUTF16("filesystem:http"), AutocompleteInput::URL }, - { ASCIIToUTF16("filesystem:"), AutocompleteInput::URL }, - { ASCIIToUTF16("ftp:"), AutocompleteInput::URL }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) { diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc index 0bc331f..ccb5615 100644 --- a/chrome/browser/browsing_data_database_helper.cc +++ b/chrome/browser/browsing_data_database_helper.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. @@ -44,6 +44,12 @@ BrowsingDataDatabaseHelper::DatabaseInfo::DatabaseInfo( BrowsingDataDatabaseHelper::DatabaseInfo::~DatabaseInfo() {} +bool BrowsingDataDatabaseHelper::DatabaseInfo::IsFileSchemeData() { + return StartsWithASCII(origin_identifier, + std::string(chrome::kFileScheme), + true); +} + BrowsingDataDatabaseHelper::BrowsingDataDatabaseHelper(Profile* profile) : is_fetching_(false), tracker_(BrowserContext::GetDatabaseTracker(profile)) { diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h index 3d974ee..2d3a853 100644 --- a/chrome/browser/browsing_data_database_helper.h +++ b/chrome/browser/browsing_data_database_helper.h @@ -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. @@ -41,6 +41,8 @@ class BrowsingDataDatabaseHelper base::Time last_modified); ~DatabaseInfo(); + bool IsFileSchemeData(); + std::string host; std::string database_name; std::string origin_identifier; diff --git a/chrome/browser/browsing_data_indexed_db_helper.h b/chrome/browser/browsing_data_indexed_db_helper.h index 5916b40..5d7177e50 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.h +++ b/chrome/browser/browsing_data_indexed_db_helper.h @@ -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. @@ -38,6 +38,10 @@ class BrowsingDataIndexedDBHelper base::Time last_modified); ~IndexedDBInfo(); + bool IsFileSchemeData() { + return origin.SchemeIsFile(); + } + GURL origin; int64 size; base::Time last_modified; diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h index 359f14c..7f88985 100644 --- a/chrome/browser/browsing_data_local_storage_helper.h +++ b/chrome/browser/browsing_data_local_storage_helper.h @@ -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. @@ -49,6 +49,10 @@ class BrowsingDataLocalStorageHelper base::Time last_modified); ~LocalStorageInfo(); + bool IsFileSchemeData() { + return protocol == chrome::kFileScheme; + } + std::string protocol; std::string host; unsigned short port; diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc index 95d3723..c4853a9 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api.cc @@ -160,7 +160,6 @@ bool IsSensitiveURL(const GURL& url) { bool HasWebRequestScheme(const GURL& url) { return (url.SchemeIs(chrome::kAboutScheme) || url.SchemeIs(chrome::kFileScheme) || - url.SchemeIs(chrome::kFileSystemScheme) || url.SchemeIs(chrome::kFtpScheme) || url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme) || diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index b092a7c..485435d 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -49,7 +49,6 @@ const char* kValidSchemes[] = { chrome::kFtpScheme, chrome::kJavaScriptScheme, chrome::kDataScheme, - chrome::kFileSystemScheme, }; // Returns the frame ID as it will be passed to the extension: diff --git a/chrome/browser/history/url_index_private_data.cc b/chrome/browser/history/url_index_private_data.cc index b35acf0f..de779f4 100644 --- a/chrome/browser/history/url_index_private_data.cc +++ b/chrome/browser/history/url_index_private_data.cc @@ -912,7 +912,6 @@ void URLIndexPrivateData::InitializeSchemeWhitelist( whitelist->insert(std::string(chrome::kAboutScheme)); whitelist->insert(std::string(chrome::kChromeUIScheme)); whitelist->insert(std::string(chrome::kFileScheme)); - whitelist->insert(std::string(chrome::kFileSystemScheme)); whitelist->insert(std::string(chrome::kFtpScheme)); whitelist->insert(std::string(chrome::kHttpScheme)); whitelist->insert(std::string(chrome::kHttpsScheme)); diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 4a4a883..2e025fc 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.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. @@ -412,13 +412,6 @@ std::string URLFixerUpper::SegmentURL(const std::string& text, url_parse::Component(0, static_cast<int>(scheme.length()))))) return scheme; - if (scheme == chrome::kFileSystemScheme) { - // Have the GURL parser do the heavy lifting for us. - url_parse::ParseFileSystemURL(text.data(), - static_cast<int>(text.length()), parts); - return scheme; - } - if (parts->scheme.is_valid()) { // Have the GURL parser do the heavy lifting for us. url_parse::ParseStandardURL(text.data(), static_cast<int>(text.length()), @@ -485,13 +478,6 @@ GURL URLFixerUpper::FixupURL(const std::string& text, if (scheme == chrome::kFileScheme) return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); - // We handle the filesystem scheme separately. - if (scheme == chrome::kFileSystemScheme) { - if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) - return GURL(text); - return GURL(); - } - // Parse and rebuild about: and chrome: URLs, except about:blank. bool chrome_url = !LowerCaseEqualsASCII(trimmed, chrome::kAboutBlankURL) && ((scheme == chrome::kAboutScheme) || (scheme == chrome::kChromeUIScheme)); diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index 575e72a..4ff951f 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -135,7 +135,6 @@ void CreateShortcut( bool IsValidUrl(const GURL& url) { static const char* const kValidUrlSchemes[] = { chrome::kFileScheme, - chrome::kFileSystemScheme, chrome::kFtpScheme, chrome::kHttpScheme, chrome::kHttpsScheme, diff --git a/chrome/common/content_settings_pattern.cc b/chrome/common/content_settings_pattern.cc index 8feef19..8008cba 100644 --- a/chrome/common/content_settings_pattern.cc +++ b/chrome/common/content_settings_pattern.cc @@ -313,33 +313,28 @@ ContentSettingsPattern ContentSettingsPattern::FromURL( scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( ContentSettingsPattern::CreateBuilder(false)); - const GURL* local_url = &url; - if (url.SchemeIsFileSystem() && url.inner_url()) { - local_url = url.inner_url(); - } - if (local_url->SchemeIsFile()) { - builder->WithScheme(local_url->scheme())->WithPath(local_url->path()); + if (url.SchemeIsFile()) { + builder->WithScheme(url.scheme())->WithPath(url.path()); } else { // Please keep the order of the ifs below as URLs with an IP as host can // also have a "http" scheme. - if (local_url->HostIsIPAddress()) { - builder->WithScheme(local_url->scheme())->WithHost(local_url->host()); - } else if (local_url->SchemeIs(chrome::kHttpScheme)) { - builder->WithSchemeWildcard()->WithDomainWildcard()->WithHost( - local_url->host()); - } else if (local_url->SchemeIs(chrome::kHttpsScheme)) { - builder->WithScheme(local_url->scheme())->WithDomainWildcard()->WithHost( - local_url->host()); + if (url.HostIsIPAddress()) { + builder->WithScheme(url.scheme())->WithHost(url.host()); + } else if (url.SchemeIs(chrome::kHttpScheme)) { + builder->WithSchemeWildcard()->WithDomainWildcard()->WithHost(url.host()); + } else if (url.SchemeIs(chrome::kHttpsScheme)) { + builder->WithScheme(url.scheme())->WithDomainWildcard()->WithHost( + url.host()); } else { // Unsupported scheme } - if (local_url->port().empty()) { - if (local_url->SchemeIs(chrome::kHttpsScheme)) + if (url.port().empty()) { + if (url.SchemeIs(chrome::kHttpsScheme)) builder->WithPort(GetDefaultPort(chrome::kHttpsScheme)); else builder->WithPortWildcard(); } else { - builder->WithPort(local_url->port()); + builder->WithPort(url.port()); } } return builder->Build(); @@ -351,18 +346,14 @@ ContentSettingsPattern ContentSettingsPattern::FromURLNoWildcard( scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( ContentSettingsPattern::CreateBuilder(false)); - const GURL* local_url = &url; - if (url.SchemeIsFileSystem() && url.inner_url()) { - local_url = url.inner_url(); - } - if (local_url->SchemeIsFile()) { - builder->WithScheme(local_url->scheme())->WithPath(local_url->path()); + if (url.SchemeIsFile()) { + builder->WithScheme(url.scheme())->WithPath(url.path()); } else { - builder->WithScheme(local_url->scheme())->WithHost(local_url->host()); - if (local_url->port().empty()) { - builder->WithPort(GetDefaultPort(local_url->scheme())); + builder->WithScheme(url.scheme())->WithHost(url.host()); + if (url.port().empty()) { + builder->WithPort(GetDefaultPort(url.scheme())); } else { - builder->WithPort(local_url->port()); + builder->WithPort(url.port()); } } return builder->Build(); @@ -423,13 +414,8 @@ bool ContentSettingsPattern::Matches( if (!is_valid_) return false; - const GURL* local_url = &url; - if (url.SchemeIsFileSystem() && url.inner_url()) { - local_url = url.inner_url(); - } - // Match the scheme part. - const std::string scheme(local_url->scheme()); + const std::string scheme(url.scheme()); if (!parts_.is_scheme_wildcard && parts_.scheme != scheme) { return false; @@ -437,17 +423,11 @@ bool ContentSettingsPattern::Matches( // File URLs have no host. Matches if the pattern has the path wildcard set, // or if the path in the URL is identical to the one in the pattern. - // For filesystem:file URLs, the path used is the filesystem type, so all - // filesystem:file:///temporary/... are equivalent. - // TODO(markusheintz): Content settings should be defined for all files on - // a machine. Unless there is a good use case for supporting paths for file - // patterns, stop supporting path for file patterns. if (!parts_.is_scheme_wildcard && scheme == chrome::kFileScheme) - return parts_.is_path_wildcard || - parts_.path == std::string(local_url->path()); + return parts_.is_path_wildcard || parts_.path == std::string(url.path()); // Match the host part. - const std::string host(net::TrimEndingDot(local_url->host())); + const std::string host(net::TrimEndingDot(url.host())); if (!parts_.has_domain_wildcard) { if (parts_.host != host) return false; @@ -461,7 +441,7 @@ bool ContentSettingsPattern::Matches( return true; // Match the port part. - std::string port(local_url->port()); + std::string port(url.port()); // Use the default port if the port string is empty. GURL returns an empty // string if no port at all was specified or if the default port was diff --git a/chrome/common/content_settings_pattern_unittest.cc b/chrome/common/content_settings_pattern_unittest.cc index bd79338..f0eeca5 100644 --- a/chrome/common/content_settings_pattern_unittest.cc +++ b/chrome/common/content_settings_pattern_unittest.cc @@ -73,7 +73,6 @@ TEST(ContentSettingsPatternTest, FromURL) { pattern = ContentSettingsPattern::FromURL(GURL("https://www.google.com:443")); EXPECT_TRUE(pattern.Matches(GURL("https://www.google.com"))); - EXPECT_TRUE(pattern.Matches(GURL("https://foo.www.google.com"))); EXPECT_TRUE(pattern.Matches(GURL("https://www.google.com:443"))); EXPECT_FALSE(pattern.Matches(GURL("https://www.google.com:444"))); EXPECT_FALSE(pattern.Matches(GURL("http://www.google.com:443"))); @@ -90,49 +89,6 @@ TEST(ContentSettingsPatternTest, FromURL) { EXPECT_EQ("file:///foo/bar.html", pattern.ToString()); } -TEST(ContentSettingsPatternTest, FilesystemUrls) { - ContentSettingsPattern pattern = - ContentSettingsPattern::FromURL(GURL("http://www.google.com")); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:http://www.google.com/temporary/"))); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:http://foo.www.google.com/temporary/"))); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:http://www.google.com:80/temporary/"))); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:http://www.google.com:81/temporary/"))); - - pattern = ContentSettingsPattern::FromURL(GURL("https://www.google.com")); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:https://www.google.com/temporary/"))); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:https://www.google.com:443/temporary/"))); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:https://foo.www.google.com/temporary/"))); - EXPECT_FALSE(pattern.Matches( - GURL("filesystem:https://www.google.com:81/temporary/"))); - - // A pattern from a filesystem URLs is equivalent to a pattern from the inner - // URL of the filesystem URL. - ContentSettingsPattern pattern2 = ContentSettingsPattern::FromURL( - GURL("filesystem:https://www.google.com/temporary/")); - EXPECT_EQ(ContentSettingsPattern::IDENTITY, pattern.Compare(pattern2)); - - EXPECT_STREQ("https://[*.]www.google.com:443", pattern2.ToString().c_str()); - - pattern = - ContentSettingsPattern::FromURL( - GURL("filesystem:file:///temporary/foo/bar")); - EXPECT_TRUE(pattern.Matches(GURL("filesystem:file:///temporary/"))); - EXPECT_TRUE(pattern.Matches(GURL("filesystem:file:///temporary/test.txt"))); - EXPECT_TRUE(pattern.Matches(GURL("file:///temporary"))); - EXPECT_FALSE(pattern.Matches(GURL("file://foo/bar"))); - pattern2 = - ContentSettingsPattern::FromURL( - GURL("filesystem:file:///persistent/foo2/bar2")); - EXPECT_EQ(ContentSettingsPattern::IDENTITY, pattern.Compare(pattern2)); -} - TEST(ContentSettingsPatternTest, FromURLNoWildcard) { // If no port is specifed GURLs always use the default port for the schemes // HTTP and HTTPS. Hence a GURL always carries a port specification either @@ -158,21 +114,8 @@ TEST(ContentSettingsPatternTest, FromURLNoWildcard) { EXPECT_TRUE(pattern.Matches(GURL("https://www.example.com"))); EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.example.com"))); - // Pattern for filesystem URLs - pattern = - ContentSettingsPattern::FromURLNoWildcard( - GURL("filesystem:http://www.google.com/temporary/")); - EXPECT_TRUE(pattern.IsValid()); - EXPECT_TRUE(pattern.Matches(GURL("http://www.google.com"))); - EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.google.com"))); - EXPECT_TRUE(pattern.Matches( - GURL("filesystem:http://www.google.com/persistent/"))); - EXPECT_FALSE(pattern.Matches( - GURL("filesystem:https://www.google.com/persistent/"))); - EXPECT_FALSE(pattern.Matches( - GURL("filesystem:https://www.google.com:81/temporary/"))); - EXPECT_FALSE(pattern.Matches( - GURL("filesystem:https://foo.www.google.com/temporary/"))); + pattern = ContentSettingsPattern::FromURLNoWildcard( + GURL("https://www.example.com")); } TEST(ContentSettingsPatternTest, Wildcard) { diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index d5d2e1e..a57b8e1 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -2326,27 +2326,16 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler( return NULL; } StringToLowerASCII(&filter); - if (!StartsWithASCII(filter, - std::string(chrome::kFileSystemScheme) + ':', - true)) { - *error = ExtensionErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidURLPatternError, filter); - return NULL; - } - // The user inputs filesystem:*; we don't actually implement scheme - // wildcards in URLPattern, so transform to what will match correctly. - filter.replace(0, 11, "chrome-extension://*/"); - URLPattern pattern(URLPattern::SCHEME_EXTENSION); - pattern.set_partial_filesystem_support_hack(true); + URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { *error = ExtensionErrorUtils::FormatErrorMessageUTF16( errors::kInvalidURLPatternError, filter); return NULL; } std::string path = pattern.path(); - bool allowed = path == "/*" || path == "/*.*" || - (path.compare(0, 3, "/*.") == 0 && - path.find_first_of('*', 3) == std::string::npos); + bool allowed = path == "*" || path == "*.*" || + (path.compare(0, 2, "*.") == 0 && + path.find_first_of('*', 2) == std::string::npos); if (!allowed) { *error = ExtensionErrorUtils::FormatErrorMessageUTF16( errors::kInvalidURLPatternError, filter); diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index 7cfd038..94fd1cd 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -1004,7 +1004,6 @@ TEST_F(ExtensionManifestTest, FileBrowserHandlers) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("filebrowser_valid.json")); - ASSERT_TRUE(extension.get()); ASSERT_TRUE(extension->file_browser_handlers() != NULL); ASSERT_EQ(extension->file_browser_handlers()->size(), 1U); const FileBrowserHandler* action = diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index c0b04b7..ac64811 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -97,14 +97,12 @@ bool IsValidPortForScheme(const std::string scheme, const std::string& port) { URLPattern::URLPattern() : valid_schemes_(SCHEME_NONE), match_all_urls_(false), - partial_filesystem_support_hack_(false), match_subdomains_(false), port_("*") {} URLPattern::URLPattern(int valid_schemes) : valid_schemes_(valid_schemes), match_all_urls_(false), - partial_filesystem_support_hack_(false), match_subdomains_(false), port_("*") {} @@ -113,7 +111,6 @@ URLPattern::URLPattern(int valid_schemes, const std::string& pattern) // appropriate when we know |pattern| is valid. : valid_schemes_(valid_schemes), match_all_urls_(false), - partial_filesystem_support_hack_(false), match_subdomains_(false), port_("*") { if (PARSE_SUCCESS != Parse(pattern)) @@ -298,27 +295,14 @@ bool URLPattern::SetPort(const std::string& port) { } bool URLPattern::MatchesURL(const GURL& test) const { - const GURL* test_url = &test; - bool has_inner_url = test.inner_url() != NULL; - - if (partial_filesystem_support_hack_ != has_inner_url) - return false; - - if (has_inner_url) - test_url = test.inner_url(); - - if (!MatchesScheme(test_url->scheme())) + if (!MatchesScheme(test.scheme())) return false; if (match_all_urls_) return true; - std::string path_for_request = test.PathForRequest(); - if (has_inner_url) - path_for_request = test_url->path() + path_for_request; - - return MatchesSecurityOriginHelper(*test_url) && - MatchesPath(path_for_request); + return MatchesSecurityOriginHelper(test) && + MatchesPath(test.PathForRequest()); } bool URLPattern::MatchesSecurityOrigin(const GURL& test) const { @@ -449,10 +433,6 @@ bool URLPattern::OverlapsWith(const URLPattern& other) const { DCHECK(path_.find('*') == path_.size() - 1); DCHECK(other.path().find('*') == other.path().size() - 1); - if (partial_filesystem_support_hack_ != - other.partial_filesystem_support_hack()) - return false; - if (!MatchesPath(other.path().substr(0, other.path().size() - 1)) && !other.MatchesPath(path_.substr(0, path_.size() - 1))) return false; diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h index 3cde957..6a83c01 100644 --- a/chrome/common/extensions/url_pattern.h +++ b/chrome/common/extensions/url_pattern.h @@ -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. #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ @@ -119,15 +119,6 @@ class URLPattern { bool match_all_urls() const { return match_all_urls_; } void SetMatchAllURLs(bool val); - // Returns true if this pattern matches inner URLs of filesystem: URLs only. - // Returns false if this pattern matches only non-filesystem URLs. - bool partial_filesystem_support_hack() const { - return partial_filesystem_support_hack_; - } - void set_partial_filesystem_support_hack(bool val) { - partial_filesystem_support_hack_ = val; - } - // Sets the scheme for pattern matches. This can be a single '*' if the // pattern matches all valid schemes (as defined by the valid_schemes_ // property). Returns false on failure (if the scheme is not valid). @@ -213,11 +204,6 @@ class URLPattern { // True if this is a special-case "<all_urls>" pattern. bool match_all_urls_; - // True if we're trying to match against the inner URL of a filesystem URL; - // this is a temporary hack so as not to break ChromeOS as we work on full - // support. - bool partial_filesystem_support_hack_; - // The scheme for the pattern. std::string scheme_; diff --git a/chrome/common/extensions/url_pattern_unittest.cc b/chrome/common/extensions/url_pattern_unittest.cc index 10dff3d..3996b99 100644 --- a/chrome/common/extensions/url_pattern_unittest.cc +++ b/chrome/common/extensions/url_pattern_unittest.cc @@ -110,11 +110,6 @@ TEST(ExtensionURLPatternTest, Match2) { EXPECT_TRUE(pattern.MatchesURL(GURL("https://www.google.com/foobar"))); EXPECT_FALSE(pattern.MatchesURL(GURL("http://www.google.com/foo"))); EXPECT_FALSE(pattern.MatchesURL(GURL("https://www.google.com/"))); - EXPECT_FALSE(pattern.MatchesURL( - GURL("filesystem:https://www.google.com/foobar/"))); - pattern.set_partial_filesystem_support_hack(true); - EXPECT_TRUE(pattern.MatchesURL( - GURL("filesystem:https://www.google.com/foobar/bas"))); } // subdomains @@ -132,11 +127,6 @@ TEST(URLPatternTest, Match3) { EXPECT_TRUE(pattern.MatchesURL( GURL("http://monkey.images.google.com/foooobar"))); EXPECT_FALSE(pattern.MatchesURL(GURL("http://yahoo.com/foobar"))); - EXPECT_FALSE(pattern.MatchesURL( - GURL("filesystem:http://google.com/foobar/"))); - pattern.set_partial_filesystem_support_hack(true); - EXPECT_FALSE(pattern.MatchesURL( - GURL("filesystem:http://google.com/temporary/foobar"))); } // glob escaping @@ -236,7 +226,6 @@ TEST(ExtensionURLPatternTest, Match11) { EXPECT_TRUE(pattern.MatchesScheme("http")); EXPECT_TRUE(pattern.MatchesScheme("https")); EXPECT_TRUE(pattern.MatchesScheme("file")); - EXPECT_TRUE(pattern.MatchesScheme("filesystem")); EXPECT_TRUE(pattern.MatchesScheme("chrome-extension")); EXPECT_TRUE(pattern.match_subdomains()); EXPECT_TRUE(pattern.match_all_urls()); @@ -268,7 +257,6 @@ TEST(ExtensionURLPatternTest, Match12) { EXPECT_TRUE(pattern.MatchesScheme("http")); EXPECT_TRUE(pattern.MatchesScheme("https")); EXPECT_TRUE(pattern.MatchesScheme("file")); - EXPECT_TRUE(pattern.MatchesScheme("filesystem")); EXPECT_TRUE(pattern.MatchesScheme("javascript")); EXPECT_TRUE(pattern.MatchesScheme("data")); EXPECT_TRUE(pattern.MatchesScheme("about")); @@ -380,11 +368,6 @@ TEST(ExtensionURLPatternTest, Match17) { EXPECT_TRUE(pattern.MatchesURL(GURL("http://www.example.com:80/foo"))); EXPECT_TRUE(pattern.MatchesURL(GURL("http://www.example.com/foo"))); EXPECT_FALSE(pattern.MatchesURL(GURL("http://www.example.com:8080/foo"))); - EXPECT_FALSE(pattern.MatchesURL( - GURL("filesystem:http://www.example.com:8080/foo/"))); - EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:http://www.example.com/f/foo"))); - pattern.set_partial_filesystem_support_hack(true); - EXPECT_FALSE(pattern.MatchesURL(GURL("filesystem:http://www.example.com/f/foo"))); } // Explicit port wildcard @@ -401,8 +384,6 @@ TEST(ExtensionURLPatternTest, Match18) { EXPECT_TRUE(pattern.MatchesURL(GURL("http://www.example.com:80/foo"))); EXPECT_TRUE(pattern.MatchesURL(GURL("http://www.example.com/foo"))); EXPECT_TRUE(pattern.MatchesURL(GURL("http://www.example.com:8080/foo"))); - EXPECT_FALSE(pattern.MatchesURL( - GURL("filesystem:http://www.example.com:8080/foo/"))); } // chrome-extension:// @@ -421,11 +402,6 @@ TEST(ExtensionURLPatternTest, Match19) { EXPECT_TRUE(pattern.MatchesURL( GURL("chrome-extension://ftw/https://google.com"))); EXPECT_FALSE(pattern.MatchesURL(GURL("chrome-extension://foobar"))); - EXPECT_FALSE(pattern.MatchesURL( - GURL("filesystem:chrome-extension://ftw/t/file.txt"))); - pattern.set_partial_filesystem_support_hack(true); - EXPECT_TRUE(pattern.MatchesURL( - GURL("filesystem:chrome-extension://ftw/t/file.txt"))); }; static const struct GetAsStringPatterns { diff --git a/chrome/test/data/extensions/api_test/filebrowser_component/main.js b/chrome/test/data/extensions/api_test/filebrowser_component/main.js index 102b927..38ffa8a 100644 --- a/chrome/test/data/extensions/api_test/filebrowser_component/main.js +++ b/chrome/test/data/extensions/api_test/filebrowser_component/main.js @@ -14,7 +14,7 @@ This component extension test does the following: var cleanupError = 'Got unexpected error while cleaning up test directory.'; -// Class specified by the client running the TestRunner. +// Class specified by the client runnig the TestRunner. // |expectedTasks| should contain list of actions defined for abc files defined // by filesystem_handler part of the test. // |fileVerifierFunction| method that will verify test results received from the @@ -79,9 +79,7 @@ TestExpectations.prototype.verifyTasks = function(tasks, patterns = patterns.sort(); expectedPatterns = expectedPatterns.sort(); for (var j = 0; j < patterns.length; ++j) { - var translatedPattern = expectedPatterns[j].replace( - /^filesystem:/, "chrome-extension://*/"); - if (patterns[j] != translatedPattern) { + if (patterns[j] != expectedPatterns[j]) { errorCallback({message: 'Wrong patterns set for task ' + taskName + '. ' + 'Got: ' + patterns + diff --git a/content/browser/browser_url_handler_impl.cc b/content/browser/browser_url_handler_impl.cc index 2585844..7eef43f 100644 --- a/content/browser/browser_url_handler_impl.cc +++ b/content/browser/browser_url_handler_impl.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. @@ -24,7 +24,7 @@ static bool HandleViewSource(GURL* url, static const char* const allowed_sub_schemes[] = { chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kFtpScheme, chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, - chrome::kFileScheme, chrome::kFileSystemScheme + chrome::kFileScheme }; bool is_sub_scheme_allowed = false; diff --git a/content/public/common/url_constants.cc b/content/public/common/url_constants.cc index bbc5c2f..26dee8e 100644 --- a/content/public/common/url_constants.cc +++ b/content/public/common/url_constants.cc @@ -12,7 +12,6 @@ const char* kDefaultSavableSchemes[] = { chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kFileScheme, - chrome::kFileSystemScheme, chrome::kFtpScheme, chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc index a6f8198..b0b6d03 100644 --- a/net/base/mime_sniffer.cc +++ b/net/base/mime_sniffer.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. @@ -567,12 +567,12 @@ bool ShouldSniffMimeType(const GURL& url, const std::string& mime_type) { if (!should_sniff_counter) should_sniff_counter = UMASnifferHistogramGet("mime_sniffer.ShouldSniffMimeType2", 3); + // We are willing to sniff the mime type for HTTP, HTTPS, and FTP bool sniffable_scheme = url.is_empty() || url.SchemeIs("http") || url.SchemeIs("https") || url.SchemeIs("ftp") || - url.SchemeIsFile() || - url.SchemeIsFileSystem(); + url.SchemeIsFile(); if (!sniffable_scheme) { should_sniff_counter->Add(1); return false; diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 5fd3ddb..2ba3b46 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -1907,9 +1907,8 @@ string16 FormatUrl(const GURL& url, bool CanStripTrailingSlash(const GURL& url) { // Omit the path only for standard, non-file URLs with nothing but "/" after // the hostname. - return url.IsStandard() && !url.SchemeIsFile() && - !url.SchemeIsFileSystem() && !url.has_query() && !url.has_ref() - && url.path() == "/"; + return url.IsStandard() && !url.SchemeIsFile() && !url.has_query() && + !url.has_ref() && url.path() == "/"; } GURL SimplifyUrlForRequest(const GURL& url) { diff --git a/ui/base/text/text_elider.cc b/ui/base/text/text_elider.cc index bfd7f90..62ad7d0 100644 --- a/ui/base/text/text_elider.cc +++ b/ui/base/text/text_elider.cc @@ -225,8 +225,8 @@ string16 ElideUrl(const GURL& url, if (available_pixel_width <= 0) return url_string; - // If non-standard, return plain eliding. - if (!url.IsStandard()) + // If non-standard or not file type, return plain eliding. + if (!(url.SchemeIsFile() || url.IsStandard())) return ElideText(url_string, font, available_pixel_width, ELIDE_AT_END); // Now start eliding url_string to fit within available pixel width. diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc index 70de5ff..aac9766 100644 --- a/webkit/appcache/appcache_interfaces.cc +++ b/webkit/appcache/appcache_interfaces.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. @@ -63,11 +63,11 @@ bool IsSchemeSupported(const GURL& url) { bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme); #ifndef NDEBUG // TODO(michaeln): It would be really nice if this could optionally work for - // file and filesystem urls too to help web developers experiment and test - // their apps, perhaps enabled via a cmd line flag or some other developer - // tool setting. Unfortunately file scheme net::URLRequests don't produce the - // same signalling (200 response codes, headers) as http URLRequests, so this - // doesn't work just yet. + // file urls too to help web developers experiment and test their apps, + // perhaps enabled via a cmd line flag or some other developer tool setting. + // Unfortunately file scheme net::URLRequest don't produce the same signalling + // (200 response codes, headers) as http URLRequests, so this doesn't work + // just yet. // supported |= url.SchemeIsFile(); #endif return supported; diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc index 382c7b6..c5a3047 100644 --- a/webkit/fileapi/file_system_util.cc +++ b/webkit/fileapi/file_system_util.cc @@ -19,9 +19,9 @@ namespace fileapi { -const char kPersistentDir[] = "/persistent"; -const char kTemporaryDir[] = "/temporary"; -const char kExternalDir[] = "/external"; +const char kPersistentDir[] = "/persistent/"; +const char kTemporaryDir[] = "/temporary/"; +const char kExternalDir[] = "/external/"; const char kPersistentName[] = "Persistent"; const char kTemporaryName[] = "Temporary"; @@ -32,45 +32,62 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, GURL origin; FileSystemType file_system_type; - if (!url.is_valid() || !url.SchemeIsFileSystem()) + if (url.scheme() != "filesystem") return false; - DCHECK(url.inner_url()); - std::string inner_path = url.inner_url()->path(); - if (inner_path.compare( - 0, arraysize(kPersistentDir) - 1, kPersistentDir) == 0) { + std::string temp = url.path(); + // TODO(ericu): This should probably be done elsewhere after the stackable + // layers are properly in. We're supposed to reject any paths that contain + // '..' segments, but the GURL constructor is helpfully resolving them for us. + // Make sure there aren't any before we call it. + size_t pos = temp.find(".."); + for (; pos != std::string::npos; pos = temp.find("..", pos + 1)) { + if ((pos == 0 || temp[pos - 1] == '/') && + (pos == temp.length() - 2 || temp[pos + 2] == '/')) + return false; + } + + // bare_url will look something like: + // http://example.com/temporary/dir/file.txt. + GURL bare_url(temp); + + // The input URL was malformed, bail out early. + if (bare_url.path().empty()) + return false; + + origin = bare_url.GetOrigin(); + + // The input URL was malformed, bail out early. + if (origin.is_empty()) + return false; + + std::string path = net::UnescapeURLComponent(bare_url.path(), + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS | + net::UnescapeRule::CONTROL_CHARS); + if (path.compare(0, strlen(kPersistentDir), kPersistentDir) == 0) { file_system_type = kFileSystemTypePersistent; - } else if (inner_path.compare( - 0, arraysize(kTemporaryDir) - 1, kTemporaryDir) == 0) { + path = path.substr(strlen(kPersistentDir)); + } else if (path.compare(0, strlen(kTemporaryDir), kTemporaryDir) == 0) { file_system_type = kFileSystemTypeTemporary; - } else if (inner_path.compare( - 0, arraysize(kExternalDir) - 1, kExternalDir) == 0) { + path = path.substr(strlen(kTemporaryDir)); + } else if (path.compare(0, strlen(kExternalDir), kExternalDir) == 0) { file_system_type = kFileSystemTypeExternal; + path = path.substr(strlen(kExternalDir)); } else { return false; } - std::string path = net::UnescapeURLComponent(url.path(), - net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS | - net::UnescapeRule::CONTROL_CHARS); - // Ensure the path is relative. while (!path.empty() && path[0] == '/') path.erase(0, 1); - FilePath converted_path = FilePath::FromUTF8Unsafe(path); - - // All parent references should have been resolved in the renderer. - if (converted_path.ReferencesParent()) - return false; - if (origin_url) - *origin_url = url.GetOrigin(); + *origin_url = origin; if (type) *type = file_system_type; if (file_path) - *file_path = converted_path.NormalizePathSeparators(). - StripTrailingSeparators(); + *file_path = FilePath::FromUTF8Unsafe(path). + NormalizePathSeparators().StripTrailingSeparators(); return true; } @@ -121,28 +138,23 @@ void VirtualPath::GetComponents( } GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) { - // origin_url is based on a security origin, so http://foo.com or file:/// - // instead of the corresponding filesystem URL. - DCHECK(!origin_url.SchemeIsFileSystem()); - - std::string url = "filesystem:" + origin_url.GetWithEmptyPath().spec(); + std::string path("filesystem:"); + path += origin_url.spec(); switch (type) { case kFileSystemTypeTemporary: - url += (kTemporaryDir + 1); // We don't want the leading slash. + path += (kTemporaryDir + 1); // We don't want the leading slash. break; case kFileSystemTypePersistent: - url += (kPersistentDir + 1); // We don't want the leading slash. + path += (kPersistentDir + 1); // We don't want the leading slash. break; case kFileSystemTypeExternal: - url += (kExternalDir + 1); // We don't want the leading slash. + path += (kExternalDir + 1); // We don't want the leading slash. break; default: NOTREACHED(); return GURL(); } - url += "/"; - - return GURL(url); + return GURL(path); } std::string GetFileSystemName(const GURL& origin_url, FileSystemType type) { diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index 34aec23..b5a9a8b 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -651,9 +651,6 @@ bool SandboxMountPointProvider::IsAllowedScheme(const GURL& url) const { // only if --allow-file-access-from-files flag is given. if (url.SchemeIs("http") || url.SchemeIs("https")) return true; - if (url.SchemeIsFileSystem()) - return url.inner_url() && IsAllowedScheme(*url.inner_url()); - for (size_t i = 0; i < file_system_options_.additional_allowed_schemes().size(); ++i) { |