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_impl.h" | 5 #include "chrome/browser/ui/app_list/app_list_service_impl.h" |
6 | 6 |
7 #include "apps/pref_names.h" | 7 #include "apps/pref_names.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 20 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 void SendAppListAppLaunch(int count) { | 25 void SendAppListAppLaunch(int count) { |
25 UMA_HISTOGRAM_CUSTOM_COUNTS( | 26 UMA_HISTOGRAM_CUSTOM_COUNTS( |
26 "Apps.AppListDailyAppLaunches", count, 1, 1000, 50); | 27 "Apps.AppListDailyAppLaunches", count, 1, 1000, 50); |
27 if (count > 0) | 28 if (count > 0) |
28 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHasLaunchedAppToday", 1, 2); | 29 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHasLaunchedAppToday", 1, 2); |
29 } | 30 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 Profile* AppListServiceImpl::GetCurrentAppListProfile() { | 193 Profile* AppListServiceImpl::GetCurrentAppListProfile() { |
193 return profile(); | 194 return profile(); |
194 } | 195 } |
195 | 196 |
196 void AppListServiceImpl::SetProfile(Profile* new_profile) { | 197 void AppListServiceImpl::SetProfile(Profile* new_profile) { |
197 registrar_.RemoveAll(); | 198 registrar_.RemoveAll(); |
198 profile_ = new_profile; | 199 profile_ = new_profile; |
199 if (!profile_) | 200 if (!profile_) |
200 return; | 201 return; |
201 | 202 |
| 203 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 204 content::NotificationService::AllSources()); |
202 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, | 205 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
203 content::Source<Profile>(profile_)); | 206 content::Source<Profile>(profile_)); |
204 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, | 207 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, |
205 content::Source<Profile>(profile_)); | 208 content::Source<Profile>(profile_)); |
206 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 209 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
207 content::Source<Profile>(profile_)); | 210 content::Source<Profile>(profile_)); |
208 } | 211 } |
209 | 212 |
210 void AppListServiceImpl::InvalidatePendingProfileLoads() { | 213 void AppListServiceImpl::InvalidatePendingProfileLoads() { |
211 profile_loader_.InvalidatePendingProfileLoads(); | 214 profile_loader_.InvalidatePendingProfileLoads(); |
212 } | 215 } |
213 | 216 |
| 217 void AppListServiceImpl::ShowForProfileAtIndex(size_t index) { |
| 218 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 219 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 220 if (index >= cache.GetNumberOfProfiles()) { |
| 221 NOTREACHED(); |
| 222 return; |
| 223 } |
| 224 base::FilePath profile_path = cache.GetPathOfProfileAtIndex(index); |
| 225 profile_loader().LoadProfileInvalidatingOtherLoads( |
| 226 profile_path, |
| 227 base::Bind(&AppListServiceImpl::ShowForProfile, |
| 228 weak_factory_.GetWeakPtr())); |
| 229 } |
| 230 |
214 void AppListServiceImpl::HandleCommandLineFlags(Profile* initial_profile) { | 231 void AppListServiceImpl::HandleCommandLineFlags(Profile* initial_profile) { |
215 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppList)) | 232 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppList)) |
216 EnableAppList(initial_profile); | 233 EnableAppList(initial_profile); |
217 | 234 |
218 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAppList)) | 235 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAppList)) |
219 SetAppListEnabledPreference(false); | 236 SetAppListEnabledPreference(false); |
220 } | 237 } |
OLD | NEW |