Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'
import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'

import {BaseMixin} from '../base_mixin.js'
import {loadTimeData} from '../i18n_setup.js'
import {
WebUiListenerMixin,
WebUiListenerMixinInterface,
} from 'chrome://resources/cr_elements/web_ui_listener_mixin.js'
import { loadTimeData } from '../i18n_setup.js'

import {getTemplate} from './brave_personalization_options.html.js'
import {BravePrivacyBrowserProxy, BravePrivacyBrowserProxyImpl} from './brave_privacy_page_browser_proxy.js'
import { getTemplate } from './brave_personalization_options.html.js'
import {
BravePrivacyBrowserProxy,
BravePrivacyBrowserProxyImpl,
} from './brave_privacy_page_browser_proxy.js'

import { assert } from 'chrome://resources/js/assert.js'
import { SettingsToggleButtonElement } from '../controls/settings_toggle_button.js'

import '../privacy_page/do_not_track_toggle.js'

const SettingsBravePersonalizationOptionsBase = BaseMixin(PolymerElement) as {
new(): PolymerElement
const SettingsBravePersonalizationOptionsBase = WebUiListenerMixin(
PolymerElement,
) as {
new (): PolymerElement & WebUiListenerMixinInterface
}

export class SettingsBravePersonalizationOptions extends SettingsBravePersonalizationOptionsBase {
Expand All @@ -34,9 +45,18 @@ export class SettingsBravePersonalizationOptions extends SettingsBravePersonaliz
value: function () {
return [
{ value: 'default', name: loadTimeData.getString('webRTCDefault') },
{ value: 'default_public_and_private_interfaces', name: loadTimeData.getString('defaultPublicAndPrivateInterfaces') },
{ value: 'default_public_interface_only', name: loadTimeData.getString('defaultPublicInterfaceOnly') },
{ value: 'disable_non_proxied_udp', name: loadTimeData.getString('disableNonProxiedUdp') }
{
value: 'default_public_and_private_interfaces',
name: loadTimeData.getString('defaultPublicAndPrivateInterfaces'),
},
{
value: 'default_public_interface_only',
name: loadTimeData.getString('defaultPublicInterfaceOnly'),
},
{
value: 'disable_non_proxied_udp',
name: loadTimeData.getString('disableNonProxiedUdp'),
},
]
},
},
Expand All @@ -46,14 +66,14 @@ export class SettingsBravePersonalizationOptions extends SettingsBravePersonaliz
type: Boolean,
value: function () {
return loadTimeData.getBoolean('isDebounceFeatureEnabled')
}
},
},
isRequestOTRFeatureEnabled_: {
readOnly: true,
type: Boolean,
value: function () {
return loadTimeData.getBoolean('isRequestOTRFeatureEnabled')
}
},
},
requestOTRActions_: {
readOnly: true,
Expand All @@ -67,25 +87,60 @@ export class SettingsBravePersonalizationOptions extends SettingsBravePersonaliz
},
},
requestOTRAction_: String,
isWindowsRecallAvailable_: {
readOnly: true,
type: Boolean,
value: () => {
return loadTimeData.getBoolean('isWindowsRecallAvailable')
},
},
windowsRecallDisabledPref_: {
type: Object,
value: () => {
return {}
},
},
}
}

private declare webRTCPolicies_: Object[]
private declare webRTCPolicy_: String
private declare isDebounceFeatureEnabled_: boolean
private declare isRequestOTRFeatureEnabled_: boolean
private declare requestOTRActions_: Object[]
private declare requestOTRAction_: String
declare private webRTCPolicies_: Object[]
declare private webRTCPolicy_: String
declare private isDebounceFeatureEnabled_: boolean
declare private isRequestOTRFeatureEnabled_: boolean
declare private requestOTRActions_: Object[]
declare private requestOTRAction_: String
declare private isWindowsRecallAvailable_: boolean
declare private windowsRecallDisabledPref_: chrome.settingsPrivate.PrefObject

browserProxy_: BravePrivacyBrowserProxy = BravePrivacyBrowserProxyImpl.getInstance()
browserProxy_: BravePrivacyBrowserProxy =
BravePrivacyBrowserProxyImpl.getInstance()

shouldShowRestart_(enabled: boolean) {
return enabled != this.browserProxy_.wasPushMessagingEnabledAtStartup()
}

shouldShowRestartWindowsRecall_(disabled: boolean) {
return disabled != this.browserProxy_.wasWindowsRecallDisabledAtStartup()
}

