| 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" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/browser_shutdown.h" | 19 #include "chrome/browser/browser_shutdown.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" | 21 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
| 22 #include "chrome/browser/ui/app_list/profile_loader.h" | 22 #include "chrome/browser/ui/app_list/profile_loader.h" |
| 23 #include "chrome/browser/ui/app_list/profile_store.h" | 23 #include "chrome/browser/ui/app_list/profile_store.h" |
| 24 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
| 25 #include "chrome/common/chrome_switches.h" | |
| 26 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 27 #include "ui/app_list/app_list_model.h" | 26 #include "ui/app_list/app_list_model.h" |
| 27 #include "ui/app_list/app_list_switches.h" |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const int kDiscoverabilityTimeoutMinutes = 60; | 31 const int kDiscoverabilityTimeoutMinutes = 60; |
| 32 | 32 |
| 33 void SendAppListAppLaunch(int count) { | 33 void SendAppListAppLaunch(int count) { |
| 34 UMA_HISTOGRAM_CUSTOM_COUNTS( | 34 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 35 "Apps.AppListDailyAppLaunches", count, 1, 1000, 50); | 35 "Apps.AppListDailyAppLaunches", count, 1, 1000, 50); |
| 36 if (count > 0) | 36 if (count > 0) |
| 37 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHasLaunchedAppToday", 1, 2); | 37 UMA_HISTOGRAM_ENUMERATION("Apps.AppListHasLaunchedAppToday", 1, 2); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 430 |
| 431 void AppListServiceImpl::InvalidatePendingProfileLoads() { | 431 void AppListServiceImpl::InvalidatePendingProfileLoads() { |
| 432 profile_loader_->InvalidatePendingProfileLoads(); | 432 profile_loader_->InvalidatePendingProfileLoads(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void AppListServiceImpl::PerformStartupChecks(Profile* initial_profile) { | 435 void AppListServiceImpl::PerformStartupChecks(Profile* initial_profile) { |
| 436 // Except in rare, once-off cases, this just checks that a pref is "0" and | 436 // Except in rare, once-off cases, this just checks that a pref is "0" and |
| 437 // returns. | 437 // returns. |
| 438 RecordAppListDiscoverability(local_state_, true); | 438 RecordAppListDiscoverability(local_state_, true); |
| 439 | 439 |
| 440 if (command_line_.HasSwitch(switches::kResetAppListInstallState)) | 440 if (command_line_.HasSwitch(app_list::switches::kResetAppListInstallState)) |
| 441 local_state_->SetBoolean(prefs::kAppLauncherHasBeenEnabled, false); | 441 local_state_->SetBoolean(prefs::kAppLauncherHasBeenEnabled, false); |
| 442 | 442 |
| 443 if (command_line_.HasSwitch(switches::kEnableAppList)) | 443 if (command_line_.HasSwitch(app_list::switches::kEnableAppList)) |
| 444 EnableAppList(initial_profile, ENABLE_VIA_COMMAND_LINE); | 444 EnableAppList(initial_profile, ENABLE_VIA_COMMAND_LINE); |
| 445 | 445 |
| 446 if (!base::ThreadTaskRunnerHandle::IsSet()) | 446 if (!base::ThreadTaskRunnerHandle::IsSet()) |
| 447 return; // In a unit test. | 447 return; // In a unit test. |
| 448 | 448 |
| 449 // Send app list usage stats after a delay. | 449 // Send app list usage stats after a delay. |
| 450 const int kSendUsageStatsDelay = 5; | 450 const int kSendUsageStatsDelay = 5; |
| 451 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 451 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 452 FROM_HERE, base::Bind(&AppListServiceImpl::SendAppListStats), | 452 FROM_HERE, base::Bind(&AppListServiceImpl::SendAppListStats), |
| 453 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 453 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
| 454 } | 454 } |
| OLD | NEW |