Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Unified Diff: chrome/browser/browsing_data/cookies_tree_model.cc

Issue 2005783005: Re-enable storage for Suborigins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address msramek's nits and add comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/cookies_tree_model.cc
diff --git a/chrome/browser/browsing_data/cookies_tree_model.cc b/chrome/browser/browsing_data/cookies_tree_model.cc
index 959624e12a0d987bad35f31d0e4275cfa89e3e80..f6e83550e334c0e9a886ea4a92f739185bf07cdc 100644
--- a/chrome/browser/browsing_data/cookies_tree_model.cc
+++ b/chrome/browser/browsing_data/cookies_tree_model.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/cookie_settings.h"
+#include "content/public/common/origin_util.h"
#include "content/public/common/url_constants.h"
#include "grit/theme_resources.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
@@ -70,19 +71,27 @@ struct HostNodeComparator {
};
std::string CanonicalizeHost(const GURL& url) {
- // The canonicalized representation makes the registry controlled domain
- // come first, and then adds subdomains in reverse order, e.g.
- // 1.mail.google.com would become google.com.mail.1, and then a standard
- // string comparison works to order hosts by registry controlled domain
- // first. Leading dots are ignored, ".google.com" is the same as
- // "google.com".
+ // The canonicalized representation makes the registry controlled domain come
+ // first, and then adds subdomains in reverse order, e.g. 1.mail.google.com
+ // would become google.com.mail.1, and then a standard string comparison works
+ // to order hosts by registry controlled domain first. Leading dots are
+ // ignored, ".google.com" is the same as "google.com".
+ //
+ // Suborigins, an experimental Web platform feature defined in
+ // https://w3c.github.io/webappsec-suborigins/, are treated as part of the
+ // physical origin they are associated with. From a users perspective, they
+ // are part of and should be visualized as part of that host. For example,
+ // given a a Suborigin 'foobar' at 'https://example.com', this is serialized
+ // into the URL as 'https://foobar_example.com'. Thus, the host for this URL
+ // is canonicalized as 'example.com' to treat it as being part of that host,
+ // and thus the Suborigin is striped from the URL.
if (url.SchemeIsFile()) {
return std::string(url::kFileScheme) +
url::kStandardSchemeSeparator;
}
- std::string host = url.host();
+ std::string host = content::HostFromUrlStripSuborigin(url);
std::string retval =
net::registry_controlled_domains::GetDomainAndRegistry(
host,
@@ -631,8 +640,9 @@ CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const {
base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) {
const std::string file_origin_node_name(
std::string(url::kFileScheme) + url::kStandardSchemeSeparator);
- return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name
- : url.host());
+ return base::UTF8ToUTF16(url.SchemeIsFile()
+ ? file_origin_node_name
+ : content::HostFromUrlStripSuborigin(url));
}
CookieTreeHostNode::CookieTreeHostNode(const GURL& url)

Powered by Google App Engine
This is Rietveld 408576698