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

Side by Side 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: Compile fix Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/cookies_tree_model.h" 5 #include "chrome/browser/browsing_data/cookies_tree_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
11 #include <map> 11 #include <map>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" 18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" 19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
20 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" 20 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
21 #include "chrome/browser/content_settings/cookie_settings_factory.h" 21 #include "chrome/browser/content_settings/cookie_settings_factory.h"
22 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "chrome/grit/theme_resources.h" 23 #include "chrome/grit/theme_resources.h"
24 #include "components/content_settings/core/browser/cookie_settings.h" 24 #include "components/content_settings/core/browser/cookie_settings.h"
25 #include "content/public/common/origin_util.h"
25 #include "content/public/common/url_constants.h" 26 #include "content/public/common/url_constants.h"
26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 27 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
27 #include "net/cookies/canonical_cookie.h" 28 #include "net/cookies/canonical_cookie.h"
28 #include "net/url_request/url_request_context.h" 29 #include "net/url_request/url_request_context.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/image/image_skia.h" 32 #include "ui/gfx/image/image_skia.h"
32 #include "ui/resources/grit/ui_resources.h" 33 #include "ui/resources/grit/ui_resources.h"
33 34
34 #if defined(ENABLE_EXTENSIONS) 35 #if defined(ENABLE_EXTENSIONS)
(...skipping 28 matching lines...) Expand all
63 // We want to order by registry controlled domain, so we would get 64 // We want to order by registry controlled domain, so we would get
64 // google.com, ad.google.com, www.google.com, 65 // google.com, ad.google.com, www.google.com,
65 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins 66 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins
66 // into a form like google.com.www so that string comparisons work. 67 // into a form like google.com.www so that string comparisons work.
67 return (ltn->canonicalized_host() < 68 return (ltn->canonicalized_host() <
68 rtn->canonicalized_host()); 69 rtn->canonicalized_host());
69 } 70 }
70 }; 71 };
71 72
72 std::string CanonicalizeHost(const GURL& url) { 73 std::string CanonicalizeHost(const GURL& url) {
73 // The canonicalized representation makes the registry controlled domain 74 // The canonicalized representation makes the registry controlled domain come
74 // come first, and then adds subdomains in reverse order, e.g. 75 // first, and then adds subdomains in reverse order, e.g. 1.mail.google.com
75 // 1.mail.google.com would become google.com.mail.1, and then a standard 76 // would become google.com.mail.1, and then a standard string comparison works
76 // string comparison works to order hosts by registry controlled domain 77 // to order hosts by registry controlled domain first. Leading dots are
77 // first. Leading dots are ignored, ".google.com" is the same as 78 // ignored, ".google.com" is the same as "google.com".
78 // "google.com". 79 //
79 80 // Suborigins, an experimental web platform feature defined in
81 // https://w3c.github.io/webappsec-suborigins/, are treated as part of the
82 // physical origin they are associated with. From a users perspective, they
83 // are part of and should be visualized as part of that host. For example,
84 // given a a suborigin 'foobar' at 'https://example.com', this is serialized
85 // into the URL as 'https-so://foobar.example.com'. Thus, the host for this
86 // URL is canonicalized as 'example.com' to treat it as being part of that
87 // host, and thus the suborigin is striped from the URL.
80 if (url.SchemeIsFile()) { 88 if (url.SchemeIsFile()) {
81 return std::string(url::kFileScheme) + 89 return std::string(url::kFileScheme) +
82 url::kStandardSchemeSeparator; 90 url::kStandardSchemeSeparator;
83 } 91 }
84 92
85 std::string host = url.host(); 93 std::string host = content::StripSuboriginFromUrl(url).host();
86 std::string retval = 94 std::string retval =
87 net::registry_controlled_domains::GetDomainAndRegistry( 95 net::registry_controlled_domains::GetDomainAndRegistry(
88 host, 96 host,
89 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 97 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
90 if (!retval.length()) // Is an IP address or other special origin. 98 if (!retval.length()) // Is an IP address or other special origin.
91 return host; 99 return host;
92 100
93 std::string::size_type position = host.rfind(retval); 101 std::string::size_type position = host.rfind(retval);
94 102
95 // The host may be the registry controlled domain, in which case fail fast. 103 // The host may be the registry controlled domain, in which case fail fast.
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); 617 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT);
610 } 618 }
611 619
612 /////////////////////////////////////////////////////////////////////////////// 620 ///////////////////////////////////////////////////////////////////////////////
613 // CookieTreeHostNode, public: 621 // CookieTreeHostNode, public:
614 622
615 // static 623 // static
616 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { 624 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) {
617 const std::string file_origin_node_name( 625 const std::string file_origin_node_name(
618 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); 626 std::string(url::kFileScheme) + url::kStandardSchemeSeparator);
619 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name 627 return base::UTF8ToUTF16(url.SchemeIsFile()
620 : url.host()); 628 ? file_origin_node_name
629 : content::StripSuboriginFromUrl(url).host());
621 } 630 }
622 631
623 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) 632 CookieTreeHostNode::CookieTreeHostNode(const GURL& url)
624 : CookieTreeNode(TitleForUrl(url)), 633 : CookieTreeNode(TitleForUrl(url)),
625 url_(url), 634 url_(url),
626 canonicalized_host_(CanonicalizeHost(url)) {} 635 canonicalized_host_(CanonicalizeHost(url)) {}
627 636
628 CookieTreeHostNode::~CookieTreeHostNode() {} 637 CookieTreeHostNode::~CookieTreeHostNode() {}
629 638
630 std::string CookieTreeHostNode::GetHost() const { 639 std::string CookieTreeHostNode::GetHost() const {
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 // Only notify the observers if this is the outermost call to EndBatch() if 1531 // Only notify the observers if this is the outermost call to EndBatch() if
1523 // called in a nested manner. 1532 // called in a nested manner.
1524 if (batches_ended_ == batches_started_ && 1533 if (batches_ended_ == batches_started_ &&
1525 batches_seen_ == batches_expected_) { 1534 batches_seen_ == batches_expected_) {
1526 FOR_EACH_OBSERVER(Observer, 1535 FOR_EACH_OBSERVER(Observer,
1527 cookies_observer_list_, 1536 cookies_observer_list_,
1528 TreeModelEndBatch(this)); 1537 TreeModelEndBatch(this));
1529 SetBatchExpectation(0, true); 1538 SetBatchExpectation(0, true);
1530 } 1539 }
1531 } 1540 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698