summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-06 05:06:20 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-06 05:06:20 +0000
commit7fc13edf63fcb30391edec083ea496809607917a (patch)
tree16d7123511520ba9b7f1ca1d36093bdc71dc97d1
parent309d27740389acc1cfdda031b8fb43781e6022a3 (diff)
downloadchromium_src-7fc13edf63fcb30391edec083ea496809607917a.zip
chromium_src-7fc13edf63fcb30391edec083ea496809607917a.tar.gz
chromium_src-7fc13edf63fcb30391edec083ea496809607917a.tar.bz2
Pulls the latest googleurl to get the fix for
BUG=http://crbug.com/160 and integrates the update to IsStandard in that version. Adds several internal schemes as "standard" and initializes them at startup. Fixes a few hardcoded URL schemes I noticed. Make typing "//foo" into the URL bar treat slashes in "strict" mode on Windows, which means we'll only accept UNC if you use backslashes. This matches IE's behavior. BUG=http://crbug.com/33038 TEST=covered by unit tests git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40818 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--chrome/app/chrome_dll_main.cc6
-rw-r--r--chrome/browser/child_process_security_policy.cc2
-rw-r--r--chrome/browser/dom_ui/chrome_url_data_manager.cc5
-rw-r--r--chrome/browser/extensions/extension_popup_api.cc3
-rw-r--r--chrome/browser/extensions/extension_process_manager_unittest.cc6
-rw-r--r--chrome/browser/net/url_fixer_upper.cc8
-rw-r--r--chrome/browser/net/url_fixer_upper_unittest.cc10
-rw-r--r--chrome/chrome_common.gypi1
-rw-r--r--chrome/common/url_constants.cc8
-rw-r--r--chrome/common/url_constants.h4
-rw-r--r--chrome/test/unit/chrome_test_suite.h2
-rw-r--r--net/base/net_util_unittest.cc4
-rw-r--r--net/url_request/request_tracker_unittest.cc18
14 files changed, 54 insertions, 25 deletions
diff --git a/DEPS b/DEPS
index fa23dd2..7a448e4 100644
--- a/DEPS
+++ b/DEPS
@@ -17,7 +17,7 @@ deps = {
"/trunk/deps/support@20411",
"src/googleurl":
- "http://google-url.googlecode.com/svn/trunk@122",
+ "http://google-url.googlecode.com/svn/trunk@124",
"src/sdch/open-vcdiff":
"http://open-vcdiff.googlecode.com/svn/trunk@28",
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index b8188bf..60d5d6a 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -55,6 +55,7 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/sandbox_init_wrapper.h"
+#include "chrome/common/url_constants.h"
#include "ipc/ipc_switches.h"
#if defined(USE_NSS)
@@ -644,6 +645,11 @@ int ChromeMain(int argc, char** argv) {
}
logging::InitChromeLogging(parsed_command_line, file_state);
+ // Register internal Chrome schemes so they'll be parsed correctly. This must
+ // happen before we process any URLs with the affected schemes, and must be
+ // done in all processes that work with these URLs (i.e. including renderers).
+ chrome::RegisterChromeSchemes();
+
#ifdef NDEBUG
if (parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK) &&
parsed_command_line.HasSwitch(switches::kEnableDCHECK)) {
diff --git a/chrome/browser/child_process_security_policy.cc b/chrome/browser/child_process_security_policy.cc
index 7f28d31..615364e 100644
--- a/chrome/browser/child_process_security_policy.cc
+++ b/chrome/browser/child_process_security_policy.cc
@@ -108,7 +108,7 @@ ChildProcessSecurityPolicy::ChildProcessSecurityPolicy() {
RegisterWebSafeScheme(chrome::kFtpScheme);
RegisterWebSafeScheme(chrome::kDataScheme);
RegisterWebSafeScheme("feed");
- RegisterWebSafeScheme("chrome-extension");
+ RegisterWebSafeScheme(chrome::kExtensionScheme);
// We know about the following psuedo schemes and treat them specially.
RegisterPseudoScheme(chrome::kAboutScheme);
diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc
index d6b73ff..0fa68d4 100644
--- a/chrome/browser/dom_ui/chrome_url_data_manager.cc
+++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc
@@ -94,11 +94,8 @@ void RegisterURLRequestChromeJob() {
// Being a standard scheme allows us to resolve relative paths. This method
// is invoked multiple times during testing, so only add the scheme once.
url_parse::Component url_scheme_component(0, strlen(chrome::kChromeUIScheme));
- if (!url_util::IsStandard(chrome::kChromeUIScheme,
- strlen(chrome::kChromeUIScheme),
- url_scheme_component)) {
+ if (!url_util::IsStandard(chrome::kChromeUIScheme, url_scheme_component))
url_util::AddStandardScheme(chrome::kChromeUIScheme);
- }
FilePath inspector_dir;
if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) {
diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc
index d6edbc0..00e6365 100644
--- a/chrome/browser/extensions/extension_popup_api.cc
+++ b/chrome/browser/extensions/extension_popup_api.cc
@@ -12,6 +12,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
+#include "chrome/common/url_constants.h"
#include "chrome/browser/extensions/extension_dom_ui.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_message_service.h"
@@ -137,7 +138,7 @@ bool PopupShowFunction::RunImpl() {
// extension view's extension.
const std::string& extension_id = url.host();
if (extension_id != dispatcher()->GetExtension()->id() ||
- !url.SchemeIs("chrome-extension")) {
+ !url.SchemeIs(chrome::kExtensionScheme)) {
error_ = kInvalidURLError;
return false;
}
diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/extension_process_manager_unittest.cc
index 76c163d..ae9eefe 100644
--- a/chrome/browser/extensions/extension_process_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_process_manager_unittest.cc
@@ -41,9 +41,9 @@ TEST_F(ExtensionProcessManagerTest, ProcessGrouping) {
// Extensions with common origins ("scheme://id/") should be grouped in the
// same SiteInstance.
- GURL ext1_url1("chrome-extensions://ext1_id/index.html");
- GURL ext1_url2("chrome-extensions://ext1_id/toolstrips/toolstrip.html");
- GURL ext2_url1("chrome-extensions://ext2_id/index.html");
+ GURL ext1_url1("chrome-extension://ext1_id/index.html");
+ GURL ext1_url2("chrome-extension://ext1_id/toolstrips/toolstrip.html");
+ GURL ext2_url1("chrome-extension://ext2_id/index.html");
scoped_refptr<SiteInstance> site11 =
manager1->GetSiteInstanceForURL(ext1_url1);
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index 6909ddf..cc85420 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -399,7 +399,7 @@ string URLFixerUpper::SegmentURL(const string& text,
#if defined(OS_WIN)
int trimmed_length = static_cast<int>(trimmed.length());
if (url_parse::DoesBeginWindowsDriveSpec(trimmed.data(), 0, trimmed_length) ||
- url_parse::DoesBeginUNCPath(trimmed.data(), 0, trimmed_length, false))
+ url_parse::DoesBeginUNCPath(trimmed.data(), 0, trimmed_length, true))
return "file";
#elif defined(OS_POSIX)
if (FilePath::IsSeparator(trimmed.data()[0]) || trimmed.data()[0] == '~')
@@ -417,7 +417,7 @@ string URLFixerUpper::SegmentURL(const string& text,
// Not segmenting file schemes or nonstandard schemes.
if ((scheme == chrome::kFileScheme) ||
- !url_util::IsStandard(scheme.c_str(), static_cast<int>(scheme.length()),
+ !url_util::IsStandard(scheme.c_str(),
url_parse::Component(0, static_cast<int>(scheme.length()))))
return scheme;
@@ -476,7 +476,7 @@ string URLFixerUpper::FixupURL(const string& text,
return (parts.scheme.is_valid() ? text : FixupPath(text));
// For some schemes whose layouts we understand, we rebuild it.
- if (url_util::IsStandard(scheme.c_str(), static_cast<int>(scheme.length()),
+ if (url_util::IsStandard(scheme.c_str(),
url_parse::Component(0, static_cast<int>(scheme.length())))) {
string url(scheme);
url.append("://");
diff --git a/chrome/browser/net/url_fixer_upper_unittest.cc b/chrome/browser/net/url_fixer_upper_unittest.cc
index a9d77ed..2205f73 100644
--- a/chrome/browser/net/url_fixer_upper_unittest.cc
+++ b/chrome/browser/net/url_fixer_upper_unittest.cc
@@ -342,8 +342,16 @@ TEST(URLFixerUpperTest, FixupFile) {
// should be returned just converted to a file: URL.
{"\\\\SomeNonexistentHost\\foo\\bar.txt", "",
"file://somenonexistenthost/foo/bar.txt"},
+ // We do this strictly, like IE8, which only accepts this form using
+ // backslashes and not forward ones. Its a bit weird that the host/path is
+ // "more canonicalized" in the UNC case above, and in the http case it
+ // isn't lowercased, etc. That level of canonicalization will happen when
+ // it's actually turned into a GURL, so we don't care about it here. Turning
+ // "//foo" into "http" matches Firefox and IE, silly though it may seem
+ // (it falls out of adding "http" as the default protocol if you haven't
+ // entered one).
{"//SomeNonexistentHost\\foo/bar.txt", "",
- "file://somenonexistenthost/foo/bar.txt"},
+ "http://SomeNonexistentHost\\foo/bar.txt"},
{"file:///C:/foo/bar", "", "file:///C:/foo/bar"},
// These are fixups we don't do, but could consider:
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index f8772cc..6ef8050 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -347,6 +347,7 @@
'../webkit/glue/webkit_glue_dummy.cc',
'common/resource_dispatcher_dummy.cc',
'common/socket_stream_dispatcher_dummy.cc',
+ 'common/url_constants.cc',
],
'export_dependent_settings': [
'../app/app.gyp:app_base_nacl_win64',
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 6ddf90c..f2e3ff7 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include "chrome/common/url_constants.h"
+#include "googleurl/src/url_util.h"
namespace chrome {
@@ -82,4 +83,11 @@ const char kSyncSetupDonePath[] = "setupdone";
const char kNetworkViewInternalsURL[] = "chrome://net-internals/";
const char kNetworkViewCacheURL[] = "chrome://net-internals/view-cache";
+void RegisterChromeSchemes() {
+ // Don't need "chrome-internal" which was used in old versions of Chrome for
+ // the new tab page.
+ url_util::AddStandardScheme(kChromeUIScheme);
+ url_util::AddStandardScheme(kExtensionScheme);
+}
+
} // namespace chrome
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index f7f1476..a44992f 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -83,6 +83,10 @@ extern const char kSyncSetupDonePath[];
extern const char kNetworkViewCacheURL[];
extern const char kNetworkViewInternalsURL[];
+// Call near the beginning of startup to register Chrome's internal URLs that
+// should be parsed as "standard" with the googleurl library.
+void RegisterChromeSchemes();
+
} // namespace chrome
#endif // CHROME_COMMON_URL_CONSTANTS_H_
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 7a77a94..72e9baa 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -22,6 +22,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/testing_browser_process.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/net_util.h"
@@ -94,6 +95,7 @@ class ChromeTestSuite : public TestSuite {
TestSuite::Initialize();
+ chrome::RegisterChromeSchemes();
host_resolver_proc_ = new WarningHostResolverProc();
scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc
index 9265f0a4..f24b10a 100644
--- a/net/base/net_util_unittest.cc
+++ b/net/base/net_util_unittest.cc
@@ -1592,9 +1592,9 @@ TEST(NetUtilTest, SimplifyUrlForRequest) {
"ftp://user:pass@google.com:80/sup?yo#X#X",
"ftp://google.com:80/sup?yo",
},
- { // Try an standard URL with unknow scheme.
+ { // Try an nonstandard URL
+ "foobar://user:pass@google.com:80/sup?yo#X#X",
"foobar://user:pass@google.com:80/sup?yo#X#X",
- "foobar://google.com:80/sup?yo",
},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
diff --git a/net/url_request/request_tracker_unittest.cc b/net/url_request/request_tracker_unittest.cc
index d31587c..633c923 100644
--- a/net/url_request/request_tracker_unittest.cc
+++ b/net/url_request/request_tracker_unittest.cc
@@ -199,30 +199,32 @@ TEST(RequestTrackerTest, GraveyardCanBeFiltered) {
tracker.SetGraveyardFilter(ShouldRequestBeAddedToGraveyard);
// This will be excluded.
- TestRequest req1(GURL("chrome://dontcare"));
+ GURL url1("chrome://dontcare/");
+ TestRequest req1(url1);
tracker.Add(&req1);
tracker.Remove(&req1);
// This will be be added to graveyard.
- TestRequest req2(GURL("chrome2://dontcare"));
+ GURL url2("chrome2://dontcare/");
+ TestRequest req2(url2);
tracker.Add(&req2);
tracker.Remove(&req2);
// This will be be added to graveyard.
- TestRequest req3(GURL("http://foo"));
+ GURL url3("http://foo/");
+ TestRequest req3(url3);
tracker.Add(&req3);
tracker.Remove(&req3);
// This will be be excluded.
- TestRequest req4(GURL("data:sup"));
+ GURL url4("data:sup");
+ TestRequest req4(url4);
tracker.Add(&req4);
tracker.Remove(&req4);
ASSERT_EQ(2u, tracker.GetRecentlyDeceased().size());
- EXPECT_EQ("chrome2://dontcare/",
- tracker.GetRecentlyDeceased()[0].original_url.spec());
- EXPECT_EQ("http://foo/",
- tracker.GetRecentlyDeceased()[1].original_url.spec());
+ EXPECT_EQ(url2, tracker.GetRecentlyDeceased()[0].original_url);
+ EXPECT_EQ(url3, tracker.GetRecentlyDeceased()[1].original_url);
}
// Convert an unbounded tracker back to being bounded.