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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 return false; | 504 return false; |
505 return file_util::WriteFile(first_run_sentinel, "", 0) != -1; | 505 return file_util::WriteFile(first_run_sentinel, "", 0) != -1; |
506 } | 506 } |
507 | 507 |
508 std::string GetPingDelayPrefName() { | 508 std::string GetPingDelayPrefName() { |
509 return base::StringPrintf("%s.%s", | 509 return base::StringPrintf("%s.%s", |
510 installer::master_preferences::kDistroDict, | 510 installer::master_preferences::kDistroDict, |
511 installer::master_preferences::kDistroPingDelay); | 511 installer::master_preferences::kDistroPingDelay); |
512 } | 512 } |
513 | 513 |
514 void RegisterUserPrefs(PrefService* prefs) { | 514 void RegisterUserPrefs(PrefServiceSyncable* prefs) { |
515 prefs->RegisterIntegerPref(GetPingDelayPrefName().c_str(), | 515 prefs->RegisterIntegerPref(GetPingDelayPrefName().c_str(), |
516 0, | 516 0, |
517 PrefService::UNSYNCABLE_PREF); | 517 PrefServiceSyncable::UNSYNCABLE_PREF); |
518 } | 518 } |
519 | 519 |
520 bool RemoveSentinel() { | 520 bool RemoveSentinel() { |
521 FilePath first_run_sentinel; | 521 FilePath first_run_sentinel; |
522 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) | 522 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) |
523 return false; | 523 return false; |
524 return file_util::Delete(first_run_sentinel, false); | 524 return file_util::Delete(first_run_sentinel, false); |
525 } | 525 } |
526 | 526 |
527 bool SetShowFirstRunBubblePref(bool show_bubble) { | 527 bool SetShowFirstRunBubblePref(bool show_bubble) { |
528 PrefService* local_state = g_browser_process->local_state(); | 528 PrefService* local_state = g_browser_process->local_state(); |
529 if (!local_state) | 529 if (!local_state) |
530 return false; | 530 return false; |
531 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble); | 531 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble); |
532 return true; | 532 return true; |
533 } | 533 } |
534 | 534 |
535 bool SetShowWelcomePagePref() { | 535 bool SetShowWelcomePagePref() { |
536 PrefService* local_state = g_browser_process->local_state(); | 536 PrefServiceSimple* local_state = g_browser_process->local_state(); |
537 if (!local_state) | 537 if (!local_state) |
538 return false; | 538 return false; |
| 539 // TODO(joi): This should happen via browser_prefs::RegisterLocalState(). |
539 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { | 540 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { |
540 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); | 541 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); |
541 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); | 542 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); |
542 } | 543 } |
543 return true; | 544 return true; |
544 } | 545 } |
545 | 546 |
546 bool SetPersonalDataManagerFirstRunPref() { | 547 bool SetPersonalDataManagerFirstRunPref() { |
547 PrefService* local_state = g_browser_process->local_state(); | 548 PrefServiceSimple* local_state = g_browser_process->local_state(); |
548 if (!local_state) | 549 if (!local_state) |
549 return false; | 550 return false; |
550 if (!local_state->FindPreference( | 551 if (!local_state->FindPreference( |
551 prefs::kAutofillPersonalDataManagerFirstRun)) { | 552 prefs::kAutofillPersonalDataManagerFirstRun)) { |
| 553 // TODO(joi): This should happen via browser_prefs::RegisterLocalState(). |
552 local_state->RegisterBooleanPref( | 554 local_state->RegisterBooleanPref( |
553 prefs::kAutofillPersonalDataManagerFirstRun, false); | 555 prefs::kAutofillPersonalDataManagerFirstRun, false); |
554 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); | 556 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); |
555 } | 557 } |
556 return true; | 558 return true; |
557 } | 559 } |
558 | 560 |
559 void LogFirstRunMetric(FirstRunBubbleMetric metric) { | 561 void LogFirstRunMetric(FirstRunBubbleMetric metric) { |
560 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, | 562 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, |
561 NUM_FIRST_RUN_BUBBLE_METRICS); | 563 NUM_FIRST_RUN_BUBBLE_METRICS); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return SKIP_FIRST_RUN; | 685 return SKIP_FIRST_RUN; |
684 | 686 |
685 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); | 687 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); |
686 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 688 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
687 internal::SetDefaultBrowser(install_prefs.get()); | 689 internal::SetDefaultBrowser(install_prefs.get()); |
688 | 690 |
689 return SKIP_FIRST_RUN; | 691 return SKIP_FIRST_RUN; |
690 } | 692 } |
691 | 693 |
692 } // namespace first_run | 694 } // namespace first_run |
OLD | NEW |