windowsRecallDisabledChange_(event: Event) {
const target = event.target
assert(target instanceof SettingsToggleButtonElement)
this.browserProxy_.setWindowsRecallDisabled(target.checked)
}

setWindowsRecallDisabled_(disabled: boolean) {
const pref = {
key: '',
type: chrome.settingsPrivate.PrefType.BOOLEAN,
value: disabled,
}
this.windowsRecallDisabledPref_ = pref
}

restartBrowser_(e: Event) {
e.stopPropagation()
window.open("chrome://restart", "_self")
window.open('chrome://restart', '_self')
}

override ready() {
Expand All @@ -99,14 +154,28 @@ export class SettingsBravePersonalizationOptions extends SettingsBravePersonaliz
toggle.setAttribute('class', toggleClass + ' hr')
} else {
console.log(
'[Brave Settings Overrides] Could not find doNotTrack toggle')
'[Brave Settings Overrides] Could not find doNotTrack toggle',
)
}
} else {
console.log(
'[Brave Settings Overrides] Could not find element with id doNotTrack')
'[Brave Settings Overrides] Could not find element with id doNotTrack',
)
}

if (this.isWindowsRecallAvailable_) {
this.addWebUiListener(
'windows-recall-disabled-changed',
this.setWindowsRecallDisabled_.bind(this),
)
this.browserProxy_
.isWindowsRecallDisabled()
.then(this.setWindowsRecallDisabled_.bind(this))
}
}
}

customElements.define(
SettingsBravePersonalizationOptions.is, SettingsBravePersonalizationOptions)
SettingsBravePersonalizationOptions.is,
SettingsBravePersonalizationOptions,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,32 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at https://mozilla.org/MPL/2.0/.

import {sendWithPromise} from 'chrome://resources/js/cr.js';
import {loadTimeData} from '../i18n_setup.js';
import { sendWithPromise } from 'chrome://resources/js/cr.js'
import { loadTimeData } from '../i18n_setup.js'

export interface BravePrivacyBrowserProxy {
wasPushMessagingEnabledAtStartup(): boolean
wasWindowsRecallDisabledAtStartup(): boolean

isWindowsRecallDisabled: () => Promise<boolean>
setWindowsRecallDisabled: (disabled: boolean) => void
}

