| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(bool show_bubble) { | 417 bool SetShowFirstRunBubblePref(bool show_bubble) { |
| 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 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble); | 421 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble); |
| 422 return true; | 422 return true; |
| 423 } | 423 } |
| 424 | 424 |
| 425 bool SetShowWelcomePagePref() { | 425 bool SetShowWelcomePagePref() { |
| 426 PrefService* local_state = g_browser_process->local_state(); | 426 PrefServiceSimple* local_state = g_browser_process->local_state(); |
| 427 if (!local_state) | 427 if (!local_state) |
| 428 return false; | 428 return false; |
| 429 // TODO(joi): This should happen via browser_prefs::RegisterLocalState(). |
| 429 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { | 430 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { |
| 430 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); | 431 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); |
| 431 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); | 432 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); |
| 432 } | 433 } |
| 433 return true; | 434 return true; |
| 434 } | 435 } |
| 435 | 436 |
| 436 bool SetPersonalDataManagerFirstRunPref() { | 437 bool SetPersonalDataManagerFirstRunPref() { |
| 437 PrefService* local_state = g_browser_process->local_state(); | 438 PrefServiceSimple* local_state = g_browser_process->local_state(); |
| 438 if (!local_state) | 439 if (!local_state) |
| 439 return false; | 440 return false; |
| 440 if (!local_state->FindPreference( | 441 if (!local_state->FindPreference( |
| 441 prefs::kAutofillPersonalDataManagerFirstRun)) { | 442 prefs::kAutofillPersonalDataManagerFirstRun)) { |
| 443 // TODO(joi): This should happen via browser_prefs::RegisterLocalState(). |
| 442 local_state->RegisterBooleanPref( | 444 local_state->RegisterBooleanPref( |
| 443 prefs::kAutofillPersonalDataManagerFirstRun, false); | 445 prefs::kAutofillPersonalDataManagerFirstRun, false); |
| 444 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); | 446 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); |
| 445 } | 447 } |
| 446 return true; | 448 return true; |
| 447 } | 449 } |
| 448 | 450 |
| 449 void LogFirstRunMetric(FirstRunBubbleMetric metric) { | 451 void LogFirstRunMetric(FirstRunBubbleMetric metric) { |
| 450 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, | 452 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, |
| 451 NUM_FIRST_RUN_BUBBLE_METRICS); | 453 NUM_FIRST_RUN_BUBBLE_METRICS); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 TemplateURLService* template_url = | 692 TemplateURLService* template_url = |
| 691 TemplateURLServiceFactory::GetForProfile(profile); | 693 TemplateURLServiceFactory::GetForProfile(profile); |
| 692 if (template_url && template_url->GetDefaultSearchProvider()) | 694 if (template_url && template_url->GetDefaultSearchProvider()) |
| 693 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 695 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
| 694 SetShowWelcomePagePref(); | 696 SetShowWelcomePagePref(); |
| 695 SetPersonalDataManagerFirstRunPref(); | 697 SetPersonalDataManagerFirstRunPref(); |
| 696 #endif // !defined(USE_AURA) | 698 #endif // !defined(USE_AURA) |
| 697 } | 699 } |
| 698 | 700 |
| 699 } // namespace first_run | 701 } // namespace first_run |
| OLD | NEW |