| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 mock_browsing_data_quota_helper_ = nullptr; | 101 mock_browsing_data_quota_helper_ = nullptr; |
| 102 mock_browsing_data_file_system_helper_ = nullptr; | 102 mock_browsing_data_file_system_helper_ = nullptr; |
| 103 mock_browsing_data_indexed_db_helper_ = nullptr; | 103 mock_browsing_data_indexed_db_helper_ = nullptr; |
| 104 mock_browsing_data_appcache_helper_ = nullptr; | 104 mock_browsing_data_appcache_helper_ = nullptr; |
| 105 mock_browsing_data_session_storage_helper_ = nullptr; | 105 mock_browsing_data_session_storage_helper_ = nullptr; |
| 106 mock_browsing_data_local_storage_helper_ = nullptr; | 106 mock_browsing_data_local_storage_helper_ = nullptr; |
| 107 mock_browsing_data_database_helper_ = nullptr; | 107 mock_browsing_data_database_helper_ = nullptr; |
| 108 mock_browsing_data_flash_lso_helper_ = nullptr; | 108 mock_browsing_data_flash_lso_helper_ = nullptr; |
| 109 base::RunLoop().RunUntilIdle(); | 109 base::RunLoop().RunUntilIdle(); |
| 110 } | 110 } |
| 111 | |
| 112 std::unique_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample() { | 111 std::unique_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample() { |
| 113 LocalDataContainer* container = | 112 LocalDataContainer* container = |
| 114 new LocalDataContainer(mock_browsing_data_cookie_helper_, | 113 new LocalDataContainer(mock_browsing_data_cookie_helper_, |
| 115 mock_browsing_data_database_helper_, | 114 mock_browsing_data_database_helper_, |
| 116 mock_browsing_data_local_storage_helper_, | 115 mock_browsing_data_local_storage_helper_, |
| 117 mock_browsing_data_session_storage_helper_, | 116 mock_browsing_data_session_storage_helper_, |
| 118 mock_browsing_data_appcache_helper_, | 117 mock_browsing_data_appcache_helper_, |
| 119 mock_browsing_data_indexed_db_helper_, | 118 mock_browsing_data_indexed_db_helper_, |
| 120 mock_browsing_data_file_system_helper_, | 119 mock_browsing_data_file_system_helper_, |
| 121 mock_browsing_data_quota_helper_, | 120 mock_browsing_data_quota_helper_, |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 mock_browsing_data_cache_storage_helper_, | 1645 mock_browsing_data_cache_storage_helper_, |
| 1647 mock_browsing_data_flash_lso_helper_); | 1646 mock_browsing_data_flash_lso_helper_); |
| 1648 CookiesTreeModel cookies_model(container, special_storage_policy()); | 1647 CookiesTreeModel cookies_model(container, special_storage_policy()); |
| 1649 | 1648 |
| 1650 mock_browsing_data_cookie_helper_-> | 1649 mock_browsing_data_cookie_helper_-> |
| 1651 AddCookieSamples(GURL(), "A=1"); | 1650 AddCookieSamples(GURL(), "A=1"); |
| 1652 mock_browsing_data_cookie_helper_->Notify(); | 1651 mock_browsing_data_cookie_helper_->Notify(); |
| 1653 EXPECT_EQ("A", GetDisplayedCookies(&cookies_model)); | 1652 EXPECT_EQ("A", GetDisplayedCookies(&cookies_model)); |
| 1654 } | 1653 } |
| 1655 | 1654 |
| 1655 TEST_F(CookiesTreeModelTest, Suborigins) { |
| 1656 LocalDataContainer* container = |
| 1657 new LocalDataContainer(mock_browsing_data_cookie_helper_.get(), |
| 1658 mock_browsing_data_database_helper_.get(), |
| 1659 mock_browsing_data_local_storage_helper_.get(), |
| 1660 mock_browsing_data_session_storage_helper_.get(), |
| 1661 mock_browsing_data_appcache_helper_.get(), |
| 1662 mock_browsing_data_indexed_db_helper_.get(), |
| 1663 mock_browsing_data_file_system_helper_.get(), |
| 1664 mock_browsing_data_quota_helper_.get(), |
| 1665 mock_browsing_data_channel_id_helper_.get(), |
| 1666 mock_browsing_data_service_worker_helper_.get(), |
| 1667 mock_browsing_data_cache_storage_helper_.get(), |
| 1668 mock_browsing_data_flash_lso_helper_.get()); |
| 1669 CookiesTreeModel cookies_model(container, special_storage_policy()); |
| 1670 |
| 1671 mock_browsing_data_local_storage_helper_ |
| 1672 ->AddLocalStorageSamplesWithSuborigins(); |
| 1673 mock_browsing_data_local_storage_helper_->Notify(); |
| 1674 { |
| 1675 SCOPED_TRACE( |
| 1676 "Suborigins get their own storage partitions and are folded into their " |
| 1677 "respective hosts"); |
| 1678 // root |
| 1679 // host4 -> local storage -> http-so://foobar.host4:4 |
| 1680 // -> http://host4:4 |
| 1681 // host3 -> local storage -> http-so://foobar.host3:3 |
| 1682 // host2 -> local storage -> http://host2:2 |
| 1683 // host1 -> local storage -> http://host1:1 |
| 1684 EXPECT_EQ(14, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 1685 EXPECT_EQ( |
| 1686 "http://host1:1/,http://host2:2/,http-so://foobar.host3:3/," |
| 1687 "http-so://foobar.host4:4/,http://host4:4/", |
| 1688 GetDisplayedLocalStorages(&cookies_model)); |
| 1689 // Delete host4, which should delete foobar_host4:4 in addition to host4:4 |
| 1690 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(3)); |
| 1691 EXPECT_EQ(10, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 1692 } |
| 1693 } |
| 1694 |
| 1656 } // namespace | 1695 } // namespace |
| OLD | NEW |