export class BravePrivacyBrowserProxyImpl implements BravePrivacyBrowserProxy {
wasPushMessagingEnabledAtStartup(): boolean {
return loadTimeData.getBoolean('pushMessagingEnabledAtStartup');
return loadTimeData.getBoolean('pushMessagingEnabledAtStartup')
}

wasWindowsRecallDisabledAtStartup(): boolean {
return loadTimeData.getBoolean('windowsRecallDisabledAtStartup')
}

isWindowsRecallDisabled(): Promise<boolean> {
return sendWithPromise('isWindowsRecallDisabled')
}

setWindowsRecallDisabled(disabled: boolean) {
chrome.send('setWindowsRecallDisabled', [disabled])
}

static getInstance(): BravePrivacyBrowserProxyImpl {
Expand Down
1 change: 1 addition & 0 deletions browser/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ if (is_win) {
]

brave_chrome_browser_deps += [
"//brave/components/windows_recall",
"//chrome/install_static:install_static_util",
"//chrome/installer/util:with_no_strings",
]
Expand Down
4 changes: 4 additions & 0 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ source_set("ui") {
]
}

if (is_win) {
deps += [ "//brave/components/windows_recall" ]
}

if (enable_pin_shortcut) {
sources += [
"webui/settings/pin_shortcut_handler.cc",
Expand Down
50 changes: 50 additions & 0 deletions browser/ui/webui/settings/brave_privacy_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include "brave/browser/gcm_driver/brave_gcm_channel_status.h"
#endif

#if BUILDFLAG(IS_WIN)
#include "brave/components/windows_recall/windows_recall.h"
#endif

BravePrivacyHandler::BravePrivacyHandler() {
local_state_change_registrar_.Init(g_browser_process->local_state());
local_state_change_registrar_.Add(
Expand All @@ -44,6 +48,15 @@ BravePrivacyHandler::BravePrivacyHandler() {
p3a::kP3AEnabled,
base::BindRepeating(&BravePrivacyHandler::OnP3AEnabledChanged,
base::Unretained(this)));
#if BUILDFLAG(IS_WIN)
if (windows_recall::IsWindowsRecallAvailable()) {
local_state_change_registrar_.Add(
windows_recall::prefs::kWindowsRecallDisabled,
base::BindRepeating(
&BravePrivacyHandler::OnWindowsRecallDisabledChanged,
base::Unretained(this)));
}
#endif
}

BravePrivacyHandler::~BravePrivacyHandler() {
Expand All @@ -67,6 +80,20 @@ void BravePrivacyHandler::RegisterMessages() {
"getStatsUsagePingEnabled",
base::BindRepeating(&BravePrivacyHandler::GetStatsUsagePingEnabled,
base::Unretained(this)));
#if BUILDFLAG(IS_WIN)
if (windows_recall::IsWindowsRecallAvailable()) {
web_ui()->RegisterMessageCallback(
"isWindowsRecallDisabled",
base::BindRepeating(&BravePrivacyHandler::GetLocalStateBooleanEnabled,
base::Unretained(this),
windows_recall::prefs::kWindowsRecallDisabled));
web_ui()->RegisterMessageCallback(
"setWindowsRecallDisabled",
base::BindRepeating(&BravePrivacyHandler::SetLocalStateBooleanEnabled,
base::Unretained(this),
windows_recall::prefs::kWindowsRecallDisabled));
}
#endif
}

// static
Expand Down Expand Up @@ -104,6 +131,17 @@ void BravePrivacyHandler::AddLoadTimeData(content::WebUIDataSource* data_source,
"isOpenAIChatFromBraveSearchEnabled",
ai_chat::IsAIChatEnabled(profile->GetPrefs()) &&
ai_chat::features::IsOpenAIChatFromBraveSearchEnabled());
#if BUILDFLAG(IS_WIN)
{
data_source->AddBoolean("isWindowsRecallAvailable",
windows_recall::IsWindowsRecallAvailable());
data_source->AddBoolean("windowsRecallDisabledAtStartup",
windows_recall::IsWindowsRecallDisabled(
g_browser_process->local_state()));
}
#else
data_source->AddBoolean("isWindowsRecallAvailable", false);
#endif
}

void BravePrivacyHandler::SetLocalStateBooleanEnabled(
Expand Down Expand Up @@ -166,3 +204,15 @@ void BravePrivacyHandler::OnP3AEnabledChanged() {
FireWebUIListener("p3a-enabled-changed", base::Value(enabled));
}
}

#if BUILDFLAG(IS_WIN)
void BravePrivacyHandler::OnWindowsRecallDisabledChanged() {
CHECK(windows_recall::IsWindowsRecallAvailable());
if (!IsJavascriptAllowed()) {
return;
}
FireWebUIListener("windows-recall-disabled-changed",
base::Value(g_browser_process->local_state()->GetBoolean(
windows_recall::prefs::kWindowsRecallDisabled)));
}
#endif
4 changes: 4 additions & 0 deletions browser/ui/webui/settings/brave_privacy_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class BravePrivacyHandler : public settings::SettingsPageUIHandler {
void GetP3AEnabled(const base::Value::List& args);
void OnP3AEnabledChanged();

#if BUILDFLAG(IS_WIN)
void OnWindowsRecallDisabledChanged();
#endif

raw_ptr<Profile> profile_ = nullptr;
PrefChangeRegistrar local_state_change_registrar_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
{"requestOTRDefault", IDS_SETTINGS_REQUEST_OTR_DEFAULT},
{"requestOTRAlways", IDS_SETTINGS_REQUEST_OTR_ALWAYS},
{"requestOTRNever", IDS_SETTINGS_REQUEST_OTR_NEVER},
#endif
#if BUILDFLAG(IS_WIN)
{"windowsRecallDisabledLabel",
IDS_SETTINGS_WINDOWS_RECALL_DISABLED_LABEL},
{"windowsRecallDisabledSubLabel",
IDS_SETTINGS_WINDOWS_RECALL_DISABLED_SUBLABEL},
#endif
{"braveSync", IDS_SETTINGS_BRAVE_SYNC_TITLE},
{"braveSyncSetupActionLabel", IDS_SETTINGS_BRAVE_SYNC_SETUP_ACTION_LABEL},
Expand Down
27 changes: 27 additions & 0 deletions chromium_src/content/browser/web_contents/web_contents_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/. */

#include "content/browser/web_contents/web_contents_impl.h"

namespace content {

bool WebContentsImpl::ShouldDoLearning() {
if (!ShouldDoLearning_ChromiumImpl()) {
return false;
}
return !GetContentClient()->browser()->IsWindowsRecallDisabled();
}

bool WebContentsImpl::GetShouldDoLearningForTesting() {
return ShouldDoLearning();
}

} // namespace content

#define ShouldDoLearning(...) ShouldDoLearning_ChromiumImpl(__VA_ARGS__)

#include "src/content/browser/web_contents/web_contents_impl.cc"

#undef ShouldDoLearning
20 changes: 20 additions & 0 deletions chromium_src/content/browser/web_contents/web_contents_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_CHROMIUM_SRC_CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
#define BRAVE_CHROMIUM_SRC_CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_

#include "content/browser/renderer_host/render_widget_host_delegate.h"

#define ShouldDoLearning(...) \
ShouldDoLearning_ChromiumImpl(__VA_ARGS__); \
bool GetShouldDoLearningForTesting() override; \
bool ShouldDoLearning(__VA_ARGS__)

#include "src/content/browser/web_contents/web_contents_impl.h" // IWYU pragma: export

#undef ShouldDoLearning

#endif // BRAVE_CHROMIUM_SRC_CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ std::optional<GURL> ContentBrowserClient::SanitizeURL(content::RenderFrameHost*,
return std::nullopt;
}

bool ContentBrowserClient::IsWindowsRecallDisabled() {
return false;
}

} // namespace content
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
BrowserContext* browser_context); \
virtual std::optional<GURL> SanitizeURL(content::RenderFrameHost*, \
const GURL&); \
virtual bool IsWindowsRecallDisabled(); \
virtual void SetBrowserStartupIsCompleteForTesting

#include "src/content/public/browser/content_browser_client.h" // IWYU pragma: export
Expand Down
14 changes: 14 additions & 0 deletions chromium_src/content/public/browser/web_contents.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Copyright (c) 2024 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 https://mozilla.org/MPL/2.0/. */

#include "src/content/public/browser/web_contents.cc"

namespace content {

bool WebContents::GetShouldDoLearningForTesting() {
return true;
}

} // namespace content
17 changes: 17 additions & 0 deletions chromium_src/content/public/browser/web_contents.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright (c) 2024 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 https://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_CHROMIUM_SRC_CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_
#define BRAVE_CHROMIUM_SRC_CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_

#define IsLoading(...) \
GetShouldDoLearningForTesting(); \
virtual bool IsLoading(__VA_ARGS__)

#include "src/content/public/browser/web_contents.h" // IWYU pragma: export

#undef IsLoading

#endif // BRAVE_CHROMIUM_SRC_CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_
34 changes: 34 additions & 0 deletions components/windows_recall/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/.

import("//brave/build/config.gni")

assert(is_win)

static_library("windows_recall") {
sources = [
"windows_recall.cc",
"windows_recall.h",
]

deps = [
"//base",
"//components/prefs",
]
}

source_set("unit_tests") {
testonly = true

sources = [ "windows_recall_unittest.cc" ]

deps = [
":windows_recall",
"//base",
"//base/test:test_support",
"//components/prefs:test_support",
"//testing/gtest",
]
}
4 changes: 4 additions & 0 deletions components/windows_recall/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"+components/prefs",
"+content/public/browser",
]
68 changes: 68 additions & 0 deletions components/windows_recall/windows_recall.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/. */

