OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 friend class AppBackgroundPageApiTest; | 67 friend class AppBackgroundPageApiTest; |
68 friend class BackgroundModeManagerTest; | 68 friend class BackgroundModeManagerTest; |
69 friend class TestBackgroundModeManager; | 69 friend class TestBackgroundModeManager; |
70 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 70 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
71 BackgroundAppLoadUnload); | 71 BackgroundAppLoadUnload); |
72 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 72 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
73 BackgroundLaunchOnStartup); | 73 BackgroundLaunchOnStartup); |
74 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 74 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
75 BackgroundAppInstallUninstallWhileDisabled); | 75 BackgroundAppInstallUninstallWhileDisabled); |
76 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 76 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 77 BackgroundModeDisabledPreventsKeepAliveOnStartup); |
| 78 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 79 DisableBackgroundModeUnderTestFlag); |
| 80 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
77 EnableAfterBackgroundAppInstall); | 81 EnableAfterBackgroundAppInstall); |
78 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 82 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
79 MultiProfile); | 83 MultiProfile); |
80 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 84 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
81 ProfileInfoCacheStorage); | 85 ProfileInfoCacheStorage); |
82 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 86 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
83 ProfileInfoCacheObserver); | 87 ProfileInfoCacheObserver); |
84 | 88 |
85 class BackgroundModeData : public ui::SimpleMenuModel::Delegate { | 89 class BackgroundModeData : public ui::SimpleMenuModel::Delegate { |
86 public: | 90 public: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // which is similar to a shared_ptr. | 151 // which is similar to a shared_ptr. |
148 typedef linked_ptr<BackgroundModeData> BackgroundModeInfo; | 152 typedef linked_ptr<BackgroundModeData> BackgroundModeInfo; |
149 | 153 |
150 typedef std::map<Profile*, BackgroundModeInfo> BackgroundModeInfoMap; | 154 typedef std::map<Profile*, BackgroundModeInfo> BackgroundModeInfoMap; |
151 | 155 |
152 // content::NotificationObserver implementation. | 156 // content::NotificationObserver implementation. |
153 virtual void Observe(int type, | 157 virtual void Observe(int type, |
154 const content::NotificationSource& source, | 158 const content::NotificationSource& source, |
155 const content::NotificationDetails& details) OVERRIDE; | 159 const content::NotificationDetails& details) OVERRIDE; |
156 | 160 |
| 161 // Called when the kBackgroundModeEnabled preference changes. |
| 162 void OnBackgroundModeEnabledPrefChanged(); |
| 163 |
157 // BackgroundApplicationListModel::Observer implementation. | 164 // BackgroundApplicationListModel::Observer implementation. |
158 virtual void OnApplicationDataChanged(const extensions::Extension* extension, | 165 virtual void OnApplicationDataChanged(const extensions::Extension* extension, |
159 Profile* profile) OVERRIDE; | 166 Profile* profile) OVERRIDE; |
160 virtual void OnApplicationListChanged(Profile* profile) OVERRIDE; | 167 virtual void OnApplicationListChanged(Profile* profile) OVERRIDE; |
161 | 168 |
162 // Overrides from ProfileInfoCacheObserver | 169 // Overrides from ProfileInfoCacheObserver |
163 virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE; | 170 virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE; |
164 virtual void OnProfileWillBeRemoved(const FilePath& profile_path) OVERRIDE; | 171 virtual void OnProfileWillBeRemoved(const FilePath& profile_path) OVERRIDE; |
165 virtual void OnProfileWasRemoved(const FilePath& profile_path, | 172 virtual void OnProfileWasRemoved(const FilePath& profile_path, |
166 const string16& profile_name) OVERRIDE; | 173 const string16& profile_name) OVERRIDE; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // Turns on background mode if it's currently disabled. | 256 // Turns on background mode if it's currently disabled. |
250 void EnableBackgroundMode(); | 257 void EnableBackgroundMode(); |
251 | 258 |
252 // Returns the number of background apps in the system (virtual to allow | 259 // Returns the number of background apps in the system (virtual to allow |
253 // overriding in unit tests). | 260 // overriding in unit tests). |
254 virtual int GetBackgroundAppCount() const; | 261 virtual int GetBackgroundAppCount() const; |
255 | 262 |
256 // Returns the number of background apps for a profile. | 263 // Returns the number of background apps for a profile. |
257 virtual int GetBackgroundAppCountForProfile(Profile* const profile) const; | 264 virtual int GetBackgroundAppCountForProfile(Profile* const profile) const; |
258 | 265 |
| 266 // Returns true if we should be in background mode. |
| 267 bool ShouldBeInBackgroundMode() const; |
| 268 |
259 // Reference to the profile info cache. It is used to update the background | 269 // Reference to the profile info cache. It is used to update the background |
260 // app status of profiles when they open/close background apps. | 270 // app status of profiles when they open/close background apps. |
261 ProfileInfoCache* profile_cache_; | 271 ProfileInfoCache* profile_cache_; |
262 | 272 |
263 // Registrars for managing our change observers. | 273 // Registrars for managing our change observers. |
264 content::NotificationRegistrar registrar_; | 274 content::NotificationRegistrar registrar_; |
265 PrefChangeRegistrar pref_registrar_; | 275 PrefChangeRegistrar pref_registrar_; |
266 | 276 |
267 // The profile-keyed data for this background mode manager. Keyed on profile. | 277 // The profile-keyed data for this background mode manager. Keyed on profile. |
268 BackgroundModeInfoMap background_mode_data_; | 278 BackgroundModeInfoMap background_mode_data_; |
(...skipping 24 matching lines...) Expand all Loading... |
293 // app). | 303 // app). |
294 bool keep_alive_for_test_; | 304 bool keep_alive_for_test_; |
295 | 305 |
296 // Provides a command id for each profile as they are created. | 306 // Provides a command id for each profile as they are created. |
297 int current_command_id_; | 307 int current_command_id_; |
298 | 308 |
299 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 309 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
300 }; | 310 }; |
301 | 311 |
302 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 312 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
OLD | NEW |