| 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 "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 time_taken, | 203 time_taken, |
| 204 base::TimeDelta::FromSeconds(1), | 204 base::TimeDelta::FromSeconds(1), |
| 205 base::TimeDelta::FromMinutes(kDiscoverabilityTimeoutMinutes - 1), | 205 base::TimeDelta::FromMinutes(kDiscoverabilityTimeoutMinutes - 1), |
| 206 10 /* bucket_count */); | 206 10 /* bucket_count */); |
| 207 } | 207 } |
| 208 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHowEnabled", | 208 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHowEnabled", |
| 209 enable_source, | 209 enable_source, |
| 210 AppListService::ENABLE_NUM_ENABLE_SOURCES); | 210 AppListService::ENABLE_NUM_ENABLE_SOURCES); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Checks whether a profile name is valid for the app list. Returns false if the |
| 214 // name is empty, or represents a guest profile. |
| 215 bool IsValidProfileName(const std::string& profile_name) { |
| 216 if (profile_name.empty()) |
| 217 return false; |
| 218 |
| 219 return profile_name != |
| 220 base::FilePath(chrome::kGuestProfileDir).AsUTF8Unsafe(); |
| 221 } |
| 222 |
| 213 } // namespace | 223 } // namespace |
| 214 | 224 |
| 215 void AppListServiceImpl::RecordAppListLaunch() { | 225 void AppListServiceImpl::RecordAppListLaunch() { |
| 216 RecordDailyEventFrequency(prefs::kLastAppListLaunchPing, | 226 RecordDailyEventFrequency(prefs::kLastAppListLaunchPing, |
| 217 prefs::kAppListLaunchCount, | 227 prefs::kAppListLaunchCount, |
| 218 &SendAppListLaunch); | 228 &SendAppListLaunch); |
| 219 RecordAppListDiscoverability(local_state_, false); | 229 RecordAppListDiscoverability(local_state_, false); |
| 220 RecordAppListLastLaunch(); | 230 RecordAppListLastLaunch(); |
| 221 } | 231 } |
| 222 | 232 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 304 |
| 295 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { | 305 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { |
| 296 local_state_->SetString( | 306 local_state_->SetString( |
| 297 prefs::kAppListProfile, | 307 prefs::kAppListProfile, |
| 298 profile_path.BaseName().MaybeAsASCII()); | 308 profile_path.BaseName().MaybeAsASCII()); |
| 299 } | 309 } |
| 300 | 310 |
| 301 void AppListServiceImpl::CreateShortcut() {} | 311 void AppListServiceImpl::CreateShortcut() {} |
| 302 | 312 |
| 303 std::string AppListServiceImpl::GetProfileName() { | 313 std::string AppListServiceImpl::GetProfileName() { |
| 304 const std::string app_list_profile = | 314 std::string app_list_profile = |
| 305 local_state_->GetString(prefs::kAppListProfile); | 315 local_state_->GetString(prefs::kAppListProfile); |
| 306 if (!app_list_profile.empty()) | 316 if (IsValidProfileName(app_list_profile)) |
| 307 return app_list_profile; | 317 return app_list_profile; |
| 308 | 318 |
| 309 // If the user has no profile preference for the app launcher, default to the | 319 // If the user has no profile preference for the app launcher, default to the |
| 310 // last browser profile used. | 320 // last browser profile used. |
| 311 return profile_store_->GetLastUsedProfileName(); | 321 app_list_profile = profile_store_->GetLastUsedProfileName(); |
| 322 if (IsValidProfileName(app_list_profile)) |
| 323 return app_list_profile; |
| 324 |
| 325 // If the last profile used was invalid (ie, guest profile), use the initial |
| 326 // profile. |
| 327 return chrome::kInitialProfile; |
| 312 } | 328 } |
| 313 | 329 |
| 314 void AppListServiceImpl::OnProfileWillBeRemoved( | 330 void AppListServiceImpl::OnProfileWillBeRemoved( |
| 315 const base::FilePath& profile_path) { | 331 const base::FilePath& profile_path) { |
| 316 // We need to watch for profile removal to keep kAppListProfile updated, for | 332 // We need to watch for profile removal to keep kAppListProfile updated, for |
| 317 // the case that the deleted profile is being used by the app list. | 333 // the case that the deleted profile is being used by the app list. |
| 318 std::string app_list_last_profile = local_state_->GetString( | 334 std::string app_list_last_profile = local_state_->GetString( |
| 319 prefs::kAppListProfile); | 335 prefs::kAppListProfile); |
| 320 if (profile_path.BaseName().MaybeAsASCII() != app_list_last_profile) | 336 if (profile_path.BaseName().MaybeAsASCII() != app_list_last_profile) |
| 321 return; | 337 return; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 if (!base::MessageLoop::current()) | 446 if (!base::MessageLoop::current()) |
| 431 return; // In a unit test. | 447 return; // In a unit test. |
| 432 | 448 |
| 433 // Send app list usage stats after a delay. | 449 // Send app list usage stats after a delay. |
| 434 const int kSendUsageStatsDelay = 5; | 450 const int kSendUsageStatsDelay = 5; |
| 435 base::MessageLoop::current()->PostDelayedTask( | 451 base::MessageLoop::current()->PostDelayedTask( |
| 436 FROM_HERE, | 452 FROM_HERE, |
| 437 base::Bind(&AppListServiceImpl::SendAppListStats), | 453 base::Bind(&AppListServiceImpl::SendAppListStats), |
| 438 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 454 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
| 439 } | 455 } |
| OLD | NEW |