Commit ce4e5e0e authored by Thanh Nguyen's avatar Thanh Nguyen Committed by Chromium LUCI CQ

[local-search-service] Local state injection for LocalSearchService

This CL allows us to inject local state to LocalSearchService.

Design doc: go/lss-sandboxing
Implementation plan: go/lss-sandboxing-impl

Bug: 1137560
Change-Id: I83dbdeb1e1161393b6408866a99b8ddce1c43530
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560283
Commit-Queue: Thanh Nguyen <thanhdng@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832653}
parent 3220de6b
...@@ -122,7 +122,7 @@ source_set("chromeos") { ...@@ -122,7 +122,7 @@ source_set("chromeos") {
"//chromeos/components/drivefs", "//chromeos/components/drivefs",
"//chromeos/components/drivefs/mojom", "//chromeos/components/drivefs/mojom",
"//chromeos/components/help_app_ui", "//chromeos/components/help_app_ui",
"//chromeos/components/local_search_service", "//chromeos/components/local_search_service/public/cpp:cpp",
"//chromeos/components/media_app_ui", "//chromeos/components/media_app_ui",
"//chromeos/components/mojo_bootstrap", "//chromeos/components/mojo_bootstrap",
"//chromeos/components/multidevice", "//chromeos/components/multidevice",
......
...@@ -150,6 +150,7 @@ ...@@ -150,6 +150,7 @@
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/components/chromebox_for_meetings/buildflags/buildflags.h" // PLATFORM_CFM #include "chromeos/components/chromebox_for_meetings/buildflags/buildflags.h" // PLATFORM_CFM
#include "chromeos/components/drivefs/fake_drivefs_launcher_client.h" #include "chromeos/components/drivefs/fake_drivefs_launcher_client.h"
#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
#include "chromeos/components/power/dark_resume_controller.h" #include "chromeos/components/power/dark_resume_controller.h"
#include "chromeos/components/sensors/sensor_hal_dispatcher.h" #include "chromeos/components/sensors/sensor_hal_dispatcher.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
...@@ -767,6 +768,12 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { ...@@ -767,6 +768,12 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
g_browser_process->local_state()); g_browser_process->local_state());
} }
if (base::FeatureList::IsEnabled(features::kEnableLocalSearchService)) {
// Set |local_state| for LocalSearchServiceProxyFactory.
local_search_service::LocalSearchServiceProxyFactory::GetInstance()
->SetLocalState(g_browser_process->local_state());
}
// Make sure that wallpaper boot transition and other delays in OOBE // Make sure that wallpaper boot transition and other delays in OOBE
// are disabled for tests and kiosk app launch by default. // are disabled for tests and kiosk app launch by default.
// Individual tests may enable them if they want. // Individual tests may enable them if they want.
......
...@@ -10,12 +10,21 @@ ...@@ -10,12 +10,21 @@
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
namespace {
PrefService* local_state = nullptr;
} // namespace
// static // static
LocalSearchServiceProxy* LocalSearchServiceProxyFactory::GetForBrowserContext( LocalSearchServiceProxy* LocalSearchServiceProxyFactory::GetForBrowserContext(
content::BrowserContext* context) { content::BrowserContext* context) {
return static_cast<LocalSearchServiceProxy*>( DCHECK(local_state);
auto* local_search_service_proxy = static_cast<LocalSearchServiceProxy*>(
LocalSearchServiceProxyFactory::GetInstance() LocalSearchServiceProxyFactory::GetInstance()
->GetServiceForBrowserContext(context, /*create=*/true)); ->GetServiceForBrowserContext(context, /*create=*/true));
local_search_service_proxy->SetLocalState(local_state);
return local_search_service_proxy;
} }
// static // static
...@@ -24,6 +33,12 @@ LocalSearchServiceProxyFactory* LocalSearchServiceProxyFactory::GetInstance() { ...@@ -24,6 +33,12 @@ LocalSearchServiceProxyFactory* LocalSearchServiceProxyFactory::GetInstance() {
return instance.get(); return instance.get();
} }
void LocalSearchServiceProxyFactory::SetLocalState(
PrefService* local_state_pref_service) {
DCHECK(local_state_pref_service);
local_state = local_state_pref_service;
}
LocalSearchServiceProxyFactory::LocalSearchServiceProxyFactory() LocalSearchServiceProxyFactory::LocalSearchServiceProxyFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"LocalSearchServiceProxy", "LocalSearchServiceProxy",
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class PrefService;
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
class LocalSearchServiceProxy; class LocalSearchServiceProxy;
...@@ -19,6 +21,8 @@ class LocalSearchServiceProxyFactory ...@@ -19,6 +21,8 @@ class LocalSearchServiceProxyFactory
content::BrowserContext* context); content::BrowserContext* context);
static LocalSearchServiceProxyFactory* GetInstance(); static LocalSearchServiceProxyFactory* GetInstance();
void SetLocalState(PrefService* local_state_pref_service);
LocalSearchServiceProxyFactory(const LocalSearchServiceProxyFactory&) = LocalSearchServiceProxyFactory(const LocalSearchServiceProxyFactory&) =
delete; delete;
LocalSearchServiceProxyFactory& operator=( LocalSearchServiceProxyFactory& operator=(
......
...@@ -266,6 +266,10 @@ const base::Feature kEmojiSuggestAddition{"EmojiSuggestAddition", ...@@ -266,6 +266,10 @@ const base::Feature kEmojiSuggestAddition{"EmojiSuggestAddition",
const base::Feature kEnableHostnameSetting{"EnableHostnameSetting", const base::Feature kEnableHostnameSetting{"EnableHostnameSetting",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Enables LocalSearchService to be initialized.
const base::Feature kEnableLocalSearchService{
"EnableLocalSearchService", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables Device End Of Lifetime warning notifications. // Enables Device End Of Lifetime warning notifications.
const base::Feature kEolWarningNotifications{"EolWarningNotifications", const base::Feature kEolWarningNotifications{"EolWarningNotifications",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
...@@ -732,6 +736,10 @@ bool IsHostnameSettingEnabled() { ...@@ -732,6 +736,10 @@ bool IsHostnameSettingEnabled() {
return base::FeatureList::IsEnabled(kEnableHostnameSetting); return base::FeatureList::IsEnabled(kEnableHostnameSetting);
} }
bool IsLocalSearchServiceEnabled() {
return base::FeatureList::IsEnabled(kEnableLocalSearchService);
}
bool IsFamilyLinkOnSchoolDeviceEnabled() { bool IsFamilyLinkOnSchoolDeviceEnabled() {
return base::FeatureList::IsEnabled(kFamilyLinkOnSchoolDevice); return base::FeatureList::IsEnabled(kFamilyLinkOnSchoolDevice);
} }
......
...@@ -129,6 +129,8 @@ extern const base::Feature kEmojiSuggestAddition; ...@@ -129,6 +129,8 @@ extern const base::Feature kEmojiSuggestAddition;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kEnableHostnameSetting; extern const base::Feature kEnableHostnameSetting;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kEnableLocalSearchService;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kEolWarningNotifications; extern const base::Feature kEolWarningNotifications;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kExoOrdinalMotion; extern const base::Feature kExoOrdinalMotion;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment