Skip to content

Commit

Permalink
Move browsing data deletion prefs to components
Browse files Browse the repository at this point in the history
Move the pref_names related to browsing data deletion from chrome/common/ to components/browsing_data. They will be needed in the componentized counters.

BUG=620317

Review-Url: https://codereview.chromium.org/2136373003
Cr-Commit-Position: refs/heads/master@{#405123}
  • Loading branch information
ioanap authored and Commit bot committed Jul 13, 2016
1 parent 2632eee commit 918aa6d
Show file tree
Hide file tree
Showing 25 changed files with 158 additions and 160 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/autofill_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include "base/memory/scoped_vector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_data_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/browsing_data/pref_names.h"

AutofillCounter::AutofillCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeleteFormData),
: BrowsingDataCounter(browsing_data::prefs::kDeleteFormData),
profile_(profile),
web_data_service_(nullptr),
suggestions_query_(0),
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/autofill_counter_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/web_data_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_type.h"
Expand Down Expand Up @@ -134,7 +133,8 @@ class AutofillCounterTest : public InProcessBrowserTest {
// Other utils ---------------------------------------------------------------

void SetAutofillDeletionPref(bool value) {
browser()->profile()->GetPrefs()->SetBoolean(prefs::kDeleteFormData, value);
browser()->profile()->GetPrefs()->SetBoolean(
browsing_data::prefs::kDeleteFormData, value);
}

void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
Expand Down
16 changes: 8 additions & 8 deletions chrome/browser/browsing_data/browsing_data_counter_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include "chrome/browser/browsing_data/media_licenses_counter.h"
#include "chrome/browser/browsing_data/passwords_counter.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/counters/browsing_data_counter.h"
#include "components/browsing_data/pref_names.h"

#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/browsing_data/hosted_apps_counter.h"
Expand All @@ -27,26 +27,26 @@ BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile,
if (!AreCountersEnabled())
return nullptr;

if (pref_name == prefs::kDeleteBrowsingHistory)
if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory)
return base::MakeUnique<HistoryCounter>(profile);

if (pref_name == prefs::kDeleteCache)
if (pref_name == browsing_data::prefs::kDeleteCache)
return base::MakeUnique<CacheCounter>(profile);

if (pref_name == prefs::kDeletePasswords)
if (pref_name == browsing_data::prefs::kDeletePasswords)
return base::MakeUnique<PasswordsCounter>(profile);

if (pref_name == prefs::kDeleteFormData)
if (pref_name == browsing_data::prefs::kDeleteFormData)
return base::MakeUnique<AutofillCounter>(profile);

if (pref_name == prefs::kDeleteDownloadHistory)
if (pref_name == browsing_data::prefs::kDeleteDownloadHistory)
return base::MakeUnique<DownloadsCounter>(profile);

if (pref_name == prefs::kDeleteMediaLicenses)
if (pref_name == browsing_data::prefs::kDeleteMediaLicenses)
return base::MakeUnique<MediaLicensesCounter>(profile);

#if defined(ENABLE_EXTENSIONS)
if (pref_name == prefs::kDeleteHostedAppsData)
if (pref_name == browsing_data::prefs::kDeleteHostedAppsData)
return base::MakeUnique<HostedAppsCounter>(profile);
#endif

