1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
10 #include "chrome/common/extensions/extension_constants.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/user_prefs/pref_registry_syncable.h"
16 // App ID of default pinned apps.
17 const char* kDefaultPinnedApps
[] = {
18 extension_misc::kGmailAppId
,
19 extension_misc::kGoogleSearchAppId
,
20 extension_misc::kGoogleDocAppId
,
21 extension_misc::kYoutubeAppId
,
24 base::ListValue
* CreateDefaultPinnedAppsList() {
25 scoped_ptr
<base::ListValue
> apps(new base::ListValue
);
26 for (size_t i
= 0; i
< arraysize(kDefaultPinnedApps
); ++i
)
27 apps
->Append(ash::CreateAppDict(kDefaultPinnedApps
[i
]));
29 return apps
.release();
36 const char kPinnedAppsPrefAppIDPath
[] = "id";
38 const char kShelfAutoHideBehaviorAlways
[] = "Always";
39 const char kShelfAutoHideBehaviorNever
[] = "Never";
41 extern const char kShelfAlignmentBottom
[] = "Bottom";
42 extern const char kShelfAlignmentLeft
[] = "Left";
43 extern const char kShelfAlignmentRight
[] = "Right";
44 extern const char kShelfAlignmentTop
[] = "Top";
46 void RegisterChromeLauncherUserPrefs(
47 user_prefs::PrefRegistrySyncable
* registry
) {
48 // TODO: If we want to support multiple profiles this will likely need to be
49 // pushed to local state and we'll need to track profile per item.
50 registry
->RegisterIntegerPref(
51 prefs::kShelfChromeIconIndex
,
53 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
54 registry
->RegisterListPref(prefs::kPinnedLauncherApps
,
55 CreateDefaultPinnedAppsList(),
56 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
57 registry
->RegisterStringPref(prefs::kShelfAutoHideBehavior
,
58 kShelfAutoHideBehaviorNever
,
59 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
60 registry
->RegisterStringPref(
61 prefs::kShelfAutoHideBehaviorLocal
,
63 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
64 registry
->RegisterStringPref(prefs::kShelfAlignment
,
65 kShelfAlignmentBottom
,
66 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
67 registry
->RegisterStringPref(
68 prefs::kShelfAlignmentLocal
,
70 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
71 registry
->RegisterDictionaryPref(
72 prefs::kShelfPreferences
,
73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
74 registry
->RegisterIntegerPref(
75 prefs::kLogoutDialogDurationMs
,
77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
78 registry
->RegisterBooleanPref(
79 prefs::kShowLogoutButtonInTray
,
81 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
84 base::DictionaryValue
* CreateAppDict(const std::string
& app_id
) {
85 scoped_ptr
<base::DictionaryValue
> app_value(new base::DictionaryValue
);
86 app_value
->SetString(kPinnedAppsPrefAppIDPath
, app_id
);
87 return app_value
.release();