summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/master_preferences.h
blob: 178587fe0102afa8de1961ab3ac0654d10ca2bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file contains functions processing master preference file used by
// setup and first run.

#ifndef CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
#define CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_

#include <vector>

#include "base/file_path.h"
#include "base/values.h"
#include "googleurl/src/gurl.h"

namespace installer_util {

namespace master_preferences {
// All the preferences below are expected to be inside the JSON "distribution"
// block. Some of them also have equivalent command line option. If same option
// is specified in master preference as well as command line, the commnd line
// value takes precedence.

// Boolean. Use alternate text for the shortcut. Cmd line override present.
extern const wchar_t kAltShortcutText[];
// Boolean. Use alternate smaller first run info bubble.
extern const wchar_t kAltFirstRunBubble[];
// Integer. Icon index from chrome.exe to use for shortcuts.
extern const wchar_t kChromeShortcutIconIndex[];
// Boolean. Create Desktop and QuickLaunch shortcuts. Cmd line override present.
extern const wchar_t kCreateAllShortcuts[];
// Boolean pref that triggers silent import of the default browser bookmarks.
extern const wchar_t kDistroImportBookmarksPref[];
// Boolean pref that triggers silent import of the default browser history.
extern const wchar_t kDistroImportHistoryPref[];
// Boolean pref that triggers silent import of the default browser homepage.
extern const wchar_t kDistroImportHomePagePref[];
// Boolean pref that triggers silent import of the default search engine.
extern const wchar_t kDistroImportSearchPref[];
// Integer. RLZ ping delay in seconds.
extern const wchar_t kDistroPingDelay[];
// Boolean pref that triggers loading the welcome page.
extern const wchar_t kDistroShowWelcomePage[];
// Boolean pref that triggers skipping the first run dialogs.
extern const wchar_t kDistroSkipFirstRunPref[];
// Boolean. Do not create Chrome desktop shortcuts. Cmd line override present.
extern const wchar_t kDoNotCreateShortcuts[];
// Boolean. Do not launch Chrome after first install. Cmd line override present.
extern const wchar_t kDoNotLaunchChrome[];
// Boolean. Do not register with Google Update to have Chrome launched after
// install. Cmd line override present.
extern const wchar_t kDoNotRegisterForUpdateLaunch[];
// Boolean. Register Chrome as default browser. Cmd line override present.
extern const wchar_t kMakeChromeDefault[];
// Boolean. Register Chrome as default browser for the current user.
extern const wchar_t kMakeChromeDefaultForUser[];
// Boolean. Expect to be run by an MSI installer. Cmd line override present.
extern const wchar_t kMsi[];
// Boolean. Show EULA dialog before install.
extern const wchar_t kRequireEula[];
// Boolean. Install Chrome to system wise location. Cmd line override present.
extern const wchar_t kSystemLevel[];
// Boolean. Run installer in verbose mode. Cmd line override present.
extern const wchar_t kVerboseLogging[];
// Name of the block that contains the extensions on the master preferences.
extern const wchar_t kExtensionsBlock[];
}

// This is the default name for the master preferences file used to pre-set
// values in the user profile at first run.
const char kDefaultMasterPrefs[] = "master_preferences";

// Gets the value of given boolean preference |name| from |prefs| dictionary
// which is assumed to contain a dictionary named "distribution". Returns
// true if the value is read successfully, otherwise false.
bool GetDistroBooleanPreference(const DictionaryValue* prefs,
                                const std::wstring& name,
                                bool* value);

// This function gets value of an integer preference from master
// preferences. Returns true if the value is read successfully, otherwise false.
bool GetDistroIntegerPreference(const DictionaryValue* prefs,
                                const std::wstring& name,
                                int* value);

// The master preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function parses the distribution
// section of the preferences file.
//
// A prototypical 'master_preferences' file looks like this:
//
// {
//   "distribution": {
//      "alternate_shortcut_text": false,
//      "oem_bubble": false,
//      "chrome_shortcut_icon_index": 0,
//      "create_all_shortcuts": true,
//      "import_bookmarks": false,
//      "import_history": false,
//      "import_home_page": false,
//      "import_search_engine": true,
//      "ping_delay": 40,
//      "show_welcome_page": true,
//      "skip_first_run_ui": true,
//      "do_not_launch_chrome": false,
//      "make_chrome_default": false,
//      "make_chrome_default_for_user": true,
//      "require_eula": true,
//      "system_level": false,
//      "verbose_logging": true
//   },
//   "browser": {
//      "show_home_button": true
//   },
//   "bookmark_bar": {
//      "show_on_all_tabs": true
//   },
//   "first_run_tabs": [
//      "http://gmail.com",
//      "https://igoogle.com"
//   ],
//   "homepage": "http://example.org",
//   "homepage_is_newtabpage": false
// }
//
// A reserved "distribution" entry in the file is used to group related
// installation properties. This entry will be ignored at other times.
// This function parses the 'distribution' entry and returns a combination
// of MasterPrefResult.
DictionaryValue* ParseDistributionPreferences(
    const FilePath& master_prefs_path);

// As part of the master preferences an optional section indicates the tabs
// to open during first run. An example is the following:
//
//  {
//    "first_run_tabs": [
//       "http://google.com/f1",
//       "https://google.com/f2"
//    ]
//  }
//
// Note that the entries are usually urls but they don't have to.
//
// This function retuns the list as a vector of GURLs.  If the master
// preferences file does not contain such list the vector is empty.
std::vector<GURL> GetFirstRunTabs(const DictionaryValue* prefs);

// As part of the master preferences an optional section indicates the
// pre-installed bookmarks. An example is the following:
//
//  {
//    "default_bookmarks": [
//       "http://google.com/b1",
//       "https://google.com/b2"
//    ]
//  }
//
// Note that the entries need to be urls.
//
// This function retuns the list as a vector of GURLs. If the master
// preferences file does not contain such list the vector is empty.
std::vector<GURL> GetDefaultBookmarks(const DictionaryValue* prefs);

// Sets the value of given boolean preference |name| in "distribution"
// dictionary inside |prefs| dictionary.
bool SetDistroBooleanPreference(DictionaryValue* prefs,
                                const std::wstring& name,
                                bool value);

// The master preferences can also contain a regular extensions
// preference block. If so, the extensions referenced there will be
// installed during the first run experience.
// An extension can go in the master prefs needs just the basic
// elements such as:
//   1- An extension entry under settings, assigned by the gallery
//   2- The "location" : 1 entry
//   3- A minimal "manifest" block with key, name, permissions, update url
//      and version. The version needs to be lower than the version of
//      the extension that is hosted in the gallery.
//   4- The "path" entry with the version as last component
//   5- The "state" : 1 entry
//
// The following is an example of a master pref file that installs
// Google XYZ:
//
//  {
//     "extensions": {
//        "settings": {
//           "ppflmjolhbonpkbkooiamcnenbmbjcbb": {
//              "location": 1,
//              "manifest": {
//                 "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4<rest of key ommited>",
//                 "name": "Google XYZ (Installing...)",
//                 "permissions": [ "tabs", "http://xyz.google.com/" ],
//                 "update_url": "http://fixme.com/fixme/fixme/crx",
//                 "version": "0.0"
//              },
//              "path": "ppflmjolhbonpkbkooiamcnenbmbjcbb\\0.0",
//              "state": 1
//           }
//        }
//     }
//  }
//
bool HasExtensionsBlock(const DictionaryValue* prefs,
                        DictionaryValue** extensions);

}  // namespace installer_util

#endif  // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_