Expand Down
26 changes: 13 additions & 13 deletions chrome/browser/browsing_data/browsing_data_counter_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ base::string16 GetCounterTextFromResult(
// The counter is still counting.
text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING);

} else if (pref_name == prefs::kDeletePasswords ||
pref_name == prefs::kDeleteDownloadHistory) {
} else if (pref_name == browsing_data::prefs::kDeletePasswords ||
pref_name == browsing_data::prefs::kDeleteDownloadHistory) {
// Counters with trivially formatted result: passwords and downloads.
browsing_data::BrowsingDataCounter::ResultInt count =
static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>(
result)
->Value();
text = l10n_util::GetPluralStringFUTF16(
pref_name == prefs::kDeletePasswords
pref_name == browsing_data::prefs::kDeletePasswords
? IDS_DEL_PASSWORDS_COUNTER
: IDS_DEL_DOWNLOADS_COUNTER,
count);

} else if (pref_name == prefs::kDeleteCache) {
} else if (pref_name == browsing_data::prefs::kDeleteCache) {
// Cache counter.
browsing_data::BrowsingDataCounter::ResultInt cache_size_bytes =
static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>(
Expand All @@ -101,7 +101,7 @@ base::string16 GetCounterTextFromResult(
text = l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY);
}

} else if (pref_name == prefs::kDeleteBrowsingHistory) {
} else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) {
// History counter.
const HistoryCounter::HistoryResult* history_result =
static_cast<const HistoryCounter::HistoryResult*>(result);
Expand All @@ -115,7 +115,7 @@ base::string16 GetCounterTextFromResult(
: l10n_util::GetPluralStringFUTF16(
IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count);

} else if (pref_name == prefs::kDeleteFormData) {
} else if (pref_name == browsing_data::prefs::kDeleteFormData) {
// Autofill counter.
const AutofillCounter::AutofillResult* autofill_result =
static_cast<const AutofillCounter::AutofillResult*>(result);
Expand Down Expand Up @@ -178,7 +178,7 @@ base::string16 GetCounterTextFromResult(
NOTREACHED();
}

} else if (pref_name == prefs::kDeleteMediaLicenses) {
} else if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) {
const MediaLicensesCounter::MediaLicenseResult* media_license_result =
static_cast<const MediaLicensesCounter::MediaLicenseResult*>(result);
if (media_license_result->Value() > 0) {
Expand All @@ -191,7 +191,7 @@ base::string16 GetCounterTextFromResult(
}

#if defined(ENABLE_EXTENSIONS)
} else if (pref_name == prefs::kDeleteHostedAppsData) {
} else if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) {
// Hosted apps counter.
const HostedAppsCounter::HostedAppsResult* hosted_apps_result =
static_cast<const HostedAppsCounter::HostedAppsResult*>(result);
Expand Down Expand Up @@ -235,19 +235,19 @@ bool GetDeletionPreferenceFromDataType(
std::string* out_pref) {
switch (data_type) {
case browsing_data::HISTORY:
*out_pref = prefs::kDeleteBrowsingHistory;
*out_pref = browsing_data::prefs::kDeleteBrowsingHistory;
return true;
case browsing_data::CACHE:
*out_pref = prefs::kDeleteCache;
*out_pref = browsing_data::prefs::kDeleteCache;
return true;
case browsing_data::COOKIES:
*out_pref = prefs::kDeleteCookies;
*out_pref = browsing_data::prefs::kDeleteCookies;
return true;
case browsing_data::PASSWORDS:
*out_pref = prefs::kDeletePasswords;
*out_pref = browsing_data::prefs::kDeletePasswords;
return true;
case browsing_data::FORM_DATA:
*out_pref = prefs::kDeleteFormData;
*out_pref = browsing_data::prefs::kDeleteFormData;
return true;
case browsing_data::BOOKMARKS:
// Bookmarks are deleted on the Android side. No corresponding deletion
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/cache_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include "chrome/browser/browsing_data/cache_counter.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/pref_names.h"
#include "components/browsing_data/storage_partition_http_cache_data_remover.h"
#include "net/base/net_errors.h"

CacheCounter::CacheCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeleteCache),
: BrowsingDataCounter(browsing_data::prefs::kDeleteCache),
profile_(profile),
pending_(false),
weak_ptr_factory_(this) {}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/cache_counter_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "base/run_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/browsing_data/browsing_data_utils.h"
Expand All @@ -39,7 +38,8 @@ class CacheCounterTest : public InProcessBrowserTest {
}

void SetCacheDeletionPref(bool value) {
browser()->profile()->GetPrefs()->SetBoolean(prefs::kDeleteCache, value);
browser()->profile()->GetPrefs()->SetBoolean(
browsing_data::prefs::kDeleteCache, value);
}

void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/browsing_data/downloads_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

#include "chrome/browser/download/download_history.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/pref_names.h"
#include "content/public/browser/download_manager.h"

DownloadsCounter::DownloadsCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeleteDownloadHistory), profile_(profile) {}
: BrowsingDataCounter(browsing_data::prefs::kDeleteDownloadHistory),
profile_(profile) {}

DownloadsCounter::~DownloadsCounter() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/browsing_data/browsing_data_utils.h"
#include "components/browsing_data/pref_names.h"
Expand Down Expand Up @@ -165,7 +164,7 @@ class DownloadsCounterTest : public InProcessBrowserTest,

void SetDownloadsDeletionPref(bool value) {
browser()->profile()->GetPrefs()->SetBoolean(
prefs::kDeleteDownloadHistory, value);
browsing_data::prefs::kDeleteDownloadHistory, value);
}

