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" | |
26 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
27 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
28 #include "net/cookies/canonical_cookie.h" | 27 #include "net/cookies/canonical_cookie.h" |
29 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
30 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/gfx/image/image_skia.h" | 31 #include "ui/gfx/image/image_skia.h" |
33 #include "ui/resources/grit/ui_resources.h" | 32 #include "ui/resources/grit/ui_resources.h" |
| 33 #include "url/gurl.h" |
| 34 #include "url/origin.h" |
34 | 35 |
35 #if defined(ENABLE_EXTENSIONS) | 36 #if defined(ENABLE_EXTENSIONS) |
36 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 37 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
37 #include "extensions/common/extension_set.h" | 38 #include "extensions/common/extension_set.h" |
38 #endif | 39 #endif |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 struct NodeTitleComparator { | 43 struct NodeTitleComparator { |
43 bool operator()(const std::unique_ptr<CookieTreeNode>& lhs, | 44 bool operator()(const std::unique_ptr<CookieTreeNode>& lhs, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // are part of and should be visualized as part of that host. For example, | 84 // 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 // 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 // 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 // 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. | 88 // host, and thus the suborigin is striped from the URL. |
88 if (url.SchemeIsFile()) { | 89 if (url.SchemeIsFile()) { |
89 return std::string(url::kFileScheme) + | 90 return std::string(url::kFileScheme) + |
90 url::kStandardSchemeSeparator; | 91 url::kStandardSchemeSeparator; |
91 } | 92 } |
92 | 93 |
93 std::string host = content::StripSuboriginFromUrl(url).host(); | 94 // Pass through url::Origin to get the real host, which has the effect of |
| 95 // stripping the suborigin from the URL. |
| 96 std::string host = url::Origin(url).host(); |
94 std::string retval = | 97 std::string retval = |
95 net::registry_controlled_domains::GetDomainAndRegistry( | 98 net::registry_controlled_domains::GetDomainAndRegistry( |
96 host, | 99 host, |
97 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 100 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
98 if (!retval.length()) // Is an IP address or other special origin. | 101 if (!retval.length()) // Is an IP address or other special origin. |
99 return host; | 102 return host; |
100 | 103 |
101 std::string::size_type position = host.rfind(retval); | 104 std::string::size_type position = host.rfind(retval); |
102 | 105 |
103 // The host may be the registry controlled domain, in which case fail fast. | 106 // The host may be the registry controlled domain, in which case fail fast. |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); | 655 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); |
653 } | 656 } |
654 | 657 |
655 /////////////////////////////////////////////////////////////////////////////// | 658 /////////////////////////////////////////////////////////////////////////////// |
656 // CookieTreeHostNode, public: | 659 // CookieTreeHostNode, public: |
657 | 660 |
658 // static | 661 // static |
659 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { | 662 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { |
660 const std::string file_origin_node_name( | 663 const std::string file_origin_node_name( |
661 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); | 664 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); |
662 return base::UTF8ToUTF16(url.SchemeIsFile() | 665 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name |
663 ? file_origin_node_name | 666 : url::Origin(url).host()); |
664 : content::StripSuboriginFromUrl(url).host()); | |
665 } | 667 } |
666 | 668 |
667 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) | 669 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) |
668 : CookieTreeNode(TitleForUrl(url)), | 670 : CookieTreeNode(TitleForUrl(url)), |
669 url_(url), | 671 url_(url), |
670 canonicalized_host_(CanonicalizeHost(url)) {} | 672 canonicalized_host_(CanonicalizeHost(url)) {} |
671 | 673 |
672 CookieTreeHostNode::~CookieTreeHostNode() {} | 674 CookieTreeHostNode::~CookieTreeHostNode() {} |
673 | 675 |
674 std::string CookieTreeHostNode::GetHost() const { | 676 std::string CookieTreeHostNode::GetHost() const { |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 // Only notify the observers if this is the outermost call to EndBatch() if | 1618 // Only notify the observers if this is the outermost call to EndBatch() if |
1617 // called in a nested manner. | 1619 // called in a nested manner. |
1618 if (batches_ended_ == batches_started_ && | 1620 if (batches_ended_ == batches_started_ && |
1619 batches_seen_ == batches_expected_) { | 1621 batches_seen_ == batches_expected_) { |
1620 FOR_EACH_OBSERVER(Observer, | 1622 FOR_EACH_OBSERVER(Observer, |
1621 cookies_observer_list_, | 1623 cookies_observer_list_, |
1622 TreeModelEndBatch(this)); | 1624 TreeModelEndBatch(this)); |
1623 SetBatchExpectation(0, true); | 1625 SetBatchExpectation(0, true); |
1624 } | 1626 } |
1625 } | 1627 } |
OLD | NEW |