| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/stl_util.h" |
| 10 #include "base/strings/pattern.h" | 11 #include "base/strings/pattern.h" |
| 11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 17 #include "chrome/browser/browsing_data/chrome_browsing_data_types.h" |
| 16 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" | 18 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" |
| 17 #include "chrome/browser/extensions/extension_function_test_utils.h" | 19 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "components/browsing_data/core/browsing_data_utils.h" | 24 #include "components/browsing_data/core/browsing_data_utils.h" |
| 23 #include "components/browsing_data/core/pref_names.h" | 25 #include "components/browsing_data/core/pref_names.h" |
| 24 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 25 | 27 |
| 26 using extension_function_test_utils::RunFunctionAndReturnError; | 28 using extension_function_test_utils::RunFunctionAndReturnError; |
| 27 using extension_function_test_utils::RunFunctionAndReturnSingleResult; | 29 using extension_function_test_utils::RunFunctionAndReturnSingleResult; |
| 30 using content::BrowsingDataType; |
| 28 | 31 |
| 29 namespace { | 32 namespace { |
| 30 | 33 |
| 31 enum OriginTypeMask { | 34 enum OriginTypeMask { |
| 32 UNPROTECTED_WEB = BrowsingDataHelper::UNPROTECTED_WEB, | 35 UNPROTECTED_WEB = BrowsingDataHelper::UNPROTECTED_WEB, |
| 33 PROTECTED_WEB = BrowsingDataHelper::PROTECTED_WEB, | 36 PROTECTED_WEB = BrowsingDataHelper::PROTECTED_WEB, |
| 34 EXTENSION = BrowsingDataHelper::EXTENSION | 37 EXTENSION = BrowsingDataHelper::EXTENSION |
| 35 }; | 38 }; |
| 36 | 39 |
| 37 const char kRemoveEverythingArguments[] = | 40 const char kRemoveEverythingArguments[] = |
| 38 "[{\"since\": 1000}, {" | 41 "[{\"since\": 1000}, {" |
| 39 "\"appcache\": true, \"cache\": true, \"cookies\": true, " | 42 "\"appcache\": true, \"cache\": true, \"cookies\": true, " |
| 40 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, " | 43 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, " |
| 41 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, " | 44 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, " |
| 42 "\"serverBoundCertificates\": true, \"passwords\": true, " | 45 "\"serverBoundCertificates\": true, \"passwords\": true, " |
| 43 "\"pluginData\": true, \"serviceWorkers\": true, \"cacheStorage\": true, " | 46 "\"pluginData\": true, \"serviceWorkers\": true, \"cacheStorage\": true, " |
| 44 "\"webSQL\": true" | 47 "\"webSQL\": true" |
| 45 "}]"; | 48 "}]"; |
| 46 | 49 |
| 47 class ExtensionBrowsingDataTest : public InProcessBrowserTest { | 50 class ExtensionBrowsingDataTest : public InProcessBrowserTest { |
| 48 public: | 51 public: |
| 49 const base::Time& GetBeginTime() { | 52 const base::Time& GetBeginTime() { |
| 50 return remover_->GetLastUsedBeginTime(); | 53 return remover_->GetLastUsedBeginTime(); |
| 51 } | 54 } |
| 52 | 55 |
| 53 int GetRemovalMask() { | 56 const std::set<const BrowsingDataType*>& GetRemovalMask() { |
| 54 return remover_->GetLastUsedRemovalMask(); | 57 return remover_->GetLastUsedRemovalMask(); |
| 55 } | 58 } |
| 56 | 59 |
| 57 int GetOriginTypeMask() { | 60 int GetOriginTypeMask() { |
| 58 return remover_->GetLastUsedOriginTypeMask(); | 61 return remover_->GetLastUsedOriginTypeMask(); |
| 59 } | 62 } |
| 60 | 63 |
| 61 protected: | 64 protected: |
| 62 void SetUpOnMainThread() override { | 65 void SetUpOnMainThread() override { |
| 63 remover_ = | 66 remover_ = |
| 64 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 67 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); |
| 65 } | 68 } |
| 66 | 69 |
| 67 int GetAsMask(const base::DictionaryValue* dict, std::string path, | 70 int GetAsMask(const base::DictionaryValue* dict, std::string path, |
| 68 int mask_value) { | 71 int mask_value) { |
| 69 bool result; | 72 bool result; |
| 70 EXPECT_TRUE(dict->GetBoolean(path, &result)) << "for " << path; | 73 EXPECT_TRUE(dict->GetBoolean(path, &result)) << "for " << path; |
| 71 return result ? mask_value : 0; | 74 return result ? mask_value : 0; |
| 72 } | 75 } |
| 73 | 76 |
| 77 const BrowsingDataType* GetAsMask(const base::DictionaryValue* dict, |
| 78 std::string path, |
| 79 const BrowsingDataType* mask_value) { |
| 80 bool result; |
| 81 EXPECT_TRUE(dict->GetBoolean(path, &result)) << "for " << path; |
| 82 return result ? mask_value : nullptr; |
| 83 } |
| 84 |
| 74 void RunBrowsingDataRemoveFunctionAndCompareRemovalMask( | 85 void RunBrowsingDataRemoveFunctionAndCompareRemovalMask( |
| 75 const std::string& data_types, | 86 const std::string& data_types, |
| 76 int expected_mask) { | 87 const std::set<const BrowsingDataType*>& expected_mask) { |
| 77 scoped_refptr<BrowsingDataRemoveFunction> function = | 88 scoped_refptr<BrowsingDataRemoveFunction> function = |
| 78 new BrowsingDataRemoveFunction(); | 89 new BrowsingDataRemoveFunction(); |
| 79 SCOPED_TRACE(data_types); | 90 SCOPED_TRACE(data_types); |
| 80 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( | 91 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( |
| 81 function.get(), | 92 function.get(), |
| 82 std::string("[{\"since\": 1},") + data_types + "]", | 93 std::string("[{\"since\": 1},") + data_types + "]", |
| 83 browser())); | 94 browser())); |
| 84 EXPECT_EQ(expected_mask, GetRemovalMask()); | 95 EXPECT_EQ(expected_mask, GetRemovalMask()); |
| 85 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); | 96 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); |
| 86 } | 97 } |
| 87 | 98 |
| 88 void RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 99 void RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 89 const std::string& key, | 100 const std::string& key, |
| 90 int expected_mask) { | 101 const std::set<const BrowsingDataType*>& expected_mask) { |
| 91 RunBrowsingDataRemoveFunctionAndCompareRemovalMask( | 102 RunBrowsingDataRemoveFunctionAndCompareRemovalMask( |
| 92 std::string("{\"") + key + "\": true}", expected_mask); | 103 std::string("{\"") + key + "\": true}", expected_mask); |
| 93 } | 104 } |
| 94 | 105 |
| 95 void RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( | 106 void RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( |
| 96 const std::string& protectedStr, | 107 const std::string& protectedStr, |
| 97 int expected_mask) { | 108 int expected_mask) { |
| 98 scoped_refptr<BrowsingDataRemoveFunction> function = | 109 scoped_refptr<BrowsingDataRemoveFunction> function = |
| 99 new BrowsingDataRemoveFunction(); | 110 new BrowsingDataRemoveFunction(); |
| 100 SCOPED_TRACE(protectedStr); | 111 SCOPED_TRACE(protectedStr); |
| 101 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( | 112 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( |
| 102 function.get(), | 113 function.get(), |
| 103 "[{\"originTypes\": " + protectedStr + "}, {\"cookies\": true}]", | 114 "[{\"originTypes\": " + protectedStr + "}, {\"cookies\": true}]", |
| 104 browser())); | 115 browser())); |
| 105 EXPECT_EQ(expected_mask, GetOriginTypeMask()); | 116 EXPECT_EQ(expected_mask, GetOriginTypeMask()); |
| 106 } | 117 } |
| 107 | 118 |
| 108 template<class ShortcutFunction> | 119 template <class ShortcutFunction> |
| 109 void RunAndCompareRemovalMask(int expected_mask) { | 120 void RunAndCompareRemovalMask( |
| 121 const std::set<const BrowsingDataType*>& expected_mask) { |
| 110 scoped_refptr<ShortcutFunction> function = | 122 scoped_refptr<ShortcutFunction> function = |
| 111 new ShortcutFunction(); | 123 new ShortcutFunction(); |
| 112 SCOPED_TRACE(ShortcutFunction::function_name()); | 124 SCOPED_TRACE(ShortcutFunction::function_name()); |
| 113 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( | 125 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( |
| 114 function.get(), | 126 function.get(), |
| 115 std::string("[{\"since\": 1}]"), | 127 std::string("[{\"since\": 1}]"), |
| 116 browser())); | 128 browser())); |
| 117 EXPECT_EQ(expected_mask, GetRemovalMask()); | 129 EXPECT_EQ(expected_mask, GetRemovalMask()); |
| 118 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); | 130 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); |
| 119 } | 131 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 141 expected_since = time.ToJsTime(); | 153 expected_since = time.ToJsTime(); |
| 142 } | 154 } |
| 143 // Even a synchronous function takes nonzero time, but the difference | 155 // Even a synchronous function takes nonzero time, but the difference |
| 144 // between when the function was called and now should be well under a | 156 // between when the function was called and now should be well under a |
| 145 // second, so we'll make sure the requested start time is within 10 seconds. | 157 // second, so we'll make sure the requested start time is within 10 seconds. |
| 146 // Since the smallest selectable period is an hour, that should be | 158 // Since the smallest selectable period is an hour, that should be |
| 147 // sufficient. | 159 // sufficient. |
| 148 EXPECT_LE(expected_since, since + 10.0 * 1000.0); | 160 EXPECT_LE(expected_since, since + 10.0 * 1000.0); |
| 149 } | 161 } |
| 150 | 162 |
| 151 void SetPrefsAndVerifySettings(int data_type_flags, | 163 void SetPrefsAndVerifySettings( |
| 152 int expected_origin_type_mask, | 164 const std::set<const BrowsingDataType*>& data_type_flags, |
| 153 int expected_removal_mask) { | 165 int expected_origin_type_mask, |
| 166 const std::set<const BrowsingDataType*>& expected_removal_mask) { |
| 154 PrefService* prefs = browser()->profile()->GetPrefs(); | 167 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 155 prefs->SetBoolean(browsing_data::prefs::kDeleteCache, | 168 prefs->SetBoolean( |
| 156 !!(data_type_flags & BrowsingDataRemover::REMOVE_CACHE)); | 169 browsing_data::prefs::kDeleteCache, |
| 157 prefs->SetBoolean(browsing_data::prefs::kDeleteCookies, | 170 base::ContainsValue(data_type_flags, &kBrowsingDataTypeCache)); |
| 158 !!(data_type_flags & BrowsingDataRemover::REMOVE_COOKIES)); | 171 prefs->SetBoolean( |
| 159 prefs->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, | 172 browsing_data::prefs::kDeleteCookies, |
| 160 !!(data_type_flags & BrowsingDataRemover::REMOVE_HISTORY)); | 173 base::ContainsValue(data_type_flags, &kBrowsingDataTypeCookies)); |
| 161 prefs->SetBoolean(browsing_data::prefs::kDeleteFormData, | 174 prefs->SetBoolean( |
| 162 !!(data_type_flags & BrowsingDataRemover::REMOVE_FORM_DATA)); | 175 browsing_data::prefs::kDeleteBrowsingHistory, |
| 163 prefs->SetBoolean(browsing_data::prefs::kDeleteDownloadHistory, | 176 base::ContainsValue(data_type_flags, &kBrowsingDataTypeHistory)); |
| 164 !!(data_type_flags & BrowsingDataRemover::REMOVE_DOWNLOADS)); | 177 prefs->SetBoolean( |
| 165 prefs->SetBoolean(browsing_data::prefs::kDeleteHostedAppsData, | 178 browsing_data::prefs::kDeleteFormData, |
| 166 !!(data_type_flags & | 179 base::ContainsValue(data_type_flags, &kBrowsingDataTypeFormData)); |
| 167 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY)); | 180 prefs->SetBoolean( |
| 168 prefs->SetBoolean(browsing_data::prefs::kDeletePasswords, | 181 browsing_data::prefs::kDeleteDownloadHistory, |
| 169 !!(data_type_flags & BrowsingDataRemover::REMOVE_PASSWORDS)); | 182 base::ContainsValue(data_type_flags, &kBrowsingDataTypeDownloads)); |
| 170 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, | 183 prefs->SetBoolean( |
| 171 !!(data_type_flags & BrowsingDataRemover::REMOVE_PLUGIN_DATA)); | 184 browsing_data::prefs::kDeleteHostedAppsData, |
| 185 base::ContainsValue(data_type_flags, |
| 186 &kBrowsingDataTypeHostedAppDataTestOnly)); |
| 187 prefs->SetBoolean( |
| 188 browsing_data::prefs::kDeletePasswords, |
| 189 base::ContainsValue(data_type_flags, &kBrowsingDataTypePasswords)); |
| 190 prefs->SetBoolean( |
| 191 prefs::kClearPluginLSODataEnabled, |
| 192 base::ContainsValue(data_type_flags, &kBrowsingDataTypePluginData)); |
| 172 | 193 |
| 173 scoped_refptr<BrowsingDataSettingsFunction> function = | 194 scoped_refptr<BrowsingDataSettingsFunction> function = |
| 174 new BrowsingDataSettingsFunction(); | 195 new BrowsingDataSettingsFunction(); |
| 175 SCOPED_TRACE("settings"); | 196 SCOPED_TRACE("settings"); |
| 176 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( | 197 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( |
| 177 function.get(), std::string("[]"), browser())); | 198 function.get(), std::string("[]"), browser())); |
| 178 | 199 |
| 179 base::DictionaryValue* result; | 200 base::DictionaryValue* result; |
| 180 EXPECT_TRUE(result_value->GetAsDictionary(&result)); | 201 EXPECT_TRUE(result_value->GetAsDictionary(&result)); |
| 181 | 202 |
| 182 base::DictionaryValue* options; | 203 base::DictionaryValue* options; |
| 183 EXPECT_TRUE(result->GetDictionary("options", &options)); | 204 EXPECT_TRUE(result->GetDictionary("options", &options)); |
| 184 base::DictionaryValue* origin_types; | 205 base::DictionaryValue* origin_types; |
| 185 EXPECT_TRUE(options->GetDictionary("originTypes", &origin_types)); | 206 EXPECT_TRUE(options->GetDictionary("originTypes", &origin_types)); |
| 186 int origin_type_mask = GetAsMask(origin_types, "unprotectedWeb", | 207 int origin_type_mask = GetAsMask(origin_types, "unprotectedWeb", |
| 187 UNPROTECTED_WEB) | | 208 UNPROTECTED_WEB) | |
| 188 GetAsMask(origin_types, "protectedWeb", | 209 GetAsMask(origin_types, "protectedWeb", |
| 189 PROTECTED_WEB) | | 210 PROTECTED_WEB) | |
| 190 GetAsMask(origin_types, "extension", EXTENSION); | 211 GetAsMask(origin_types, "extension", EXTENSION); |
| 191 EXPECT_EQ(expected_origin_type_mask, origin_type_mask); | 212 EXPECT_EQ(expected_origin_type_mask, origin_type_mask); |
| 192 | 213 |
| 193 base::DictionaryValue* data_to_remove; | 214 base::DictionaryValue* data_to_remove; |
| 194 EXPECT_TRUE(result->GetDictionary("dataToRemove", &data_to_remove)); | 215 EXPECT_TRUE(result->GetDictionary("dataToRemove", &data_to_remove)); |
| 195 int removal_mask = | 216 |
| 196 GetAsMask(data_to_remove, "appcache", | 217 std::set<const BrowsingDataType*> removal_mask; |
| 197 BrowsingDataRemover::REMOVE_APPCACHE) | | 218 removal_mask.insert( |
| 198 GetAsMask(data_to_remove, "cache", BrowsingDataRemover::REMOVE_CACHE) | | 219 GetAsMask(data_to_remove, "appcache", &kBrowsingDataTypeAppCache)); |
| 199 GetAsMask(data_to_remove, "cookies", | 220 removal_mask.insert( |
| 200 BrowsingDataRemover::REMOVE_COOKIES) | | 221 GetAsMask(data_to_remove, "cache", &kBrowsingDataTypeCache)); |
| 201 GetAsMask(data_to_remove, "downloads", | 222 removal_mask.insert( |
| 202 BrowsingDataRemover::REMOVE_DOWNLOADS) | | 223 GetAsMask(data_to_remove, "cookies", &kBrowsingDataTypeCookies)); |
| 203 GetAsMask(data_to_remove, "fileSystems", | 224 removal_mask.insert( |
| 204 BrowsingDataRemover::REMOVE_FILE_SYSTEMS) | | 225 GetAsMask(data_to_remove, "downloads", &kBrowsingDataTypeDownloads)); |
| 205 GetAsMask(data_to_remove, "formData", | 226 removal_mask.insert(GetAsMask(data_to_remove, "fileSystems", |
| 206 BrowsingDataRemover::REMOVE_FORM_DATA) | | 227 &kBrowsingDataTypeFileSystems)); |
| 207 GetAsMask(data_to_remove, "history", | 228 removal_mask.insert( |
| 208 BrowsingDataRemover::REMOVE_HISTORY) | | 229 GetAsMask(data_to_remove, "formData", &kBrowsingDataTypeFormData)); |
| 209 GetAsMask(data_to_remove, "indexedDB", | 230 removal_mask.insert( |
| 210 BrowsingDataRemover::REMOVE_INDEXEDDB) | | 231 GetAsMask(data_to_remove, "history", &kBrowsingDataTypeHistory)); |
| 211 GetAsMask(data_to_remove, "localStorage", | 232 removal_mask.insert( |
| 212 BrowsingDataRemover::REMOVE_LOCAL_STORAGE) | | 233 GetAsMask(data_to_remove, "indexedDB", &kBrowsingDataTypeIndexedDB)); |
| 213 GetAsMask(data_to_remove, "pluginData", | 234 removal_mask.insert(GetAsMask(data_to_remove, "localStorage", |
| 214 BrowsingDataRemover::REMOVE_PLUGIN_DATA) | | 235 &kBrowsingDataTypeLocalStorage)); |
| 215 GetAsMask(data_to_remove, "passwords", | 236 removal_mask.insert( |
| 216 BrowsingDataRemover::REMOVE_PASSWORDS) | | 237 GetAsMask(data_to_remove, "pluginData", &kBrowsingDataTypePluginData)); |
| 217 GetAsMask(data_to_remove, "serviceWorkers", | 238 removal_mask.insert( |
| 218 BrowsingDataRemover::REMOVE_SERVICE_WORKERS) | | 239 GetAsMask(data_to_remove, "passwords", &kBrowsingDataTypePasswords)); |
| 219 GetAsMask(data_to_remove, "cacheStorage", | 240 removal_mask.insert(GetAsMask(data_to_remove, "serviceWorkers", |
| 220 BrowsingDataRemover::REMOVE_CACHE_STORAGE) | | 241 &kBrowsingDataTypeServiceWorkers)); |
| 221 GetAsMask(data_to_remove, "webSQL", | 242 removal_mask.insert(GetAsMask(data_to_remove, "cacheStorage", |
| 222 BrowsingDataRemover::REMOVE_WEBSQL) | | 243 &kBrowsingDataTypeCacheStorage)); |
| 223 GetAsMask(data_to_remove, "serverBoundCertificates", | 244 removal_mask.insert( |
| 224 BrowsingDataRemover::REMOVE_CHANNEL_IDS); | 245 GetAsMask(data_to_remove, "webSQL", &kBrowsingDataTypeWebSQL)); |
| 246 removal_mask.insert(GetAsMask(data_to_remove, "serverBoundCertificates", |
| 247 &kBrowsingDataTypeChannelIDs)); |
| 248 |
| 249 // GetAsMask() adds a nullptr for excluded types. |
| 250 removal_mask.erase(nullptr); |
| 225 | 251 |
| 226 EXPECT_EQ(expected_removal_mask, removal_mask); | 252 EXPECT_EQ(expected_removal_mask, removal_mask); |
| 227 } | 253 } |
| 228 | 254 |
| 229 // The kAllowDeletingBrowserHistory pref must be set to false before this | 255 // The kAllowDeletingBrowserHistory pref must be set to false before this |
| 230 // is called. | 256 // is called. |
| 231 void CheckRemovalPermitted(const std::string& data_types, bool permitted) { | 257 void CheckRemovalPermitted(const std::string& data_types, bool permitted) { |
| 232 scoped_refptr<BrowsingDataRemoveFunction> function = | 258 scoped_refptr<BrowsingDataRemoveFunction> function = |
| 233 new BrowsingDataRemoveFunction(); | 259 new BrowsingDataRemoveFunction(); |
| 234 std::string args = "[{\"since\": 1}," + data_types + "]"; | 260 std::string args = "[{\"since\": 1}," + data_types + "]"; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 308 } |
| 283 | 309 |
| 284 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, RemoveBrowsingDataAll) { | 310 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, RemoveBrowsingDataAll) { |
| 285 scoped_refptr<BrowsingDataRemoveFunction> function = | 311 scoped_refptr<BrowsingDataRemoveFunction> function = |
| 286 new BrowsingDataRemoveFunction(); | 312 new BrowsingDataRemoveFunction(); |
| 287 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult(function.get(), | 313 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult(function.get(), |
| 288 kRemoveEverythingArguments, | 314 kRemoveEverythingArguments, |
| 289 browser())); | 315 browser())); |
| 290 | 316 |
| 291 EXPECT_EQ(base::Time::FromDoubleT(1.0), GetBeginTime()); | 317 EXPECT_EQ(base::Time::FromDoubleT(1.0), GetBeginTime()); |
| 292 EXPECT_EQ( | 318 std::set<const BrowsingDataType*> expected_mask = |
| 293 (BrowsingDataRemover::REMOVE_SITE_DATA | | 319 BrowsingDataTypeSetSiteData(); |
| 294 BrowsingDataRemover::REMOVE_CACHE | | 320 expected_mask.insert(&kBrowsingDataTypeCache); |
| 295 BrowsingDataRemover::REMOVE_DOWNLOADS | | 321 expected_mask.insert(&kBrowsingDataTypeDownloads); |
| 296 BrowsingDataRemover::REMOVE_FORM_DATA | | 322 expected_mask.insert(&kBrowsingDataTypeFormData); |
| 297 BrowsingDataRemover::REMOVE_HISTORY | | 323 expected_mask.insert(&kBrowsingDataTypeHistory); |
| 298 BrowsingDataRemover::REMOVE_PASSWORDS) & | 324 expected_mask.insert(&kBrowsingDataTypePasswords); |
| 299 // TODO(benwells): implement clearing of site usage data via the | 325 // TODO(benwells): implement clearing of site usage data via the |
| 300 // browsing data API. https://crbug.com/500801. | 326 // browsing data API. https://crbug.com/500801. |
| 301 ~BrowsingDataRemover::REMOVE_SITE_USAGE_DATA & | 327 expected_mask.erase(&kBrowsingDataTypeSiteUsageData); |
| 302 // TODO(dmurph): implement clearing of durable storage permission | 328 // TODO(dmurph): implement clearing of durable storage permission |
| 303 // via the browsing data API. https://crbug.com/500801. | 329 // via the browsing data API. https://crbug.com/500801. |
| 304 ~BrowsingDataRemover::REMOVE_DURABLE_PERMISSION & | 330 expected_mask.erase(&kBrowsingDataTypeDurablePermission); |
| 305 // We can't remove plugin data inside a test profile. | 331 // We can't remove plugin data inside a test profile. |
| 306 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA & | 332 expected_mask.erase(&kBrowsingDataTypePluginData); |
| 307 // TODO(ramyasharma): implement clearing of external protocol data | 333 // TODO(ramyasharma): implement clearing of external protocol data |
| 308 // via the browsing data API. https://crbug.com/692850. | 334 // via the browsing data API. https://crbug.com/692850. |
| 309 ~BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA, | 335 expected_mask.erase(&kBrowsingDataTypeExternalProtocolData); |
| 310 GetRemovalMask()); | 336 |
| 337 EXPECT_EQ(expected_mask, GetRemovalMask()); |
| 311 } | 338 } |
| 312 | 339 |
| 313 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, BrowsingDataOriginTypeMask) { | 340 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, BrowsingDataOriginTypeMask) { |
| 314 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask("{}", 0); | 341 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask("{}", 0); |
| 315 | 342 |
| 316 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( | 343 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( |
| 317 "{\"unprotectedWeb\": true}", UNPROTECTED_WEB); | 344 "{\"unprotectedWeb\": true}", UNPROTECTED_WEB); |
| 318 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( | 345 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( |
| 319 "{\"protectedWeb\": true}", PROTECTED_WEB); | 346 "{\"protectedWeb\": true}", PROTECTED_WEB); |
| 320 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( | 347 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 332 | 359 |
| 333 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( | 360 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask( |
| 334 ("{\"unprotectedWeb\": true, \"protectedWeb\": true, " | 361 ("{\"unprotectedWeb\": true, \"protectedWeb\": true, " |
| 335 "\"extension\": true}"), | 362 "\"extension\": true}"), |
| 336 UNPROTECTED_WEB | PROTECTED_WEB | EXTENSION); | 363 UNPROTECTED_WEB | PROTECTED_WEB | EXTENSION); |
| 337 } | 364 } |
| 338 | 365 |
| 339 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, | 366 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, |
| 340 BrowsingDataRemovalMask) { | 367 BrowsingDataRemovalMask) { |
| 341 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 368 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 342 "appcache", BrowsingDataRemover::REMOVE_APPCACHE); | 369 "appcache", {&kBrowsingDataTypeAppCache}); |
| 370 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask("cache", |
| 371 {&kBrowsingDataTypeCache}); |
| 343 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 372 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 344 "cache", BrowsingDataRemover::REMOVE_CACHE); | 373 "cookies", {&kBrowsingDataTypeCookies}); |
| 345 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 374 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 346 "cookies", BrowsingDataRemover::REMOVE_COOKIES); | 375 "downloads", {&kBrowsingDataTypeDownloads}); |
| 347 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 376 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 348 "downloads", BrowsingDataRemover::REMOVE_DOWNLOADS); | 377 "fileSystems", {&kBrowsingDataTypeFileSystems}); |
| 349 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 378 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 350 "fileSystems", BrowsingDataRemover::REMOVE_FILE_SYSTEMS); | 379 "formData", {&kBrowsingDataTypeFormData}); |
| 351 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 380 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 352 "formData", BrowsingDataRemover::REMOVE_FORM_DATA); | 381 "history", {&kBrowsingDataTypeHistory}); |
| 353 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 382 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 354 "history", BrowsingDataRemover::REMOVE_HISTORY); | 383 "indexedDB", {&kBrowsingDataTypeIndexedDB}); |
| 355 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 384 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 356 "indexedDB", BrowsingDataRemover::REMOVE_INDEXEDDB); | 385 "localStorage", {&kBrowsingDataTypeLocalStorage}); |
| 357 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 386 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 358 "localStorage", BrowsingDataRemover::REMOVE_LOCAL_STORAGE); | 387 "serverBoundCertificates", {&kBrowsingDataTypeChannelIDs}); |
| 359 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 388 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 360 "serverBoundCertificates", | 389 "passwords", {&kBrowsingDataTypePasswords}); |
| 361 BrowsingDataRemover::REMOVE_CHANNEL_IDS); | |
| 362 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | |
| 363 "passwords", BrowsingDataRemover::REMOVE_PASSWORDS); | |
| 364 // We can't remove plugin data inside a test profile. | 390 // We can't remove plugin data inside a test profile. |
| 365 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 391 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 366 "serviceWorkers", BrowsingDataRemover::REMOVE_SERVICE_WORKERS); | 392 "serviceWorkers", {&kBrowsingDataTypeServiceWorkers}); |
| 367 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 393 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( |
| 368 "cacheStorage", BrowsingDataRemover::REMOVE_CACHE_STORAGE); | 394 "cacheStorage", {&kBrowsingDataTypeCacheStorage}); |
| 369 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( | 395 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask("webSQL", |
| 370 "webSQL", BrowsingDataRemover::REMOVE_WEBSQL); | 396 {&kBrowsingDataTypeWebSQL}); |
| 371 } | 397 } |
| 372 | 398 |
| 373 // Test an arbitrary combination of data types. | 399 // Test an arbitrary combination of data types. |
| 374 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, | 400 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, |
| 375 BrowsingDataRemovalMaskCombination) { | 401 BrowsingDataRemovalMaskCombination) { |
| 376 RunBrowsingDataRemoveFunctionAndCompareRemovalMask( | 402 RunBrowsingDataRemoveFunctionAndCompareRemovalMask( |
| 377 "{\"appcache\": true, \"cookies\": true, \"history\": true}", | 403 "{\"appcache\": true, \"cookies\": true, \"history\": true}", |
| 378 BrowsingDataRemover::REMOVE_APPCACHE | | 404 {&kBrowsingDataTypeAppCache, &kBrowsingDataTypeCookies, |
| 379 BrowsingDataRemover::REMOVE_COOKIES | | 405 &kBrowsingDataTypeHistory}); |
| 380 BrowsingDataRemover::REMOVE_HISTORY); | |
| 381 } | 406 } |
| 382 | 407 |
| 383 // Make sure the remove() function accepts the format produced by settings(). | 408 // Make sure the remove() function accepts the format produced by settings(). |
| 384 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, | 409 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, |
| 385 BrowsingDataRemovalInputFromSettings) { | 410 BrowsingDataRemovalInputFromSettings) { |
| 386 PrefService* prefs = browser()->profile()->GetPrefs(); | 411 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 387 prefs->SetBoolean(browsing_data::prefs::kDeleteCache, true); | 412 prefs->SetBoolean(browsing_data::prefs::kDeleteCache, true); |
| 388 prefs->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); | 413 prefs->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); |
| 389 prefs->SetBoolean(browsing_data::prefs::kDeleteDownloadHistory, true); | 414 prefs->SetBoolean(browsing_data::prefs::kDeleteDownloadHistory, true); |
| 390 prefs->SetBoolean(browsing_data::prefs::kDeleteCookies, false); | 415 prefs->SetBoolean(browsing_data::prefs::kDeleteCookies, false); |
| 391 prefs->SetBoolean(browsing_data::prefs::kDeleteFormData, false); | 416 prefs->SetBoolean(browsing_data::prefs::kDeleteFormData, false); |
| 392 prefs->SetBoolean(browsing_data::prefs::kDeleteHostedAppsData, false); | 417 prefs->SetBoolean(browsing_data::prefs::kDeleteHostedAppsData, false); |
| 393 prefs->SetBoolean(browsing_data::prefs::kDeletePasswords, false); | 418 prefs->SetBoolean(browsing_data::prefs::kDeletePasswords, false); |
| 394 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, false); | 419 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, false); |
| 395 int expected_mask = BrowsingDataRemover::REMOVE_CACHE | | 420 const std::set<const BrowsingDataType*>& expected_mask = { |
| 396 BrowsingDataRemover::REMOVE_DOWNLOADS | | 421 &kBrowsingDataTypeCache, &kBrowsingDataTypeDownloads, |
| 397 BrowsingDataRemover::REMOVE_HISTORY; | 422 &kBrowsingDataTypeHistory}; |
| 398 std::string json; | 423 std::string json; |
| 399 // Scoping for the traces. | 424 // Scoping for the traces. |
| 400 { | 425 { |
| 401 scoped_refptr<BrowsingDataSettingsFunction> settings_function = | 426 scoped_refptr<BrowsingDataSettingsFunction> settings_function = |
| 402 new BrowsingDataSettingsFunction(); | 427 new BrowsingDataSettingsFunction(); |
| 403 SCOPED_TRACE("settings_json"); | 428 SCOPED_TRACE("settings_json"); |
| 404 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( | 429 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( |
| 405 settings_function.get(), std::string("[]"), browser())); | 430 settings_function.get(), std::string("[]"), browser())); |
| 406 | 431 |
| 407 base::DictionaryValue* result; | 432 base::DictionaryValue* result; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 420 remove_function.get(), | 445 remove_function.get(), |
| 421 std::string("[{\"since\": 1},") + json + "]", | 446 std::string("[{\"since\": 1},") + json + "]", |
| 422 browser())); | 447 browser())); |
| 423 EXPECT_EQ(expected_mask, GetRemovalMask()); | 448 EXPECT_EQ(expected_mask, GetRemovalMask()); |
| 424 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); | 449 EXPECT_EQ(UNPROTECTED_WEB, GetOriginTypeMask()); |
| 425 } | 450 } |
| 426 } | 451 } |
| 427 | 452 |
| 428 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, ShortcutFunctionRemovalMask) { | 453 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, ShortcutFunctionRemovalMask) { |
| 429 RunAndCompareRemovalMask<BrowsingDataRemoveAppcacheFunction>( | 454 RunAndCompareRemovalMask<BrowsingDataRemoveAppcacheFunction>( |
| 430 BrowsingDataRemover::REMOVE_APPCACHE); | 455 {&kBrowsingDataTypeAppCache}); |
| 431 RunAndCompareRemovalMask<BrowsingDataRemoveCacheFunction>( | 456 RunAndCompareRemovalMask<BrowsingDataRemoveCacheFunction>( |
| 432 BrowsingDataRemover::REMOVE_CACHE); | 457 {&kBrowsingDataTypeCache}); |
| 433 RunAndCompareRemovalMask<BrowsingDataRemoveCookiesFunction>( | 458 RunAndCompareRemovalMask<BrowsingDataRemoveCookiesFunction>( |
| 434 BrowsingDataRemover::REMOVE_COOKIES | | 459 {&kBrowsingDataTypeCookies, &kBrowsingDataTypeChannelIDs}); |
| 435 BrowsingDataRemover::REMOVE_CHANNEL_IDS); | |
| 436 RunAndCompareRemovalMask<BrowsingDataRemoveDownloadsFunction>( | 460 RunAndCompareRemovalMask<BrowsingDataRemoveDownloadsFunction>( |
| 437 BrowsingDataRemover::REMOVE_DOWNLOADS); | 461 {&kBrowsingDataTypeDownloads}); |
| 438 RunAndCompareRemovalMask<BrowsingDataRemoveFileSystemsFunction>( | 462 RunAndCompareRemovalMask<BrowsingDataRemoveFileSystemsFunction>( |
| 439 BrowsingDataRemover::REMOVE_FILE_SYSTEMS); | 463 {&kBrowsingDataTypeFileSystems}); |
| 440 RunAndCompareRemovalMask<BrowsingDataRemoveFormDataFunction>( | 464 RunAndCompareRemovalMask<BrowsingDataRemoveFormDataFunction>( |
| 441 BrowsingDataRemover::REMOVE_FORM_DATA); | 465 {&kBrowsingDataTypeFormData}); |
| 442 RunAndCompareRemovalMask<BrowsingDataRemoveHistoryFunction>( | 466 RunAndCompareRemovalMask<BrowsingDataRemoveHistoryFunction>( |
| 443 BrowsingDataRemover::REMOVE_HISTORY); | 467 {&kBrowsingDataTypeHistory}); |
| 444 RunAndCompareRemovalMask<BrowsingDataRemoveIndexedDBFunction>( | 468 RunAndCompareRemovalMask<BrowsingDataRemoveIndexedDBFunction>( |
| 445 BrowsingDataRemover::REMOVE_INDEXEDDB); | 469 {&kBrowsingDataTypeIndexedDB}); |
| 446 RunAndCompareRemovalMask<BrowsingDataRemoveLocalStorageFunction>( | 470 RunAndCompareRemovalMask<BrowsingDataRemoveLocalStorageFunction>( |
| 447 BrowsingDataRemover::REMOVE_LOCAL_STORAGE); | 471 {&kBrowsingDataTypeLocalStorage}); |
| 448 // We can't remove plugin data inside a test profile. | 472 // We can't remove plugin data inside a test profile. |
| 449 RunAndCompareRemovalMask<BrowsingDataRemovePasswordsFunction>( | 473 RunAndCompareRemovalMask<BrowsingDataRemovePasswordsFunction>( |
| 450 BrowsingDataRemover::REMOVE_PASSWORDS); | 474 {&kBrowsingDataTypePasswords}); |
| 451 RunAndCompareRemovalMask<BrowsingDataRemoveServiceWorkersFunction>( | 475 RunAndCompareRemovalMask<BrowsingDataRemoveServiceWorkersFunction>( |
| 452 BrowsingDataRemover::REMOVE_SERVICE_WORKERS); | 476 {&kBrowsingDataTypeServiceWorkers}); |
| 453 RunAndCompareRemovalMask<BrowsingDataRemoveWebSQLFunction>( | 477 RunAndCompareRemovalMask<BrowsingDataRemoveWebSQLFunction>( |
| 454 BrowsingDataRemover::REMOVE_WEBSQL); | 478 {&kBrowsingDataTypeWebSQL}); |
| 455 } | 479 } |
| 456 | 480 |
| 457 // Test the processing of the 'delete since' preference. | 481 // Test the processing of the 'delete since' preference. |
| 458 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSince) { | 482 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSince) { |
| 459 SetSinceAndVerify(browsing_data::ALL_TIME); | 483 SetSinceAndVerify(browsing_data::ALL_TIME); |
| 460 SetSinceAndVerify(browsing_data::LAST_HOUR); | 484 SetSinceAndVerify(browsing_data::LAST_HOUR); |
| 461 SetSinceAndVerify(browsing_data::LAST_DAY); | 485 SetSinceAndVerify(browsing_data::LAST_DAY); |
| 462 SetSinceAndVerify(browsing_data::LAST_WEEK); | 486 SetSinceAndVerify(browsing_data::LAST_WEEK); |
| 463 SetSinceAndVerify(browsing_data::FOUR_WEEKS); | 487 SetSinceAndVerify(browsing_data::FOUR_WEEKS); |
| 464 } | 488 } |
| 465 | 489 |
| 466 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionEmpty) { | 490 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionEmpty) { |
| 467 SetPrefsAndVerifySettings(0, 0, 0); | 491 std::set<const BrowsingDataType*> empty_mask; |
| 492 SetPrefsAndVerifySettings(empty_mask, 0, empty_mask); |
| 468 } | 493 } |
| 469 | 494 |
| 470 // Test straightforward settings, mapped 1:1 to data types. | 495 // Test straightforward settings, mapped 1:1 to data types. |
| 471 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSimple) { | 496 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSimple) { |
| 472 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_CACHE, 0, | 497 SetPrefsAndVerifySettings({&kBrowsingDataTypeCache}, 0, |
| 473 BrowsingDataRemover::REMOVE_CACHE); | 498 {&kBrowsingDataTypeCache}); |
| 474 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_HISTORY, 0, | 499 SetPrefsAndVerifySettings({&kBrowsingDataTypeHistory}, 0, |
| 475 BrowsingDataRemover::REMOVE_HISTORY); | 500 {&kBrowsingDataTypeHistory}); |
| 476 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_FORM_DATA, 0, | 501 SetPrefsAndVerifySettings({&kBrowsingDataTypeFormData}, 0, |
| 477 BrowsingDataRemover::REMOVE_FORM_DATA); | 502 {&kBrowsingDataTypeFormData}); |
| 478 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_DOWNLOADS, 0, | 503 SetPrefsAndVerifySettings({&kBrowsingDataTypeDownloads}, 0, |
| 479 BrowsingDataRemover::REMOVE_DOWNLOADS); | 504 {&kBrowsingDataTypeDownloads}); |
| 480 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_PASSWORDS, 0, | 505 SetPrefsAndVerifySettings({&kBrowsingDataTypePasswords}, 0, |
| 481 BrowsingDataRemover::REMOVE_PASSWORDS); | 506 {&kBrowsingDataTypePasswords}); |
| 482 } | 507 } |
| 483 | 508 |
| 484 // Test cookie and app data settings. | 509 // Test cookie and app data settings. |
| 485 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSiteData) { | 510 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSiteData) { |
| 486 int site_data_no_durable_or_usage_or_external = | 511 std::set<const BrowsingDataType*> site_data_no_durable_or_usage_or_external = |
| 487 BrowsingDataRemover::REMOVE_SITE_DATA & | 512 BrowsingDataTypeSetSiteData(); |
| 488 ~BrowsingDataRemover::REMOVE_SITE_USAGE_DATA & | 513 site_data_no_durable_or_usage_or_external.erase( |
| 489 ~BrowsingDataRemover::REMOVE_DURABLE_PERMISSION & | 514 &kBrowsingDataTypeSiteUsageData); |
| 490 ~BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA; | 515 site_data_no_durable_or_usage_or_external.erase( |
| 491 int site_data_no_plugins_durable_usage_external = | 516 &kBrowsingDataTypeDurablePermission); |
| 492 site_data_no_durable_or_usage_or_external & | 517 site_data_no_durable_or_usage_or_external.erase( |
| 493 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; | 518 &kBrowsingDataTypeExternalProtocolData); |
| 519 std::set<const BrowsingDataType*> |
| 520 site_data_no_plugins_durable_usage_external = |
| 521 site_data_no_durable_or_usage_or_external; |
| 522 site_data_no_plugins_durable_usage_external.erase( |
| 523 &kBrowsingDataTypePluginData); |
| 494 | 524 |
| 495 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES, | 525 SetPrefsAndVerifySettings({&kBrowsingDataTypeCookies}, UNPROTECTED_WEB, |
| 496 UNPROTECTED_WEB, | 526 site_data_no_plugins_durable_usage_external); |
| 527 SetPrefsAndVerifySettings({&kBrowsingDataTypeHostedAppDataTestOnly}, |
| 528 PROTECTED_WEB, |
| 497 site_data_no_plugins_durable_usage_external); | 529 site_data_no_plugins_durable_usage_external); |
| 498 SetPrefsAndVerifySettings( | 530 SetPrefsAndVerifySettings( |
| 499 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY, PROTECTED_WEB, | 531 {&kBrowsingDataTypeCookies, &kBrowsingDataTypeHostedAppDataTestOnly}, |
| 532 PROTECTED_WEB | UNPROTECTED_WEB, |
| 500 site_data_no_plugins_durable_usage_external); | 533 site_data_no_plugins_durable_usage_external); |
| 501 SetPrefsAndVerifySettings( | 534 SetPrefsAndVerifySettings( |
| 502 BrowsingDataRemover::REMOVE_COOKIES | | 535 {&kBrowsingDataTypeCookies, &kBrowsingDataTypePluginData}, |
| 503 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY, | 536 UNPROTECTED_WEB, site_data_no_durable_or_usage_or_external); |
| 504 PROTECTED_WEB | UNPROTECTED_WEB, | |
| 505 site_data_no_plugins_durable_usage_external); | |
| 506 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES | | |
| 507 BrowsingDataRemover::REMOVE_PLUGIN_DATA, | |
| 508 UNPROTECTED_WEB, | |
| 509 site_data_no_durable_or_usage_or_external); | |
| 510 } | 537 } |
| 511 | 538 |
| 512 // Test an arbitrary assortment of settings. | 539 // Test an arbitrary assortment of settings. |
| 513 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionAssorted) { | 540 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionAssorted) { |
| 514 int site_data_no_plugins_durable_usage_external = | 541 std::set<const BrowsingDataType*> |
| 515 BrowsingDataRemover::REMOVE_SITE_DATA & | 542 site_data_no_plugins_durable_usage_external = |
| 516 ~BrowsingDataRemover::REMOVE_DURABLE_PERMISSION & | 543 BrowsingDataTypeSetSiteData(); |
| 517 ~BrowsingDataRemover::REMOVE_SITE_USAGE_DATA & | 544 site_data_no_plugins_durable_usage_external.erase( |
| 518 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA & | 545 &kBrowsingDataTypeDurablePermission); |
| 519 ~BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA; | 546 site_data_no_plugins_durable_usage_external.erase( |
| 547 &kBrowsingDataTypeSiteUsageData); |
| 548 site_data_no_plugins_durable_usage_external.erase( |
| 549 &kBrowsingDataTypePluginData); |
| 550 site_data_no_plugins_durable_usage_external.erase( |
| 551 &kBrowsingDataTypeExternalProtocolData); |
| 520 | 552 |
| 521 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES | | 553 std::set<const BrowsingDataType*> expected_mask = |
| 522 BrowsingDataRemover::REMOVE_HISTORY | | 554 site_data_no_plugins_durable_usage_external; |
| 523 BrowsingDataRemover::REMOVE_DOWNLOADS, | 555 expected_mask.insert(&kBrowsingDataTypeHistory); |
| 524 UNPROTECTED_WEB, | 556 expected_mask.insert(&kBrowsingDataTypeDownloads); |
| 525 site_data_no_plugins_durable_usage_external | | 557 |
| 526 BrowsingDataRemover::REMOVE_HISTORY | | 558 SetPrefsAndVerifySettings( |
| 527 BrowsingDataRemover::REMOVE_DOWNLOADS); | 559 {&kBrowsingDataTypeCookies, &kBrowsingDataTypeHistory, |
| 560 &kBrowsingDataTypeDownloads}, |
| 561 UNPROTECTED_WEB, expected_mask); |
| 528 } | 562 } |
| OLD | NEW |