OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
18 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" | 18 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" |
19 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
20 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
25 #include "chrome/test/base/testing_pref_service.h" | 25 #include "chrome/test/base/testing_pref_service.h" |
26 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
27 #include "content/public/browser/dom_storage_context.h" | 27 #include "content/public/browser/dom_storage_context.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/storage_partition.h" |
29 #include "content/public/test/test_browser_thread.h" | 30 #include "content/public/test/test_browser_thread.h" |
30 #include "net/base/server_bound_cert_service.h" | 31 #include "net/base/server_bound_cert_service.h" |
31 #include "net/base/server_bound_cert_store.h" | 32 #include "net/base/server_bound_cert_store.h" |
32 #include "net/base/ssl_client_cert_type.h" | 33 #include "net/base/ssl_client_cert_type.h" |
33 #include "net/cookies/cookie_monster.h" | 34 #include "net/cookies/cookie_monster.h" |
34 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
35 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 HistoryService* history_service_; | 310 HistoryService* history_service_; |
310 | 311 |
311 DISALLOW_COPY_AND_ASSIGN(RemoveHistoryTester); | 312 DISALLOW_COPY_AND_ASSIGN(RemoveHistoryTester); |
312 }; | 313 }; |
313 | 314 |
314 class RemoveLocalStorageTester : public BrowsingDataRemoverTester { | 315 class RemoveLocalStorageTester : public BrowsingDataRemoverTester { |
315 public: | 316 public: |
316 explicit RemoveLocalStorageTester(TestingProfile* profile) | 317 explicit RemoveLocalStorageTester(TestingProfile* profile) |
317 : profile_(profile), dom_storage_context_(NULL) { | 318 : profile_(profile), dom_storage_context_(NULL) { |
318 dom_storage_context_ = | 319 dom_storage_context_ = |
319 content::BrowserContext::GetDefaultDOMStorageContext(profile); | 320 content::BrowserContext::GetDefaultStoragePartition(profile)-> |
| 321 GetDOMStorageContext(); |
320 } | 322 } |
321 | 323 |
322 // Returns true, if the given origin URL exists. | 324 // Returns true, if the given origin URL exists. |
323 bool DOMStorageExistsForOrigin(const GURL& origin) { | 325 bool DOMStorageExistsForOrigin(const GURL& origin) { |
324 GetUsageInfo(); | 326 GetUsageInfo(); |
325 BlockUntilNotified(); | 327 BlockUntilNotified(); |
326 for (size_t i = 0; i < infos_.size(); ++i) { | 328 for (size_t i = 0; i < infos_.size(); ++i) { |
327 if (origin == infos_[i].origin) | 329 if (origin == infos_[i].origin) |
328 return true; | 330 return true; |
329 } | 331 } |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 1149 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
1148 | 1150 |
1149 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1151 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
1150 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2, tester.get()); | 1152 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2, tester.get()); |
1151 | 1153 |
1152 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1154 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1153 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); | 1155 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); |
1154 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 1156 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
1155 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 1157 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
1156 } | 1158 } |
OLD | NEW |