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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 time_taken, | 199 time_taken, |
200 base::TimeDelta::FromSeconds(1), | 200 base::TimeDelta::FromSeconds(1), |
201 base::TimeDelta::FromMinutes(kDiscoverabilityTimeoutMinutes - 1), | 201 base::TimeDelta::FromMinutes(kDiscoverabilityTimeoutMinutes - 1), |
202 10 /* bucket_count */); | 202 10 /* bucket_count */); |
203 } | 203 } |
204 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHowEnabled", | 204 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHowEnabled", |
205 enable_source, | 205 enable_source, |
206 AppListService::ENABLE_NUM_ENABLE_SOURCES); | 206 AppListService::ENABLE_NUM_ENABLE_SOURCES); |
207 } | 207 } |
208 | 208 |
| 209 // Checks whether a profile name is valid for the app list. Returns false if the |
| 210 // name is empty, or represents a guest profile. |
| 211 bool IsValidProfileName(const std::string& profile_name) { |
| 212 if (profile_name.empty()) |
| 213 return false; |
| 214 |
| 215 return profile_name != |
| 216 base::FilePath(chrome::kGuestProfileDir).AsUTF8Unsafe(); |
| 217 } |
| 218 |
209 } // namespace | 219 } // namespace |
210 | 220 |
211 void AppListServiceImpl::RecordAppListLaunch() { | 221 void AppListServiceImpl::RecordAppListLaunch() { |
212 RecordDailyEventFrequency(prefs::kLastAppListLaunchPing, | 222 RecordDailyEventFrequency(prefs::kLastAppListLaunchPing, |
213 prefs::kAppListLaunchCount, | 223 prefs::kAppListLaunchCount, |
214 &SendAppListLaunch); | 224 &SendAppListLaunch); |
215 RecordAppListDiscoverability(local_state_, false); | 225 RecordAppListDiscoverability(local_state_, false); |
216 RecordAppListLastLaunch(); | 226 RecordAppListLastLaunch(); |
217 } | 227 } |
218 | 228 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 void AppListServiceImpl::Init(Profile* initial_profile) {} | 294 void AppListServiceImpl::Init(Profile* initial_profile) {} |
285 | 295 |
286 base::FilePath AppListServiceImpl::GetProfilePath( | 296 base::FilePath AppListServiceImpl::GetProfilePath( |
287 const base::FilePath& user_data_dir) { | 297 const base::FilePath& user_data_dir) { |
288 std::string app_list_profile; | 298 std::string app_list_profile; |
289 if (local_state_->HasPrefPath(prefs::kAppListProfile)) | 299 if (local_state_->HasPrefPath(prefs::kAppListProfile)) |
290 app_list_profile = local_state_->GetString(prefs::kAppListProfile); | 300 app_list_profile = local_state_->GetString(prefs::kAppListProfile); |
291 | 301 |
292 // If the user has no profile preference for the app launcher, default to the | 302 // If the user has no profile preference for the app launcher, default to the |
293 // last browser profile used. | 303 // last browser profile used. |
294 if (app_list_profile.empty() && | 304 if (!IsValidProfileName(app_list_profile) && |
295 local_state_->HasPrefPath(prefs::kProfileLastUsed)) { | 305 local_state_->HasPrefPath(prefs::kProfileLastUsed)) { |
296 app_list_profile = local_state_->GetString(prefs::kProfileLastUsed); | 306 app_list_profile = local_state_->GetString(prefs::kProfileLastUsed); |
297 } | 307 } |
298 | 308 |
299 // If there is no last used profile recorded, use the initial profile. | 309 // If there is no last used profile recorded, use the initial profile. |
300 if (app_list_profile.empty()) | 310 if (!IsValidProfileName(app_list_profile)) |
301 app_list_profile = chrome::kInitialProfile; | 311 app_list_profile = chrome::kInitialProfile; |
302 | 312 |
303 return user_data_dir.AppendASCII(app_list_profile); | 313 return user_data_dir.AppendASCII(app_list_profile); |
304 } | 314 } |
305 | 315 |
306 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { | 316 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { |
307 local_state_->SetString( | 317 local_state_->SetString( |
308 prefs::kAppListProfile, | 318 prefs::kAppListProfile, |
309 profile_path.BaseName().MaybeAsASCII()); | 319 profile_path.BaseName().MaybeAsASCII()); |
310 } | 320 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (!base::MessageLoop::current()) | 440 if (!base::MessageLoop::current()) |
431 return; // In a unit test. | 441 return; // In a unit test. |
432 | 442 |
433 // Send app list usage stats after a delay. | 443 // Send app list usage stats after a delay. |
434 const int kSendUsageStatsDelay = 5; | 444 const int kSendUsageStatsDelay = 5; |
435 base::MessageLoop::current()->PostDelayedTask( | 445 base::MessageLoop::current()->PostDelayedTask( |
436 FROM_HERE, | 446 FROM_HERE, |
437 base::Bind(&AppListServiceImpl::SendAppListStats), | 447 base::Bind(&AppListServiceImpl::SendAppListStats), |
438 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 448 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
439 } | 449 } |
OLD | NEW |