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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 8 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
OLDNEW
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
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 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { 539 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) {
540 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); 540 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false);
Mattias Nissler (ping if slow) 2012/12/19 19:50:22 random note: this should happen via browser_prefs:
Jói 2012/12/20 16:30:31 Added TODO.
541 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); 541 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true);
542 } 542 }
543 return true; 543 return true;
544 } 544 }
545 545
546 bool SetPersonalDataManagerFirstRunPref() { 546 bool SetPersonalDataManagerFirstRunPref() {
547 PrefService* local_state = g_browser_process->local_state(); 547 PrefServiceSimple* local_state = g_browser_process->local_state();
548 if (!local_state) 548 if (!local_state)
549 return false; 549 return false;
550 if (!local_state->FindPreference( 550 if (!local_state->FindPreference(
551 prefs::kAutofillPersonalDataManagerFirstRun)) { 551 prefs::kAutofillPersonalDataManagerFirstRun)) {
552 local_state->RegisterBooleanPref( 552 local_state->RegisterBooleanPref(
Mattias Nissler (ping if slow) 2012/12/19 19:50:22 same here.
Jói 2012/12/20 16:30:31 Added TODO.
553 prefs::kAutofillPersonalDataManagerFirstRun, false); 553 prefs::kAutofillPersonalDataManagerFirstRun, false);
554 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); 554 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true);
555 } 555 }
556 return true; 556 return true;
557 } 557 }
558 558
559 void LogFirstRunMetric(FirstRunBubbleMetric metric) { 559 void LogFirstRunMetric(FirstRunBubbleMetric metric) {
560 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, 560 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric,
561 NUM_FIRST_RUN_BUBBLE_METRICS); 561 NUM_FIRST_RUN_BUBBLE_METRICS);
562 } 562 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 return SKIP_FIRST_RUN; 683 return SKIP_FIRST_RUN;
684 684
685 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); 685 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get());
686 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); 686 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get());
687 internal::SetDefaultBrowser(install_prefs.get()); 687 internal::SetDefaultBrowser(install_prefs.get());
688 688
689 return SKIP_FIRST_RUN; 689 return SKIP_FIRST_RUN;
690 } 690 }
691 691
692 } // namespace first_run 692 } // namespace first_run
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698