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 "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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "apps/pref_names.h" | 9 #include "apps/pref_names.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 } | 277 } |
| 278 | 278 |
| 279 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { | 279 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { |
| 280 local_state_->SetString( | 280 local_state_->SetString( |
| 281 prefs::kAppListProfile, | 281 prefs::kAppListProfile, |
| 282 profile_path.BaseName().MaybeAsASCII()); | 282 profile_path.BaseName().MaybeAsASCII()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void AppListServiceImpl::CreateShortcut() {} | 285 void AppListServiceImpl::CreateShortcut() {} |
| 286 | 286 |
| 287 // We need to watch for profile removal to keep kAppListProfile updated. | |
| 288 void AppListServiceImpl::OnProfileWillBeRemoved( | 287 void AppListServiceImpl::OnProfileWillBeRemoved( |
| 289 const base::FilePath& profile_path) { | 288 const base::FilePath& profile_path) { |
| 290 // If the profile the app list uses just got deleted, reset it to the last | 289 // We need to watch for profile removal to keep kAppListProfile updated, for |
| 291 // used profile. | 290 // the case that the deleted profile is being used by the app list. |
| 292 std::string app_list_last_profile = local_state_->GetString( | 291 std::string app_list_last_profile = local_state_->GetString( |
| 293 prefs::kAppListProfile); | 292 prefs::kAppListProfile); |
| 294 if (profile_path.BaseName().MaybeAsASCII() == app_list_last_profile) { | 293 if (profile_path.BaseName().MaybeAsASCII() != app_list_last_profile) |
| 295 local_state_->SetString(prefs::kAppListProfile, | 294 return; |
| 296 local_state_->GetString(prefs::kProfileLastUsed)); | 295 |
| 297 } | 296 // Before ProfileInfoCache::DeleteProfileFromCache() calls this function, |
|
Matt Giuca
2014/08/25 04:48:46
// Switch the app list over to a valid profile. <f
tapted
2014/08/25 06:17:00
Done.
| |
| 297 // ProfileManager::ScheduleProfileForDeletion() will have checked to see if | |
| 298 // the deleted profile was also "last used", and updated that setting with | |
| 299 // something valid. | |
| 300 local_state_->SetString(prefs::kAppListProfile, | |
| 301 local_state_->GetString(prefs::kProfileLastUsed)); | |
| 302 | |
| 303 // Now, the Chrome AppListViewDelegate needs to be torn down, since it has | |
|
Matt Giuca
2014/08/25 04:48:46
It might be simpler to lay this out as a bullet li
tapted
2014/08/25 06:17:00
Done.
| |
| 304 // many references to the profile and can't be profile-keyed. Note also that | |
| 305 // the last used profile might not be loaded yet, since that's sometimes done | |
|
Matt Giuca
2014/08/25 04:48:46
nit: "sometimes done *by*"
tapted
2014/08/25 06:17:00
Done.
| |
| 306 // ProfileManager asynchronously, so the app list can't just switch to that. | |
| 307 // Currently, the AppListViewDelegate is owned by the platform-specific | |
| 308 // AppListView, so just force-close the window. | |
| 309 DestroyAppList(); | |
| 298 } | 310 } |
| 299 | 311 |
| 300 void AppListServiceImpl::Show() { | 312 void AppListServiceImpl::Show() { |
| 301 profile_loader_->LoadProfileInvalidatingOtherLoads( | 313 profile_loader_->LoadProfileInvalidatingOtherLoads( |
| 302 GetProfilePath(profile_store_->GetUserDataDir()), | 314 GetProfilePath(profile_store_->GetUserDataDir()), |
| 303 base::Bind(&AppListServiceImpl::ShowForProfile, | 315 base::Bind(&AppListServiceImpl::ShowForProfile, |
| 304 weak_factory_.GetWeakPtr())); | 316 weak_factory_.GetWeakPtr())); |
| 305 } | 317 } |
| 306 | 318 |
| 307 void AppListServiceImpl::AutoShowForProfile(Profile* requested_profile) { | 319 void AppListServiceImpl::AutoShowForProfile(Profile* requested_profile) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 if (!base::MessageLoop::current()) | 372 if (!base::MessageLoop::current()) |
| 361 return; // In a unit test. | 373 return; // In a unit test. |
| 362 | 374 |
| 363 // Send app list usage stats after a delay. | 375 // Send app list usage stats after a delay. |
| 364 const int kSendUsageStatsDelay = 5; | 376 const int kSendUsageStatsDelay = 5; |
| 365 base::MessageLoop::current()->PostDelayedTask( | 377 base::MessageLoop::current()->PostDelayedTask( |
| 366 FROM_HERE, | 378 FROM_HERE, |
| 367 base::Bind(&AppListServiceImpl::SendAppListStats), | 379 base::Bind(&AppListServiceImpl::SendAppListStats), |
| 368 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 380 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
| 369 } | 381 } |
| OLD | NEW |