| OLD | NEW |
| 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/ptr_util.h" | 15 #include "base/memory/ptr_util.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 Loading... |
| 63 | 64 |
| 64 // We want to order by registry controlled domain, so we would get | 65 // We want to order by registry controlled domain, so we would get |
| 65 // google.com, ad.google.com, www.google.com, | 66 // google.com, ad.google.com, www.google.com, |
| 66 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins | 67 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins |
| 67 // into a form like google.com.www so that string comparisons work. | 68 // into a form like google.com.www so that string comparisons work. |
| 68 return ltn->canonicalized_host() < rtn->canonicalized_host(); | 69 return ltn->canonicalized_host() < 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); | 616 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); |
| 609 } | 617 } |
| 610 | 618 |
| 611 /////////////////////////////////////////////////////////////////////////////// | 619 /////////////////////////////////////////////////////////////////////////////// |
| 612 // CookieTreeHostNode, public: | 620 // CookieTreeHostNode, public: |
| 613 | 621 |
| 614 // static | 622 // static |
| 615 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { | 623 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { |
| 616 const std::string file_origin_node_name( | 624 const std::string file_origin_node_name( |
| 617 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); | 625 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); |
| 618 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name | 626 return base::UTF8ToUTF16(url.SchemeIsFile() |
| 619 : url.host()); | 627 ? file_origin_node_name |
| 628 : content::StripSuboriginFromUrl(url).host()); |
| 620 } | 629 } |
| 621 | 630 |
| 622 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) | 631 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) |
| 623 : CookieTreeNode(TitleForUrl(url)), | 632 : CookieTreeNode(TitleForUrl(url)), |
| 624 url_(url), | 633 url_(url), |
| 625 canonicalized_host_(CanonicalizeHost(url)) {} | 634 canonicalized_host_(CanonicalizeHost(url)) {} |
| 626 | 635 |
| 627 CookieTreeHostNode::~CookieTreeHostNode() {} | 636 CookieTreeHostNode::~CookieTreeHostNode() {} |
| 628 | 637 |
| 629 std::string CookieTreeHostNode::GetHost() const { | 638 std::string CookieTreeHostNode::GetHost() const { |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 // Only notify the observers if this is the outermost call to EndBatch() if | 1526 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1518 // called in a nested manner. | 1527 // called in a nested manner. |
| 1519 if (batches_ended_ == batches_started_ && | 1528 if (batches_ended_ == batches_started_ && |
| 1520 batches_seen_ == batches_expected_) { | 1529 batches_seen_ == batches_expected_) { |
| 1521 FOR_EACH_OBSERVER(Observer, | 1530 FOR_EACH_OBSERVER(Observer, |
| 1522 cookies_observer_list_, | 1531 cookies_observer_list_, |
| 1523 TreeModelEndBatch(this)); | 1532 TreeModelEndBatch(this)); |
| 1524 SetBatchExpectation(0, true); | 1533 SetBatchExpectation(0, true); |
| 1525 } | 1534 } |
| 1526 } | 1535 } |
| OLD | NEW |