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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 std::string CanonicalizeHost(const GURL& url) { | 66 std::string CanonicalizeHost(const GURL& url) { |
67 // The canonicalized representation makes the registry controlled domain | 67 // The canonicalized representation makes the registry controlled domain |
68 // come first, and then adds subdomains in reverse order, e.g. | 68 // come first, and then adds subdomains in reverse order, e.g. |
69 // 1.mail.google.com would become google.com.mail.1, and then a standard | 69 // 1.mail.google.com would become google.com.mail.1, and then a standard |
70 // string comparison works to order hosts by registry controlled domain | 70 // string comparison works to order hosts by registry controlled domain |
71 // first. Leading dots are ignored, ".google.com" is the same as | 71 // first. Leading dots are ignored, ".google.com" is the same as |
72 // "google.com". | 72 // "google.com". |
73 | 73 |
74 if (url.SchemeIsFile()) { | 74 if (url.SchemeIsFile()) { |
75 return std::string(content::kFileScheme) + | 75 return std::string(url::kFileScheme) + |
76 content::kStandardSchemeSeparator; | 76 content::kStandardSchemeSeparator; |
77 } | 77 } |
78 | 78 |
79 std::string host = url.host(); | 79 std::string host = url.host(); |
80 std::string retval = | 80 std::string retval = |
81 net::registry_controlled_domains::GetDomainAndRegistry( | 81 net::registry_controlled_domains::GetDomainAndRegistry( |
82 host, | 82 host, |
83 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 83 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
84 if (!retval.length()) // Is an IP address or other special origin. | 84 if (!retval.length()) // Is an IP address or other special origin. |
85 return host; | 85 return host; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { | 552 CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { |
553 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); | 553 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); |
554 } | 554 } |
555 | 555 |
556 /////////////////////////////////////////////////////////////////////////////// | 556 /////////////////////////////////////////////////////////////////////////////// |
557 // CookieTreeHostNode, public: | 557 // CookieTreeHostNode, public: |
558 | 558 |
559 // static | 559 // static |
560 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { | 560 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { |
561 const std::string file_origin_node_name( | 561 const std::string file_origin_node_name( |
562 std::string(content::kFileScheme) + content::kStandardSchemeSeparator); | 562 std::string(url::kFileScheme) + content::kStandardSchemeSeparator); |
563 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name | 563 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name |
564 : url.host()); | 564 : url.host()); |
565 } | 565 } |
566 | 566 |
567 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) | 567 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) |
568 : CookieTreeNode(TitleForUrl(url)), | 568 : CookieTreeNode(TitleForUrl(url)), |
569 cookies_child_(NULL), | 569 cookies_child_(NULL), |
570 databases_child_(NULL), | 570 databases_child_(NULL), |
571 local_storages_child_(NULL), | 571 local_storages_child_(NULL), |
572 session_storages_child_(NULL), | 572 session_storages_child_(NULL), |
573 appcaches_child_(NULL), | 573 appcaches_child_(NULL), |
574 indexed_dbs_child_(NULL), | 574 indexed_dbs_child_(NULL), |
575 file_systems_child_(NULL), | 575 file_systems_child_(NULL), |
576 quota_child_(NULL), | 576 quota_child_(NULL), |
577 server_bound_certs_child_(NULL), | 577 server_bound_certs_child_(NULL), |
578 flash_lso_child_(NULL), | 578 flash_lso_child_(NULL), |
579 url_(url), | 579 url_(url), |
580 canonicalized_host_(CanonicalizeHost(url)) {} | 580 canonicalized_host_(CanonicalizeHost(url)) {} |
581 | 581 |
582 CookieTreeHostNode::~CookieTreeHostNode() {} | 582 CookieTreeHostNode::~CookieTreeHostNode() {} |
583 | 583 |
584 const std::string CookieTreeHostNode::GetHost() const { | 584 const std::string CookieTreeHostNode::GetHost() const { |
585 const std::string file_origin_node_name( | 585 const std::string file_origin_node_name( |
586 std::string(content::kFileScheme) + content::kStandardSchemeSeparator); | 586 std::string(url::kFileScheme) + content::kStandardSchemeSeparator); |
587 return url_.SchemeIsFile() ? file_origin_node_name : url_.host(); | 587 return url_.SchemeIsFile() ? file_origin_node_name : url_.host(); |
588 } | 588 } |
589 | 589 |
590 CookieTreeNode::DetailedInfo CookieTreeHostNode::GetDetailedInfo() const { | 590 CookieTreeNode::DetailedInfo CookieTreeHostNode::GetDetailedInfo() const { |
591 return DetailedInfo().InitHost(); | 591 return DetailedInfo().InitHost(); |
592 } | 592 } |
593 | 593 |
594 CookieTreeCookiesNode* CookieTreeHostNode::GetOrCreateCookiesNode() { | 594 CookieTreeCookiesNode* CookieTreeHostNode::GetOrCreateCookiesNode() { |
595 if (cookies_child_) | 595 if (cookies_child_) |
596 return cookies_child_; | 596 return cookies_child_; |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 | 1335 |
1336 void CookiesTreeModel::NotifyObserverEndBatch() { | 1336 void CookiesTreeModel::NotifyObserverEndBatch() { |
1337 // Only notify the observers if this is the outermost call to EndBatch() if | 1337 // Only notify the observers if this is the outermost call to EndBatch() if |
1338 // called in a nested manner. | 1338 // called in a nested manner. |
1339 if (--batch_update_ == 0) { | 1339 if (--batch_update_ == 0) { |
1340 FOR_EACH_OBSERVER(Observer, | 1340 FOR_EACH_OBSERVER(Observer, |
1341 cookies_observer_list_, | 1341 cookies_observer_list_, |
1342 TreeModelEndBatch(this)); | 1342 TreeModelEndBatch(this)); |
1343 } | 1343 } |
1344 } | 1344 } |
OLD | NEW |