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