| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 15 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 16 #include "chrome/browser/profiles/profile_loader.h" | 16 #include "chrome/browser/profiles/profile_loader.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_service.h" | 17 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | |
| 19 #include "content/public/browser/notification_registrar.h" | |
| 20 | 18 |
| 21 namespace base { | 19 namespace base { |
| 22 class FilePath; | 20 class FilePath; |
| 23 } | 21 } |
| 24 | 22 |
| 25 namespace content { | |
| 26 class NotificationSource; | |
| 27 class NotificationDetails; | |
| 28 } | |
| 29 | |
| 30 // Parts of the AppListService implementation shared between platforms. | 23 // Parts of the AppListService implementation shared between platforms. |
| 31 class AppListServiceImpl : public AppListService, | 24 class AppListServiceImpl : public AppListService, |
| 32 public ProfileInfoCacheObserver, | 25 public ProfileInfoCacheObserver { |
| 33 public content::NotificationObserver { | |
| 34 public: | 26 public: |
| 35 static void RecordAppListLaunch(); | 27 static void RecordAppListLaunch(); |
| 36 static void RecordAppListAppLaunch(); | 28 static void RecordAppListAppLaunch(); |
| 37 static void SendAppListStats(); | 29 static void SendAppListStats(); |
| 38 | 30 |
| 39 protected: | 31 protected: |
| 40 AppListServiceImpl(); | 32 AppListServiceImpl(); |
| 41 virtual ~AppListServiceImpl(); | 33 virtual ~AppListServiceImpl(); |
| 42 | 34 |
| 43 Profile* profile() const { return profile_; } | 35 Profile* profile() const { return profile_; } |
| 44 void SetProfile(Profile* new_profile); | 36 void SetProfile(Profile* new_profile); |
| 45 void InvalidatePendingProfileLoads(); | 37 void InvalidatePendingProfileLoads(); |
| 46 ProfileLoader& profile_loader() { return profile_loader_; } | 38 ProfileLoader& profile_loader() { return profile_loader_; } |
| 47 const ProfileLoader& profile_loader() const { return profile_loader_; } | 39 const ProfileLoader& profile_loader() const { return profile_loader_; } |
| 48 | 40 |
| 49 // Process command line flags shared between desktop implementations of the | 41 // Process command line flags shared between desktop implementations of the |
| 50 // app list. Currently this allows for enabling or disabling the app list. | 42 // app list. Currently this allows for enabling or disabling the app list. |
| 51 void HandleCommandLineFlags(Profile* initial_profile); | 43 void HandleCommandLineFlags(Profile* initial_profile); |
| 52 | 44 |
| 53 // Create a platform-specific shortcut for the app list. | 45 // Create a platform-specific shortcut for the app list. |
| 54 virtual void CreateShortcut(); | 46 virtual void CreateShortcut(); |
| 55 | 47 |
| 56 // Called in response to observed successful and unsuccessful signin changes. | |
| 57 virtual void OnSigninStatusChanged(); | |
| 58 | |
| 59 // AppListService overrides: | 48 // AppListService overrides: |
| 60 virtual void HandleFirstRun() OVERRIDE; | 49 virtual void HandleFirstRun() OVERRIDE; |
| 61 virtual void Init(Profile* initial_profile) OVERRIDE; | 50 virtual void Init(Profile* initial_profile) OVERRIDE; |
| 62 | 51 |
| 63 // Returns the app list path configured in BrowserProcess::local_state(). | 52 // Returns the app list path configured in BrowserProcess::local_state(). |
| 64 virtual base::FilePath GetProfilePath( | 53 virtual base::FilePath GetProfilePath( |
| 65 const base::FilePath& user_data_dir) OVERRIDE; | 54 const base::FilePath& user_data_dir) OVERRIDE; |
| 66 virtual void SetProfilePath(const base::FilePath& profile_path) OVERRIDE; | 55 virtual void SetProfilePath(const base::FilePath& profile_path) OVERRIDE; |
| 67 virtual void Show() OVERRIDE; | 56 virtual void Show() OVERRIDE; |
| 68 virtual void EnableAppList(Profile* initial_profile) OVERRIDE; | 57 virtual void EnableAppList(Profile* initial_profile) OVERRIDE; |
| 69 virtual AppListControllerDelegate* CreateControllerDelegate() OVERRIDE; | 58 virtual AppListControllerDelegate* CreateControllerDelegate() OVERRIDE; |
| 70 | 59 |
| 71 private: | 60 private: |
| 72 // Loads a profile asynchronously and calls OnProfileLoaded() when done. | 61 // Loads a profile asynchronously and calls OnProfileLoaded() when done. |
| 73 void LoadProfileAsync(const base::FilePath& profile_file_path); | 62 void LoadProfileAsync(const base::FilePath& profile_file_path); |
| 74 | 63 |
| 75 // Callback for asynchronous profile load. | 64 // Callback for asynchronous profile load. |
| 76 void OnProfileLoaded(int profile_load_sequence_id, | 65 void OnProfileLoaded(int profile_load_sequence_id, |
| 77 Profile* profile, | 66 Profile* profile, |
| 78 Profile::CreateStatus status); | 67 Profile::CreateStatus status); |
| 79 | 68 |
| 80 virtual Profile* GetCurrentAppListProfile() OVERRIDE; | 69 virtual Profile* GetCurrentAppListProfile() OVERRIDE; |
| 81 | 70 |
| 82 // ProfileInfoCacheObserver overrides: | 71 // ProfileInfoCacheObserver overrides: |
| 83 virtual void OnProfileWillBeRemoved( | 72 virtual void OnProfileWillBeRemoved( |
| 84 const base::FilePath& profile_path) OVERRIDE; | 73 const base::FilePath& profile_path) OVERRIDE; |
| 85 | 74 |
| 86 // content::NotificationObserver | |
| 87 virtual void Observe(int type, | |
| 88 const content::NotificationSource& source, | |
| 89 const content::NotificationDetails& details) OVERRIDE; | |
| 90 | |
| 91 // The profile the AppList is currently displaying. | 75 // The profile the AppList is currently displaying. |
| 92 Profile* profile_; | 76 Profile* profile_; |
| 93 | 77 |
| 94 // Incremented to indicate that pending profile loads are no longer valid. | 78 // Incremented to indicate that pending profile loads are no longer valid. |
| 95 int profile_load_sequence_id_; | 79 int profile_load_sequence_id_; |
| 96 | 80 |
| 97 // How many profile loads are pending. | 81 // How many profile loads are pending. |
| 98 int pending_profile_loads_; | 82 int pending_profile_loads_; |
| 99 | 83 |
| 100 base::WeakPtrFactory<AppListServiceImpl> weak_factory_; | 84 base::WeakPtrFactory<AppListServiceImpl> weak_factory_; |
| 101 content::NotificationRegistrar registrar_; | |
| 102 | 85 |
| 103 ProfileLoader profile_loader_; | 86 ProfileLoader profile_loader_; |
| 104 | 87 |
| 105 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl); | 88 DISALLOW_COPY_AND_ASSIGN(AppListServiceImpl); |
| 106 }; | 89 }; |
| 107 | 90 |
| 108 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ | 91 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_IMPL_H_ |
| OLD | NEW |