| 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/browser_process.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/chromeos/first_run/first_run_controller.h" | 10 #include "chrome/browser/chromeos/first_run/first_run_controller.h" |
| 10 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 14 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "chromeos/chromeos_switches.h" | 17 #include "chromeos/chromeos_switches.h" |
| 17 #include "components/pref_registry/pref_registry_syncable.h" | 18 #include "components/pref_registry/pref_registry_syncable.h" |
| 19 #include "components/user_manager/user_manager.h" |
| 18 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 21 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 23 | 25 |
| 24 namespace chromeos { | 26 namespace chromeos { |
| 25 namespace first_run { | 27 namespace first_run { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| 61 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 62 const content::NotificationDetails& details) OVERRIDE { | 64 const content::NotificationDetails& details) OVERRIDE { |
| 63 DCHECK(type == chrome::NOTIFICATION_SESSION_STARTED); | 65 DCHECK(type == chrome::NOTIFICATION_SESSION_STARTED); |
| 64 DCHECK(content::Details<const user_manager::User>(details).ptr() == | 66 DCHECK(content::Details<const user_manager::User>(details).ptr() == |
| 65 ProfileHelper::Get()->GetUserByProfile(profile_)); | 67 ProfileHelper::Get()->GetUserByProfile(profile_)); |
| 66 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 68 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 67 bool launched_in_test = command_line->HasSwitch(::switches::kTestType); | 69 bool launched_in_test = command_line->HasSwitch(::switches::kTestType); |
| 68 bool launched_in_telemetry = | 70 bool launched_in_telemetry = |
| 69 command_line->HasSwitch(switches::kOobeSkipPostLogin); | 71 command_line->HasSwitch(switches::kOobeSkipPostLogin); |
| 70 bool is_user_new = chromeos::UserManager::Get()->IsCurrentUserNew(); | 72 bool is_user_new = user_manager::UserManager::Get()->IsCurrentUserNew(); |
| 71 bool first_run_forced = command_line->HasSwitch(switches::kForceFirstRunUI); | 73 bool first_run_forced = command_line->HasSwitch(switches::kForceFirstRunUI); |
| 72 bool first_run_seen = | 74 bool first_run_seen = |
| 73 profile_->GetPrefs()->GetBoolean(prefs::kFirstRunTutorialShown); | 75 profile_->GetPrefs()->GetBoolean(prefs::kFirstRunTutorialShown); |
| 74 if (!launched_in_telemetry && | 76 if (!launched_in_telemetry && |
| 75 ((is_user_new && !first_run_seen && !launched_in_test) || | 77 ((is_user_new && !first_run_seen && !launched_in_test) || |
| 76 first_run_forced)) { | 78 first_run_forced)) { |
| 77 LaunchDialogForProfile(profile_); | 79 LaunchDialogForProfile(profile_); |
| 78 } | 80 } |
| 79 delete this; | 81 delete this; |
| 80 } | 82 } |
| 81 | 83 |
| 82 private: | 84 private: |
| 83 Profile* profile_; | 85 Profile* profile_; |
| 84 content::NotificationRegistrar registrar_; | 86 content::NotificationRegistrar registrar_; |
| 85 | 87 |
| 86 DISALLOW_COPY_AND_ASSIGN(DialogLauncher); | 88 DISALLOW_COPY_AND_ASSIGN(DialogLauncher); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 } // namespace | 91 } // namespace |
| 90 | 92 |
| 91 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 93 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 92 registry->RegisterBooleanPref( | 94 registry->RegisterBooleanPref( |
| 93 prefs::kFirstRunTutorialShown, | 95 prefs::kFirstRunTutorialShown, |
| 94 false, | 96 false, |
| 95 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); | 97 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void MaybeLaunchDialogAfterSessionStart() { | 100 void MaybeLaunchDialogAfterSessionStart() { |
| 99 UserManager* user_manager = UserManager::Get(); | |
| 100 new DialogLauncher(ProfileHelper::Get()->GetProfileByUserUnsafe( | 101 new DialogLauncher(ProfileHelper::Get()->GetProfileByUserUnsafe( |
| 101 user_manager->GetActiveUser())); | 102 user_manager::UserManager::Get()->GetActiveUser())); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void LaunchTutorial() { | 105 void LaunchTutorial() { |
| 105 UMA_HISTOGRAM_BOOLEAN("CrosFirstRun.TutorialLaunched", true); | 106 UMA_HISTOGRAM_BOOLEAN("CrosFirstRun.TutorialLaunched", true); |
| 106 FirstRunController::Start(); | 107 FirstRunController::Start(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace first_run | 110 } // namespace first_run |
| 110 } // namespace chromeos | 111 } // namespace chromeos |
| OLD | NEW |