| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); | 619 return DetailedInfo().Init(DetailedInfo::TYPE_ROOT); |
| 617 } | 620 } |
| 618 | 621 |
| 619 /////////////////////////////////////////////////////////////////////////////// | 622 /////////////////////////////////////////////////////////////////////////////// |
| 620 // CookieTreeHostNode, public: | 623 // CookieTreeHostNode, public: |
| 621 | 624 |
| 622 // static | 625 // static |
| 623 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { | 626 base::string16 CookieTreeHostNode::TitleForUrl(const GURL& url) { |
| 624 const std::string file_origin_node_name( | 627 const std::string file_origin_node_name( |
| 625 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); | 628 std::string(url::kFileScheme) + url::kStandardSchemeSeparator); |
| 626 return base::UTF8ToUTF16(url.SchemeIsFile() | 629 return base::UTF8ToUTF16(url.SchemeIsFile() ? file_origin_node_name |
| 627 ? file_origin_node_name | 630 : url::Origin(url).host()); |
| 628 : content::StripSuboriginFromUrl(url).host()); | |
| 629 } | 631 } |
| 630 | 632 |
| 631 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) | 633 CookieTreeHostNode::CookieTreeHostNode(const GURL& url) |
| 632 : CookieTreeNode(TitleForUrl(url)), | 634 : CookieTreeNode(TitleForUrl(url)), |
| 633 url_(url), | 635 url_(url), |
| 634 canonicalized_host_(CanonicalizeHost(url)) {} | 636 canonicalized_host_(CanonicalizeHost(url)) {} |
| 635 | 637 |
| 636 CookieTreeHostNode::~CookieTreeHostNode() {} | 638 CookieTreeHostNode::~CookieTreeHostNode() {} |
| 637 | 639 |
| 638 std::string CookieTreeHostNode::GetHost() const { | 640 std::string CookieTreeHostNode::GetHost() const { |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 // Only notify the observers if this is the outermost call to EndBatch() if | 1528 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1527 // called in a nested manner. | 1529 // called in a nested manner. |
| 1528 if (batches_ended_ == batches_started_ && | 1530 if (batches_ended_ == batches_started_ && |
| 1529 batches_seen_ == batches_expected_) { | 1531 batches_seen_ == batches_expected_) { |
| 1530 FOR_EACH_OBSERVER(Observer, | 1532 FOR_EACH_OBSERVER(Observer, |
| 1531 cookies_observer_list_, | 1533 cookies_observer_list_, |
| 1532 TreeModelEndBatch(this)); | 1534 TreeModelEndBatch(this)); |
| 1533 SetBatchExpectation(0, true); | 1535 SetBatchExpectation(0, true); |
| 1534 } | 1536 } |
| 1535 } | 1537 } |
| OLD | NEW |