browser_ui_prefs.cc revision a02191e04bc25c4935f804f2c080ae28663d096d
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/translate/core/common/translate_pref_names.h"
13#include "components/user_prefs/pref_registry_syncable.h"
14
15namespace chrome {
16
17void RegisterBrowserPrefs(PrefRegistrySimple* registry) {
18  registry->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0);
19  registry->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true);
20  registry->RegisterIntegerPref(prefs::kShowFirstRunBubbleOption,
21                             first_run::FIRST_RUN_BUBBLE_DONT_SHOW);
22}
23
24void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable* registry) {
25  registry->RegisterBooleanPref(
26      prefs::kHomePageIsNewTabPage,
27      true,
28      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
29  registry->RegisterBooleanPref(
30      prefs::kShowHomeButton,
31      false,
32      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
33#if defined(OS_MACOSX)
34  // This really belongs in platform code, but there's no good place to
35  // initialize it between the time when the AppController is created
36  // (where there's no profile) and the time the controller gets another
37  // crack at the start of the main event loop. By that time,
38  // StartupBrowserCreator has already created the browser window, and it's too
39  // late: we need the pref to be already initialized. Doing it here also saves
40  // us from having to hard-code pref registration in the several unit tests
41  // that use this preference.
42  registry->RegisterBooleanPref(
43      prefs::kShowUpdatePromotionInfoBar,
44      true,
45      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
46#endif
47  registry->RegisterBooleanPref(
48      prefs::kDeleteBrowsingHistory,
49      true,
50      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
51  registry->RegisterBooleanPref(
52      prefs::kDeleteDownloadHistory,
53      true,
54      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
55  registry->RegisterBooleanPref(
56      prefs::kDeleteCache,
57      true,
58      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
59  registry->RegisterBooleanPref(
60      prefs::kDeleteCookies,
61      true,
62      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
63  registry->RegisterBooleanPref(
64      prefs::kDeletePasswords,
65      false,
66      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
67  registry->RegisterBooleanPref(
68      prefs::kDeleteFormData,
69      false,
70      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
71  registry->RegisterBooleanPref(
72      prefs::kDeleteHostedAppsData,
73      false,
74      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
75  registry->RegisterIntegerPref(
76      prefs::kDeleteTimePeriod,
77      0,
78      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
79  registry->RegisterInt64Pref(
80      prefs::kLastClearBrowsingDataTime,
81      0,
82      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
83  registry->RegisterIntegerPref(prefs::kModuleConflictBubbleShown,
84      0,
85      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
86  registry->RegisterBooleanPref(
87      prefs::kCheckDefaultBrowser,
88      true,
89      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
90#if defined(OS_WIN)
91  // As with Mac-spacific code above, it should be in a platform-specific
92  // section somewhere, but there is no good place for it.
93  registry->RegisterBooleanPref(
94      prefs::kSuppressSwitchToMetroModeOnSetDefault,
95      false,
96      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
97#endif
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->RegisterDictionaryPref(
131      prefs::kBrowserWindowPlacement,
132      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
133  registry->RegisterDictionaryPref(
134      prefs::kBrowserWindowPlacementPopup,
135      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
136  registry->RegisterDictionaryPref(
137      prefs::kPreferencesWindowPlacement,
138      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
139  registry->RegisterBooleanPref(
140      prefs::kImportBookmarks,
141      true,
142      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
143  registry->RegisterBooleanPref(
144      prefs::kImportHistory,
145      true,
146      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
147  registry->RegisterBooleanPref(
148      prefs::kImportHomepage,
149      true,
150      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
151  registry->RegisterBooleanPref(
152      prefs::kImportSearchEngine,
153      true,
154      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
155  registry->RegisterBooleanPref(
156      prefs::kImportSavedPasswords,
157      true,
158      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
159  registry->RegisterBooleanPref(
160      prefs::kEnableDoNotTrack,
161      false,
162      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
163
164  // Dictionaries to keep track of default tasks in the file browser.
165  registry->RegisterDictionaryPref(
166      prefs::kDefaultTasksByMimeType,
167      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
168  registry->RegisterDictionaryPref(
169      prefs::kDefaultTasksBySuffix,
170      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
171
172  // We need to register the type of these preferences in order to query
173  // them even though they're only typically controlled via policy.
174  registry->RegisterBooleanPref(
175      prefs::kPluginsAllowOutdated,
176      false,
177      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
178  registry->RegisterBooleanPref(
179      prefs::kPluginsAlwaysAuthorize,
180      false,
181      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
182  registry->RegisterBooleanPref(
183      prefs::kClearPluginLSODataEnabled,
184      true,
185      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
186  registry->RegisterBooleanPref(
187      prefs::kHideWebStoreIcon,
188      false,
189      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
190#if !defined(OS_MACOSX)
191  registry->RegisterBooleanPref(
192      prefs::kFullscreenAllowed,
193      true,
194      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
195#endif
196}
197
198void RegisterAppPrefs(const std::string& app_name, Profile* profile) {
199  // We need to register the window position pref.
200  //
201  // TODO(mnissler): Use a separate pref name pointing to a single
202  // dictionary instead. Also tracked as http://crbug.com/167256
203  std::string window_pref(prefs::kBrowserWindowPlacement);
204  window_pref.append("_");
205  window_pref.append(app_name);
206  PrefService* prefs = profile->GetPrefs();
207  if (!prefs->FindPreference(window_pref.c_str())) {
208    // TODO(joi): Do all registration up front.
209    scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
210        static_cast<user_prefs::PrefRegistrySyncable*>(
211            prefs->DeprecatedGetPrefRegistry()));
212    registry->RegisterDictionaryPref(
213        window_pref.c_str(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
214  }
215}
216
217
218}  // namespace chrome
219