Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Side by Side Diff: chrome/browser/browsing_data/downloads_counter_browsertest.cc

Issue 2136373003: Move browsing data deletion prefs to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_history.h" 13 #include "chrome/browser/download/download_history.h"
14 #include "chrome/browser/download/download_service.h" 14 #include "chrome/browser/download/download_service.h"
15 #include "chrome/browser/download/download_service_factory.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/common/pref_names.h"
19 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
20 #include "components/browsing_data/browsing_data_utils.h" 19 #include "components/browsing_data/browsing_data_utils.h"
21 #include "components/browsing_data/pref_names.h" 20 #include "components/browsing_data/pref_names.h"
22 #include "components/history/core/browser/download_row.h" 21 #include "components/history/core/browser/download_row.h"
23 #include "components/prefs/pref_service.h" 22 #include "components/prefs/pref_service.h"
24 #include "content/public/browser/download_manager.h" 23 #include "content/public/browser/download_manager.h"
25 24
26 #if defined(ENABLE_EXTENSIONS) 25 #if defined(ENABLE_EXTENSIONS)
27 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
28 #endif 27 #endif
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void RemoveDownload(const std::string& guid) { 157 void RemoveDownload(const std::string& guid) {
159 content::DownloadItem* item = manager_->GetDownloadByGuid(guid); 158 content::DownloadItem* item = manager_->GetDownloadByGuid(guid);
160 ids_to_remove_.insert(item->GetId()); 159 ids_to_remove_.insert(item->GetId());
161 item->Remove(); 160 item->Remove();
162 } 161 }
163 162
164 // Miscellaneous. ------------------------------------------------------------ 163 // Miscellaneous. ------------------------------------------------------------
165 164
166 void SetDownloadsDeletionPref(bool value) { 165 void SetDownloadsDeletionPref(bool value) {
167 browser()->profile()->GetPrefs()->SetBoolean( 166 browser()->profile()->GetPrefs()->SetBoolean(
168 prefs::kDeleteDownloadHistory, value); 167 browsing_data::prefs::kDeleteDownloadHistory, value);
169 } 168 }
170 169
171 void SetDeletionPeriodPref(browsing_data::TimePeriod period) { 170 void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
172 browser()->profile()->GetPrefs()->SetInteger( 171 browser()->profile()->GetPrefs()->SetInteger(
173 browsing_data::prefs::kDeleteTimePeriod, static_cast<int>(period)); 172 browsing_data::prefs::kDeleteTimePeriod, static_cast<int>(period));
174 } 173 }
175 174
176 void RevertTimeInHours(int days) { 175 void RevertTimeInHours(int days) {
177 time_ -= base::TimeDelta::FromHours(days); 176 time_ -= base::TimeDelta::FromHours(days);
178 } 177 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 EXPECT_EQ(7u, GetResult()); 388 EXPECT_EQ(7u, GetResult());
390 389
391 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS); 390 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS);
392 EXPECT_EQ(8u, GetResult()); 391 EXPECT_EQ(8u, GetResult());
393 392
394 SetDeletionPeriodPref(browsing_data::EVERYTHING); 393 SetDeletionPeriodPref(browsing_data::EVERYTHING);
395 EXPECT_EQ(11u, GetResult()); 394 EXPECT_EQ(11u, GetResult());
396 } 395 }
397 396
398 } // namespace 397 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/downloads_counter.cc ('k') | chrome/browser/browsing_data/history_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698