browser_ui_prefs.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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/browser_ui_prefs.h"
6
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"
13
14namespace chrome {
15
16void 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);
21}
22
23void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable* registry) {
24  registry->RegisterBooleanPref(
25      prefs::kHomePageIsNewTabPage,
26      true,
27      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
28  registry->RegisterBooleanPref(
29      prefs::kShowHomeButton,
30      false,
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,
43      true,
44      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
45#endif
46  registry->RegisterBooleanPref(
47      prefs::kDeleteBrowsingHistory,
48      true,
49      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
50  registry->RegisterBooleanPref(
51      prefs::kDeleteDownloadHistory,
52      true,
53      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
54  registry->RegisterBooleanPref(
55      prefs::kDeleteCache,
56      true,
57      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
58  registry->RegisterBooleanPref(
59      prefs::kDeleteCookies,
60      true,
61      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
62  registry->RegisterBooleanPref(
63      prefs::kDeletePasswords,
64      false,
65      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
66  registry->RegisterBooleanPref(
67      prefs::kDeleteFormData,
68      false,
69      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
70  registry->RegisterBooleanPref(
71      prefs::kDeleteHostedAppsData,
72      false,
73      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
74  registry->RegisterIntegerPref(
75      prefs::kDeleteTimePeriod,
76      0,
77      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
78  registry->RegisterInt64Pref(
79      prefs::kLastClearBrowsingDataTime,
80      0,
81      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
82  registry->RegisterBooleanPref(
83      prefs::kCheckDefaultBrowser,
84      true,
85      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
86#if defined(OS_WIN)
87  // As with Mac-spacific code above, it should be in a platform-specific
88  // section somewhere, but there is no good place for it.
89  registry->RegisterBooleanPref(
90      prefs::kSuppressSwitchToMetroModeOnSetDefault,
91      false,
92      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
93#endif
94  registry->RegisterBooleanPref(
95      prefs::kShowOmniboxSearchHint,
96      true,
97      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
98  registry->RegisterBooleanPref(
99      prefs::kWebAppCreateOnDesktop,
100      true,
101      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
102  registry->RegisterBooleanPref(
103      prefs::kWebAppCreateInAppsMenu,
104      true,
105      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
106  registry->RegisterBooleanPref(
107      prefs::kWebAppCreateInQuickLaunchBar,
108      true,
109      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
110  registry->RegisterBooleanPref(
111      prefs::kEnableTranslate,
112      true,
113      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
114  registry->RegisterStringPref(
115      prefs::kCloudPrintEmail,
116      std::string(),
117      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
118  registry->RegisterBooleanPref(
119      prefs::kCloudPrintProxyEnabled,
120      true,
121      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
122  registry->RegisterBooleanPref(
123      prefs::kCloudPrintSubmitEnabled,
124      true,
125      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
126  registry->RegisterBooleanPref(
127      prefs::kDevToolsDisabled,
128      false,
129      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
130  registry->RegisterIntegerPref(
131      prefs::kDevToolsHSplitLocation,
132      -1,
133      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
134  registry->RegisterIntegerPref(
135      prefs::kDevToolsVSplitLocation,
136      -1,
137      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
138  registry->RegisterDictionaryPref(
139      prefs::kBrowserWindowPlacement,
140      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
141  registry->RegisterDictionaryPref(
142      prefs::kPreferencesWindowPlacement,
143      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
144  registry->RegisterBooleanPref(
145      prefs::kImportBookmarks,
146      true,
147      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
148  registry->RegisterBooleanPref(
149      prefs::kImportHistory,
150      true,
151      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
152  registry->RegisterBooleanPref(
153      prefs::kImportHomepage,
154      true,
155      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
156  registry->RegisterBooleanPref(
157      prefs::kImportSearchEngine,
158      true,
159      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
160  registry->RegisterBooleanPref(
161      prefs::kImportSavedPasswords,
162      true,
163      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
164  registry->RegisterBooleanPref(
165      prefs::kEnableDoNotTrack,
166      false,
167      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
168
169  // Dictionaries to keep track of default tasks in the file browser.
170  registry->RegisterDictionaryPref(
171      prefs::kDefaultTasksByMimeType,
172      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
173  registry->RegisterDictionaryPref(
174      prefs::kDefaultTasksBySuffix,
175      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
176
177  // We need to register the type of these preferences in order to query
178  // them even though they're only typically controlled via policy.
179  registry->RegisterBooleanPref(
180      prefs::kPluginsAllowOutdated,
181      false,
182      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
183  registry->RegisterBooleanPref(
184      prefs::kPluginsAlwaysAuthorize,
185      false,
186      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
187  registry->RegisterBooleanPref(
188      prefs::kClearPluginLSODataEnabled,
189      true,
190      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
191  registry->RegisterBooleanPref(
192      prefs::kHideWebStoreIcon,
193      false,
194      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
195
196  registry->RegisterBooleanPref(
197      prefs::kResetDefaultSearchEngine,
198      true,
199      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
200  registry->RegisterBooleanPref(
201      prefs::kResetHomepage,
202      true,
203      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
204  registry->RegisterBooleanPref(
205      prefs::kResetContentSettings,
206      true,
207      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
208  registry->RegisterBooleanPref(
209      prefs::kResetCookiesAndSiteData,
210      true,
211      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
212  registry->RegisterBooleanPref(
213      prefs::kResetExtensions,
214      true,
215      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
216  registry->RegisterIntegerPref(
217      prefs::kResetExtensionsHandling,
218      0,
219      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
220}
221
222void RegisterAppPrefs(const std::string& app_name, Profile* profile) {
223  // We need to register the window position pref.
224  //
225  // TODO(mnissler): Use a separate pref name pointing to a single
226  // dictionary instead. Also tracked as http://crbug.com/167256
227  std::string window_pref(prefs::kBrowserWindowPlacement);
228  window_pref.append("_");
229  window_pref.append(app_name);
230  PrefService* prefs = profile->GetPrefs();
231  if (!prefs->FindPreference(window_pref.c_str())) {
232    // TODO(joi): Do all registration up front.
233    scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
234        static_cast<user_prefs::PrefRegistrySyncable*>(
235            prefs->DeprecatedGetPrefRegistry()));
236    registry->RegisterDictionaryPref(
237        window_pref.c_str(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
238  }
239}
240
241
242}  // namespace chrome
243