| 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" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // 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. |
| 158 // Since the smallest selectable period is an hour, that should be | 158 // Since the smallest selectable period is an hour, that should be |
| 159 // sufficient. | 159 // sufficient. |
| 160 EXPECT_LE(expected_since, since + 10.0 * 1000.0); | 160 EXPECT_LE(expected_since, since + 10.0 * 1000.0); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void SetPrefsAndVerifySettings(int data_type_flags, | 163 void SetPrefsAndVerifySettings(int data_type_flags, |
| 164 int expected_origin_type_mask, | 164 int expected_origin_type_mask, |
| 165 int expected_removal_mask) { | 165 int expected_removal_mask) { |
| 166 PrefService* prefs = browser()->profile()->GetPrefs(); | 166 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 167 prefs->SetBoolean(prefs::kDeleteCache, | 167 prefs->SetBoolean(browsing_data::prefs::kDeleteCache, |
| 168 !!(data_type_flags & BrowsingDataRemover::REMOVE_CACHE)); | 168 !!(data_type_flags & BrowsingDataRemover::REMOVE_CACHE)); |
| 169 prefs->SetBoolean(prefs::kDeleteCookies, | 169 prefs->SetBoolean(browsing_data::prefs::kDeleteCookies, |
| 170 !!(data_type_flags & BrowsingDataRemover::REMOVE_COOKIES)); | 170 !!(data_type_flags & BrowsingDataRemover::REMOVE_COOKIES)); |
| 171 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, | 171 prefs->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, |
| 172 !!(data_type_flags & BrowsingDataRemover::REMOVE_HISTORY)); | 172 !!(data_type_flags & BrowsingDataRemover::REMOVE_HISTORY)); |
| 173 prefs->SetBoolean(prefs::kDeleteFormData, | 173 prefs->SetBoolean(browsing_data::prefs::kDeleteFormData, |
| 174 !!(data_type_flags & BrowsingDataRemover::REMOVE_FORM_DATA)); | 174 !!(data_type_flags & BrowsingDataRemover::REMOVE_FORM_DATA)); |
| 175 prefs->SetBoolean(prefs::kDeleteDownloadHistory, | 175 prefs->SetBoolean(browsing_data::prefs::kDeleteDownloadHistory, |
| 176 !!(data_type_flags & BrowsingDataRemover::REMOVE_DOWNLOADS)); | 176 !!(data_type_flags & BrowsingDataRemover::REMOVE_DOWNLOADS)); |
| 177 prefs->SetBoolean(prefs::kDeleteHostedAppsData, | 177 prefs->SetBoolean(browsing_data::prefs::kDeleteHostedAppsData, |
| 178 !!(data_type_flags & | 178 !!(data_type_flags & |
| 179 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY)); | 179 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY)); |
| 180 prefs->SetBoolean(prefs::kDeletePasswords, | 180 prefs->SetBoolean(browsing_data::prefs::kDeletePasswords, |
| 181 !!(data_type_flags & BrowsingDataRemover::REMOVE_PASSWORDS)); | 181 !!(data_type_flags & BrowsingDataRemover::REMOVE_PASSWORDS)); |
| 182 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, | 182 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, |
| 183 !!(data_type_flags & BrowsingDataRemover::REMOVE_PLUGIN_DATA)); | 183 !!(data_type_flags & BrowsingDataRemover::REMOVE_PLUGIN_DATA)); |
| 184 | 184 |
| 185 scoped_refptr<BrowsingDataSettingsFunction> function = | 185 scoped_refptr<BrowsingDataSettingsFunction> function = |
| 186 new BrowsingDataSettingsFunction(); | 186 new BrowsingDataSettingsFunction(); |
| 187 SCOPED_TRACE("settings"); | 187 SCOPED_TRACE("settings"); |
| 188 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( | 188 std::unique_ptr<base::Value> result_value(RunFunctionAndReturnSingleResult( |
| 189 function.get(), std::string("[]"), browser())); | 189 function.get(), std::string("[]"), browser())); |
| 190 | 190 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 "{\"appcache\": true, \"cookies\": true, \"history\": true}", | 398 "{\"appcache\": true, \"cookies\": true, \"history\": true}", |
| 399 BrowsingDataRemover::REMOVE_APPCACHE | | 399 BrowsingDataRemover::REMOVE_APPCACHE | |
| 400 BrowsingDataRemover::REMOVE_COOKIES | | 400 BrowsingDataRemover::REMOVE_COOKIES | |
| 401 BrowsingDataRemover::REMOVE_HISTORY); | 401 BrowsingDataRemover::REMOVE_HISTORY); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // Make sure the remove() function accepts the format produced by settings(). | 404 // Make sure the remove() function accepts the format produced by settings(). |
| 405 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, | 405 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, |
| 406 BrowsingDataRemovalInputFromSettings) { | 406 BrowsingDataRemovalInputFromSettings) { |
| 407 PrefService* prefs = browser()->profile()->GetPrefs(); | 407 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 408 prefs->SetBoolean(prefs::kDeleteCache, true); | 408 prefs->SetBoolean(browsing_data::prefs::kDeleteCache, true); |
| 409 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, true); | 409 prefs->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); |
| 410 prefs->SetBoolean(prefs::kDeleteDownloadHistory, true); | 410 prefs->SetBoolean(browsing_data::prefs::kDeleteDownloadHistory, true); |
| 411 prefs->SetBoolean(prefs::kDeleteCookies, false); | 411 prefs->SetBoolean(browsing_data::prefs::kDeleteCookies, false); |
| 412 prefs->SetBoolean(prefs::kDeleteFormData, false); | 412 prefs->SetBoolean(browsing_data::prefs::kDeleteFormData, false); |
| 413 prefs->SetBoolean(prefs::kDeleteHostedAppsData, false); | 413 prefs->SetBoolean(browsing_data::prefs::kDeleteHostedAppsData, false); |
| 414 prefs->SetBoolean(prefs::kDeletePasswords, false); | 414 prefs->SetBoolean(browsing_data::prefs::kDeletePasswords, false); |
| 415 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, false); | 415 prefs->SetBoolean(prefs::kClearPluginLSODataEnabled, false); |
| 416 int expected_mask = BrowsingDataRemover::REMOVE_CACHE | | 416 int expected_mask = BrowsingDataRemover::REMOVE_CACHE | |
| 417 BrowsingDataRemover::REMOVE_DOWNLOADS | | 417 BrowsingDataRemover::REMOVE_DOWNLOADS | |
| 418 BrowsingDataRemover::REMOVE_HISTORY; | 418 BrowsingDataRemover::REMOVE_HISTORY; |
| 419 std::string json; | 419 std::string json; |
| 420 // Scoping for the traces. | 420 // Scoping for the traces. |
| 421 { | 421 { |
| 422 scoped_refptr<BrowsingDataSettingsFunction> settings_function = | 422 scoped_refptr<BrowsingDataSettingsFunction> settings_function = |
| 423 new BrowsingDataSettingsFunction(); | 423 new BrowsingDataSettingsFunction(); |
| 424 SCOPED_TRACE("settings_json"); | 424 SCOPED_TRACE("settings_json"); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 536 |
| 537 SetPrefsAndVerifySettings( | 537 SetPrefsAndVerifySettings( |
| 538 BrowsingDataRemover::REMOVE_COOKIES | | 538 BrowsingDataRemover::REMOVE_COOKIES | |
| 539 BrowsingDataRemover::REMOVE_HISTORY | | 539 BrowsingDataRemover::REMOVE_HISTORY | |
| 540 BrowsingDataRemover::REMOVE_DOWNLOADS, | 540 BrowsingDataRemover::REMOVE_DOWNLOADS, |
| 541 UNPROTECTED_WEB, | 541 UNPROTECTED_WEB, |
| 542 site_data_no_plugins | | 542 site_data_no_plugins | |
| 543 BrowsingDataRemover::REMOVE_HISTORY | | 543 BrowsingDataRemover::REMOVE_HISTORY | |
| 544 BrowsingDataRemover::REMOVE_DOWNLOADS); | 544 BrowsingDataRemover::REMOVE_DOWNLOADS); |
| 545 } | 545 } |
| OLD | NEW |