OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 base::FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); | 243 base::FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); |
244 if (user_prefs.empty()) | 244 if (user_prefs.empty()) |
245 return false; | 245 return false; |
246 | 246 |
247 // The master prefs are regular prefs so we can just copy the file | 247 // The master prefs are regular prefs so we can just copy the file |
248 // to the default place and they just work. | 248 // to the default place and they just work. |
249 return file_util::CopyFile(master_prefs_path, user_prefs); | 249 return file_util::CopyFile(master_prefs_path, user_prefs); |
250 } | 250 } |
251 | 251 |
252 void SetupMasterPrefsFromInstallPrefs( | 252 void SetupMasterPrefsFromInstallPrefs( |
253 MasterPrefs* out_prefs, | 253 const installer::MasterPreferences& install_prefs, |
254 installer::MasterPreferences* install_prefs) { | 254 MasterPrefs* out_prefs) { |
255 bool value = false; | 255 bool value = false; |
256 if (install_prefs->GetBool( | 256 if (install_prefs.GetBool( |
257 installer::master_preferences::kDistroImportSearchPref, &value)) { | 257 installer::master_preferences::kDistroImportSearchPref, &value)) { |
258 if (value) { | 258 if (value) { |
259 out_prefs->do_import_items |= importer::SEARCH_ENGINES; | 259 out_prefs->do_import_items |= importer::SEARCH_ENGINES; |
260 } else { | 260 } else { |
261 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; | 261 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 // If we're suppressing the first-run bubble, set that preference now. | 265 // If we're suppressing the first-run bubble, set that preference now. |
266 // Otherwise, wait until the user has completed first run to set it, so the | 266 // Otherwise, wait until the user has completed first run to set it, so the |
267 // user is guaranteed to see the bubble iff he or she has completed the first | 267 // user is guaranteed to see the bubble iff he or she has completed the first |
268 // run process. | 268 // run process. |
269 if (install_prefs->GetBool( | 269 if (install_prefs.GetBool( |
270 installer::master_preferences::kDistroSuppressFirstRunBubble, | 270 installer::master_preferences::kDistroSuppressFirstRunBubble, |
271 &value) && value) | 271 &value) && value) |
272 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SUPPRESS); | 272 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SUPPRESS); |
273 | 273 |
274 if (install_prefs->GetBool( | 274 if (install_prefs.GetBool( |
275 installer::master_preferences::kDistroImportHistoryPref, | 275 installer::master_preferences::kDistroImportHistoryPref, |
276 &value)) { | 276 &value)) { |
277 if (value) { | 277 if (value) { |
278 out_prefs->do_import_items |= importer::HISTORY; | 278 out_prefs->do_import_items |= importer::HISTORY; |
279 } else { | 279 } else { |
280 out_prefs->dont_import_items |= importer::HISTORY; | 280 out_prefs->dont_import_items |= importer::HISTORY; |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 std::string not_used; | 284 std::string not_used; |
285 out_prefs->homepage_defined = install_prefs->GetString( | 285 out_prefs->homepage_defined = install_prefs.GetString( |
286 prefs::kHomePage, ¬_used); | 286 prefs::kHomePage, ¬_used); |
287 | 287 |
288 if (install_prefs->GetBool( | 288 if (install_prefs.GetBool( |
289 installer::master_preferences::kDistroImportHomePagePref, | 289 installer::master_preferences::kDistroImportHomePagePref, |
290 &value)) { | 290 &value)) { |
291 if (value) { | 291 if (value) { |
292 out_prefs->do_import_items |= importer::HOME_PAGE; | 292 out_prefs->do_import_items |= importer::HOME_PAGE; |
293 } else { | 293 } else { |
294 out_prefs->dont_import_items |= importer::HOME_PAGE; | 294 out_prefs->dont_import_items |= importer::HOME_PAGE; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 // Bookmarks are never imported unless specifically turned on. | 298 // Bookmarks are never imported unless specifically turned on. |
299 if (install_prefs->GetBool( | 299 if (install_prefs.GetBool( |
300 installer::master_preferences::kDistroImportBookmarksPref, | 300 installer::master_preferences::kDistroImportBookmarksPref, |
301 &value)) { | 301 &value)) { |
302 if (value) | 302 if (value) |
303 out_prefs->do_import_items |= importer::FAVORITES; | 303 out_prefs->do_import_items |= importer::FAVORITES; |
304 else | 304 else |
305 out_prefs->dont_import_items |= importer::FAVORITES; | 305 out_prefs->dont_import_items |= importer::FAVORITES; |
306 } | 306 } |
307 | 307 |
308 if (install_prefs->GetBool( | 308 if (install_prefs.GetBool( |
309 installer::master_preferences::kMakeChromeDefaultForUser, | 309 installer::master_preferences::kMakeChromeDefaultForUser, |
310 &value) && value) { | 310 &value) && value) { |
311 out_prefs->make_chrome_default = true; | 311 out_prefs->make_chrome_default = true; |
312 } | 312 } |
313 | 313 |
314 if (install_prefs->GetBool( | 314 if (install_prefs.GetBool( |
315 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, | 315 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, |
316 &value) && value) { | 316 &value) && value) { |
317 out_prefs->suppress_first_run_default_browser_prompt = true; | 317 out_prefs->suppress_first_run_default_browser_prompt = true; |
318 } | 318 } |
| 319 |
| 320 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); |
319 } | 321 } |
320 | 322 |
321 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ | 323 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ |
322 // Even on the first run we only allow for the user choice to take effect if | 324 // Even on the first run we only allow for the user choice to take effect if |
323 // no policy has been set by the admin. | 325 // no policy has been set by the admin. |
324 if (!g_browser_process->local_state()->IsManagedPreference( | 326 if (!g_browser_process->local_state()->IsManagedPreference( |
325 prefs::kDefaultBrowserSettingEnabled)) { | 327 prefs::kDefaultBrowserSettingEnabled)) { |
326 bool value = false; | 328 bool value = false; |
327 if (install_prefs->GetBool( | 329 if (install_prefs->GetBool( |
328 installer::master_preferences::kMakeChromeDefaultForUser, | 330 installer::master_preferences::kMakeChromeDefaultForUser, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 internal::SetRLZPref(out_prefs, install_prefs.get()); | 590 internal::SetRLZPref(out_prefs, install_prefs.get()); |
589 | 591 |
590 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 592 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
591 return EULA_EXIT_NOW; | 593 return EULA_EXIT_NOW; |
592 | 594 |
593 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 595 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
594 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; | 596 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; |
595 | 597 |
596 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 598 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
597 | 599 |
598 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, | 600 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); |
599 install_prefs.get()); | |
600 | 601 |
601 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 602 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
602 internal::SetDefaultBrowser(install_prefs.get()); | 603 internal::SetDefaultBrowser(install_prefs.get()); |
603 | 604 |
604 return DO_FIRST_RUN_TASKS; | 605 return DO_FIRST_RUN_TASKS; |
605 } | 606 } |
606 | 607 |
607 void AutoImport( | 608 void AutoImport( |
608 Profile* profile, | 609 Profile* profile, |
609 bool homepage_defined, | 610 bool homepage_defined, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 if (template_url && template_url->GetDefaultSearchProvider()) | 721 if (template_url && template_url->GetDefaultSearchProvider()) |
721 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 722 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
722 SetShowWelcomePagePref(); | 723 SetShowWelcomePagePref(); |
723 SetPersonalDataManagerFirstRunPref(); | 724 SetPersonalDataManagerFirstRunPref(); |
724 #endif // !defined(USE_AURA) | 725 #endif // !defined(USE_AURA) |
725 | 726 |
726 internal::DoPostImportPlatformSpecificTasks(); | 727 internal::DoPostImportPlatformSpecificTasks(); |
727 } | 728 } |
728 | 729 |
729 } // namespace first_run | 730 } // namespace first_run |
OLD | NEW |