Chromium Code Reviews| 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/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 "components/content_settings/core/browser/cookie_settings.h" | 23 #include "components/content_settings/core/browser/cookie_settings.h" |
| 24 #include "content/public/common/origin_util.h" | |
| 24 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
| 25 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.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 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 74 // come first, and then adds subdomains in reverse order, e.g. | 75 // come first, and then adds subdomains in reverse order, e.g. |
| 75 // 1.mail.google.com would become google.com.mail.1, and then a standard | 76 // 1.mail.google.com would become google.com.mail.1, and then a standard |
| 76 // string comparison works to order hosts by registry controlled domain | 77 // string comparison works to order hosts by registry controlled domain |
| 77 // first. Leading dots are ignored, ".google.com" is the same as | 78 // first. Leading dots are ignored, ".google.com" is the same as |
| 78 // "google.com". | 79 // "google.com". |
|
msramek
2016/05/25 16:09:28
Please expand the comment with the treatment of su
jww
2016/05/25 20:46:22
Done.
| |
| 79 | 80 |
| 80 if (url.SchemeIsFile()) { | 81 if (url.SchemeIsFile()) { |
| 81 return std::string(url::kFileScheme) + | 82 return std::string(url::kFileScheme) + |
| 82 url::kStandardSchemeSeparator; | 83 url::kStandardSchemeSeparator; |
| 83 } | 84 } |
| 84 | 85 |
| 85 std::string host = url.host(); | 86 std::string host = content::HostFromUrlStripSuborigin(url); |
| 86 std::string retval = | 87 std::string retval = |
| 87 net::registry_controlled_domains::GetDomainAndRegistry( | 88 net::registry_controlled_domains::GetDomainAndRegistry( |
| 88 host, | 89 host, |
| 89 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 90 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 90 if (!retval.length()) // Is an IP address or other special origin. | 91 if (!retval.length()) // Is an IP address or other special origin. |
| 91 return host; | 92 return host; |
| 92 | 93 |
| 93 std::string::size_type position = host.rfind(retval); | 94 std::string::size_type position = host.rfind(retval); |
| 94 | 95 |
| 95 // The host may be the registry controlled domain, in which case fail fast. | 96 // The host may be the registry controlled domain, in which case fail fast. |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); | 625 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); |
| 625 } | 626 } |
| 626 | 627 |
| 627 /////////////////////////////////////////////////////////////////////////////// | 628 /////////////////////////////////////////////////////////////////////////////// |
| 628 // CookieTreeHostNode, public: | 629 // CookieTreeHostNode, public: |
| 629 | 630 |
| 630 // static | 631 // static |
| 631 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { | 632 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { |
| 632 const std::string file_origin_node_name( | 633 const std::string file_origin_node_name( |
| 633 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); | 634 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); |
| 634 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name | 635 return base::UTF8ToUTF16(url.SchemeIsFile() |
| 635 : url.host()); | 636 ? file_origin_node_name |
| 637 : content::HostFromUrlStripSuborigin(url)); | |
| 636 } | 638 } |
| 637 | 639 |
| 638 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) | 640 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) |
| 639 : CookieTreeNode(TitleForUrl(url)), | 641 : CookieTreeNode(TitleForUrl(url)), |
| 640 url_(url), | 642 url_(url), |
| 641 canonicalized_host_(CanonicalizeHost(url)) {} | 643 canonicalized_host_(CanonicalizeHost(url)) {} |
| 642 | 644 |
| 643 CookieTreeHostNode::~CookieTreeHostNode() {} | 645 CookieTreeHostNode::~CookieTreeHostNode() {} |
| 644 | 646 |
| 645 std::string CookieTreeHostNode::GetHost() const { | 647 std::string CookieTreeHostNode::GetHost() const { |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1542 void CookiesTreeModel::MaybeNotifyBatchesEnded() { | 1544 void CookiesTreeModel::MaybeNotifyBatchesEnded() { |
| 1543 // Only notify the observers if this is the outermost call to EndBatch() if | 1545 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1544 // called in a nested manner. | 1546 // called in a nested manner. |
| 1545 if (batches_ended_ == batches_started_ && | 1547 if (batches_ended_ == batches_started_ && |
| 1546 batches_seen_ == batches_expected_) { | 1548 batches_seen_ == batches_expected_) { |
| 1547 FOR_EACH_OBSERVER(Observer, | 1549 FOR_EACH_OBSERVER(Observer, |
| 1548 cookies_observer_list_, | 1550 cookies_observer_list_, |
| 1549 TreeModelEndBatch(this)); | 1551 TreeModelEndBatch(this)); |
| 1550 } | 1552 } |
| 1551 } | 1553 } |
| OLD | NEW |