OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/downloads_counter.h" | 5 #include "chrome/browser/browsing_data/downloads_counter.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/download/download_core_service.h" |
| 14 #include "chrome/browser/download/download_core_service_factory.h" |
13 #include "chrome/browser/download/download_history.h" | 15 #include "chrome/browser/download/download_history.h" |
14 #include "chrome/browser/download/download_service.h" | |
15 #include "chrome/browser/download/download_service_factory.h" | |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "components/browsing_data/core/browsing_data_utils.h" | 19 #include "components/browsing_data/core/browsing_data_utils.h" |
20 #include "components/browsing_data/core/pref_names.h" | 20 #include "components/browsing_data/core/pref_names.h" |
21 #include "components/history/core/browser/download_row.h" | 21 #include "components/history/core/browser/download_row.h" |
22 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
23 #include "content/public/browser/download_manager.h" | 23 #include "content/public/browser/download_manager.h" |
24 #include "extensions/features/features.h" | 24 #include "extensions/features/features.h" |
25 | 25 |
26 #if BUILDFLAG(ENABLE_EXTENSIONS) | 26 #if BUILDFLAG(ENABLE_EXTENSIONS) |
27 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
28 #endif | 28 #endif |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 class DownloadsCounterTest : public InProcessBrowserTest, | 32 class DownloadsCounterTest : public InProcessBrowserTest, |
33 public DownloadHistory::Observer { | 33 public DownloadHistory::Observer { |
34 public: | 34 public: |
35 void SetUpOnMainThread() override { | 35 void SetUpOnMainThread() override { |
36 time_ = base::Time::Now(); | 36 time_ = base::Time::Now(); |
37 items_count_ = 0; | 37 items_count_ = 0; |
38 manager_ = | 38 manager_ = |
39 content::BrowserContext::GetDownloadManager(browser()->profile()); | 39 content::BrowserContext::GetDownloadManager(browser()->profile()); |
40 history_ = | 40 history_ = |
41 DownloadServiceFactory::GetForBrowserContext(browser()->profile())-> | 41 DownloadCoreServiceFactory::GetForBrowserContext(browser()->profile()) |
42 GetDownloadHistory(); | 42 ->GetDownloadHistory(); |
43 history_->AddObserver(this); | 43 history_->AddObserver(this); |
44 | 44 |
45 otr_manager_ = | 45 otr_manager_ = |
46 content::BrowserContext::GetDownloadManager( | 46 content::BrowserContext::GetDownloadManager( |
47 browser()->profile()->GetOffTheRecordProfile()); | 47 browser()->profile()->GetOffTheRecordProfile()); |
48 SetDownloadsDeletionPref(true); | 48 SetDownloadsDeletionPref(true); |
49 SetDeletionPeriodPref(browsing_data::TimePeriod::ALL_TIME); | 49 SetDeletionPeriodPref(browsing_data::TimePeriod::ALL_TIME); |
50 } | 50 } |
51 | 51 |
52 void TearDownOnMainThread() override { | 52 void TearDownOnMainThread() override { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 EXPECT_EQ(7u, GetResult()); | 378 EXPECT_EQ(7u, GetResult()); |
379 | 379 |
380 SetDeletionPeriodPref(browsing_data::TimePeriod::FOUR_WEEKS); | 380 SetDeletionPeriodPref(browsing_data::TimePeriod::FOUR_WEEKS); |
381 EXPECT_EQ(8u, GetResult()); | 381 EXPECT_EQ(8u, GetResult()); |
382 | 382 |
383 SetDeletionPeriodPref(browsing_data::TimePeriod::ALL_TIME); | 383 SetDeletionPeriodPref(browsing_data::TimePeriod::ALL_TIME); |
384 EXPECT_EQ(11u, GetResult()); | 384 EXPECT_EQ(11u, GetResult()); |
385 } | 385 } |
386 | 386 |
387 } // namespace | 387 } // namespace |
OLD | NEW |