Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_MODE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ | 6 #define CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/menus/simple_menu_model.h" | 9 #include "app/menus/simple_menu_model.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/task.h" | |
|
Andrew T Wilson (Slow)
2010/12/04 18:49:48
Remove this #include.
The wrong rickcam account
2010/12/07 22:59:57
Done.
| |
| 11 #include "chrome/browser/background_application_list_model.h" | 12 #include "chrome/browser/background_application_list_model.h" |
| 12 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/status_icons/status_icon.h" | 14 #include "chrome/browser/status_icons/status_icon.h" |
| 14 #include "chrome/common/notification_observer.h" | 15 #include "chrome/common/notification_observer.h" |
| 15 #include "chrome/common/notification_registrar.h" | 16 #include "chrome/common/notification_registrar.h" |
| 16 | 17 |
| 17 class Browser; | 18 class Browser; |
| 18 class CommandLine; | 19 class CommandLine; |
| 19 class Extension; | 20 class Extension; |
| 20 class PrefService; | 21 class PrefService; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 37 // no open windows to allow apps with the "background" permission to run in the | 38 // no open windows to allow apps with the "background" permission to run in the |
| 38 // background. | 39 // background. |
| 39 class BackgroundModeManager | 40 class BackgroundModeManager |
| 40 : public NotificationObserver, | 41 : public NotificationObserver, |
| 41 public menus::SimpleMenuModel::Delegate, | 42 public menus::SimpleMenuModel::Delegate, |
| 42 public BackgroundApplicationListModel::Observer { | 43 public BackgroundApplicationListModel::Observer { |
| 43 public: | 44 public: |
| 44 BackgroundModeManager(Profile* profile, CommandLine* command_line); | 45 BackgroundModeManager(Profile* profile, CommandLine* command_line); |
| 45 virtual ~BackgroundModeManager(); | 46 virtual ~BackgroundModeManager(); |
| 46 | 47 |
| 47 static void RegisterUserPrefs(PrefService* prefs); | |
| 48 | |
| 49 static bool IsBackgroundModeEnabled(const CommandLine* command_line); | 48 static bool IsBackgroundModeEnabled(const CommandLine* command_line); |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 friend class TestBackgroundModeManager; | 51 friend class TestBackgroundModeManager; |
| 53 friend class BackgroundModeManagerTest; | 52 friend class BackgroundModeManagerTest; |
| 54 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 53 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 55 BackgroundAppLoadUnload); | 54 BackgroundAppLoadUnload); |
| 56 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 55 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 57 BackgroundAppInstallUninstall); | 56 BackgroundAppInstallUninstall); |
| 58 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 57 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 88 void OnBackgroundAppUnloaded(); | 87 void OnBackgroundAppUnloaded(); |
| 89 | 88 |
| 90 // Invoked when an extension is installed so we can ensure that | 89 // Invoked when an extension is installed so we can ensure that |
| 91 // launch-on-startup is enabled if appropriate. | 90 // launch-on-startup is enabled if appropriate. |
| 92 void OnBackgroundAppInstalled(); | 91 void OnBackgroundAppInstalled(); |
| 93 | 92 |
| 94 // Invoked when an extension is uninstalled so we can ensure that | 93 // Invoked when an extension is uninstalled so we can ensure that |
| 95 // launch-on-startup is disabled if appropriate. | 94 // launch-on-startup is disabled if appropriate. |
| 96 void OnBackgroundAppUninstalled(); | 95 void OnBackgroundAppUninstalled(); |
| 97 | 96 |
| 98 // Returns true if chrome has set "launch on startup" property for itself | |
| 99 // earlier and is allowed to reset it later, reducing likelihood of | |
| 100 // overriding user choices. | |
| 101 bool IsLaunchOnStartupResetAllowed(); | |
| 102 void SetLaunchOnStartupResetAllowed(bool allowed); | |
| 103 | |
| 104 // Called to make sure that our launch-on-startup mode is properly set. | 97 // Called to make sure that our launch-on-startup mode is properly set. |
| 105 // (virtual so we can override for tests). | 98 // (virtual so we can override for tests). |
| 106 virtual void EnableLaunchOnStartup(bool should_launch); | 99 virtual void EnableLaunchOnStartup(bool should_launch); |
| 107 | 100 |
| 108 // Invoked to put Chrome in KeepAlive mode - chrome runs in the background | 101 // Invoked to put Chrome in KeepAlive mode - chrome runs in the background |
| 109 // and has a status bar icon. | 102 // and has a status bar icon. |
| 110 void StartBackgroundMode(); | 103 void StartBackgroundMode(); |
| 111 | 104 |
| 112 // Invoked to take Chrome out of KeepAlive mode - chrome stops running in | 105 // Invoked to take Chrome out of KeepAlive mode - chrome stops running in |
| 113 // the background and removes its status bar icon. | 106 // the background and removes its status bar icon. |
| 114 void EndBackgroundMode(); | 107 void EndBackgroundMode(); |
| 115 | 108 |
| 116 // If --no-startup-window is passed, BackgroundModeManager will manually keep | 109 // If --no-startup-window is passed, BackgroundModeManager will manually keep |
| 117 // chrome running while waiting for apps to load. This is called when we no | 110 // chrome running while waiting for apps to load. This is called when we no |
| 118 // longer need to do this (either because the user has chosen to exit chrome | 111 // longer need to do this (either because the user has chosen to exit chrome |
| 119 // manually, or all apps have been loaded). | 112 // manually, or all apps have been loaded). |
| 120 void EndKeepAliveForStartup(); | 113 void EndKeepAliveForStartup(); |
| 121 | 114 |
| 115 // Return an appropriate name for a Preferences menu entry. Preferences is | |
| 116 // sometimes called Options or Settings. | |
| 117 string16 GetPreferencesMenuLabel(); | |
| 118 | |
| 122 // Create a status tray icon to allow the user to shutdown Chrome when running | 119 // Create a status tray icon to allow the user to shutdown Chrome when running |
| 123 // in background mode. Virtual to enable testing. | 120 // in background mode. Virtual to enable testing. |
| 124 virtual void CreateStatusTrayIcon(); | 121 virtual void CreateStatusTrayIcon(); |
| 125 | 122 |
| 126 // Removes the status tray icon because we are exiting background mode. | 123 // Removes the status tray icon because we are exiting background mode. |
| 127 // Virtual to enable testing. | 124 // Virtual to enable testing. |
| 128 virtual void RemoveStatusTrayIcon(); | 125 virtual void RemoveStatusTrayIcon(); |
| 129 | 126 |
| 130 // Updates the status icon's context menu entry corresponding to |extension| | 127 // Updates the status icon's context menu entry corresponding to |extension| |
| 131 // to use the icon associated with |extension| in the | 128 // to use the icon associated with |extension| in the |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 // platform doesn't support status icons. | 172 // platform doesn't support status icons. |
| 176 StatusTray* status_tray_; | 173 StatusTray* status_tray_; |
| 177 | 174 |
| 178 // Reference to our status icon (if any) - owned by the StatusTray. | 175 // Reference to our status icon (if any) - owned by the StatusTray. |
| 179 StatusIcon* status_icon_; | 176 StatusIcon* status_icon_; |
| 180 | 177 |
| 181 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 178 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
| 182 }; | 179 }; |
| 183 | 180 |
| 184 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ | 181 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ |
| OLD | NEW |