| 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 "chrome/browser/ui/app_list/app_list_service.h" | 5 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 base::Time GetOriginalProcessStartTime(const base::CommandLine& command_line) { | 37 base::Time GetOriginalProcessStartTime(const base::CommandLine& command_line) { |
| 38 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { | 38 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { |
| 39 std::string start_time_string = | 39 std::string start_time_string = |
| 40 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); | 40 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); |
| 41 int64_t remote_start_time; | 41 int64_t remote_start_time; |
| 42 base::StringToInt64(start_time_string, &remote_start_time); | 42 base::StringToInt64(start_time_string, &remote_start_time); |
| 43 return base::Time::FromInternalValue(remote_start_time); | 43 return base::Time::FromInternalValue(remote_start_time); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // base::CurrentProcessInfo::CreationTime() is only defined on some | |
| 47 // platforms. | |
| 48 #if defined(OS_LINUX) | |
| 49 return base::CurrentProcessInfo::CreationTime(); | 46 return base::CurrentProcessInfo::CreationTime(); |
| 50 #else | |
| 51 return base::Time(); | |
| 52 #endif | |
| 53 } | 47 } |
| 54 | 48 |
| 55 StartupType GetStartupType(const base::CommandLine& command_line) { | 49 StartupType GetStartupType(const base::CommandLine& command_line) { |
| 56 // The presence of kOriginalProcessStartTime implies that another process | 50 // The presence of kOriginalProcessStartTime implies that another process |
| 57 // has sent us its command line to handle, ie: we are already running. | 51 // has sent us its command line to handle, ie: we are already running. |
| 58 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { | 52 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { |
| 59 return command_line.HasSwitch(switches::kFastStart) ? | 53 return command_line.HasSwitch(switches::kFastStart) ? |
| 60 WARM_START_FAST : WARM_START; | 54 WARM_START_FAST : WARM_START; |
| 61 } | 55 } |
| 62 return COLD_START; | 56 return COLD_START; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0); | 136 registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0); |
| 143 registry->RegisterIntegerPref(prefs::kAppListLaunchCount, 0); | 137 registry->RegisterIntegerPref(prefs::kAppListLaunchCount, 0); |
| 144 registry->RegisterInt64Pref(prefs::kLastAppListAppLaunchPing, 0); | 138 registry->RegisterInt64Pref(prefs::kLastAppListAppLaunchPing, 0); |
| 145 registry->RegisterIntegerPref(prefs::kAppListAppLaunchCount, 0); | 139 registry->RegisterIntegerPref(prefs::kAppListAppLaunchCount, 0); |
| 146 registry->RegisterStringPref(prefs::kAppListProfile, std::string()); | 140 registry->RegisterStringPref(prefs::kAppListProfile, std::string()); |
| 147 registry->RegisterBooleanPref(prefs::kAppLauncherHasBeenEnabled, false); | 141 registry->RegisterBooleanPref(prefs::kAppLauncherHasBeenEnabled, false); |
| 148 registry->RegisterIntegerPref(prefs::kAppListEnableMethod, | 142 registry->RegisterIntegerPref(prefs::kAppListEnableMethod, |
| 149 ENABLE_NOT_RECORDED); | 143 ENABLE_NOT_RECORDED); |
| 150 registry->RegisterInt64Pref(prefs::kAppListEnableTime, 0); | 144 registry->RegisterInt64Pref(prefs::kAppListEnableTime, 0); |
| 151 | 145 |
| 152 #if defined(OS_MACOSX) | |
| 153 registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0); | |
| 154 #endif | |
| 155 | |
| 156 // Identifies whether we should show the app launcher promo or not. This | 146 // Identifies whether we should show the app launcher promo or not. This |
| 157 // becomes false when the user dismisses the promo. | 147 // becomes false when the user dismisses the promo. |
| 158 registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); | 148 registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); |
| 159 } | 149 } |
| 160 | 150 |
| 161 // static | 151 // static |
| 162 bool AppListService::HandleLaunchCommandLine( | 152 bool AppListService::HandleLaunchCommandLine( |
| 163 const base::CommandLine& command_line, | 153 const base::CommandLine& command_line, |
| 164 Profile* launch_profile) { | 154 Profile* launch_profile) { |
| 165 InitAll(launch_profile, launch_profile->GetPath()); | 155 InitAll(launch_profile, launch_profile->GetPath()); |
| 166 if (!command_line.HasSwitch(switches::kShowAppList)) | 156 if (!command_line.HasSwitch(switches::kShowAppList)) |
| 167 return false; | 157 return false; |
| 168 | 158 |
| 169 AppListService* service = Get(); | 159 AppListService* service = Get(); |
| 170 DCHECK(service); | 160 DCHECK(service); |
| 171 RecordStartupInfo(service, command_line, launch_profile); | 161 RecordStartupInfo(service, command_line, launch_profile); |
| 172 service->ShowForProfile(launch_profile); | 162 service->ShowForProfile(launch_profile); |
| 173 return true; | 163 return true; |
| 174 } | 164 } |
| OLD | NEW |