#include "brave/components/windows_recall/windows_recall.h"

#include "base/check_is_test.h"
#include "base/win/windows_version.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"

namespace windows_recall {

namespace {
bool* g_windows_recall_disabled_override_for_testing = nullptr;
}

bool IsWindowsRecallAvailable() {
return base::win::GetVersion() >= base::win::Version::WIN11;
}

void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
if (!IsWindowsRecallAvailable()) {
return;
}

registry->RegisterBooleanPref(prefs::kWindowsRecallDisabled, true);
}

bool IsWindowsRecallDisabled(PrefService* local_state) {
if (!IsWindowsRecallAvailable()) {
return false;
}

static bool disabled = local_state->GetBoolean(prefs::kWindowsRecallDisabled);

if (g_windows_recall_disabled_override_for_testing) {
CHECK_IS_TEST();
return *g_windows_recall_disabled_override_for_testing;
}

return disabled;
}

namespace test {

// static
ScopedWindowsRecallDisabledOverride*
ScopedWindowsRecallDisabledOverride::instance_ = nullptr;

ScopedWindowsRecallDisabledOverride::ScopedWindowsRecallDisabledOverride(
bool disabled)
: disabled_(disabled), original_instance_(instance_) {
CHECK_IS_TEST();
instance_ = this;
g_windows_recall_disabled_override_for_testing = &instance_->disabled_;
}

ScopedWindowsRecallDisabledOverride::~ScopedWindowsRecallDisabledOverride() {
instance_ = original_instance_;
g_windows_recall_disabled_override_for_testing =
instance_ ? &instance_->disabled_ : nullptr;
}

} // namespace test

} // namespace windows_recall
49 changes: 49 additions & 0 deletions components/windows_recall/windows_recall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_COMPONENTS_WINDOWS_RECALL_WINDOWS_RECALL_H_
#define BRAVE_COMPONENTS_WINDOWS_RECALL_WINDOWS_RECALL_H_

