Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1005)

Side by Side Diff: chrome/browser/first_run/first_run.cc

Issue 5756007: Revert 69165 - Merge the installer, installer_util and setup_util namespaces ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main_win.cc ('k') | chrome/browser/first_run/first_run_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/first_run/first_run.h" 5 #include "chrome/browser/first_run/first_run.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 // TODO(port): move more code in back from the first_run_win.cc module. 9 // TODO(port): move more code in back from the first_run_win.cc module.
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 // static 88 // static
89 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, 89 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
90 MasterPrefs* out_prefs) { 90 MasterPrefs* out_prefs) {
91 DCHECK(!user_data_dir.empty()); 91 DCHECK(!user_data_dir.empty());
92 92
93 // The standard location of the master prefs is next to the chrome binary. 93 // The standard location of the master prefs is next to the chrome binary.
94 FilePath master_prefs; 94 FilePath master_prefs;
95 if (!PathService::Get(base::DIR_EXE, &master_prefs)) 95 if (!PathService::Get(base::DIR_EXE, &master_prefs))
96 return true; 96 return true;
97 master_prefs = master_prefs.AppendASCII(installer::kDefaultMasterPrefs); 97 master_prefs = master_prefs.AppendASCII(installer_util::kDefaultMasterPrefs);
98 98
99 installer::MasterPreferences prefs(master_prefs); 99 installer_util::MasterPreferences prefs(master_prefs);
100 if (!prefs.read_from_file()) 100 if (!prefs.read_from_file())
101 return true; 101 return true;
102 102
103 out_prefs->new_tabs = prefs.GetFirstRunTabs(); 103 out_prefs->new_tabs = prefs.GetFirstRunTabs();
104 104
105 bool value = false; 105 bool value = false;
106 106
107 #if defined(OS_WIN) 107 #if defined(OS_WIN)
108 // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/ 108 // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/
109 // Linux, enable it here. 109 // Linux, enable it here.
110 if (!prefs.GetInt(installer::master_preferences::kDistroPingDelay, 110 if (!prefs.GetInt(installer_util::master_preferences::kDistroPingDelay,
111 &out_prefs->ping_delay)) { 111 &out_prefs->ping_delay)) {
112 // 90 seconds is the default that we want to use in case master 112 // 90 seconds is the default that we want to use in case master
113 // preferences is missing, corrupt or ping_delay is missing. 113 // preferences is missing, corrupt or ping_delay is missing.
114 out_prefs->ping_delay = 90; 114 out_prefs->ping_delay = 90;
115 } 115 }
116 116
117 if (prefs.GetBool(installer::master_preferences::kRequireEula, &value) && 117 if (prefs.GetBool(installer_util::master_preferences::kRequireEula, &value) &&
118 value) { 118 value) {
119 // Show the post-installation EULA. This is done by setup.exe and the 119 // Show the post-installation EULA. This is done by setup.exe and the
120 // result determines if we continue or not. We wait here until the user 120 // result determines if we continue or not. We wait here until the user
121 // dismisses the dialog. 121 // dismisses the dialog.
122 122
123 // The actual eula text is in a resource in chrome. We extract it to 123 // The actual eula text is in a resource in chrome. We extract it to
124 // a text file so setup.exe can use it as an inner frame. 124 // a text file so setup.exe can use it as an inner frame.
125 FilePath inner_html; 125 FilePath inner_html;
126 if (WriteEULAtoTempFile(&inner_html)) { 126 if (WriteEULAtoTempFile(&inner_html)) {
127 int retcode = 0; 127 int retcode = 0;
128 if (!LaunchSetupWithParam(installer::switches::kShowEula, 128 if (!LaunchSetupWithParam(installer_util::switches::kShowEula,
129 inner_html.ToWStringHack(), &retcode) || 129 inner_html.ToWStringHack(), &retcode) ||
130 (retcode == installer::EULA_REJECTED)) { 130 (retcode == installer_util::EULA_REJECTED)) {
131 LOG(WARNING) << "EULA rejected. Fast exit."; 131 LOG(WARNING) << "EULA rejected. Fast exit.";
132 ::ExitProcess(1); 132 ::ExitProcess(1);
133 } 133 }
134 if (retcode == installer::EULA_ACCEPTED) { 134 if (retcode == installer_util::EULA_ACCEPTED) {
135 VLOG(1) << "EULA : no collection"; 135 VLOG(1) << "EULA : no collection";
136 GoogleUpdateSettings::SetCollectStatsConsent(false); 136 GoogleUpdateSettings::SetCollectStatsConsent(false);
137 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) { 137 } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) {
138 VLOG(1) << "EULA : collection consent"; 138 VLOG(1) << "EULA : collection consent";
139 GoogleUpdateSettings::SetCollectStatsConsent(true); 139 GoogleUpdateSettings::SetCollectStatsConsent(true);
140 } 140 }
141 } 141 }
142 } 142 }
143 #endif 143 #endif
144 144
145 if (prefs.GetBool(installer::master_preferences::kAltFirstRunBubble, 145 if (prefs.GetBool(installer_util::master_preferences::kAltFirstRunBubble,
146 &value) && value) { 146 &value) && value) {
147 FirstRun::SetOEMFirstRunBubblePref(); 147 FirstRun::SetOEMFirstRunBubblePref();
148 } 148 }
149 149
150 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); 150 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
151 if (user_prefs.empty()) 151 if (user_prefs.empty())
152 return true; 152 return true;
153 153
154 // The master prefs are regular prefs so we can just copy the file 154 // The master prefs are regular prefs so we can just copy the file
155 // to the default place and they just work. 155 // to the default place and they just work.
156 if (!file_util::CopyFile(master_prefs, user_prefs)) 156 if (!file_util::CopyFile(master_prefs, user_prefs))
157 return true; 157 return true;
158 158
159 #if defined(OS_WIN) 159 #if defined(OS_WIN)
160 DictionaryValue* extensions = 0; 160 DictionaryValue* extensions = 0;
161 if (prefs.GetExtensionsBlock(&extensions)) { 161 if (prefs.GetExtensionsBlock(&extensions)) {
162 VLOG(1) << "Extensions block found in master preferences"; 162 VLOG(1) << "Extensions block found in master preferences";
163 DoDelayedInstallExtensions(); 163 DoDelayedInstallExtensions();
164 } 164 }
165 #endif 165 #endif
166 166
167 if (prefs.GetBool(installer::master_preferences::kDistroImportSearchPref, 167 if (prefs.GetBool(installer_util::master_preferences::kDistroImportSearchPref,
168 &value)) { 168 &value)) {
169 if (value) { 169 if (value) {
170 out_prefs->do_import_items |= importer::SEARCH_ENGINES; 170 out_prefs->do_import_items |= importer::SEARCH_ENGINES;
171 } else { 171 } else {
172 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; 172 out_prefs->dont_import_items |= importer::SEARCH_ENGINES;
173 } 173 }
174 } 174 }
175 175
176 // Check to see if search engine logos should be randomized. 176 // Check to see if search engine logos should be randomized.
177 if (prefs.GetBool( 177 if (prefs.GetBool(
178 installer::master_preferences:: 178 installer_util::master_preferences::
179 kSearchEngineExperimentRandomizePref, 179 kSearchEngineExperimentRandomizePref,
180 &value) && value) { 180 &value) && value) {
181 out_prefs->randomize_search_engine_experiment = true; 181 out_prefs->randomize_search_engine_experiment = true;
182 } 182 }
183 183
184 // If we're suppressing the first-run bubble, set that preference now. 184 // If we're suppressing the first-run bubble, set that preference now.
185 // Otherwise, wait until the user has completed first run to set it, so the 185 // Otherwise, wait until the user has completed first run to set it, so the
186 // user is guaranteed to see the bubble iff he or she has completed the first 186 // user is guaranteed to see the bubble iff he or she has completed the first
187 // run process. 187 // run process.
188 if (prefs.GetBool( 188 if (prefs.GetBool(
189 installer::master_preferences::kDistroSuppressFirstRunBubble, 189 installer_util::master_preferences::kDistroSuppressFirstRunBubble,
190 &value) && value) 190 &value) && value)
191 FirstRun::SetShowFirstRunBubblePref(false); 191 FirstRun::SetShowFirstRunBubblePref(false);
192 192
193 if (prefs.GetBool( 193 if (prefs.GetBool(
194 installer::master_preferences::kDistroImportHistoryPref, 194 installer_util::master_preferences::kDistroImportHistoryPref,
195 &value)) { 195 &value)) {
196 if (value) { 196 if (value) {
197 out_prefs->do_import_items |= importer::HISTORY; 197 out_prefs->do_import_items |= importer::HISTORY;
198 } else { 198 } else {
199 out_prefs->dont_import_items |= importer::HISTORY; 199 out_prefs->dont_import_items |= importer::HISTORY;
200 } 200 }
201 } 201 }
202 202
203 std::string not_used; 203 std::string not_used;
204 out_prefs->homepage_defined = prefs.GetString(prefs::kHomePage, &not_used); 204 out_prefs->homepage_defined = prefs.GetString(prefs::kHomePage, &not_used);
205 205
206 if (prefs.GetBool( 206 if (prefs.GetBool(
207 installer::master_preferences::kDistroImportHomePagePref, 207 installer_util::master_preferences::kDistroImportHomePagePref,
208 &value)) { 208 &value)) {
209 if (value) { 209 if (value) {
210 out_prefs->do_import_items |= importer::HOME_PAGE; 210 out_prefs->do_import_items |= importer::HOME_PAGE;
211 } else { 211 } else {
212 out_prefs->dont_import_items |= importer::HOME_PAGE; 212 out_prefs->dont_import_items |= importer::HOME_PAGE;
213 } 213 }
214 } 214 }
215 215
216 // Bookmarks are never imported unless specifically turned on. 216 // Bookmarks are never imported unless specifically turned on.
217 if (prefs.GetBool( 217 if (prefs.GetBool(
218 installer::master_preferences::kDistroImportBookmarksPref, 218 installer_util::master_preferences::kDistroImportBookmarksPref,
219 &value) && value) { 219 &value) && value) {
220 out_prefs->do_import_items |= importer::FAVORITES; 220 out_prefs->do_import_items |= importer::FAVORITES;
221 } 221 }
222 222
223 if (prefs.GetBool( 223 if (prefs.GetBool(
224 installer::master_preferences::kMakeChromeDefaultForUser, 224 installer_util::master_preferences::kMakeChromeDefaultForUser,
225 &value) && value) { 225 &value) && value) {
226 out_prefs->make_chrome_default = true; 226 out_prefs->make_chrome_default = true;
227 } 227 }
228 228
229 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run 229 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run
230 // import process. http://crbug.com/49647 230 // import process. http://crbug.com/49647
231 // Note we are skipping all other master preferences if skip-first-run-ui 231 // Note we are skipping all other master preferences if skip-first-run-ui
232 // is *not* specified. (That is, we continue only if skipping first run ui.) 232 // is *not* specified. (That is, we continue only if skipping first run ui.)
233 if (!prefs.GetBool( 233 if (!prefs.GetBool(
234 installer::master_preferences::kDistroSkipFirstRunPref, 234 installer_util::master_preferences::kDistroSkipFirstRunPref,
235 &value) || !value) { 235 &value) || !value) {
236 return true; 236 return true;
237 } 237 }
238 238
239 #if !defined(OS_WIN) 239 #if !defined(OS_WIN)
240 // From here on we won't show first run so we need to do the work to show the 240 // From here on we won't show first run so we need to do the work to show the
241 // bubble anyway, unless it's already been explicitly suppressed. 241 // bubble anyway, unless it's already been explicitly suppressed.
242 FirstRun::SetShowFirstRunBubblePref(true); 242 FirstRun::SetShowFirstRunBubblePref(true);
243 #endif 243 #endif
244 244
245 // We need to be able to create the first run sentinel or else we cannot 245 // We need to be able to create the first run sentinel or else we cannot
246 // proceed because ImportSettings will launch the importer process which 246 // proceed because ImportSettings will launch the importer process which
247 // would end up here if the sentinel is not present. 247 // would end up here if the sentinel is not present.
248 if (!FirstRun::CreateSentinel()) 248 if (!FirstRun::CreateSentinel())
249 return false; 249 return false;
250 250
251 if (prefs.GetBool(installer::master_preferences::kDistroShowWelcomePage, 251 if (prefs.GetBool(installer_util::master_preferences::kDistroShowWelcomePage,
252 &value) && value) { 252 &value) && value) {
253 FirstRun::SetShowWelcomePagePref(); 253 FirstRun::SetShowWelcomePagePref();
254 } 254 }
255 255
256 std::string import_bookmarks_path; 256 std::string import_bookmarks_path;
257 prefs.GetString( 257 prefs.GetString(
258 installer::master_preferences::kDistroImportBookmarksFromFilePref, 258 installer_util::master_preferences::kDistroImportBookmarksFromFilePref,
259 &import_bookmarks_path); 259 &import_bookmarks_path);
260 260
261 #if defined(OS_WIN) 261 #if defined(OS_WIN)
262 std::wstring brand; 262 std::wstring brand;
263 GoogleUpdateSettings::GetBrand(&brand); 263 GoogleUpdateSettings::GetBrand(&brand);
264 // This should generally be true, as skip_first_run_ui is a setting used for 264 // This should generally be true, as skip_first_run_ui is a setting used for
265 // non-organic builds. 265 // non-organic builds.
266 if (!GoogleUpdateSettings::IsOrganic(brand)) { 266 if (!GoogleUpdateSettings::IsOrganic(brand)) {
267 // If search engines aren't explicitly imported, don't import. 267 // If search engines aren't explicitly imported, don't import.
268 if (!(out_prefs->do_import_items & importer::SEARCH_ENGINES)) { 268 if (!(out_prefs->do_import_items & importer::SEARCH_ENGINES)) {
(...skipping 26 matching lines...) Expand all
295 // There are bookmarks to import from a file. 295 // There are bookmarks to import from a file.
296 FilePath path = FilePath::FromWStringHack(UTF8ToWide( 296 FilePath path = FilePath::FromWStringHack(UTF8ToWide(
297 import_bookmarks_path)); 297 import_bookmarks_path));
298 if (!FirstRun::ImportBookmarks(path)) { 298 if (!FirstRun::ImportBookmarks(path)) {
299 LOG(WARNING) << "silent bookmark import failed"; 299 LOG(WARNING) << "silent bookmark import failed";
300 } 300 }
301 } 301 }
302 #endif 302 #endif
303 303
304 if (prefs.GetBool( 304 if (prefs.GetBool(
305 installer::master_preferences::kMakeChromeDefaultForUser, 305 installer_util::master_preferences::kMakeChromeDefaultForUser,
306 &value) && value) { 306 &value) && value) {
307 ShellIntegration::SetAsDefaultBrowser(); 307 ShellIntegration::SetAsDefaultBrowser();
308 } 308 }
309 309
310 return false; 310 return false;
311 } 311 }
312 312
313 // static 313 // static
314 bool FirstRun::IsChromeFirstRun() { 314 bool FirstRun::IsChromeFirstRun() {
315 if (first_run_ != FIRST_RUN_UNKNOWN) 315 if (first_run_ != FIRST_RUN_UNKNOWN)
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (!observer->ended()) { 674 if (!observer->ended()) {
675 observer->set_should_quit_message_loop(); 675 observer->set_should_quit_message_loop();
676 MessageLoop::current()->Run(); 676 MessageLoop::current()->Run();
677 } 677 }
678 678
679 // Unfortunately there's no success/fail signal in ImporterHost. 679 // Unfortunately there's no success/fail signal in ImporterHost.
680 return true; 680 return true;
681 } 681 }
682 682
683 #endif // OS_POSIX 683 #endif // OS_POSIX
OLDNEW
« no previous file with comments | « chrome/browser/browser_main_win.cc ('k') | chrome/browser/first_run/first_run_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698