browser_ui_prefs.cc revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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/pref_registry/pref_registry_syncable.h"
13#include "components/translate/core/common/translate_pref_names.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  registry->RegisterBooleanPref(
91      prefs::kWebAppCreateOnDesktop,
92      true,
93      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
94  registry->RegisterBooleanPref(
95      prefs::kWebAppCreateInAppsMenu,
96      true,
97      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
98  registry->RegisterBooleanPref(
99      prefs::kWebAppCreateInQuickLaunchBar,
100      true,
101      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
102  registry->RegisterBooleanPref(
103      prefs::kEnableTranslate,
104      true,
105      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
106  registry->RegisterStringPref(
107      prefs::kCloudPrintEmail,
108      std::string(),
109      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
110  registry->RegisterBooleanPref(
111      prefs::kCloudPrintProxyEnabled,
112      true,
113      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
114  registry->RegisterBooleanPref(
115      prefs::kCloudPrintSubmitEnabled,
116      true,
117      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
118  registry->RegisterBooleanPref(
119      prefs::kDevToolsDisabled,
120      false,
121      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
122  registry->RegisterDictionaryPref(
123      prefs::kBrowserWindowPlacement,
124      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
125  registry->RegisterDictionaryPref(
126      prefs::kBrowserWindowPlacementPopup,
127      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
128  registry->RegisterDictionaryPref(
129      prefs::kPreferencesWindowPlacement,
130      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
131  registry->RegisterBooleanPref(
132      prefs::kImportBookmarks,
133      true,
134      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
135  registry->RegisterBooleanPref(
136      prefs::kImportHistory,
137      true,
138      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
139  registry->RegisterBooleanPref(
140      prefs::kImportHomepage,
141      true,
142      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
143  registry->RegisterBooleanPref(
144      prefs::kImportSearchEngine,
145      true,
146      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
147  registry->RegisterBooleanPref(
148      prefs::kImportSavedPasswords,
149      true,
150      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
151  registry->RegisterBooleanPref(
152      prefs::kEnableDoNotTrack,
153      false,
154      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
155
156  // Dictionaries to keep track of default tasks in the file browser.
157  registry->RegisterDictionaryPref(
158      prefs::kDefaultTasksByMimeType,
159      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
160  registry->RegisterDictionaryPref(
161      prefs::kDefaultTasksBySuffix,
162      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
163
164  // We need to register the type of these preferences in order to query
165  // them even though they're only typically controlled via policy.
166  registry->RegisterBooleanPref(
167      prefs::kPluginsAllowOutdated,
168      false,
169      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
170  registry->RegisterBooleanPref(
171      prefs::kPluginsAlwaysAuthorize,
172      false,
173      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
174  registry->RegisterBooleanPref(
175      prefs::kClearPluginLSODataEnabled,
176      true,
177      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
178  registry->RegisterBooleanPref(
179      prefs::kHideWebStoreIcon,
180      false,
181      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
182#if !defined(OS_MACOSX)
183  registry->RegisterBooleanPref(
184      prefs::kFullscreenAllowed,
185      true,
186      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
187#endif
188}
189
190void RegisterAppPrefs(const std::string& app_name, Profile* profile) {
191  // We need to register the window position pref.
192  //
193  // TODO(mnissler): Use a separate pref name pointing to a single
194  // dictionary instead. Also tracked as http://crbug.com/167256
195  std::string window_pref(prefs::kBrowserWindowPlacement);
196  window_pref.append("_");
197  window_pref.append(app_name);
198  PrefService* prefs = profile->GetPrefs();
199  if (!prefs->FindPreference(window_pref.c_str())) {
200    // TODO(joi): Do all registration up front.
201    scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
202        static_cast<user_prefs::PrefRegistrySyncable*>(
203            prefs->DeprecatedGetPrefRegistry()));
204    registry->RegisterDictionaryPref(
205        window_pref.c_str(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
206  }
207}
208
209
210}  // namespace chrome
211