| 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/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/background/background_application_list_model.h" | 13 #include "chrome/browser/background/background_application_list_model.h" |
| 14 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 14 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 15 #include "chrome/browser/status_icons/status_icon.h" | 15 #include "chrome/browser/status_icons/status_icon.h" |
| 16 #include "chrome/browser/status_icons/status_icon_menu_model.h" | 16 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
| 17 #include "chrome/browser/ui/browser_list_observer.h" | 17 #include "chrome/browser/ui/browser_list_observer.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 21 | 21 |
| 22 class Browser; | 22 class Browser; |
| 23 class CommandLine; | |
| 24 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
| 25 class Profile; | 24 class Profile; |
| 26 class ProfileInfoCache; | 25 class ProfileInfoCache; |
| 27 class StatusIcon; | 26 class StatusIcon; |
| 28 class StatusTray; | 27 class StatusTray; |
| 29 | 28 |
| 29 namespace base { |
| 30 class CommandLine; |
| 31 } |
| 32 |
| 30 namespace extensions { | 33 namespace extensions { |
| 31 class Extension; | 34 class Extension; |
| 32 } | 35 } |
| 33 | 36 |
| 34 typedef std::vector<int> CommandIdExtensionVector; | 37 typedef std::vector<int> CommandIdExtensionVector; |
| 35 | 38 |
| 36 // BackgroundModeManager is responsible for switching Chrome into and out of | 39 // BackgroundModeManager is responsible for switching Chrome into and out of |
| 37 // "background mode" and for providing UI for the user to exit Chrome when there | 40 // "background mode" and for providing UI for the user to exit Chrome when there |
| 38 // are no open browser windows. | 41 // are no open browser windows. |
| 39 // | 42 // |
| 40 // Chrome enters background mode whenever there is an application with the | 43 // Chrome enters background mode whenever there is an application with the |
| 41 // "background" permission installed. This class monitors the set of | 44 // "background" permission installed. This class monitors the set of |
| 42 // installed/loaded extensions to ensure that Chrome enters/exits background | 45 // installed/loaded extensions to ensure that Chrome enters/exits background |
| 43 // mode at the appropriate time. | 46 // mode at the appropriate time. |
| 44 // | 47 // |
| 45 // When Chrome is in background mode, it will continue running even after the | 48 // When Chrome is in background mode, it will continue running even after the |
| 46 // last browser window is closed, until the user explicitly exits the app. | 49 // last browser window is closed, until the user explicitly exits the app. |
| 47 // Additionally, when in background mode, Chrome will launch on OS login with | 50 // Additionally, when in background mode, Chrome will launch on OS login with |
| 48 // no open windows to allow apps with the "background" permission to run in the | 51 // no open windows to allow apps with the "background" permission to run in the |
| 49 // background. | 52 // background. |
| 50 class BackgroundModeManager | 53 class BackgroundModeManager |
| 51 : public content::NotificationObserver, | 54 : public content::NotificationObserver, |
| 52 public chrome::BrowserListObserver, | 55 public chrome::BrowserListObserver, |
| 53 public BackgroundApplicationListModel::Observer, | 56 public BackgroundApplicationListModel::Observer, |
| 54 public ProfileInfoCacheObserver, | 57 public ProfileInfoCacheObserver, |
| 55 public StatusIconMenuModel::Delegate { | 58 public StatusIconMenuModel::Delegate { |
| 56 public: | 59 public: |
| 57 BackgroundModeManager(CommandLine* command_line, | 60 BackgroundModeManager(base::CommandLine* command_line, |
| 58 ProfileInfoCache* profile_cache); | 61 ProfileInfoCache* profile_cache); |
| 59 virtual ~BackgroundModeManager(); | 62 virtual ~BackgroundModeManager(); |
| 60 | 63 |
| 61 static void RegisterPrefs(PrefRegistrySimple* registry); | 64 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 62 | 65 |
| 63 virtual void RegisterProfile(Profile* profile); | 66 virtual void RegisterProfile(Profile* profile); |
| 64 | 67 |
| 65 static void LaunchBackgroundApplication(Profile* profile, | 68 static void LaunchBackgroundApplication(Profile* profile, |
| 66 const extensions::Extension* extension); | 69 const extensions::Extension* extension); |
| 67 | 70 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // Set to true when background mode is suspended. | 341 // Set to true when background mode is suspended. |
| 339 bool background_mode_suspended_; | 342 bool background_mode_suspended_; |
| 340 | 343 |
| 341 // Set to true when background mode is keeping Chrome alive. | 344 // Set to true when background mode is keeping Chrome alive. |
| 342 bool keeping_alive_; | 345 bool keeping_alive_; |
| 343 | 346 |
| 344 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 347 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
| 345 }; | 348 }; |
| 346 | 349 |
| 347 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 350 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
| OLD | NEW |