browser_ui_prefs.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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(PrefRegistrySyncable* registry) {
24  registry->RegisterBooleanPref(prefs::kHomePageChanged,
25                                false,
26                                PrefRegistrySyncable::UNSYNCABLE_PREF);
27  registry->RegisterBooleanPref(prefs::kHomePageIsNewTabPage,
28                                true,
29                                PrefRegistrySyncable::SYNCABLE_PREF);
30  registry->RegisterBooleanPref(prefs::kShowHomeButton,
31                                false,
32                                PrefRegistrySyncable::SYNCABLE_PREF);
33  registry->RegisterIntegerPref(prefs::kExtensionsSideloadWipeoutBubbleShown,
34                                0,
35                                PrefRegistrySyncable::SYNCABLE_PREF);
36#if defined(OS_MACOSX)
37  // This really belongs in platform code, but there's no good place to
38  // initialize it between the time when the AppController is created
39  // (where there's no profile) and the time the controller gets another
40  // crack at the start of the main event loop. By that time,
41  // StartupBrowserCreator has already created the browser window, and it's too
42  // late: we need the pref to be already initialized. Doing it here also saves
43  // us from having to hard-code pref registration in the several unit tests
44  // that use this preference.
45  registry->RegisterBooleanPref(prefs::kShowUpdatePromotionInfoBar,
46                                true,
47                                PrefRegistrySyncable::UNSYNCABLE_PREF);
48#endif
49  registry->RegisterBooleanPref(prefs::kDeleteBrowsingHistory,
50                                true,
51                                PrefRegistrySyncable::SYNCABLE_PREF);
52  registry->RegisterBooleanPref(prefs::kDeleteDownloadHistory,
53                                true,
54                                PrefRegistrySyncable::SYNCABLE_PREF);
55  registry->RegisterBooleanPref(prefs::kDeleteCache,
56                                true,
57                                PrefRegistrySyncable::SYNCABLE_PREF);
58  registry->RegisterBooleanPref(prefs::kDeleteCookies,
59                                true,
60                                PrefRegistrySyncable::SYNCABLE_PREF);
61  registry->RegisterBooleanPref(prefs::kDeletePasswords,
62                                false,
63                                PrefRegistrySyncable::SYNCABLE_PREF);
64  registry->RegisterBooleanPref(prefs::kDeleteFormData,
65                                false,
66                                PrefRegistrySyncable::SYNCABLE_PREF);
67  registry->RegisterBooleanPref(prefs::kDeleteHostedAppsData,
68                                false,
69                                PrefRegistrySyncable::SYNCABLE_PREF);
70  registry->RegisterIntegerPref(prefs::kDeleteTimePeriod,
71                                0,
72                                PrefRegistrySyncable::SYNCABLE_PREF);
73  registry->RegisterInt64Pref(prefs::kLastClearBrowsingDataTime,
74                              0,
75                              PrefRegistrySyncable::UNSYNCABLE_PREF);
76  registry->RegisterBooleanPref(prefs::kCheckDefaultBrowser,
77                                true,
78                                PrefRegistrySyncable::UNSYNCABLE_PREF);
79#if defined(OS_WIN)
80  // As with Mac-spacific code above, it should be in a platform-specific
81  // section somewhere, but there is no good place for it.
82  registry->RegisterBooleanPref(prefs::kSuppressSwitchToMetroModeOnSetDefault,
83                                false,
84                                PrefRegistrySyncable::UNSYNCABLE_PREF);
85#endif
86  registry->RegisterBooleanPref(prefs::kShowOmniboxSearchHint,
87                                true,
88                                PrefRegistrySyncable::UNSYNCABLE_PREF);
89  registry->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop,
90                                true,
91                                PrefRegistrySyncable::UNSYNCABLE_PREF);
92  registry->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu,
93                                true,
94                                PrefRegistrySyncable::UNSYNCABLE_PREF);
95  registry->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar,
96                                true,
97                                PrefRegistrySyncable::UNSYNCABLE_PREF);
98  registry->RegisterBooleanPref(prefs::kEnableTranslate,
99                                true,
100                                PrefRegistrySyncable::SYNCABLE_PREF);
101  registry->RegisterStringPref(prefs::kCloudPrintEmail,
102                               std::string(),
103                               PrefRegistrySyncable::UNSYNCABLE_PREF);
104  registry->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled,
105                                true,
106                                PrefRegistrySyncable::UNSYNCABLE_PREF);
107  registry->RegisterBooleanPref(prefs::kCloudPrintSubmitEnabled,
108                                true,
109                                PrefRegistrySyncable::UNSYNCABLE_PREF);
110  registry->RegisterBooleanPref(prefs::kDevToolsDisabled,
111                                false,
112                                PrefRegistrySyncable::UNSYNCABLE_PREF);
113  registry->RegisterIntegerPref(prefs::kDevToolsHSplitLocation,
114                                -1,
115                                PrefRegistrySyncable::UNSYNCABLE_PREF);
116  registry->RegisterIntegerPref(prefs::kDevToolsVSplitLocation,
117                                -1,
118                                PrefRegistrySyncable::UNSYNCABLE_PREF);
119  registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement,
120                                   PrefRegistrySyncable::UNSYNCABLE_PREF);
121  registry->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement,
122                                   PrefRegistrySyncable::UNSYNCABLE_PREF);
123  registry->RegisterBooleanPref(prefs::kImportBookmarks,
124                                true,
125                                PrefRegistrySyncable::UNSYNCABLE_PREF);
126  registry->RegisterBooleanPref(prefs::kImportHistory,
127                                true,
128                                PrefRegistrySyncable::UNSYNCABLE_PREF);
129  registry->RegisterBooleanPref(prefs::kImportHomepage,
130                                true,
131                                PrefRegistrySyncable::UNSYNCABLE_PREF);
132  registry->RegisterBooleanPref(prefs::kImportSearchEngine,
133                                true,
134                                PrefRegistrySyncable::UNSYNCABLE_PREF);
135  registry->RegisterBooleanPref(prefs::kImportSavedPasswords,
136                                true,
137                                PrefRegistrySyncable::UNSYNCABLE_PREF);
138  registry->RegisterBooleanPref(prefs::kEnableDoNotTrack,
139                                false,
140                                PrefRegistrySyncable::SYNCABLE_PREF);
141
142  // Dictionaries to keep track of default tasks in the file browser.
143  registry->RegisterDictionaryPref(prefs::kDefaultTasksByMimeType,
144                                   PrefRegistrySyncable::SYNCABLE_PREF);
145  registry->RegisterDictionaryPref(prefs::kDefaultTasksBySuffix,
146                                   PrefRegistrySyncable::SYNCABLE_PREF);
147
148  // We need to register the type of these preferences in order to query
149  // them even though they're only typically controlled via policy.
150  registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated,
151                                false,
152                                PrefRegistrySyncable::UNSYNCABLE_PREF);
153  registry->RegisterBooleanPref(prefs::kPluginsAlwaysAuthorize,
154                                false,
155                                PrefRegistrySyncable::UNSYNCABLE_PREF);
156  registry->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled,
157                                true,
158                                PrefRegistrySyncable::UNSYNCABLE_PREF);
159  registry->RegisterBooleanPref(prefs::kHideWebStoreIcon,
160                                false,
161                                PrefRegistrySyncable::UNSYNCABLE_PREF);
162}
163
164void RegisterAppPrefs(const std::string& app_name, Profile* profile) {
165  // We need to register the window position pref.
166  //
167  // TODO(mnissler): Use a separate pref name pointing to a single
168  // dictionary instead. Also tracked as http://crbug.com/167256
169  std::string window_pref(prefs::kBrowserWindowPlacement);
170  window_pref.append("_");
171  window_pref.append(app_name);
172  PrefService* prefs = profile->GetPrefs();
173  if (!prefs->FindPreference(window_pref.c_str())) {
174    // TODO(joi): Do all registration up front.
175    scoped_refptr<PrefRegistrySyncable> registry(
176        static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry()));
177    registry->RegisterDictionaryPref(window_pref.c_str(),
178                                     PrefRegistrySyncable::UNSYNCABLE_PREF);
179  }
180}
181
182
183}  // namespace chrome
184