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" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/memory/weak_ptr.h" | |
12 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
13 #include "chrome/browser/background/background_application_list_model.h" | 14 #include "chrome/browser/background/background_application_list_model.h" |
14 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 15 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
15 #include "chrome/browser/status_icons/status_icon.h" | 16 #include "chrome/browser/status_icons/status_icon.h" |
16 #include "chrome/browser/status_icons/status_icon_menu_model.h" | 17 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
17 #include "chrome/browser/ui/browser_list_observer.h" | 18 #include "chrome/browser/ui/browser_list_observer.h" |
18 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
21 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 107 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
107 DeleteBackgroundProfile); | 108 DeleteBackgroundProfile); |
108 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerWithExtensionsTest, | 109 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerWithExtensionsTest, |
109 BackgroundMenuGeneration); | 110 BackgroundMenuGeneration); |
110 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerWithExtensionsTest, | 111 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerWithExtensionsTest, |
111 BackgroundMenuGenerationMultipleProfile); | 112 BackgroundMenuGenerationMultipleProfile); |
112 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerWithExtensionsTest, | 113 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerWithExtensionsTest, |
113 BalloonDisplay); | 114 BalloonDisplay); |
114 FRIEND_TEST_ALL_PREFIXES(BackgroundAppBrowserTest, | 115 FRIEND_TEST_ALL_PREFIXES(BackgroundAppBrowserTest, |
115 ReloadBackgroundApp); | 116 ReloadBackgroundApp); |
116 | |
Lei Zhang
2015/05/06 21:35:49
Please leave this blank line in.
Pranay
2015/05/07 03:24:46
Done.
| |
117 class BackgroundModeData : public StatusIconMenuModel::Delegate { | 117 class BackgroundModeData : public StatusIconMenuModel::Delegate { |
118 public: | 118 public: |
119 explicit BackgroundModeData( | 119 explicit BackgroundModeData( |
120 Profile* profile, | 120 Profile* profile, |
121 CommandIdExtensionVector* command_id_extension_vector); | 121 CommandIdExtensionVector* command_id_extension_vector); |
122 ~BackgroundModeData() override; | 122 ~BackgroundModeData() override; |
123 | 123 |
124 // The cached list of BackgroundApplications. | 124 // The cached list of BackgroundApplications. |
125 scoped_ptr<BackgroundApplicationListModel> applications_; | 125 scoped_ptr<BackgroundApplicationListModel> applications_; |
126 | 126 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 // which is similar to a shared_ptr. | 188 // which is similar to a shared_ptr. |
189 typedef linked_ptr<BackgroundModeData> BackgroundModeInfo; | 189 typedef linked_ptr<BackgroundModeData> BackgroundModeInfo; |
190 | 190 |
191 typedef std::map<Profile*, BackgroundModeInfo> BackgroundModeInfoMap; | 191 typedef std::map<Profile*, BackgroundModeInfo> BackgroundModeInfoMap; |
192 | 192 |
193 // content::NotificationObserver implementation. | 193 // content::NotificationObserver implementation. |
194 void Observe(int type, | 194 void Observe(int type, |
195 const content::NotificationSource& source, | 195 const content::NotificationSource& source, |
196 const content::NotificationDetails& details) override; | 196 const content::NotificationDetails& details) override; |
197 | 197 |
198 // Called when ExtensionSystem is ready. | |
199 void OnExtensionsReady(); | |
200 | |
198 // Called when the kBackgroundModeEnabled preference changes. | 201 // Called when the kBackgroundModeEnabled preference changes. |
199 void OnBackgroundModeEnabledPrefChanged(); | 202 void OnBackgroundModeEnabledPrefChanged(); |
200 | 203 |
201 // BackgroundApplicationListModel::Observer implementation. | 204 // BackgroundApplicationListModel::Observer implementation. |
202 void OnApplicationDataChanged(const extensions::Extension* extension, | 205 void OnApplicationDataChanged(const extensions::Extension* extension, |
203 Profile* profile) override; | 206 Profile* profile) override; |
204 void OnApplicationListChanged(Profile* profile) override; | 207 void OnApplicationListChanged(Profile* profile) override; |
205 | 208 |
206 // Overrides from ProfileInfoCacheObserver | 209 // Overrides from ProfileInfoCacheObserver |
207 void OnProfileAdded(const base::FilePath& profile_path) override; | 210 void OnProfileAdded(const base::FilePath& profile_path) override; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 // (used for testing background mode without having to install a background | 352 // (used for testing background mode without having to install a background |
350 // app). | 353 // app). |
351 bool keep_alive_for_test_; | 354 bool keep_alive_for_test_; |
352 | 355 |
353 // Set to true when background mode is suspended. | 356 // Set to true when background mode is suspended. |
354 bool background_mode_suspended_; | 357 bool background_mode_suspended_; |
355 | 358 |
356 // Set to true when background mode is keeping Chrome alive. | 359 // Set to true when background mode is keeping Chrome alive. |
357 bool keeping_alive_; | 360 bool keeping_alive_; |
358 | 361 |
362 base::WeakPtrFactory<BackgroundModeManager> weak_factory_; | |
363 | |
359 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 364 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
360 }; | 365 }; |
361 | 366 |
362 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 367 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
OLD | NEW |