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/profile_loader.h"
27 class AppListServiceImplTestApi
;
30 // Parts of the AppListService implementation shared between platforms.
31 class AppListServiceImpl
: public AppListService
,
32 public ProfileInfoCacheObserver
{
34 virtual ~AppListServiceImpl();
36 // Constructor used for testing.
37 AppListServiceImpl(const base::CommandLine
& command_line
,
38 PrefService
* local_state
,
39 scoped_ptr
<ProfileStore
> profile_store
);
41 void RecordAppListLaunch();
42 static void RecordAppListAppLaunch();
44 // AppListService overrides:
45 virtual void SetAppListNextPaintCallback(void (*callback
)()) OVERRIDE
;
46 virtual void HandleFirstRun() OVERRIDE
;
47 virtual void Init(Profile
* initial_profile
) OVERRIDE
;
48 virtual base::FilePath
GetProfilePath(
49 const base::FilePath
& user_data_dir
) OVERRIDE
;
50 virtual void SetProfilePath(const base::FilePath
& profile_path
) OVERRIDE
;
51 virtual void Show() OVERRIDE
;
52 virtual void AutoShowForProfile(Profile
* requested_profile
) OVERRIDE
;
53 virtual void EnableAppList(Profile
* initial_profile
,
54 AppListEnableSource enable_source
) OVERRIDE
;
55 virtual void CreateShortcut() OVERRIDE
;
60 // Destroy the app list. Called when the profile that the app list is showing
62 virtual void DestroyAppList() = 0;
64 void InvalidatePendingProfileLoads();
65 ProfileLoader
& profile_loader() { return *profile_loader_
; }
66 const ProfileLoader
& profile_loader() const { return *profile_loader_
; }
68 // Perform startup checks shared between desktop implementations of the app
69 // list. Currently this checks command line flags to enable or disable the app
70 // list, and records UMA stats delayed from a previous Chrome process.
71 void PerformStartupChecks(Profile
* initial_profile
);
74 friend class test::AppListServiceImplTestApi
;
75 static void SendAppListStats();
77 // Loads a profile asynchronously and calls OnProfileLoaded() when done.
78 void LoadProfileAsync(const base::FilePath
& profile_file_path
);
80 // Callback for asynchronous profile load.
81 void OnProfileLoaded(int profile_load_sequence_id
,
83 Profile::CreateStatus status
);
85 // ProfileInfoCacheObserver overrides:
86 virtual void OnProfileWillBeRemoved(
87 const base::FilePath
& profile_path
) OVERRIDE
;
89 scoped_ptr
<ProfileStore
> profile_store_
;
90 base::CommandLine command_line_
;
91 PrefService
* local_state_
;
92 scoped_ptr
<ProfileLoader
> profile_loader_
;
94 base::WeakPtrFactory
<AppListServiceImpl
> weak_factory_
;
96 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl
);
99 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_