• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
6 
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"
13 
14 namespace {
15 
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,
22 };
23 
CreateDefaultPinnedAppsList()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]));
28 
29   return apps.release();
30 }
31 
32 }  // namespace
33 
34 namespace ash {
35 
36 const char kPinnedAppsPrefAppIDPath[] = "id";
37 
38 const char kShelfAutoHideBehaviorAlways[] = "Always";
39 const char kShelfAutoHideBehaviorNever[] = "Never";
40 
41 extern const char kShelfAlignmentBottom[] = "Bottom";
42 extern const char kShelfAlignmentLeft[] = "Left";
43 extern const char kShelfAlignmentRight[] = "Right";
44 extern const char kShelfAlignmentTop[] = "Top";
45 
RegisterChromeLauncherUserPrefs(user_prefs::PrefRegistrySyncable * registry)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,
52       0,
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,
62       std::string(),
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,
69       std::string(),
70       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
71   registry->RegisterBooleanPref(
72       prefs::kShowLogoutButtonInTray,
73       false,
74       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
75   registry->RegisterDictionaryPref(
76       prefs::kShelfPreferences,
77       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
78 }
79 
CreateAppDict(const std::string & app_id)80 base::DictionaryValue* CreateAppDict(const std::string& app_id) {
81   scoped_ptr<base::DictionaryValue> app_value(new base::DictionaryValue);
82   app_value->SetString(kPinnedAppsPrefAppIDPath, app_id);
83   return app_value.release();
84 }
85 
86 }  // namespace ash
87