void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/history_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/browsing_data/pref_names.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/web_history_service.h"
#include "content/public/browser/browser_thread.h"
Expand All @@ -24,7 +24,7 @@ static const int64_t kWebHistoryTimeoutSeconds = 10;
}

HistoryCounter::HistoryCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeleteBrowsingHistory),
: BrowsingDataCounter(browsing_data::prefs::kDeleteBrowsingHistory),
profile_(profile),
has_synced_visits_(false),
local_counting_finished_(false),
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/browsing_data/history_counter_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/browsing_data/browsing_data_utils.h"
#include "components/browsing_data/pref_names.h"
Expand Down Expand Up @@ -59,7 +58,7 @@ class HistoryCounterTest : public SyncTest {

void SetHistoryDeletionPref(bool value) {
browser()->profile()->GetPrefs()->SetBoolean(
prefs::kDeleteBrowsingHistory, value);
browsing_data::prefs::kDeleteBrowsingHistory, value);
}

void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/browsing_data/hosted_apps_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

#include "base/memory/ptr_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/pref_names.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"

HostedAppsCounter::HostedAppsCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeleteHostedAppsData), profile_(profile) {}
: BrowsingDataCounter(browsing_data::prefs::kDeleteHostedAppsData),
profile_(profile) {}

HostedAppsCounter::~HostedAppsCounter() {}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/hosted_apps_counter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "base/bind.h"
#include "base/guid.h"
#include "base/values.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/browsing_data/browsing_data_utils.h"
#include "components/browsing_data/pref_names.h"
Expand Down Expand Up @@ -98,7 +97,8 @@ class HostedAppsCounterTest : public testing::Test {
// Setting preferences. ------------------------------------------------------

void SetHostedAppsDeletionPref(bool value) {
GetProfile()->GetPrefs()->SetBoolean(prefs::kDeleteHostedAppsData, value);
GetProfile()->GetPrefs()->SetBoolean(
browsing_data::prefs::kDeleteHostedAppsData, value);
}

void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browsing_data/media_licenses_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/task_runner_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "storage/browser/fileapi/file_system_context.h"
Expand Down Expand Up @@ -52,7 +52,7 @@ const std::string& MediaLicensesCounter::MediaLicenseResult::GetOneOrigin()
}

MediaLicensesCounter::MediaLicensesCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeleteMediaLicenses),
: BrowsingDataCounter(browsing_data::prefs::kDeleteMediaLicenses),
profile_(profile),
weak_ptr_factory_(this) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "base/run_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/browsing_data/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
Expand All @@ -33,8 +33,8 @@ class MediaLicensesCounterTest : public InProcessBrowserTest {
void SetUpOnMainThread() override { SetMediaLicenseDeletionPref(true); }

void SetMediaLicenseDeletionPref(bool value) {
browser()->profile()->GetPrefs()->SetBoolean(prefs::kDeleteMediaLicenses,
value);
browser()->profile()->GetPrefs()->SetBoolean(
browsing_data::prefs::kDeleteMediaLicenses, value);
}

// Create some test data for origin |kOrigin|.
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/browsing_data/passwords_counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#include "chrome/browser/browsing_data/passwords_counter.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/pref_names.h"
#include "components/password_manager/core/browser/password_store.h"

PasswordsCounter::PasswordsCounter(Profile* profile)
: BrowsingDataCounter(prefs::kDeletePasswords), profile_(profile) {}
: BrowsingDataCounter(browsing_data::prefs::kDeletePasswords),
profile_(profile) {}

PasswordsCounter::~PasswordsCounter() {
store_->RemoveObserver(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/sync/test/integration/passwords_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/core/common/password_form.h"
#include "components/browsing_data/browsing_data_utils.h"
Expand Down Expand Up @@ -65,7 +64,7 @@ class PasswordsCounterTest : public InProcessBrowserTest,

void SetPasswordsDeletionPref(bool value) {
browser()->profile()->GetPrefs()->SetBoolean(
prefs::kDeletePasswords, value);
browsing_data::prefs::kDeletePasswords, value);
}

void SetDeletionPeriodPref(browsing_data::TimePeriod period) {
Expand Down
Loading

0 comments on commit 918aa6d

Please sign in to comment.