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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/pattern.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover.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" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // is called. | 237 // is called. |
237 void CheckRemovalPermitted(const std::string& data_types, bool permitted) { | 238 void CheckRemovalPermitted(const std::string& data_types, bool permitted) { |
238 scoped_refptr<BrowsingDataRemoveFunction> function = | 239 scoped_refptr<BrowsingDataRemoveFunction> function = |
239 new BrowsingDataRemoveFunction(); | 240 new BrowsingDataRemoveFunction(); |
240 std::string args = "[{\"since\": 1}," + data_types + "]"; | 241 std::string args = "[{\"since\": 1}," + data_types + "]"; |
241 | 242 |
242 if (permitted) { | 243 if (permitted) { |
243 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( | 244 EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( |
244 function.get(), args, browser())) << " for " << args; | 245 function.get(), args, browser())) << " for " << args; |
245 } else { | 246 } else { |
246 EXPECT_TRUE(MatchPattern( | 247 EXPECT_TRUE(base::MatchPattern( |
247 RunFunctionAndReturnError(function.get(), args, browser()), | 248 RunFunctionAndReturnError(function.get(), args, browser()), |
248 extension_browsing_data_api_constants::kDeleteProhibitedError)) | 249 extension_browsing_data_api_constants::kDeleteProhibitedError)) |
249 << " for " << args; | 250 << " for " << args; |
250 } | 251 } |
251 } | 252 } |
252 | 253 |
253 private: | 254 private: |
254 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_; | 255 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_; |
255 | 256 |
256 BrowsingDataRemover::CallbackSubscription callback_subscription_; | 257 BrowsingDataRemover::CallbackSubscription callback_subscription_; |
257 | 258 |
258 }; | 259 }; |
259 | 260 |
260 } // namespace | 261 } // namespace |
261 | 262 |
262 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, OneAtATime) { | 263 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, OneAtATime) { |
263 BrowsingDataRemover::set_removing(true); | 264 BrowsingDataRemover::set_removing(true); |
264 scoped_refptr<BrowsingDataRemoveFunction> function = | 265 scoped_refptr<BrowsingDataRemoveFunction> function = |
265 new BrowsingDataRemoveFunction(); | 266 new BrowsingDataRemoveFunction(); |
266 EXPECT_TRUE( | 267 EXPECT_TRUE(base::MatchPattern( |
267 MatchPattern(RunFunctionAndReturnError( | 268 RunFunctionAndReturnError(function.get(), kRemoveEverythingArguments, |
268 function.get(), kRemoveEverythingArguments, browser()), | 269 browser()), |
269 extension_browsing_data_api_constants::kOneAtATimeError)); | 270 extension_browsing_data_api_constants::kOneAtATimeError)); |
270 BrowsingDataRemover::set_removing(false); | 271 BrowsingDataRemover::set_removing(false); |
271 | 272 |
272 EXPECT_EQ(base::Time(), GetBeginTime()); | 273 EXPECT_EQ(base::Time(), GetBeginTime()); |
273 EXPECT_EQ(-1, GetRemovalMask()); | 274 EXPECT_EQ(-1, GetRemovalMask()); |
274 } | 275 } |
275 | 276 |
276 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, RemovalProhibited) { | 277 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, RemovalProhibited) { |
277 PrefService* prefs = browser()->profile()->GetPrefs(); | 278 PrefService* prefs = browser()->profile()->GetPrefs(); |
278 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); | 279 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); |
279 | 280 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 527 |
527 SetPrefsAndVerifySettings( | 528 SetPrefsAndVerifySettings( |
528 BrowsingDataRemover::REMOVE_COOKIES | | 529 BrowsingDataRemover::REMOVE_COOKIES | |
529 BrowsingDataRemover::REMOVE_HISTORY | | 530 BrowsingDataRemover::REMOVE_HISTORY | |
530 BrowsingDataRemover::REMOVE_DOWNLOADS, | 531 BrowsingDataRemover::REMOVE_DOWNLOADS, |
531 UNPROTECTED_WEB, | 532 UNPROTECTED_WEB, |
532 site_data_no_plugins | | 533 site_data_no_plugins | |
533 BrowsingDataRemover::REMOVE_HISTORY | | 534 BrowsingDataRemover::REMOVE_HISTORY | |
534 BrowsingDataRemover::REMOVE_DOWNLOADS); | 535 BrowsingDataRemover::REMOVE_DOWNLOADS); |
535 } | 536 } |
OLD | NEW |