Update from https://crrev.com/306655 Includes updates to ui/ and mojo/services for cc and gpu changes and a minor update to a unit test in sky/ for skia interface changes. Review URL: https://codereview.chromium.org/761903003
diff --git a/BUILD.gn b/BUILD.gn index ec15c43..feece8d 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -117,6 +117,7 @@ deps = [ ":url", + "//base", "//base/test:run_all_unittests", "//testing/gtest", "//third_party/icu:icuuc",
diff --git a/gurl.cc b/gurl.cc index b7374b1..b580125 100644 --- a/gurl.cc +++ b/gurl.cc
@@ -322,8 +322,10 @@ } GURL GURL::GetAsReferrer() const { - if (!is_valid_ || - (!has_ref() && !has_username() && !has_password())) + if (!is_valid_ || !SchemeIsHTTPOrHTTPS()) + return GURL(); + + if (!has_ref() && !has_username() && !has_password()) return GURL(*this); url::Replacements<char> replacements;
diff --git a/gurl.h b/gurl.h index 1d388cd..f370934 100644 --- a/gurl.h +++ b/gurl.h
@@ -198,7 +198,8 @@ // A helper function to return a GURL stripped from the elements that are not // supposed to be sent as HTTP referrer: username, password and ref fragment. - // For invalid URLs the original URL will be returned. + // For invalid URLs or URLs that no valid referrers, an empty URL will be + // returned. GURL GetAsReferrer() const; // Returns true if the scheme for the current URL is a known "standard"
diff --git a/gurl_unittest.cc b/gurl_unittest.cc index 3e94550..a699189 100644 --- a/gurl_unittest.cc +++ b/gurl_unittest.cc
@@ -343,6 +343,10 @@ {"http://:pass@www.google.com", "http://www.google.com/"}, {"http://:@www.google.com", "http://www.google.com/"}, {"http://www.google.com/temp/foo?q#b", "http://www.google.com/temp/foo?q"}, + {"not a url", ""}, + {"unknown-scheme://foo.html", ""}, + {"file:///tmp/test.html", ""}, + {"https://www.google.com", "https://www.google.com/"}, }; for (size_t i = 0; i < arraysize(cases); i++) { GURL url(cases[i].input);
diff --git a/origin.cc b/origin.cc index eb2cf14..8aaa173 100644 --- a/origin.cc +++ b/origin.cc
@@ -13,7 +13,7 @@ Origin::Origin(const std::string& origin) : string_(origin) { DCHECK(origin == "null" || MatchPattern(origin, "?*://?*")); DCHECK_GT(origin.size(), 0u); - DCHECK_NE(origin[origin.size() - 1], '/'); + DCHECK(origin == "file://" || origin[origin.size() - 1] != '/'); } } // namespace url
diff --git a/origin_unittest.cc b/origin_unittest.cc index d08342e..c094ee6 100644 --- a/origin_unittest.cc +++ b/origin_unittest.cc
@@ -26,6 +26,11 @@ EXPECT_EQ("http://example.com:8080", origin.string()); } +TEST(OriginTest, constructValidFileOrigin) { + Origin origin("file://"); + EXPECT_EQ("file://", origin.string()); +} + TEST(OriginTest, constructValidOriginWithoutPort) { Origin origin("wss://example2.com"); EXPECT_EQ("wss://example2.com", origin.string());
diff --git a/url_constants.cc b/url_constants.cc index 9ef0e63..2dc1478 100644 --- a/url_constants.cc +++ b/url_constants.cc
@@ -10,6 +10,7 @@ const char kAboutScheme[] = "about"; const char kBlobScheme[] = "blob"; +const char kContentScheme[] = "content"; const char kDataScheme[] = "data"; const char kFileScheme[] = "file"; const char kFileSystemScheme[] = "filesystem";
diff --git a/url_constants.h b/url_constants.h index 3228bbb..c48dafc 100644 --- a/url_constants.h +++ b/url_constants.h
@@ -13,6 +13,8 @@ URL_EXPORT extern const char kAboutScheme[]; URL_EXPORT extern const char kBlobScheme[]; +// The content scheme is specific to Android for identifying a stored file. +URL_EXPORT extern const char kContentScheme[]; URL_EXPORT extern const char kDataScheme[]; URL_EXPORT extern const char kFileScheme[]; URL_EXPORT extern const char kFileSystemScheme[];