Chromium Code Reviews| 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" | |
| 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 12 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 16 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 17 #include "components/pref_registry/pref_registry_syncable.h" | 16 #include "components/pref_registry/pref_registry_syncable.h" |
| 17 #include "components/user_manager/user_manager.h" | |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/constants.h" | 22 #include "extensions/common/constants.h" |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 namespace first_run { | 25 namespace first_run { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| (...skipping 32 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_manager::User>(details).ptr() == | 64 DCHECK(content::Details<const user_manager::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 = user_manager::UserManager::Get()->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 new DialogLauncher(ProfileHelper::Get()->GetProfileByUser( |
|
Dmitry Polukhin
2014/08/12 09:03:12
I think it is better to replace with ProfileManag
Nikita (slow)
2014/08/12 09:34:42
Done.
| |
| 100 new DialogLauncher( | 100 user_manager::UserManager::Get()->GetActiveUser())); |
| 101 ProfileHelper::Get()->GetProfileByUser(user_manager->GetActiveUser())); | |
| 102 } | 101 } |
| 103 | 102 |
| 104 void LaunchTutorial() { | 103 void LaunchTutorial() { |
| 105 UMA_HISTOGRAM_BOOLEAN("CrosFirstRun.TutorialLaunched", true); | 104 UMA_HISTOGRAM_BOOLEAN("CrosFirstRun.TutorialLaunched", true); |
| 106 FirstRunController::Start(); | 105 FirstRunController::Start(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace first_run | 108 } // namespace first_run |
| 110 } // namespace chromeos | 109 } // namespace chromeos |
| OLD | NEW |