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/browser_ui_prefs.h"
7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/first_run/first_run.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/user_prefs/pref_registry_syncable.h"
16 void RegisterBrowserPrefs(PrefRegistrySimple
* registry
) {
17 registry
->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex
, 0);
18 registry
->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs
, true);
19 registry
->RegisterIntegerPref(prefs::kShowFirstRunBubbleOption
,
20 first_run::FIRST_RUN_BUBBLE_DONT_SHOW
);
23 void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable
* registry
) {
24 registry
->RegisterBooleanPref(
25 prefs::kHomePageIsNewTabPage
,
27 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
28 registry
->RegisterBooleanPref(
29 prefs::kShowHomeButton
,
31 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
32 #if defined(OS_MACOSX)
33 // This really belongs in platform code, but there's no good place to
34 // initialize it between the time when the AppController is created
35 // (where there's no profile) and the time the controller gets another
36 // crack at the start of the main event loop. By that time,
37 // StartupBrowserCreator has already created the browser window, and it's too
38 // late: we need the pref to be already initialized. Doing it here also saves
39 // us from having to hard-code pref registration in the several unit tests
40 // that use this preference.
41 registry
->RegisterBooleanPref(
42 prefs::kShowUpdatePromotionInfoBar
,
44 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
46 registry
->RegisterBooleanPref(
47 prefs::kDeleteBrowsingHistory
,
49 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
50 registry
->RegisterBooleanPref(
51 prefs::kDeleteDownloadHistory
,
53 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
54 registry
->RegisterBooleanPref(
57 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
58 registry
->RegisterBooleanPref(
59 prefs::kDeleteCookies
,
61 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
62 registry
->RegisterBooleanPref(
63 prefs::kDeletePasswords
,
65 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
66 registry
->RegisterBooleanPref(
67 prefs::kDeleteFormData
,
69 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
70 registry
->RegisterBooleanPref(
71 prefs::kDeleteHostedAppsData
,
73 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
74 registry
->RegisterIntegerPref(
75 prefs::kDeleteTimePeriod
,
77 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
78 registry
->RegisterInt64Pref(
79 prefs::kLastClearBrowsingDataTime
,
81 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
82 registry
->RegisterIntegerPref(prefs::kModuleConflictBubbleShown
,
84 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
85 registry
->RegisterBooleanPref(
86 prefs::kCheckDefaultBrowser
,
88 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
90 // As with Mac-spacific code above, it should be in a platform-specific
91 // section somewhere, but there is no good place for it.
92 registry
->RegisterBooleanPref(
93 prefs::kSuppressSwitchToMetroModeOnSetDefault
,
95 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
97 registry
->RegisterBooleanPref(
98 prefs::kWebAppCreateOnDesktop
,
100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
101 registry
->RegisterBooleanPref(
102 prefs::kWebAppCreateInAppsMenu
,
104 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
105 registry
->RegisterBooleanPref(
106 prefs::kWebAppCreateInQuickLaunchBar
,
108 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
109 registry
->RegisterBooleanPref(
110 prefs::kEnableTranslate
,
112 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
113 registry
->RegisterStringPref(
114 prefs::kCloudPrintEmail
,
116 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
117 registry
->RegisterBooleanPref(
118 prefs::kCloudPrintProxyEnabled
,
120 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
121 registry
->RegisterBooleanPref(
122 prefs::kCloudPrintSubmitEnabled
,
124 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
125 registry
->RegisterBooleanPref(
126 prefs::kDevToolsDisabled
,
128 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
129 registry
->RegisterDictionaryPref(
130 prefs::kBrowserWindowPlacement
,
131 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
132 registry
->RegisterDictionaryPref(
133 prefs::kPreferencesWindowPlacement
,
134 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
135 registry
->RegisterBooleanPref(
136 prefs::kImportBookmarks
,
138 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
139 registry
->RegisterBooleanPref(
140 prefs::kImportHistory
,
142 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
143 registry
->RegisterBooleanPref(
144 prefs::kImportHomepage
,
146 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
147 registry
->RegisterBooleanPref(
148 prefs::kImportSearchEngine
,
150 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
151 registry
->RegisterBooleanPref(
152 prefs::kImportSavedPasswords
,
154 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
155 registry
->RegisterBooleanPref(
156 prefs::kEnableDoNotTrack
,
158 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
160 // Dictionaries to keep track of default tasks in the file browser.
161 registry
->RegisterDictionaryPref(
162 prefs::kDefaultTasksByMimeType
,
163 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
164 registry
->RegisterDictionaryPref(
165 prefs::kDefaultTasksBySuffix
,
166 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
);
168 // We need to register the type of these preferences in order to query
169 // them even though they're only typically controlled via policy.
170 registry
->RegisterBooleanPref(
171 prefs::kPluginsAllowOutdated
,
173 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
174 registry
->RegisterBooleanPref(
175 prefs::kPluginsAlwaysAuthorize
,
177 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
178 registry
->RegisterBooleanPref(
179 prefs::kClearPluginLSODataEnabled
,
181 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
182 registry
->RegisterBooleanPref(
183 prefs::kHideWebStoreIcon
,
185 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
186 #if !defined(OS_MACOSX)
187 registry
->RegisterBooleanPref(
188 prefs::kFullscreenAllowed
,
190 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
194 void RegisterAppPrefs(const std::string
& app_name
, Profile
* profile
) {
195 // We need to register the window position pref.
197 // TODO(mnissler): Use a separate pref name pointing to a single
198 // dictionary instead. Also tracked as http://crbug.com/167256
199 std::string
window_pref(prefs::kBrowserWindowPlacement
);
200 window_pref
.append("_");
201 window_pref
.append(app_name
);
202 PrefService
* prefs
= profile
->GetPrefs();
203 if (!prefs
->FindPreference(window_pref
.c_str())) {
204 // TODO(joi): Do all registration up front.
205 scoped_refptr
<user_prefs::PrefRegistrySyncable
> registry(
206 static_cast<user_prefs::PrefRegistrySyncable
*>(
207 prefs
->DeprecatedGetPrefRegistry()));
208 registry
->RegisterDictionaryPref(
209 window_pref
.c_str(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
214 } // namespace chrome