browser_ui_prefs.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 "chrome/browser/prefs/pref_service.h"
8#include "chrome/browser/profiles/profile.h"
9#include "chrome/common/pref_names.h"
10
11namespace chrome {
12
13void RegisterBrowserPrefs(PrefService* prefs) {
14  prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0);
15  prefs->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true);
16  prefs->RegisterBooleanPref(prefs::kShouldShowFirstRunBubble, false);
17}
18
19void RegisterBrowserUserPrefs(PrefService* prefs) {
20  prefs->RegisterBooleanPref(prefs::kHomePageChanged,
21                             false,
22                             PrefService::UNSYNCABLE_PREF);
23  prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage,
24                             true,
25                             PrefService::SYNCABLE_PREF);
26  prefs->RegisterBooleanPref(prefs::kShowHomeButton,
27                             false,
28                             PrefService::SYNCABLE_PREF);
29  prefs->RegisterIntegerPref(prefs::kExtensionsSideloadWipeoutBubbleShown,
30                             0,
31                             PrefService::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  prefs->RegisterBooleanPref(prefs::kShowUpdatePromotionInfoBar,
42                             true,
43                             PrefService::UNSYNCABLE_PREF);
44#endif
45  prefs->RegisterBooleanPref(prefs::kDeleteBrowsingHistory,
46                             true,
47                             PrefService::SYNCABLE_PREF);
48  prefs->RegisterBooleanPref(prefs::kDeleteDownloadHistory,
49                             true,
50                             PrefService::SYNCABLE_PREF);
51  prefs->RegisterBooleanPref(prefs::kDeleteCache,
52                             true,
53                             PrefService::SYNCABLE_PREF);
54  prefs->RegisterBooleanPref(prefs::kDeleteCookies,
55                             true,
56                             PrefService::SYNCABLE_PREF);
57  prefs->RegisterBooleanPref(prefs::kDeletePasswords,
58                             false,
59                             PrefService::SYNCABLE_PREF);
60  prefs->RegisterBooleanPref(prefs::kDeleteFormData,
61                             false,
62                             PrefService::SYNCABLE_PREF);
63  prefs->RegisterBooleanPref(prefs::kDeleteHostedAppsData,
64                             false,
65                             PrefService::SYNCABLE_PREF);
66  prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod,
67                             0,
68                             PrefService::SYNCABLE_PREF);
69  prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser,
70                             true,
71                             PrefService::UNSYNCABLE_PREF);
72#if defined(OS_WIN)
73  // As with Mac-spacific code above, it should be in a platform-specific
74  // section somewhere, but there is no good place for it.
75  prefs->RegisterBooleanPref(prefs::kSuppressSwitchToMetroModeOnSetDefault,
76                             false,
77                             PrefService::UNSYNCABLE_PREF);
78#endif
79  prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint,
80                             true,
81                             PrefService::UNSYNCABLE_PREF);
82  prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop,
83                             true,
84                             PrefService::UNSYNCABLE_PREF);
85  prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu,
86                             true,
87                             PrefService::UNSYNCABLE_PREF);
88  prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar,
89                             true,
90                             PrefService::UNSYNCABLE_PREF);
91  prefs->RegisterBooleanPref(prefs::kEnableTranslate,
92                             true,
93                             PrefService::SYNCABLE_PREF);
94  prefs->RegisterStringPref(prefs::kCloudPrintEmail,
95                            std::string(),
96                            PrefService::UNSYNCABLE_PREF);
97  prefs->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled,
98                             true,
99                             PrefService::UNSYNCABLE_PREF);
100  prefs->RegisterBooleanPref(prefs::kCloudPrintSubmitEnabled,
101                             true,
102                             PrefService::UNSYNCABLE_PREF);
103  prefs->RegisterBooleanPref(prefs::kDevToolsDisabled,
104                             false,
105                             PrefService::UNSYNCABLE_PREF);
106  prefs->RegisterIntegerPref(prefs::kDevToolsHSplitLocation,
107                             -1,
108                             PrefService::UNSYNCABLE_PREF);
109  prefs->RegisterIntegerPref(prefs::kDevToolsVSplitLocation,
110                             -1,
111                             PrefService::UNSYNCABLE_PREF);
112  prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement,
113                                PrefService::UNSYNCABLE_PREF);
114  prefs->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement,
115                                PrefService::UNSYNCABLE_PREF);
116  prefs->RegisterBooleanPref(prefs::kImportBookmarks,
117                             true,
118                             PrefService::UNSYNCABLE_PREF);
119  prefs->RegisterBooleanPref(prefs::kImportHistory,
120                             true,
121                             PrefService::UNSYNCABLE_PREF);
122  prefs->RegisterBooleanPref(prefs::kImportHomepage,
123                             true,
124                             PrefService::UNSYNCABLE_PREF);
125  prefs->RegisterBooleanPref(prefs::kImportSearchEngine,
126                             true,
127                             PrefService::UNSYNCABLE_PREF);
128  prefs->RegisterBooleanPref(prefs::kImportSavedPasswords,
129                             true,
130                             PrefService::UNSYNCABLE_PREF);
131  prefs->RegisterBooleanPref(prefs::kEnableDoNotTrack,
132                             false,
133                             PrefService::SYNCABLE_PREF);
134
135  // Dictionaries to keep track of default tasks in the file browser.
136  prefs->RegisterDictionaryPref(prefs::kDefaultTasksByMimeType,
137                                PrefService::SYNCABLE_PREF);
138  prefs->RegisterDictionaryPref(prefs::kDefaultTasksBySuffix,
139                                PrefService::SYNCABLE_PREF);
140
141  // We need to register the type of these preferences in order to query
142  // them even though they're only typically controlled via policy.
143  prefs->RegisterBooleanPref(prefs::kPluginsAllowOutdated,
144                             false,
145                             PrefService::UNSYNCABLE_PREF);
146  prefs->RegisterBooleanPref(prefs::kPluginsAlwaysAuthorize,
147                             false,
148                             PrefService::UNSYNCABLE_PREF);
149  prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled,
150                             true,
151                             PrefService::UNSYNCABLE_PREF);
152}
153
154void RegisterAppPrefs(const std::string& app_name, Profile* profile) {
155  // We need to register the window position pref.
156  std::string window_pref(prefs::kBrowserWindowPlacement);
157  window_pref.append("_");
158  window_pref.append(app_name);
159  PrefService* prefs = profile->GetPrefs();
160  if (!prefs->FindPreference(window_pref.c_str())) {
161    prefs->RegisterDictionaryPref(window_pref.c_str(),
162                                  PrefService::UNSYNCABLE_PREF);
163  }
164}
165
166
167}  // namespace chrome
168