| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/chromeos/first_run/first_run_controller.h" | 9 #include "chrome/browser/chromeos/first_run/first_run_controller.h" |
| 10 #include "chrome/browser/chromeos/login/users/user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual void Observe(int type, | 60 virtual void Observe(int type, |
| 61 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
| 62 const content::NotificationDetails& details) OVERRIDE { | 62 const content::NotificationDetails& details) OVERRIDE { |
| 63 DCHECK(type == chrome::NOTIFICATION_SESSION_STARTED); | 63 DCHECK(type == chrome::NOTIFICATION_SESSION_STARTED); |
| 64 DCHECK(content::Details<const User>(details).ptr() == | 64 DCHECK(content::Details<const User>(details).ptr() == |
| 65 ProfileHelper::Get()->GetUserByProfile(profile_)); | 65 ProfileHelper::Get()->GetUserByProfile(profile_)); |
| 66 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 66 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 67 bool launched_in_test = command_line->HasSwitch(::switches::kTestType); | 67 bool launched_in_test = command_line->HasSwitch(::switches::kTestType); |
| 68 bool launched_in_telemetry = | 68 bool launched_in_telemetry = |
| 69 command_line->HasSwitch(switches::kOobeSkipPostLogin); | 69 command_line->HasSwitch(switches::kOobeSkipPostLogin); |
| 70 bool is_user_new = chromeos::UserManager::Get()->IsCurrentUserNew(); | 70 bool is_user_new = chromeos::GetUserManager()->IsCurrentUserNew(); |
| 71 bool first_run_forced = command_line->HasSwitch(switches::kForceFirstRunUI); | 71 bool first_run_forced = command_line->HasSwitch(switches::kForceFirstRunUI); |
| 72 bool first_run_seen = | 72 bool first_run_seen = |
| 73 profile_->GetPrefs()->GetBoolean(prefs::kFirstRunTutorialShown); | 73 profile_->GetPrefs()->GetBoolean(prefs::kFirstRunTutorialShown); |
| 74 if (!launched_in_telemetry && | 74 if (!launched_in_telemetry && |
| 75 ((is_user_new && !first_run_seen && !launched_in_test) || | 75 ((is_user_new && !first_run_seen && !launched_in_test) || |
| 76 first_run_forced)) { | 76 first_run_forced)) { |
| 77 LaunchDialogForProfile(profile_); | 77 LaunchDialogForProfile(profile_); |
| 78 } | 78 } |
| 79 delete this; | 79 delete this; |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 Profile* profile_; | 83 Profile* profile_; |
| 84 content::NotificationRegistrar registrar_; | 84 content::NotificationRegistrar registrar_; |
| 85 | 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(DialogLauncher); | 86 DISALLOW_COPY_AND_ASSIGN(DialogLauncher); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace | 89 } // namespace |
| 90 | 90 |
| 91 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 91 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 92 registry->RegisterBooleanPref( | 92 registry->RegisterBooleanPref( |
| 93 prefs::kFirstRunTutorialShown, | 93 prefs::kFirstRunTutorialShown, |
| 94 false, | 94 false, |
| 95 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); | 95 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void MaybeLaunchDialogAfterSessionStart() { | 98 void MaybeLaunchDialogAfterSessionStart() { |
| 99 UserManager* user_manager = UserManager::Get(); | 99 UserManager* user_manager = GetUserManager(); |
| 100 new DialogLauncher( | 100 new DialogLauncher( |
| 101 ProfileHelper::Get()->GetProfileByUser(user_manager->GetActiveUser())); | 101 ProfileHelper::Get()->GetProfileByUser(user_manager->GetActiveUser())); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void LaunchTutorial() { | 104 void LaunchTutorial() { |
| 105 UMA_HISTOGRAM_BOOLEAN("CrosFirstRun.TutorialLaunched", true); | 105 UMA_HISTOGRAM_BOOLEAN("CrosFirstRun.TutorialLaunched", true); |
| 106 FirstRunController::Start(); | 106 FirstRunController::Start(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace first_run | 109 } // namespace first_run |
| 110 } // namespace chromeos | 110 } // namespace chromeos |
| OLD | NEW |