Commit 79965411 authored by Julian Watson's avatar Julian Watson Committed by Commit Bot

crostini: move app prefs into pref_names

This allows the prefs to be reused elsewhere.

Bug: 1049453
Change-Id: I52de2f0d7296d3bf522af5ef2aad79cf78370d15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2114514Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Julian Watson <juwa@google.com>
Cr-Commit-Position: refs/heads/master@{#753072}
parent 8025a724
......@@ -20,7 +20,6 @@ namespace prefs {
// Crostini (Called "Linux Apps" in UI).
const char kCrostiniEnabled[] = "crostini.enabled";
const char kCrostiniMimeTypes[] = "crostini.mime_types";
const char kCrostiniRegistry[] = "crostini.registry";
// List of USB devices with their system guid, a name/description and their
// enabled state for use with Crostini.
const char kCrostiniSharedUsbDevices[] = "crostini.shared_usb_devices";
......@@ -83,7 +82,6 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kCrostiniEnabled, false);
registry->RegisterBooleanPref(kCrostiniMicSharing, true);
registry->RegisterDictionaryPref(kCrostiniMimeTypes);
registry->RegisterDictionaryPref(kCrostiniRegistry);
registry->RegisterListPref(kCrostiniPortForwarding);
registry->RegisterListPref(kCrostiniSharedUsbDevices);
......
......@@ -12,7 +12,6 @@ namespace prefs {
extern const char kCrostiniEnabled[];
extern const char kCrostiniMimeTypes[];
extern const char kCrostiniRegistry[];
extern const char kCrostiniSharedUsbDevices[];
extern const char kCrostiniContainers[];
extern const char kCrostiniTerminalSettings[];
......
......@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_test_helper.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/guest_os/guest_os_pref_names.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/dbus/vm_applications/apps.pb.h"
......@@ -550,7 +551,8 @@ TEST_F(CrostiniRegistryServiceTest, MigrateTerminal) {
// Add prefs entry for the deleted terminal.
base::DictionaryValue registry;
registry.SetKey(GetDeletedTerminalId(), base::DictionaryValue());
profile()->GetPrefs()->Set(prefs::kCrostiniRegistry, std::move(registry));
profile()->GetPrefs()->Set(guest_os::prefs::kGuestOsRegistry,
std::move(registry));
// Only current terminal returned.
RecreateService();
......@@ -560,7 +562,7 @@ TEST_F(CrostiniRegistryServiceTest, MigrateTerminal) {
// Deleted terminal removed from prefs.
EXPECT_FALSE(profile()
->GetPrefs()
->GetDictionary(prefs::kCrostiniRegistry)
->GetDictionary(guest_os::prefs::kGuestOsRegistry)
->HasKey(GetDeletedTerminalId()));
}
......
......@@ -7,6 +7,7 @@
#include "base/files/file_path.h"
#include "base/values.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/guest_os/guest_os_pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
......@@ -29,7 +30,7 @@ class CrostiniFileTasksTest : public testing::Test {
// crostini.registry {<id>: {container_name: "penguin", name: {"": <name>},
// mime_types: [<mime>,], vm_name: "termina"}}
DictionaryPrefUpdate update(profile_.GetPrefs(),
crostini::prefs::kCrostiniRegistry);
guest_os::prefs::kGuestOsRegistry);
base::DictionaryValue* registry = update.Get();
base::Value app(base::Value::Type::DICTIONARY);
app.SetKey("container_name", base::Value("penguin"));
......
......@@ -13,8 +13,28 @@ namespace prefs {
// shared with.
const char kGuestOSPathsSharedToVms[] = "guest_os.paths_shared_to_vms";
const char kGuestOsRegistry[] = "crostini.registry";
// Keys for the |kGuestOsRegistry| Dictionary stored in prefs for each app.
const char kAppDesktopFileIdKey[] = "desktop_file_id";
const char kAppVmNameKey[] = "vm_name";
const char kAppContainerNameKey[] = "container_name";
const char kAppCommentKey[] = "comment";
const char kAppMimeTypesKey[] = "mime_types";
const char kAppKeywordsKey[] = "keywords";
const char kAppExecutableFileNameKey[] = "executable_file_name";
const char kAppNameKey[] = "name";
const char kAppNoDisplayKey[] = "no_display";
const char kAppScaledKey[] = "scaled";
const char kAppPackageIdKey[] = "package_id";
const char kAppStartupWMClassKey[] = "startup_wm_class";
const char kAppStartupNotifyKey[] = "startup_notify";
const char kAppInstallTimeKey[] = "install_time";
const char kAppLastLaunchTimeKey[] = "last_launch_time";
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kGuestOSPathsSharedToVms);
registry->RegisterDictionaryPref(kGuestOsRegistry);
}
} // namespace prefs
......
......@@ -13,6 +13,23 @@ namespace prefs {
extern const char kCrostiniSharedPaths[];
extern const char kGuestOSPathsSharedToVms[];
extern const char kGuestOsRegistry[];
extern const char kAppDesktopFileIdKey[];
extern const char kAppVmNameKey[];
extern const char kAppContainerNameKey[];
extern const char kAppCommentKey[];
extern const char kAppMimeTypesKey[];
extern const char kAppKeywordsKey[];
extern const char kAppExecutableFileNameKey[];
extern const char kAppNameKey[];
extern const char kAppNoDisplayKey[];
extern const char kAppScaledKey[];
extern const char kAppPackageIdKey[];
extern const char kAppStartupWMClassKey[];
extern const char kAppStartupNotifyKey[];
extern const char kAppInstallTimeKey[];
extern const char kAppLastLaunchTimeKey[];
void RegisterProfilePrefs(PrefRegistrySimple* registry);
} // namespace prefs
......
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