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/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/prefs/public/pref_observer.h" |
12 #include "chrome/browser/background/background_application_list_model.h" | 13 #include "chrome/browser/background/background_application_list_model.h" |
13 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 14 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
14 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
15 #include "chrome/browser/status_icons/status_icon.h" | 16 #include "chrome/browser/status_icons/status_icon.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "ui/base/models/simple_menu_model.h" | 19 #include "ui/base/models/simple_menu_model.h" |
19 | 20 |
20 class Browser; | 21 class Browser; |
21 class CommandLine; | 22 class CommandLine; |
(...skipping 18 matching lines...) Expand all Loading... |
40 // | 41 // |
41 // When Chrome is in background mode, it will continue running even after the | 42 // When Chrome is in background mode, it will continue running even after the |
42 // last browser window is closed, until the user explicitly exits the app. | 43 // last browser window is closed, until the user explicitly exits the app. |
43 // Additionally, when in background mode, Chrome will launch on OS login with | 44 // Additionally, when in background mode, Chrome will launch on OS login with |
44 // no open windows to allow apps with the "background" permission to run in the | 45 // no open windows to allow apps with the "background" permission to run in the |
45 // background. | 46 // background. |
46 class BackgroundModeManager | 47 class BackgroundModeManager |
47 : public content::NotificationObserver, | 48 : public content::NotificationObserver, |
48 public BackgroundApplicationListModel::Observer, | 49 public BackgroundApplicationListModel::Observer, |
49 public ProfileInfoCacheObserver, | 50 public ProfileInfoCacheObserver, |
| 51 public PrefObserver, |
50 public ui::SimpleMenuModel::Delegate { | 52 public ui::SimpleMenuModel::Delegate { |
51 public: | 53 public: |
52 BackgroundModeManager(CommandLine* command_line, | 54 BackgroundModeManager(CommandLine* command_line, |
53 ProfileInfoCache* profile_cache); | 55 ProfileInfoCache* profile_cache); |
54 virtual ~BackgroundModeManager(); | 56 virtual ~BackgroundModeManager(); |
55 | 57 |
56 static void RegisterPrefs(PrefService* prefs); | 58 static void RegisterPrefs(PrefService* prefs); |
57 | 59 |
58 virtual void RegisterProfile(Profile* profile); | 60 virtual void RegisterProfile(Profile* profile); |
59 | 61 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // which is similar to a shared_ptr. | 153 // which is similar to a shared_ptr. |
152 typedef linked_ptr<BackgroundModeData> BackgroundModeInfo; | 154 typedef linked_ptr<BackgroundModeData> BackgroundModeInfo; |
153 | 155 |
154 typedef std::map<Profile*, BackgroundModeInfo> BackgroundModeInfoMap; | 156 typedef std::map<Profile*, BackgroundModeInfo> BackgroundModeInfoMap; |
155 | 157 |
156 // content::NotificationObserver implementation. | 158 // content::NotificationObserver implementation. |
157 virtual void Observe(int type, | 159 virtual void Observe(int type, |
158 const content::NotificationSource& source, | 160 const content::NotificationSource& source, |
159 const content::NotificationDetails& details) OVERRIDE; | 161 const content::NotificationDetails& details) OVERRIDE; |
160 | 162 |
| 163 // PrefObserver implementation. |
| 164 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 165 const std::string& pref_name) OVERRIDE; |
| 166 |
161 // Called when the kBackgroundModeEnabled preference changes. | 167 // Called when the kBackgroundModeEnabled preference changes. |
162 void OnBackgroundModeEnabledPrefChanged(); | 168 void OnBackgroundModeEnabledPrefChanged(); |
163 | 169 |
164 // BackgroundApplicationListModel::Observer implementation. | 170 // BackgroundApplicationListModel::Observer implementation. |
165 virtual void OnApplicationDataChanged(const extensions::Extension* extension, | 171 virtual void OnApplicationDataChanged(const extensions::Extension* extension, |
166 Profile* profile) OVERRIDE; | 172 Profile* profile) OVERRIDE; |
167 virtual void OnApplicationListChanged(Profile* profile) OVERRIDE; | 173 virtual void OnApplicationListChanged(Profile* profile) OVERRIDE; |
168 | 174 |
169 // Overrides from ProfileInfoCacheObserver | 175 // Overrides from ProfileInfoCacheObserver |
170 virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE; | 176 virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // app). | 309 // app). |
304 bool keep_alive_for_test_; | 310 bool keep_alive_for_test_; |
305 | 311 |
306 // Provides a command id for each profile as they are created. | 312 // Provides a command id for each profile as they are created. |
307 int current_command_id_; | 313 int current_command_id_; |
308 | 314 |
309 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 315 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
310 }; | 316 }; |
311 | 317 |
312 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 318 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
OLD | NEW |