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

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: Merge to head again, previous had unrelated broken win_rel test. 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return false; 394 return false;
395 return file_util::WriteFile(first_run_sentinel, "", 0) != -1; 395 return file_util::WriteFile(first_run_sentinel, "", 0) != -1;
396 } 396 }
397 397
398 std::string GetPingDelayPrefName() { 398 std::string GetPingDelayPrefName() {
399 return base::StringPrintf("%s.%s", 399 return base::StringPrintf("%s.%s",
400 installer::master_preferences::kDistroDict, 400 installer::master_preferences::kDistroDict,
401 installer::master_preferences::kDistroPingDelay); 401 installer::master_preferences::kDistroPingDelay);
402 } 402 }
403 403
404 void RegisterUserPrefs(PrefService* prefs) { 404 void RegisterUserPrefs(PrefServiceSyncable* prefs) {
405 prefs->RegisterIntegerPref(GetPingDelayPrefName().c_str(), 405 prefs->RegisterIntegerPref(GetPingDelayPrefName().c_str(),
406 0, 406 0,
407 PrefService::UNSYNCABLE_PREF); 407 PrefServiceSyncable::UNSYNCABLE_PREF);
408 } 408 }
409 409
410 bool RemoveSentinel() { 410 bool RemoveSentinel() {
411 FilePath first_run_sentinel; 411 FilePath first_run_sentinel;
412 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) 412 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel))
413 return false; 413 return false;
414 return file_util::Delete(first_run_sentinel, false); 414 return file_util::Delete(first_run_sentinel, false);
415 } 415 }
416 416
417 bool SetShowFirstRunBubblePref(FirstRunBubbleOptions show_bubble_option) { 417 bool SetShowFirstRunBubblePref(FirstRunBubbleOptions show_bubble_option) {
418 PrefService* local_state = g_browser_process->local_state(); 418 PrefService* local_state = g_browser_process->local_state();
419 if (!local_state) 419 if (!local_state)
420 return false; 420 return false;
421 if (local_state->GetInteger( 421 if (local_state->GetInteger(
422 prefs::kShowFirstRunBubbleOption) != FIRST_RUN_BUBBLE_SUPPRESS) { 422 prefs::kShowFirstRunBubbleOption) != FIRST_RUN_BUBBLE_SUPPRESS) {
423 // Set the new state as long as the bubble wasn't explicitly suppressed 423 // Set the new state as long as the bubble wasn't explicitly suppressed
424 // already. 424 // already.
425 local_state->SetInteger(prefs::kShowFirstRunBubbleOption, 425 local_state->SetInteger(prefs::kShowFirstRunBubbleOption,
426 show_bubble_option); 426 show_bubble_option);
427 } 427 }
428 return true; 428 return true;
429 } 429 }
430 430
431 bool SetShowWelcomePagePref() { 431 bool SetShowWelcomePagePref() {
432 PrefService* local_state = g_browser_process->local_state(); 432 PrefServiceSimple* local_state = g_browser_process->local_state();
433 if (!local_state) 433 if (!local_state)
434 return false; 434 return false;
435 // TODO(joi): This should happen via browser_prefs::RegisterLocalState().
435 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { 436 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) {
436 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); 437 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false);
437 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); 438 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true);
438 } 439 }
439 return true; 440 return true;
440 } 441 }
441 442
442 bool SetPersonalDataManagerFirstRunPref() { 443 bool SetPersonalDataManagerFirstRunPref() {
443 PrefService* local_state = g_browser_process->local_state(); 444 PrefServiceSimple* local_state = g_browser_process->local_state();
444 if (!local_state) 445 if (!local_state)
445 return false; 446 return false;
446 if (!local_state->FindPreference( 447 if (!local_state->FindPreference(
447 prefs::kAutofillPersonalDataManagerFirstRun)) { 448 prefs::kAutofillPersonalDataManagerFirstRun)) {
449 // TODO(joi): This should happen via browser_prefs::RegisterLocalState().
448 local_state->RegisterBooleanPref( 450 local_state->RegisterBooleanPref(
449 prefs::kAutofillPersonalDataManagerFirstRun, false); 451 prefs::kAutofillPersonalDataManagerFirstRun, false);
450 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); 452 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true);
451 } 453 }
452 return true; 454 return true;
453 } 455 }
454 456
455 void LogFirstRunMetric(FirstRunBubbleMetric metric) { 457 void LogFirstRunMetric(FirstRunBubbleMetric metric) {
456 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, 458 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric,
457 NUM_FIRST_RUN_BUBBLE_METRICS); 459 NUM_FIRST_RUN_BUBBLE_METRICS);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 TemplateURLService* template_url = 700 TemplateURLService* template_url =
699 TemplateURLServiceFactory::GetForProfile(profile); 701 TemplateURLServiceFactory::GetForProfile(profile);
700 if (template_url && template_url->GetDefaultSearchProvider()) 702 if (template_url && template_url->GetDefaultSearchProvider())
701 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); 703 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon();
702 SetShowWelcomePagePref(); 704 SetShowWelcomePagePref();
703 SetPersonalDataManagerFirstRunPref(); 705 SetPersonalDataManagerFirstRunPref();
704 #endif // !defined(USE_AURA) 706 #endif // !defined(USE_AURA)
705 } 707 }
706 708
707 } // namespace first_run 709 } // namespace first_run
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run.h ('k') | chrome/browser/geolocation/chrome_access_token_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698