| 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/cookies_tree_model.h" | 5 #include "chrome/browser/cookies_tree_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
| 11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 11 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 12 #include "chrome/browser/content_settings/mock_settings_observer.h" | 12 #include "chrome/browser/content_settings/mock_settings_observer.h" |
| 13 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 13 #include "chrome/browser/mock_browsing_data_appcache_helper.h" | 14 #include "chrome/browser/mock_browsing_data_appcache_helper.h" |
| 14 #include "chrome/browser/mock_browsing_data_cookie_helper.h" | 15 #include "chrome/browser/mock_browsing_data_cookie_helper.h" |
| 15 #include "chrome/browser/mock_browsing_data_database_helper.h" | 16 #include "chrome/browser/mock_browsing_data_database_helper.h" |
| 16 #include "chrome/browser/mock_browsing_data_file_system_helper.h" | 17 #include "chrome/browser/mock_browsing_data_file_system_helper.h" |
| 17 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | 18 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
| 18 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 19 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
| 19 #include "chrome/browser/mock_browsing_data_quota_helper.h" | 20 #include "chrome/browser/mock_browsing_data_quota_helper.h" |
| 20 #include "chrome/browser/mock_browsing_data_server_bound_cert_helper.h" | 21 #include "chrome/browser/mock_browsing_data_server_bound_cert_helper.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 36 class CookiesTreeModelTest : public testing::Test { | 37 class CookiesTreeModelTest : public testing::Test { |
| 37 public: | 38 public: |
| 38 CookiesTreeModelTest() | 39 CookiesTreeModelTest() |
| 39 : ui_thread_(BrowserThread::UI, &message_loop_), | 40 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 40 file_user_blocking_(BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 41 file_user_blocking_(BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
| 41 io_thread_(BrowserThread::IO, &message_loop_) { | 42 io_thread_(BrowserThread::IO, &message_loop_) { |
| 42 } | 43 } |
| 43 | 44 |
| 44 virtual ~CookiesTreeModelTest() { | 45 virtual ~CookiesTreeModelTest() { |
| 45 // Avoid memory leaks. | 46 // Avoid memory leaks. |
| 47 special_storage_policy_ = NULL; |
| 46 profile_.reset(); | 48 profile_.reset(); |
| 47 message_loop_.RunAllPending(); | 49 message_loop_.RunAllPending(); |
| 48 } | 50 } |
| 49 | 51 |
| 50 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() OVERRIDE { |
| 51 profile_.reset(new TestingProfile()); | 53 profile_.reset(new TestingProfile()); |
| 52 profile_->CreateRequestContext(); | 54 profile_->CreateRequestContext(); |
| 53 mock_browsing_data_cookie_helper_ = | 55 mock_browsing_data_cookie_helper_ = |
| 54 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); | 56 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); |
| 55 mock_browsing_data_database_helper_ = | 57 mock_browsing_data_database_helper_ = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 mock_browsing_data_quota_helper_ = | 69 mock_browsing_data_quota_helper_ = |
| 68 new MockBrowsingDataQuotaHelper(profile_.get()); | 70 new MockBrowsingDataQuotaHelper(profile_.get()); |
| 69 mock_browsing_data_server_bound_cert_helper_ = | 71 mock_browsing_data_server_bound_cert_helper_ = |
| 70 new MockBrowsingDataServerBoundCertHelper(); | 72 new MockBrowsingDataServerBoundCertHelper(); |
| 71 | 73 |
| 72 // It is fine to reuse the profile request context for the app, since | 74 // It is fine to reuse the profile request context for the app, since |
| 73 // the mock cookie helper maintains its own list internally and doesn't | 75 // the mock cookie helper maintains its own list internally and doesn't |
| 74 // really use the request context. Same is true for the rest. | 76 // really use the request context. Same is true for the rest. |
| 75 mock_browsing_data_cookie_helper_app_ = | 77 mock_browsing_data_cookie_helper_app_ = |
| 76 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); | 78 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); |
| 79 |
| 80 scoped_refptr<CookieSettings> cookie_settings = |
| 81 new CookieSettings(profile_->GetHostContentSettingsMap(), |
| 82 profile_->GetPrefs()); |
| 83 special_storage_policy_ = |
| 84 new ExtensionSpecialStoragePolicy(cookie_settings); |
| 77 } | 85 } |
| 78 | 86 |
| 79 virtual void TearDown() OVERRIDE { | 87 virtual void TearDown() OVERRIDE { |
| 80 mock_browsing_data_server_bound_cert_helper_ = NULL; | 88 mock_browsing_data_server_bound_cert_helper_ = NULL; |
| 81 mock_browsing_data_quota_helper_ = NULL; | 89 mock_browsing_data_quota_helper_ = NULL; |
| 82 mock_browsing_data_file_system_helper_ = NULL; | 90 mock_browsing_data_file_system_helper_ = NULL; |
| 83 mock_browsing_data_indexed_db_helper_ = NULL; | 91 mock_browsing_data_indexed_db_helper_ = NULL; |
| 84 mock_browsing_data_appcache_helper_ = NULL; | 92 mock_browsing_data_appcache_helper_ = NULL; |
| 85 mock_browsing_data_session_storage_helper_ = NULL; | 93 mock_browsing_data_session_storage_helper_ = NULL; |
| 86 mock_browsing_data_local_storage_helper_ = NULL; | 94 mock_browsing_data_local_storage_helper_ = NULL; |
| 87 mock_browsing_data_database_helper_ = NULL; | 95 mock_browsing_data_database_helper_ = NULL; |
| 88 message_loop_.RunAllPending(); | 96 message_loop_.RunAllPending(); |
| 89 } | 97 } |
| 90 | 98 |
| 91 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample(bool add_app) { | 99 scoped_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample( |
| 100 bool add_app) { |
| 92 ContainerMap containers_map; | 101 ContainerMap containers_map; |
| 93 | 102 |
| 94 containers_map[std::string()] = new LocalDataContainer( | 103 containers_map[std::string()] = new LocalDataContainer( |
| 95 "Drive-By-Web", std::string(), | 104 "Drive-By-Web", std::string(), |
| 96 mock_browsing_data_cookie_helper_, | 105 mock_browsing_data_cookie_helper_, |
| 97 mock_browsing_data_database_helper_, | 106 mock_browsing_data_database_helper_, |
| 98 mock_browsing_data_local_storage_helper_, | 107 mock_browsing_data_local_storage_helper_, |
| 99 mock_browsing_data_session_storage_helper_, | 108 mock_browsing_data_session_storage_helper_, |
| 100 mock_browsing_data_appcache_helper_, | 109 mock_browsing_data_appcache_helper_, |
| 101 mock_browsing_data_indexed_db_helper_, | 110 mock_browsing_data_indexed_db_helper_, |
| 102 mock_browsing_data_file_system_helper_, | 111 mock_browsing_data_file_system_helper_, |
| 103 mock_browsing_data_quota_helper_, | 112 mock_browsing_data_quota_helper_, |
| 104 mock_browsing_data_server_bound_cert_helper_); | 113 mock_browsing_data_server_bound_cert_helper_); |
| 105 | 114 |
| 106 if (add_app) { | 115 if (add_app) { |
| 107 std::string app_id = "some-random-id"; | 116 std::string app_id = "some-random-id"; |
| 108 // The cookie helper is mandatory, the rest can be NULL. | 117 // The cookie helper is mandatory, the rest can be NULL. |
| 109 containers_map[app_id] = new LocalDataContainer( | 118 containers_map[app_id] = new LocalDataContainer( |
| 110 "Isolated App", app_id, | 119 "Isolated App", app_id, |
| 111 mock_browsing_data_cookie_helper_app_, | 120 mock_browsing_data_cookie_helper_app_, |
| 112 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | 121 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| 113 } | 122 } |
| 114 | 123 |
| 115 CookiesTreeModel* cookies_model = new CookiesTreeModel(containers_map, | 124 CookiesTreeModel* cookies_model = |
| 116 false); | 125 new CookiesTreeModel(containers_map, |
| 126 special_storage_policy_, |
| 127 false); |
| 117 mock_browsing_data_cookie_helper_-> | 128 mock_browsing_data_cookie_helper_-> |
| 118 AddCookieSamples(GURL("http://foo1"), "A=1"); | 129 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 119 mock_browsing_data_cookie_helper_-> | 130 mock_browsing_data_cookie_helper_-> |
| 120 AddCookieSamples(GURL("http://foo2"), "B=1"); | 131 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 121 mock_browsing_data_cookie_helper_-> | 132 mock_browsing_data_cookie_helper_-> |
| 122 AddCookieSamples(GURL("http://foo3"), "C=1"); | 133 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 123 mock_browsing_data_cookie_helper_->Notify(); | 134 mock_browsing_data_cookie_helper_->Notify(); |
| 124 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 135 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 125 mock_browsing_data_database_helper_->Notify(); | 136 mock_browsing_data_database_helper_->Notify(); |
| 126 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 137 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 GetDisplayedSessionStorages(cookies_model)); | 201 GetDisplayedSessionStorages(cookies_model)); |
| 191 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 202 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 192 GetDisplayedIndexedDBs(cookies_model)); | 203 GetDisplayedIndexedDBs(cookies_model)); |
| 193 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 204 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 194 GetDisplayedFileSystems(cookies_model)); | 205 GetDisplayedFileSystems(cookies_model)); |
| 195 EXPECT_EQ("quotahost1,quotahost2", | 206 EXPECT_EQ("quotahost1,quotahost2", |
| 196 GetDisplayedQuotas(cookies_model)); | 207 GetDisplayedQuotas(cookies_model)); |
| 197 EXPECT_EQ("sbc1,sbc2", | 208 EXPECT_EQ("sbc1,sbc2", |
| 198 GetDisplayedServerBoundCerts(cookies_model)); | 209 GetDisplayedServerBoundCerts(cookies_model)); |
| 199 } | 210 } |
| 200 return cookies_model; | 211 return make_scoped_ptr(cookies_model); |
| 201 } | 212 } |
| 202 | 213 |
| 203 std::string GetNodesOfChildren( | 214 std::string GetNodesOfChildren( |
| 204 const CookieTreeNode* node, | 215 const CookieTreeNode* node, |
| 205 CookieTreeNode::DetailedInfo::NodeType node_type) { | 216 CookieTreeNode::DetailedInfo::NodeType node_type) { |
| 206 if (!node->empty()) { | 217 if (!node->empty()) { |
| 207 std::string retval; | 218 std::string retval; |
| 208 for (int i = 0; i < node->child_count(); ++i) { | 219 for (int i = 0; i < node->child_count(); ++i) { |
| 209 retval += GetNodesOfChildren(node->GetChild(i), node_type); | 220 retval += GetNodesOfChildren(node->GetChild(i), node_type); |
| 210 } | 221 } |
| 211 return retval; | 222 return retval; |
| 212 } else { | 223 } |
| 213 if (node->GetDetailedInfo().node_type == node_type) { | 224 |
| 214 switch (node_type) { | 225 if (node->GetDetailedInfo().node_type != node_type) |
| 215 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: | 226 return std::string(); |
| 216 return node->GetDetailedInfo(). | 227 |
| 217 session_storage_info->origin_url.spec() + ","; | 228 switch (node_type) { |
| 218 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: | 229 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE: |
| 219 return node->GetDetailedInfo(). | 230 return node->GetDetailedInfo(). |
| 220 local_storage_info->origin_url.spec() + ","; | 231 session_storage_info->origin_url.spec() + ","; |
| 221 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: | 232 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: |
| 222 return node->GetDetailedInfo().database_info->database_name + ","; | 233 return node->GetDetailedInfo(). |
| 223 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: | 234 local_storage_info->origin_url.spec() + ","; |
| 224 return node->GetDetailedInfo().cookie->Name() + ","; | 235 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: |
| 225 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 236 return node->GetDetailedInfo().database_info->database_name + ","; |
| 226 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + | 237 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: |
| 227 ","; | 238 return node->GetDetailedInfo().cookie->Name() + ","; |
| 228 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: | 239 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
| 229 return node->GetDetailedInfo().indexed_db_info->origin.spec() + | 240 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + |
| 230 ","; | 241 ","; |
| 231 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: | 242 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: |
| 232 return node->GetDetailedInfo().file_system_info->origin.spec() + | 243 return node->GetDetailedInfo().indexed_db_info->origin.spec() + |
| 233 ","; | 244 ","; |
| 234 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: | 245 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: |
| 235 return node->GetDetailedInfo().quota_info->host + ","; | 246 return node->GetDetailedInfo().file_system_info->origin.spec() + |
| 236 case CookieTreeNode::DetailedInfo::TYPE_SERVER_BOUND_CERT: | 247 ","; |
| 237 return node->GetDetailedInfo( | 248 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: |
| 238 ).server_bound_cert->server_identifier() + ","; | 249 return node->GetDetailedInfo().quota_info->host + ","; |
| 239 default: | 250 case CookieTreeNode::DetailedInfo::TYPE_SERVER_BOUND_CERT: |
| 240 return ""; | 251 return node->GetDetailedInfo( |
| 241 } | 252 ).server_bound_cert->server_identifier() + ","; |
| 242 } else { | 253 default: |
| 243 return ""; | 254 return std::string(); |
| 244 } | |
| 245 } | 255 } |
| 246 } | 256 } |
| 247 | 257 |
| 248 std::string GetCookiesOfChildren(const CookieTreeNode* node) { | 258 std::string GetCookiesOfChildren(const CookieTreeNode* node) { |
| 249 return GetNodesOfChildren(node, CookieTreeNode::DetailedInfo::TYPE_COOKIE); | 259 return GetNodesOfChildren(node, CookieTreeNode::DetailedInfo::TYPE_COOKIE); |
| 250 } | 260 } |
| 251 | 261 |
| 252 std::string GetDatabasesOfChildren(const CookieTreeNode* node) { | 262 std::string GetDatabasesOfChildren(const CookieTreeNode* node) { |
| 253 return GetNodesOfChildren(node, | 263 return GetNodesOfChildren(node, |
| 254 CookieTreeNode::DetailedInfo::TYPE_DATABASE); | 264 CookieTreeNode::DetailedInfo::TYPE_DATABASE); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 scoped_refptr<MockBrowsingDataFileSystemHelper> | 377 scoped_refptr<MockBrowsingDataFileSystemHelper> |
| 368 mock_browsing_data_file_system_helper_; | 378 mock_browsing_data_file_system_helper_; |
| 369 scoped_refptr<MockBrowsingDataQuotaHelper> | 379 scoped_refptr<MockBrowsingDataQuotaHelper> |
| 370 mock_browsing_data_quota_helper_; | 380 mock_browsing_data_quota_helper_; |
| 371 scoped_refptr<MockBrowsingDataServerBoundCertHelper> | 381 scoped_refptr<MockBrowsingDataServerBoundCertHelper> |
| 372 mock_browsing_data_server_bound_cert_helper_; | 382 mock_browsing_data_server_bound_cert_helper_; |
| 373 | 383 |
| 374 // App helpers. | 384 // App helpers. |
| 375 scoped_refptr<MockBrowsingDataCookieHelper> | 385 scoped_refptr<MockBrowsingDataCookieHelper> |
| 376 mock_browsing_data_cookie_helper_app_; | 386 mock_browsing_data_cookie_helper_app_; |
| 387 |
| 388 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; |
| 377 }; | 389 }; |
| 378 | 390 |
| 379 TEST_F(CookiesTreeModelTest, RemoveAll) { | 391 TEST_F(CookiesTreeModelTest, RemoveAll) { |
| 380 scoped_ptr<CookiesTreeModel> cookies_model( | 392 scoped_ptr<CookiesTreeModel> cookies_model( |
| 381 CreateCookiesTreeModelWithInitialSample(false)); | 393 CreateCookiesTreeModelWithInitialSample(false)); |
| 382 | 394 |
| 383 // Reset the selection of the first row. | 395 // Reset the selection of the first row. |
| 384 { | 396 { |
| 385 SCOPED_TRACE("Before removing"); | 397 SCOPED_TRACE("Before removing"); |
| 386 EXPECT_EQ("A,B,C", | 398 EXPECT_EQ("A,B,C", |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 "Drive-By-Web", std::string(), | 820 "Drive-By-Web", std::string(), |
| 809 mock_browsing_data_cookie_helper_, | 821 mock_browsing_data_cookie_helper_, |
| 810 mock_browsing_data_database_helper_, | 822 mock_browsing_data_database_helper_, |
| 811 mock_browsing_data_local_storage_helper_, | 823 mock_browsing_data_local_storage_helper_, |
| 812 mock_browsing_data_session_storage_helper_, | 824 mock_browsing_data_session_storage_helper_, |
| 813 mock_browsing_data_appcache_helper_, | 825 mock_browsing_data_appcache_helper_, |
| 814 mock_browsing_data_indexed_db_helper_, | 826 mock_browsing_data_indexed_db_helper_, |
| 815 mock_browsing_data_file_system_helper_, | 827 mock_browsing_data_file_system_helper_, |
| 816 mock_browsing_data_quota_helper_, | 828 mock_browsing_data_quota_helper_, |
| 817 mock_browsing_data_server_bound_cert_helper_); | 829 mock_browsing_data_server_bound_cert_helper_); |
| 818 CookiesTreeModel cookies_model(container_map, false); | 830 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); |
| 819 | 831 |
| 820 mock_browsing_data_cookie_helper_-> | 832 mock_browsing_data_cookie_helper_-> |
| 821 AddCookieSamples(GURL("http://foo1"), "A=1"); | 833 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 822 mock_browsing_data_cookie_helper_-> | 834 mock_browsing_data_cookie_helper_-> |
| 823 AddCookieSamples(GURL("http://foo2"), "B=1"); | 835 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 824 mock_browsing_data_cookie_helper_-> | 836 mock_browsing_data_cookie_helper_-> |
| 825 AddCookieSamples(GURL("http://foo3"), "C=1"); | 837 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 826 mock_browsing_data_cookie_helper_-> | 838 mock_browsing_data_cookie_helper_-> |
| 827 AddCookieSamples(GURL("http://foo3"), "D=1"); | 839 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 828 mock_browsing_data_cookie_helper_->Notify(); | 840 mock_browsing_data_cookie_helper_->Notify(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 "Drive-By-Web", std::string(), | 910 "Drive-By-Web", std::string(), |
| 899 mock_browsing_data_cookie_helper_, | 911 mock_browsing_data_cookie_helper_, |
| 900 mock_browsing_data_database_helper_, | 912 mock_browsing_data_database_helper_, |
| 901 mock_browsing_data_local_storage_helper_, | 913 mock_browsing_data_local_storage_helper_, |
| 902 mock_browsing_data_session_storage_helper_, | 914 mock_browsing_data_session_storage_helper_, |
| 903 mock_browsing_data_appcache_helper_, | 915 mock_browsing_data_appcache_helper_, |
| 904 mock_browsing_data_indexed_db_helper_, | 916 mock_browsing_data_indexed_db_helper_, |
| 905 mock_browsing_data_file_system_helper_, | 917 mock_browsing_data_file_system_helper_, |
| 906 mock_browsing_data_quota_helper_, | 918 mock_browsing_data_quota_helper_, |
| 907 mock_browsing_data_server_bound_cert_helper_); | 919 mock_browsing_data_server_bound_cert_helper_); |
| 908 CookiesTreeModel cookies_model(container_map, false); | 920 CookiesTreeModel cookies_model(container_map, special_storage_policy_,false); |
| 909 | 921 |
| 910 mock_browsing_data_cookie_helper_-> | 922 mock_browsing_data_cookie_helper_-> |
| 911 AddCookieSamples(GURL("http://foo1"), "A=1"); | 923 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 912 mock_browsing_data_cookie_helper_-> | 924 mock_browsing_data_cookie_helper_-> |
| 913 AddCookieSamples(GURL("http://foo2"), "B=1"); | 925 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 914 mock_browsing_data_cookie_helper_-> | 926 mock_browsing_data_cookie_helper_-> |
| 915 AddCookieSamples(GURL("http://foo3"), "C=1"); | 927 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 916 mock_browsing_data_cookie_helper_-> | 928 mock_browsing_data_cookie_helper_-> |
| 917 AddCookieSamples(GURL("http://foo3"), "D=1"); | 929 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 918 mock_browsing_data_cookie_helper_-> | 930 mock_browsing_data_cookie_helper_-> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 "Drive-By-Web", std::string(), | 1003 "Drive-By-Web", std::string(), |
| 992 mock_browsing_data_cookie_helper_, | 1004 mock_browsing_data_cookie_helper_, |
| 993 mock_browsing_data_database_helper_, | 1005 mock_browsing_data_database_helper_, |
| 994 mock_browsing_data_local_storage_helper_, | 1006 mock_browsing_data_local_storage_helper_, |
| 995 mock_browsing_data_session_storage_helper_, | 1007 mock_browsing_data_session_storage_helper_, |
| 996 mock_browsing_data_appcache_helper_, | 1008 mock_browsing_data_appcache_helper_, |
| 997 mock_browsing_data_indexed_db_helper_, | 1009 mock_browsing_data_indexed_db_helper_, |
| 998 mock_browsing_data_file_system_helper_, | 1010 mock_browsing_data_file_system_helper_, |
| 999 mock_browsing_data_quota_helper_, | 1011 mock_browsing_data_quota_helper_, |
| 1000 mock_browsing_data_server_bound_cert_helper_); | 1012 mock_browsing_data_server_bound_cert_helper_); |
| 1001 CookiesTreeModel cookies_model(container_map, false); | 1013 CookiesTreeModel cookies_model(container_map, special_storage_policy_,false); |
| 1002 | 1014 |
| 1003 mock_browsing_data_cookie_helper_-> | 1015 mock_browsing_data_cookie_helper_-> |
| 1004 AddCookieSamples(GURL("http://foo1"), "A=1"); | 1016 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 1005 mock_browsing_data_cookie_helper_-> | 1017 mock_browsing_data_cookie_helper_-> |
| 1006 AddCookieSamples(GURL("http://foo2"), "B=1"); | 1018 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 1007 mock_browsing_data_cookie_helper_-> | 1019 mock_browsing_data_cookie_helper_-> |
| 1008 AddCookieSamples(GURL("http://foo3"), "C=1"); | 1020 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 1009 mock_browsing_data_cookie_helper_-> | 1021 mock_browsing_data_cookie_helper_-> |
| 1010 AddCookieSamples(GURL("http://foo3"), "D=1"); | 1022 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 1011 mock_browsing_data_cookie_helper_-> | 1023 mock_browsing_data_cookie_helper_-> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1035 "Drive-By-Web", std::string(), | 1047 "Drive-By-Web", std::string(), |
| 1036 mock_browsing_data_cookie_helper_, | 1048 mock_browsing_data_cookie_helper_, |
| 1037 mock_browsing_data_database_helper_, | 1049 mock_browsing_data_database_helper_, |
| 1038 mock_browsing_data_local_storage_helper_, | 1050 mock_browsing_data_local_storage_helper_, |
| 1039 mock_browsing_data_session_storage_helper_, | 1051 mock_browsing_data_session_storage_helper_, |
| 1040 mock_browsing_data_appcache_helper_, | 1052 mock_browsing_data_appcache_helper_, |
| 1041 mock_browsing_data_indexed_db_helper_, | 1053 mock_browsing_data_indexed_db_helper_, |
| 1042 mock_browsing_data_file_system_helper_, | 1054 mock_browsing_data_file_system_helper_, |
| 1043 mock_browsing_data_quota_helper_, | 1055 mock_browsing_data_quota_helper_, |
| 1044 mock_browsing_data_server_bound_cert_helper_); | 1056 mock_browsing_data_server_bound_cert_helper_); |
| 1045 CookiesTreeModel cookies_model(container_map, false); | 1057 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); |
| 1046 | 1058 |
| 1047 mock_browsing_data_cookie_helper_-> | 1059 mock_browsing_data_cookie_helper_-> |
| 1048 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); | 1060 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); |
| 1049 mock_browsing_data_cookie_helper_-> | 1061 mock_browsing_data_cookie_helper_-> |
| 1050 AddCookieSamples(GURL("http://foo2.com"), "B=1"); | 1062 AddCookieSamples(GURL("http://foo2.com"), "B=1"); |
| 1051 mock_browsing_data_cookie_helper_-> | 1063 mock_browsing_data_cookie_helper_-> |
| 1052 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); | 1064 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); |
| 1053 // Leading dot on the foo4 | 1065 // Leading dot on the foo4 |
| 1054 mock_browsing_data_cookie_helper_->AddCookieSamples( | 1066 mock_browsing_data_cookie_helper_->AddCookieSamples( |
| 1055 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); | 1067 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1086 name, browser_id, | 1098 name, browser_id, |
| 1087 mock_browsing_data_cookie_helper_, | 1099 mock_browsing_data_cookie_helper_, |
| 1088 mock_browsing_data_database_helper_, | 1100 mock_browsing_data_database_helper_, |
| 1089 mock_browsing_data_local_storage_helper_, | 1101 mock_browsing_data_local_storage_helper_, |
| 1090 mock_browsing_data_session_storage_helper_, | 1102 mock_browsing_data_session_storage_helper_, |
| 1091 mock_browsing_data_appcache_helper_, | 1103 mock_browsing_data_appcache_helper_, |
| 1092 mock_browsing_data_indexed_db_helper_, | 1104 mock_browsing_data_indexed_db_helper_, |
| 1093 mock_browsing_data_file_system_helper_, | 1105 mock_browsing_data_file_system_helper_, |
| 1094 mock_browsing_data_quota_helper_, | 1106 mock_browsing_data_quota_helper_, |
| 1095 mock_browsing_data_server_bound_cert_helper_); | 1107 mock_browsing_data_server_bound_cert_helper_); |
| 1096 CookiesTreeModel cookies_model(container_map, false); | 1108 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); |
| 1097 | 1109 |
| 1098 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); | 1110 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); |
| 1099 mock_browsing_data_cookie_helper_->Notify(); | 1111 mock_browsing_data_cookie_helper_->Notify(); |
| 1100 | 1112 |
| 1101 TestingProfile profile; | 1113 TestingProfile profile; |
| 1102 HostContentSettingsMap* content_settings = | 1114 HostContentSettingsMap* content_settings = |
| 1103 profile.GetHostContentSettingsMap(); | 1115 profile.GetHostContentSettingsMap(); |
| 1104 CookieSettings* cookie_settings = | 1116 CookieSettings* cookie_settings = |
| 1105 CookieSettings::Factory::GetForProfile(&profile); | 1117 CookieSettings::Factory::GetForProfile(&profile); |
| 1106 MockSettingsObserver observer; | 1118 MockSettingsObserver observer; |
| 1107 | 1119 |
| 1108 CookieTreeRootNode* root = | 1120 CookieTreeRootNode* root = |
| 1109 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 1121 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
| 1110 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host, | 1122 CookieTreeHostNode* origin = |
| 1111 browser_id, | 1123 root->GetOrCreateHostNode(host, browser_id, name); |
| 1112 name); | |
| 1113 | 1124 |
| 1114 EXPECT_EQ(1, origin->child_count()); | 1125 EXPECT_EQ(1, origin->child_count()); |
| 1115 EXPECT_TRUE(origin->CanCreateContentException()); | 1126 EXPECT_TRUE(origin->CanCreateContentException()); |
| 1116 EXPECT_CALL(observer, | 1127 EXPECT_CALL(observer, |
| 1117 OnContentSettingsChanged( | 1128 OnContentSettingsChanged( |
| 1118 content_settings, | 1129 content_settings, |
| 1119 CONTENT_SETTINGS_TYPE_COOKIES, | 1130 CONTENT_SETTINGS_TYPE_COOKIES, |
| 1120 false, | 1131 false, |
| 1121 ContentSettingsPattern::FromURLNoWildcard(host), | 1132 ContentSettingsPattern::FromURLNoWildcard(host), |
| 1122 ContentSettingsPattern::Wildcard(), | 1133 ContentSettingsPattern::Wildcard(), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1141 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin1"), | 1152 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin1"), |
| 1142 cookies_model->GetRoot()->GetChild(16)->GetTitle()); | 1153 cookies_model->GetRoot()->GetChild(16)->GetTitle()); |
| 1143 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin2"), | 1154 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin2"), |
| 1144 cookies_model->GetRoot()->GetChild(17)->GetTitle()); | 1155 cookies_model->GetRoot()->GetChild(17)->GetTitle()); |
| 1145 } | 1156 } |
| 1146 | 1157 |
| 1147 TEST_F(CookiesTreeModelTest, FileSystemFilter) { | 1158 TEST_F(CookiesTreeModelTest, FileSystemFilter) { |
| 1148 scoped_ptr<CookiesTreeModel> cookies_model( | 1159 scoped_ptr<CookiesTreeModel> cookies_model( |
| 1149 CreateCookiesTreeModelWithInitialSample(false)); | 1160 CreateCookiesTreeModelWithInitialSample(false)); |
| 1150 | 1161 |
| 1151 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost1"))); | 1162 cookies_model->UpdateSearchResults(ASCIIToUTF16("fshost1")); |
| 1152 EXPECT_EQ("http://fshost1:1/", | 1163 EXPECT_EQ("http://fshost1:1/", |
| 1153 GetDisplayedFileSystems(cookies_model.get())); | 1164 GetDisplayedFileSystems(cookies_model.get())); |
| 1154 | 1165 |
| 1155 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost2"))); | 1166 cookies_model->UpdateSearchResults(ASCIIToUTF16("fshost2")); |
| 1156 EXPECT_EQ("http://fshost2:2/", | 1167 EXPECT_EQ("http://fshost2:2/", |
| 1157 GetDisplayedFileSystems(cookies_model.get())); | 1168 GetDisplayedFileSystems(cookies_model.get())); |
| 1158 | 1169 |
| 1159 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost3"))); | 1170 cookies_model->UpdateSearchResults(ASCIIToUTF16("fshost3")); |
| 1160 EXPECT_EQ("http://fshost3:3/", | 1171 EXPECT_EQ("http://fshost3:3/", |
| 1161 GetDisplayedFileSystems(cookies_model.get())); | 1172 GetDisplayedFileSystems(cookies_model.get())); |
| 1162 | 1173 |
| 1163 cookies_model->UpdateSearchResults(string16()); | 1174 cookies_model->UpdateSearchResults(string16()); |
| 1164 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 1175 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 1165 GetDisplayedFileSystems(cookies_model.get())); | 1176 GetDisplayedFileSystems(cookies_model.get())); |
| 1166 } | 1177 } |
| 1167 | 1178 |
| 1168 TEST_F(CookiesTreeModelTest, CookiesFilter) { | 1179 TEST_F(CookiesTreeModelTest, CookiesFilter) { |
| 1169 ContainerMap container_map; | 1180 ContainerMap container_map; |
| 1170 | 1181 |
| 1171 container_map[std::string()] = new LocalDataContainer( | 1182 container_map[std::string()] = new LocalDataContainer( |
| 1172 "Drive-By-Web", std::string(), | 1183 "Drive-By-Web", std::string(), |
| 1173 mock_browsing_data_cookie_helper_, | 1184 mock_browsing_data_cookie_helper_, |
| 1174 mock_browsing_data_database_helper_, | 1185 mock_browsing_data_database_helper_, |
| 1175 mock_browsing_data_local_storage_helper_, | 1186 mock_browsing_data_local_storage_helper_, |
| 1176 mock_browsing_data_session_storage_helper_, | 1187 mock_browsing_data_session_storage_helper_, |
| 1177 mock_browsing_data_appcache_helper_, | 1188 mock_browsing_data_appcache_helper_, |
| 1178 mock_browsing_data_indexed_db_helper_, | 1189 mock_browsing_data_indexed_db_helper_, |
| 1179 mock_browsing_data_file_system_helper_, | 1190 mock_browsing_data_file_system_helper_, |
| 1180 mock_browsing_data_quota_helper_, | 1191 mock_browsing_data_quota_helper_, |
| 1181 mock_browsing_data_server_bound_cert_helper_); | 1192 mock_browsing_data_server_bound_cert_helper_); |
| 1182 CookiesTreeModel cookies_model(container_map, false); | 1193 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); |
| 1183 | 1194 |
| 1184 mock_browsing_data_cookie_helper_-> | 1195 mock_browsing_data_cookie_helper_-> |
| 1185 AddCookieSamples(GURL("http://123.com"), "A=1"); | 1196 AddCookieSamples(GURL("http://123.com"), "A=1"); |
| 1186 mock_browsing_data_cookie_helper_-> | 1197 mock_browsing_data_cookie_helper_-> |
| 1187 AddCookieSamples(GURL("http://foo1.com"), "B=1"); | 1198 AddCookieSamples(GURL("http://foo1.com"), "B=1"); |
| 1188 mock_browsing_data_cookie_helper_-> | 1199 mock_browsing_data_cookie_helper_-> |
| 1189 AddCookieSamples(GURL("http://foo2.com"), "C=1"); | 1200 AddCookieSamples(GURL("http://foo2.com"), "C=1"); |
| 1190 mock_browsing_data_cookie_helper_-> | 1201 mock_browsing_data_cookie_helper_-> |
| 1191 AddCookieSamples(GURL("http://foo3.com"), "D=1"); | 1202 AddCookieSamples(GURL("http://foo3.com"), "D=1"); |
| 1192 mock_browsing_data_cookie_helper_->Notify(); | 1203 mock_browsing_data_cookie_helper_->Notify(); |
| 1193 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); | 1204 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1194 | 1205 |
| 1195 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo"))); | 1206 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo"))); |
| 1196 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model)); | 1207 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1197 | 1208 |
| 1198 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2"))); | 1209 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2"))); |
| 1199 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model)); | 1210 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model)); |
| 1200 | 1211 |
| 1201 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3"))); | 1212 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3"))); |
| 1202 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model)); | 1213 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model)); |
| 1203 | 1214 |
| 1204 cookies_model.UpdateSearchResults(string16()); | 1215 cookies_model.UpdateSearchResults(string16()); |
| 1205 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); | 1216 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1206 } | 1217 } |
| 1207 | 1218 |
| 1208 } // namespace | 1219 } // namespace |
| OLD | NEW |