| 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/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return false; | 334 return false; |
| 335 if (!local_state->FindPreference( | 335 if (!local_state->FindPreference( |
| 336 prefs::kAutofillPersonalDataManagerFirstRun)) { | 336 prefs::kAutofillPersonalDataManagerFirstRun)) { |
| 337 local_state->RegisterBooleanPref( | 337 local_state->RegisterBooleanPref( |
| 338 prefs::kAutofillPersonalDataManagerFirstRun, false); | 338 prefs::kAutofillPersonalDataManagerFirstRun, false); |
| 339 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); | 339 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); |
| 340 } | 340 } |
| 341 return true; | 341 return true; |
| 342 } | 342 } |
| 343 | 343 |
| 344 bool SetOEMFirstRunBubblePref() { |
| 345 PrefService* local_state = g_browser_process->local_state(); |
| 346 if (!local_state) |
| 347 return false; |
| 348 if (!local_state->FindPreference(prefs::kShouldUseOEMFirstRunBubble)) { |
| 349 local_state->RegisterBooleanPref(prefs::kShouldUseOEMFirstRunBubble, false); |
| 350 local_state->SetBoolean(prefs::kShouldUseOEMFirstRunBubble, true); |
| 351 } |
| 352 return true; |
| 353 } |
| 354 |
| 355 bool ShouldShowSearchEngineSelector(const TemplateURLService* model) { |
| 356 return model && !model->is_default_search_managed(); |
| 357 } |
| 358 |
| 344 } // namespace first_run | 359 } // namespace first_run |
| 345 | 360 |
| 346 // FirstRun ------------------------------------------------------------------- | 361 // FirstRun ------------------------------------------------------------------- |
| 347 | 362 |
| 348 FirstRun::MasterPrefs::MasterPrefs() | 363 FirstRun::MasterPrefs::MasterPrefs() |
| 349 : ping_delay(0), | 364 : ping_delay(0), |
| 350 homepage_defined(false), | 365 homepage_defined(false), |
| 351 do_import_items(0), | 366 do_import_items(0), |
| 352 dont_import_items(0), | 367 dont_import_items(0), |
| 353 run_search_engine_experiment(false), | 368 run_search_engine_experiment(false), |
| 354 randomize_search_engine_experiment(false), | 369 randomize_search_engine_experiment(false), |
| 355 make_chrome_default(false) { | 370 make_chrome_default(false) { |
| 356 } | 371 } |
| 357 | 372 |
| 358 FirstRun::MasterPrefs::~MasterPrefs() {} | 373 FirstRun::MasterPrefs::~MasterPrefs() {} |
| 359 | 374 |
| 360 // static | 375 // static |
| 361 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, | 376 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, |
| 362 MasterPrefs* out_prefs) { | 377 MasterPrefs* out_prefs) { |
| 363 DCHECK(!user_data_dir.empty()); | 378 DCHECK(!user_data_dir.empty()); |
| 364 | 379 |
| 365 FilePath master_prefs = MasterPrefsPath(); | 380 FilePath master_prefs = first_run::MasterPrefsPath(); |
| 366 if (master_prefs.empty()) | 381 if (master_prefs.empty()) |
| 367 return true; | 382 return true; |
| 368 installer::MasterPreferences prefs(master_prefs); | 383 installer::MasterPreferences prefs(master_prefs); |
| 369 if (!prefs.read_from_file()) | 384 if (!prefs.read_from_file()) |
| 370 return true; | 385 return true; |
| 371 | 386 |
| 372 out_prefs->new_tabs = prefs.GetFirstRunTabs(); | 387 out_prefs->new_tabs = prefs.GetFirstRunTabs(); |
| 373 | 388 |
| 374 bool value = false; | 389 bool value = false; |
| 375 | 390 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) { | 422 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) { |
| 408 VLOG(1) << "EULA : collection consent"; | 423 VLOG(1) << "EULA : collection consent"; |
| 409 GoogleUpdateSettings::SetCollectStatsConsent(true); | 424 GoogleUpdateSettings::SetCollectStatsConsent(true); |
| 410 } | 425 } |
| 411 } | 426 } |
| 412 } | 427 } |
| 413 #endif | 428 #endif |
| 414 | 429 |
| 415 if (prefs.GetBool(installer::master_preferences::kAltFirstRunBubble, | 430 if (prefs.GetBool(installer::master_preferences::kAltFirstRunBubble, |
| 416 &value) && value) { | 431 &value) && value) { |
| 417 FirstRun::SetOEMFirstRunBubblePref(); | 432 first_run::SetOEMFirstRunBubblePref(); |
| 418 } | 433 } |
| 419 | 434 |
| 420 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); | 435 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); |
| 421 if (user_prefs.empty()) | 436 if (user_prefs.empty()) |
| 422 return true; | 437 return true; |
| 423 | 438 |
| 424 // The master prefs are regular prefs so we can just copy the file | 439 // The master prefs are regular prefs so we can just copy the file |
| 425 // to the default place and they just work. | 440 // to the default place and they just work. |
| 426 if (!file_util::CopyFile(master_prefs, user_prefs)) | 441 if (!file_util::CopyFile(master_prefs, user_prefs)) |
| 427 return true; | 442 return true; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 599 } |
| 585 } else { | 600 } else { |
| 586 if (g_browser_process->local_state()->GetBoolean( | 601 if (g_browser_process->local_state()->GetBoolean( |
| 587 prefs::kDefaultBrowserSettingEnabled)) { | 602 prefs::kDefaultBrowserSettingEnabled)) { |
| 588 ShellIntegration::SetAsDefaultBrowser(); | 603 ShellIntegration::SetAsDefaultBrowser(); |
| 589 } | 604 } |
| 590 } | 605 } |
| 591 | 606 |
| 592 return false; | 607 return false; |
| 593 } | 608 } |
| 594 | |
| 595 // static | |
| 596 bool FirstRun::ShouldShowSearchEngineSelector(const TemplateURLService* model) { | |
| 597 return model && !model->is_default_search_managed(); | |
| 598 } | |
| 599 | |
| 600 // static | |
| 601 bool FirstRun::SetOEMFirstRunBubblePref() { | |
| 602 PrefService* local_state = g_browser_process->local_state(); | |
| 603 if (!local_state) | |
| 604 return false; | |
| 605 if (!local_state->FindPreference(prefs::kShouldUseOEMFirstRunBubble)) { | |
| 606 local_state->RegisterBooleanPref(prefs::kShouldUseOEMFirstRunBubble, false); | |
| 607 local_state->SetBoolean(prefs::kShouldUseOEMFirstRunBubble, true); | |
| 608 } | |
| 609 return true; | |
| 610 } | |
| OLD | NEW |