Commit e7776d51 authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Move kCrostiniRegistryPref into crostini_pref_names

Since we have crostini_pref_names, the kCrostiniRegistryPref for the
Crostini registry should be in there instead of being separated.

Change-Id: Ia89192dc2ac11c9cd38bf79725fc3951e3d99211
Reviewed-on: https://chromium-review.googlesource.com/1179510Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584638}
parent 5ad3b577
...@@ -12,9 +12,11 @@ namespace prefs { ...@@ -12,9 +12,11 @@ namespace prefs {
// A boolean preference representing whether a user has opted in to use // A boolean preference representing whether a user has opted in to use
// Crostini (Called "Linux Apps" in UI). // Crostini (Called "Linux Apps" in UI).
const char kCrostiniEnabled[] = "crostini.enabled"; const char kCrostiniEnabled[] = "crostini.enabled";
const char kCrostiniRegistry[] = "crostini.registry";
void RegisterProfilePrefs(PrefRegistrySimple* registry) { void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kCrostiniEnabled, false); registry->RegisterBooleanPref(kCrostiniEnabled, false);
registry->RegisterDictionaryPref(kCrostiniRegistry);
} }
} // namespace prefs } // namespace prefs
......
...@@ -11,6 +11,7 @@ namespace crostini { ...@@ -11,6 +11,7 @@ namespace crostini {
namespace prefs { namespace prefs {
extern const char kCrostiniEnabled[]; extern const char kCrostiniEnabled[];
extern const char kCrostiniRegistry[];
void RegisterProfilePrefs(PrefRegistrySimple* registry); void RegisterProfilePrefs(PrefRegistrySimple* registry);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/time/default_clock.h" #include "base/time/default_clock.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h" #include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chromeos/dbus/vm_applications/apps.pb.h" #include "chromeos/dbus/vm_applications/apps.pb.h"
...@@ -37,7 +38,6 @@ constexpr char kCrostiniWindowAppIdPrefix[] = "org.chromium.termina."; ...@@ -37,7 +38,6 @@ constexpr char kCrostiniWindowAppIdPrefix[] = "org.chromium.termina.";
// This comes after kCrostiniWindowAppIdPrefix // This comes after kCrostiniWindowAppIdPrefix
constexpr char kWMClassPrefix[] = "wmclass."; constexpr char kWMClassPrefix[] = "wmclass.";
constexpr char kCrostiniRegistryPref[] = "crostini.registry";
constexpr char kCrostiniIconFolder[] = "crostini.icons"; constexpr char kCrostiniIconFolder[] = "crostini.icons";
// Keys for the Dictionary stored in prefs for each app. // Keys for the Dictionary stored in prefs for each app.
...@@ -369,7 +369,7 @@ std::string CrostiniRegistryService::GetCrostiniShelfAppId( ...@@ -369,7 +369,7 @@ std::string CrostiniRegistryService::GetCrostiniShelfAppId(
const std::string* window_app_id, const std::string* window_app_id,
const std::string* window_startup_id) { const std::string* window_startup_id) {
const base::DictionaryValue* apps = const base::DictionaryValue* apps =
prefs_->GetDictionary(kCrostiniRegistryPref); prefs_->GetDictionary(prefs::kCrostiniRegistry);
std::string app_id; std::string app_id;
if (window_startup_id) { if (window_startup_id) {
...@@ -443,13 +443,13 @@ bool CrostiniRegistryService::IsCrostiniShelfAppId( ...@@ -443,13 +443,13 @@ bool CrostiniRegistryService::IsCrostiniShelfAppId(
// TODO(timloh): We need to handle desktop files that have been removed. // TODO(timloh): We need to handle desktop files that have been removed.
// For example, running windows with a no-longer-valid app id will try to // For example, running windows with a no-longer-valid app id will try to
// use the ExtensionContextMenuModel. // use the ExtensionContextMenuModel.
return prefs_->GetDictionary(kCrostiniRegistryPref)->FindKey(shelf_app_id) != return prefs_->GetDictionary(prefs::kCrostiniRegistry)
nullptr; ->FindKey(shelf_app_id) != nullptr;
} }
std::vector<std::string> CrostiniRegistryService::GetRegisteredAppIds() const { std::vector<std::string> CrostiniRegistryService::GetRegisteredAppIds() const {
const base::DictionaryValue* apps = const base::DictionaryValue* apps =
prefs_->GetDictionary(kCrostiniRegistryPref); prefs_->GetDictionary(prefs::kCrostiniRegistry);
std::vector<std::string> result; std::vector<std::string> result;
for (const auto& item : apps->DictItems()) for (const auto& item : apps->DictItems())
result.push_back(item.first); result.push_back(item.first);
...@@ -461,7 +461,7 @@ std::vector<std::string> CrostiniRegistryService::GetRegisteredAppIds() const { ...@@ -461,7 +461,7 @@ std::vector<std::string> CrostiniRegistryService::GetRegisteredAppIds() const {
base::Optional<CrostiniRegistryService::Registration> base::Optional<CrostiniRegistryService::Registration>
CrostiniRegistryService::GetRegistration(const std::string& app_id) const { CrostiniRegistryService::GetRegistration(const std::string& app_id) const {
const base::DictionaryValue* apps = const base::DictionaryValue* apps =
prefs_->GetDictionary(kCrostiniRegistryPref); prefs_->GetDictionary(prefs::kCrostiniRegistry);
const base::Value* pref_registration = const base::Value* pref_registration =
apps->FindKeyOfType(app_id, base::Value::Type::DICTIONARY); apps->FindKeyOfType(app_id, base::Value::Type::DICTIONARY);
...@@ -475,7 +475,7 @@ CrostiniRegistryService::GetRegistration(const std::string& app_id) const { ...@@ -475,7 +475,7 @@ CrostiniRegistryService::GetRegistration(const std::string& app_id) const {
void CrostiniRegistryService::RecordStartupMetrics() { void CrostiniRegistryService::RecordStartupMetrics() {
const base::DictionaryValue* apps = const base::DictionaryValue* apps =
prefs_->GetDictionary(kCrostiniRegistryPref); prefs_->GetDictionary(prefs::kCrostiniRegistry);
if (!IsCrostiniEnabled(profile_)) if (!IsCrostiniEnabled(profile_))
return; return;
...@@ -556,7 +556,7 @@ void CrostiniRegistryService::ClearApplicationList( ...@@ -556,7 +556,7 @@ void CrostiniRegistryService::ClearApplicationList(
std::vector<std::string> removed_apps; std::vector<std::string> removed_apps;
// The DictionaryPrefUpdate should be destructed before calling the observer. // The DictionaryPrefUpdate should be destructed before calling the observer.
{ {
DictionaryPrefUpdate update(prefs_, kCrostiniRegistryPref); DictionaryPrefUpdate update(prefs_, prefs::kCrostiniRegistry);
base::DictionaryValue* apps = update.Get(); base::DictionaryValue* apps = update.Get();
for (const auto& item : apps->DictItems()) { for (const auto& item : apps->DictItems()) {
...@@ -603,7 +603,7 @@ void CrostiniRegistryService::UpdateApplicationList( ...@@ -603,7 +603,7 @@ void CrostiniRegistryService::UpdateApplicationList(
// The DictionaryPrefUpdate should be destructed before calling the observer. // The DictionaryPrefUpdate should be destructed before calling the observer.
{ {
DictionaryPrefUpdate update(prefs_, kCrostiniRegistryPref); DictionaryPrefUpdate update(prefs_, prefs::kCrostiniRegistry);
base::DictionaryValue* apps = update.Get(); base::DictionaryValue* apps = update.Get();
for (const App& app : app_list.apps()) { for (const App& app : app_list.apps()) {
if (app.desktop_file_id().empty()) { if (app.desktop_file_id().empty()) {
...@@ -723,7 +723,7 @@ void CrostiniRegistryService::RemoveObserver(Observer* observer) { ...@@ -723,7 +723,7 @@ void CrostiniRegistryService::RemoveObserver(Observer* observer) {
} }
void CrostiniRegistryService::AppLaunched(const std::string& app_id) { void CrostiniRegistryService::AppLaunched(const std::string& app_id) {
DictionaryPrefUpdate update(prefs_, kCrostiniRegistryPref); DictionaryPrefUpdate update(prefs_, prefs::kCrostiniRegistry);
base::DictionaryValue* apps = update.Get(); base::DictionaryValue* apps = update.Get();
base::Value* app = apps->FindKey(app_id); base::Value* app = apps->FindKey(app_id);
...@@ -745,12 +745,6 @@ void CrostiniRegistryService::SetCurrentTime(base::Value* dictionary, ...@@ -745,12 +745,6 @@ void CrostiniRegistryService::SetCurrentTime(base::Value* dictionary,
dictionary->SetKey(key, base::Value(base::Int64ToString(time))); dictionary->SetKey(key, base::Value(base::Int64ToString(time)));
} }
// static
void CrostiniRegistryService::RegisterProfilePrefs(
PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kCrostiniRegistryPref);
}
void CrostiniRegistryService::RequestIcon(const std::string& app_id, void CrostiniRegistryService::RequestIcon(const std::string& app_id,
ui::ScaleFactor scale_factor) { ui::ScaleFactor scale_factor) {
// Ignore requests for app_id that isn't registered. // Ignore requests for app_id that isn't registered.
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "ui/base/resource/scale_factor.h" #include "ui/base/resource/scale_factor.h"
class Profile; class Profile;
class PrefRegistrySimple;
class PrefService; class PrefService;
namespace base { namespace base {
...@@ -175,8 +174,6 @@ class CrostiniRegistryService : public KeyedService { ...@@ -175,8 +174,6 @@ class CrostiniRegistryService : public KeyedService {
void SetClockForTesting(base::Clock* clock) { clock_ = clock; } void SetClockForTesting(base::Clock* clock) { clock_ = clock; }
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
private: private:
// Run start up tasks for the registry (e.g. recording metrics). // Run start up tasks for the registry (e.g. recording metrics).
void RecordStartupMetrics(); void RecordStartupMetrics();
......
...@@ -688,7 +688,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -688,7 +688,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry); chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry); chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
crostini::prefs::RegisterProfilePrefs(registry); crostini::prefs::RegisterProfilePrefs(registry);
crostini::CrostiniRegistryService::RegisterProfilePrefs(registry);
extensions::EPKPChallengeUserKey::RegisterProfilePrefs(registry); extensions::EPKPChallengeUserKey::RegisterProfilePrefs(registry);
flags_ui::PrefServiceFlagsStorage::RegisterProfilePrefs(registry); flags_ui::PrefServiceFlagsStorage::RegisterProfilePrefs(registry);
lock_screen_apps::StateController::RegisterProfilePrefs(registry); lock_screen_apps::StateController::RegisterProfilePrefs(registry);
......
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