* Move Brave Shields utility functions - Move utility functions that are not using `//content/` from `/components/brave_shields/content/` to `/components/brave_shields/core/` so it can be also be accessed by iOS. * Update tests - Update tests after moving functions from `/components/brave_shields/content/` to `/components/brave_shields/core/`. * Fix UNSAFE_TODO - Update brave_shields_p3a.cc to address unsafe buffer warnings.
39 lines
1.6 KiB
C++
39 lines
1.6 KiB
C++
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "brave/browser/profiles/profile_util.h"
|
|
|
|
#include "brave/components/brave_shields/core/browser/brave_shields_p3a.h"
|
|
#include "brave/components/constants/pref_names.h"
|
|
#include "brave/components/search_engines/brave_prepopulated_engines.h"
|
|
#include "chrome/browser/profiles/profile.h"
|
|
#include "components/content_settings/core/browser/cookie_settings.h"
|
|
#include "components/content_settings/core/common/pref_names.h"
|
|
#include "components/prefs/pref_service.h"
|
|
#include "components/search_engines/search_engines_pref_names.h"
|
|
|
|
namespace brave {
|
|
|
|
void SetDefaultSearchVersion(Profile* profile, bool is_new_profile) {
|
|
const PrefService::Preference* pref_default_search_version =
|
|
profile->GetPrefs()->FindPreference(prefs::kBraveDefaultSearchVersion);
|
|
if (!pref_default_search_version->HasUserSetting()) {
|
|
profile->GetPrefs()->SetInteger(
|
|
prefs::kBraveDefaultSearchVersion,
|
|
is_new_profile
|
|
? TemplateURLPrepopulateData::kBraveCurrentDataVersion
|
|
: TemplateURLPrepopulateData::kBraveFirstTrackedDataVersion);
|
|
}
|
|
}
|
|
|
|
void SetDefaultThirdPartyCookieBlockValue(Profile* profile) {
|
|
profile->GetPrefs()->SetDefaultPrefValue(
|
|
prefs::kCookieControlsMode,
|
|
base::Value(static_cast<int>(
|
|
content_settings::CookieControlsMode::kBlockThirdParty)));
|
|
}
|
|
|
|
} // namespace brave
|