#include "base/memory/raw_ptr.h"

class PrefRegistrySimple;
class PrefService;

namespace windows_recall {

namespace prefs {
inline constexpr char kWindowsRecallDisabled[] =
"brave.windows_recall_disabled";
}

void RegisterLocalStatePrefs(PrefRegistrySimple* registry);

// Checks whether the Window Recall service functionality is potentially
// available; currently, this verifies if the version is Windows 11 or newer.
bool IsWindowsRecallAvailable();

// Gets the current state of the setting in the browser.
// NOTE: This is not related to system settings and does not check the status of
// the system service.
bool IsWindowsRecallDisabled(PrefService* local_state);

namespace test {

class ScopedWindowsRecallDisabledOverride {
public:
explicit ScopedWindowsRecallDisabledOverride(bool disabled);
~ScopedWindowsRecallDisabledOverride();

private:
bool disabled_ = false;
raw_ptr<ScopedWindowsRecallDisabledOverride> original_instance_ = nullptr;
static ScopedWindowsRecallDisabledOverride* instance_;
};

} // namespace test

} // namespace windows_recall

#endif // BRAVE_COMPONENTS_WINDOWS_RECALL_WINDOWS_RECALL_H_
87 changes: 87 additions & 0 deletions components/windows_recall/windows_recall_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/.

#include "brave/components/windows_recall/windows_recall.h"

#include "base/test/scoped_os_info_override_win.h"
#include "build/build_config.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace window_recall {

TEST(WindowsRecallTest, IsWindowsRecallAvailable) {
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin10Home);
EXPECT_FALSE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin10Pro);
EXPECT_FALSE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin10Pro21H1);
EXPECT_FALSE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWinServer2016);
EXPECT_FALSE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWinServer2022);
EXPECT_FALSE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin11HomeN);
EXPECT_TRUE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin11Home);
EXPECT_TRUE(windows_recall::IsWindowsRecallAvailable());
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin11Pro);
EXPECT_TRUE(windows_recall::IsWindowsRecallAvailable());
}
}

TEST(WindowsRecallTest, IsWindowsRecallDisabled) {
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin10Home);
TestingPrefServiceSimple prefs;
windows_recall::RegisterLocalStatePrefs(prefs.registry());
EXPECT_FALSE(
prefs.FindPreference(windows_recall::prefs::kWindowsRecallDisabled));
EXPECT_FALSE(windows_recall::IsWindowsRecallDisabled(&prefs));
}
{
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin11Home);
TestingPrefServiceSimple prefs;
windows_recall::RegisterLocalStatePrefs(prefs.registry());
ASSERT_TRUE(
prefs.GetBoolean(windows_recall::prefs::kWindowsRecallDisabled));
EXPECT_TRUE(windows_recall::IsWindowsRecallDisabled(&prefs));
prefs.SetBoolean(windows_recall::prefs::kWindowsRecallDisabled, false);
// value is cached
EXPECT_TRUE(windows_recall::IsWindowsRecallDisabled(&prefs));

// reset the value to match the current pref
windows_recall::test::ScopedWindowsRecallDisabledOverride override(
prefs.GetBoolean(windows_recall::prefs::kWindowsRecallDisabled));
EXPECT_FALSE(windows_recall::IsWindowsRecallDisabled(&prefs));
}
}

} // namespace window_recall
8 changes: 7 additions & 1 deletion test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ test("brave_unit_tests") {
]

if (is_win) {
deps += [ "//brave/browser/day_zero_browser_ui_expt:unit_tests" ]
deps += [
"//brave/browser/day_zero_browser_ui_expt:unit_tests",
"//brave/components/windows_recall",
"//brave/components/windows_recall:unit_tests",
]
}

if (enable_tor) {
Expand Down Expand Up @@ -1027,6 +1031,8 @@ test("brave_browser_tests") {

if (is_win) {
public_configs = [ "//build/config/win:delayloads" ]

deps += [ "//brave/components/windows_recall" ]
}

if (use_aura) {
Expand Down