app_list_service_impl.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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/compiler_specific.h" 12#include "base/memory/scoped_ptr.h" 13#include "base/memory/weak_ptr.h" 14#include "chrome/browser/profiles/profile.h" 15#include "chrome/browser/profiles/profile_info_cache_observer.h" 16#include "chrome/browser/profiles/profile_loader.h" 17#include "chrome/browser/ui/app_list/app_list_service.h" 18 19namespace base { 20class FilePath; 21} 22 23// Parts of the AppListService implementation shared between platforms. 24class AppListServiceImpl : public AppListService, 25 public ProfileInfoCacheObserver { 26 public: 27 static void RecordAppListLaunch(); 28 static void RecordAppListAppLaunch(); 29 static void SendAppListStats(); 30 31 protected: 32 AppListServiceImpl(); 33 virtual ~AppListServiceImpl(); 34 35 Profile* profile() const { return profile_; } 36 void SetProfile(Profile* new_profile); 37 void InvalidatePendingProfileLoads(); 38 ProfileLoader& profile_loader() { return profile_loader_; } 39 const ProfileLoader& profile_loader() const { return profile_loader_; } 40 41 // Process command line flags shared between desktop implementations of the 42 // app list. Currently this allows for enabling or disabling the app list. 43 void HandleCommandLineFlags(Profile* initial_profile); 44 45 // Create a platform-specific shortcut for the app list. 46 virtual void CreateShortcut(); 47 48 // AppListService overrides: 49 virtual void SetAppListNextPaintCallback( 50 const base::Closure& callback) OVERRIDE; 51 virtual void HandleFirstRun() OVERRIDE; 52 virtual void Init(Profile* initial_profile) OVERRIDE; 53 54 // Returns the app list path configured in BrowserProcess::local_state(). 55 virtual base::FilePath GetProfilePath( 56 const base::FilePath& user_data_dir) OVERRIDE; 57 virtual void SetProfilePath(const base::FilePath& profile_path) OVERRIDE; 58 virtual void Show() OVERRIDE; 59 virtual void EnableAppList(Profile* initial_profile) OVERRIDE; 60 61 private: 62 // Loads a profile asynchronously and calls OnProfileLoaded() when done. 63 void LoadProfileAsync(const base::FilePath& profile_file_path); 64 65 // Callback for asynchronous profile load. 66 void OnProfileLoaded(int profile_load_sequence_id, 67 Profile* profile, 68 Profile::CreateStatus status); 69 70 virtual Profile* GetCurrentAppListProfile() OVERRIDE; 71 72 // ProfileInfoCacheObserver overrides: 73 virtual void OnProfileWillBeRemoved( 74 const base::FilePath& profile_path) OVERRIDE; 75 76 // The profile the AppList is currently displaying. 77 Profile* profile_; 78 79 // Incremented to indicate that pending profile loads are no longer valid. 80 int profile_load_sequence_id_; 81 82 // How many profile loads are pending. 83 int pending_profile_loads_; 84 85 base::WeakPtrFactory<AppListServiceImpl> weak_factory_; 86 87 ProfileLoader profile_loader_; 88 89 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl); 90}; 91 92#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ 93