app_list_service_impl.h revision 0529e5d033099cbfc42635f6f6183833b09dff6e
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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ 6#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/command_line.h" 12#include "base/compiler_specific.h" 13#include "base/memory/scoped_ptr.h" 14#include "base/memory/weak_ptr.h" 15#include "chrome/browser/profiles/profile.h" 16#include "chrome/browser/profiles/profile_info_cache_observer.h" 17#include "chrome/browser/ui/app_list/app_list_service.h" 18#include "chrome/browser/ui/app_list/profile_loader.h" 19 20class ProfileStore; 21 22namespace base { 23class FilePath; 24} 25 26// Parts of the AppListService implementation shared between platforms. 27class AppListServiceImpl : public AppListService, 28 public ProfileInfoCacheObserver { 29 public: 30 virtual ~AppListServiceImpl(); 31 32 // Constructor used for testing. 33 AppListServiceImpl(const base::CommandLine& command_line, 34 PrefService* local_state, 35 scoped_ptr<ProfileStore> profile_store); 36 37 void RecordAppListLaunch(); 38 static void RecordAppListAppLaunch(); 39 40 // AppListService overrides: 41 virtual void SetAppListNextPaintCallback(void (*callback)()) OVERRIDE; 42 virtual void HandleFirstRun() OVERRIDE; 43 virtual void Init(Profile* initial_profile) OVERRIDE; 44 virtual base::FilePath GetProfilePath( 45 const base::FilePath& user_data_dir) OVERRIDE; 46 virtual void SetProfilePath(const base::FilePath& profile_path) OVERRIDE; 47 virtual void Show() OVERRIDE; 48 virtual void AutoShowForProfile(Profile* requested_profile) OVERRIDE; 49 virtual void EnableAppList(Profile* initial_profile, 50 AppListEnableSource enable_source) OVERRIDE; 51 52 protected: 53 AppListServiceImpl(); 54 55 void InvalidatePendingProfileLoads(); 56 ProfileLoader& profile_loader() { return *profile_loader_; } 57 const ProfileLoader& profile_loader() const { return *profile_loader_; } 58 59 // Perform startup checks shared between desktop implementations of the app 60 // list. Currently this checks command line flags to enable or disable the app 61 // list, and records UMA stats delayed from a previous Chrome process. 62 void PerformStartupChecks(Profile* initial_profile); 63 64 // Create a platform-specific shortcut for the app list. 65 virtual void CreateShortcut(); 66 67 private: 68 static void SendAppListStats(); 69 70 // Loads a profile asynchronously and calls OnProfileLoaded() when done. 71 void LoadProfileAsync(const base::FilePath& profile_file_path); 72 73 // Callback for asynchronous profile load. 74 void OnProfileLoaded(int profile_load_sequence_id, 75 Profile* profile, 76 Profile::CreateStatus status); 77 78 // ProfileInfoCacheObserver overrides: 79 virtual void OnProfileWillBeRemoved( 80 const base::FilePath& profile_path) OVERRIDE; 81 82 scoped_ptr<ProfileStore> profile_store_; 83 base::WeakPtrFactory<AppListServiceImpl> weak_factory_; 84 base::CommandLine command_line_; 85 PrefService* local_state_; 86 scoped_ptr<ProfileLoader> profile_loader_; 87 88 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl); 89}; 90 91#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ 92