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.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_
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/keep_alive_service.h"
19 #include "chrome/browser/ui/app_list/profile_loader.h"
27 // Parts of the AppListService implementation shared between platforms.
28 class AppListServiceImpl
: public AppListService
,
29 public ProfileInfoCacheObserver
{
31 static void RecordAppListLaunch();
32 static void RecordAppListAppLaunch();
33 virtual ~AppListServiceImpl();
35 // Constructor used for testing.
36 AppListServiceImpl(const CommandLine
& command_line
,
37 PrefService
* local_state
,
38 scoped_ptr
<ProfileStore
> profile_store
,
39 scoped_ptr
<KeepAliveService
> keep_alive_service
);
41 // AppListService overrides:
42 virtual void SetAppListNextPaintCallback(void (*callback
)()) OVERRIDE
;
43 virtual void HandleFirstRun() OVERRIDE
;
44 virtual void Init(Profile
* initial_profile
) OVERRIDE
;
45 virtual base::FilePath
GetProfilePath(
46 const base::FilePath
& user_data_dir
) OVERRIDE
;
47 virtual void SetProfilePath(const base::FilePath
& profile_path
) OVERRIDE
;
48 virtual void Show() OVERRIDE
;
49 virtual void EnableAppList(Profile
* initial_profile
) OVERRIDE
;
54 void InvalidatePendingProfileLoads();
55 ProfileLoader
& profile_loader() { return *profile_loader_
; }
56 const ProfileLoader
& profile_loader() const { return *profile_loader_
; }
58 // Process command line flags shared between desktop implementations of the
59 // app list. Currently this allows for enabling or disabling the app list.
60 void HandleCommandLineFlags(Profile
* initial_profile
);
62 // Records UMA stats that try to approximate usage after a delay.
63 void SendUsageStats();
65 // Create a platform-specific shortcut for the app list.
66 virtual void CreateShortcut();
69 static void SendAppListStats();
71 // Loads a profile asynchronously and calls OnProfileLoaded() when done.
72 void LoadProfileAsync(const base::FilePath
& profile_file_path
);
74 // Callback for asynchronous profile load.
75 void OnProfileLoaded(int profile_load_sequence_id
,
77 Profile::CreateStatus status
);
79 // ProfileInfoCacheObserver overrides:
80 virtual void OnProfileWillBeRemoved(
81 const base::FilePath
& profile_path
) OVERRIDE
;
83 scoped_ptr
<ProfileStore
> profile_store_
;
84 base::WeakPtrFactory
<AppListServiceImpl
> weak_factory_
;
85 CommandLine command_line_
;
86 PrefService
* local_state_
;
87 scoped_ptr
<ProfileLoader
> profile_loader_
;
89 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl
);
92 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_