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"
20 class AppListViewDelegate
;
28 class AppListServiceImplTestApi
;
31 // Parts of the AppListService implementation shared between platforms.
32 class AppListServiceImpl
: public AppListService
,
33 public ProfileInfoCacheObserver
{
35 ~AppListServiceImpl() override
;
37 // Constructor used for testing.
38 AppListServiceImpl(const base::CommandLine
& command_line
,
39 PrefService
* local_state
,
40 scoped_ptr
<ProfileStore
> profile_store
);
42 // Lazily create the Chrome AppListViewDelegate and ensure it is set to the
44 AppListViewDelegate
* GetViewDelegate(Profile
* profile
);
46 void RecordAppListLaunch();
47 static void RecordAppListAppLaunch();
48 static void RecordAppListLastLaunch();
50 // AppListService overrides:
51 void SetAppListNextPaintCallback(void (*callback
)()) override
;
52 void Init(Profile
* initial_profile
) override
;
53 base::FilePath
GetProfilePath(const base::FilePath
& user_data_dir
) override
;
54 void SetProfilePath(const base::FilePath
& profile_path
) override
;
56 void ShowForVoiceSearch(
58 const scoped_refptr
<content::SpeechRecognitionSessionPreamble
>& preamble
)
60 void ShowForAppInstall(Profile
* profile
,
61 const std::string
& extension_id
,
62 bool start_discovery_tracking
) override
;
63 void EnableAppList(Profile
* initial_profile
,
64 AppListEnableSource enable_source
) override
;
65 void CreateShortcut() override
;
70 // Create the app list UI, and maintain its state, but do not show it.
71 virtual void CreateForProfile(Profile
* requested_profile
) = 0;
73 // Destroy the app list. Called when the profile that the app list is showing
75 virtual void DestroyAppList() = 0;
77 void InvalidatePendingProfileLoads();
78 ProfileLoader
& profile_loader() { return *profile_loader_
; }
79 const ProfileLoader
& profile_loader() const { return *profile_loader_
; }
81 // Perform startup checks shared between desktop implementations of the app
82 // list. Currently this checks command line flags to enable or disable the app
83 // list, and records UMA stats delayed from a previous Chrome process.
84 void PerformStartupChecks(Profile
* initial_profile
);
87 friend class test::AppListServiceImplTestApi
;
88 static void SendAppListStats();
90 std::string
GetProfileName();
92 // ProfileInfoCacheObserver overrides:
93 void OnProfileWillBeRemoved(const base::FilePath
& profile_path
) override
;
95 scoped_ptr
<ProfileStore
> profile_store_
;
96 base::CommandLine command_line_
;
97 PrefService
* local_state_
;
98 scoped_ptr
<ProfileLoader
> profile_loader_
;
99 scoped_ptr
<AppListViewDelegate
> view_delegate_
;
101 base::WeakPtrFactory
<AppListServiceImpl
> weak_factory_
;
103 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl
);
106 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_