| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // no open windows to allow apps with the "background" permission to run in the | 37 // no open windows to allow apps with the "background" permission to run in the |
| 38 // background. | 38 // background. |
| 39 class BackgroundModeManager | 39 class BackgroundModeManager |
| 40 : public NotificationObserver, | 40 : public NotificationObserver, |
| 41 public menus::SimpleMenuModel::Delegate, | 41 public menus::SimpleMenuModel::Delegate, |
| 42 public BackgroundApplicationListModel::Observer { | 42 public BackgroundApplicationListModel::Observer { |
| 43 public: | 43 public: |
| 44 BackgroundModeManager(Profile* profile, CommandLine* command_line); | 44 BackgroundModeManager(Profile* profile, CommandLine* command_line); |
| 45 virtual ~BackgroundModeManager(); | 45 virtual ~BackgroundModeManager(); |
| 46 | 46 |
| 47 static void RegisterUserPrefs(PrefService* prefs); | |
| 48 | |
| 49 static bool IsBackgroundModeEnabled(const CommandLine* command_line); | 47 static bool IsBackgroundModeEnabled(const CommandLine* command_line); |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 friend class TestBackgroundModeManager; | 50 friend class TestBackgroundModeManager; |
| 53 friend class BackgroundModeManagerTest; | 51 friend class BackgroundModeManagerTest; |
| 54 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 52 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 55 BackgroundAppLoadUnload); | 53 BackgroundAppLoadUnload); |
| 56 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 54 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 57 BackgroundAppInstallUninstall); | 55 BackgroundAppInstallUninstall); |
| 58 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 56 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 88 void OnBackgroundAppUnloaded(); | 86 void OnBackgroundAppUnloaded(); |
| 89 | 87 |
| 90 // Invoked when an extension is installed so we can ensure that | 88 // Invoked when an extension is installed so we can ensure that |
| 91 // launch-on-startup is enabled if appropriate. | 89 // launch-on-startup is enabled if appropriate. |
| 92 void OnBackgroundAppInstalled(); | 90 void OnBackgroundAppInstalled(); |
| 93 | 91 |
| 94 // Invoked when an extension is uninstalled so we can ensure that | 92 // Invoked when an extension is uninstalled so we can ensure that |
| 95 // launch-on-startup is disabled if appropriate. | 93 // launch-on-startup is disabled if appropriate. |
| 96 void OnBackgroundAppUninstalled(); | 94 void OnBackgroundAppUninstalled(); |
| 97 | 95 |
| 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. | 96 // Called to make sure that our launch-on-startup mode is properly set. |
| 105 // (virtual so we can override for tests). | 97 // (virtual so we can override for tests). |
| 106 virtual void EnableLaunchOnStartup(bool should_launch); | 98 virtual void EnableLaunchOnStartup(bool should_launch); |
| 107 | 99 |
| 108 // Invoked to put Chrome in KeepAlive mode - chrome runs in the background | 100 // Invoked to put Chrome in KeepAlive mode - chrome runs in the background |
| 109 // and has a status bar icon. | 101 // and has a status bar icon. |
| 110 void StartBackgroundMode(); | 102 void StartBackgroundMode(); |
| 111 | 103 |
| 112 // Invoked to take Chrome out of KeepAlive mode - chrome stops running in | 104 // Invoked to take Chrome out of KeepAlive mode - chrome stops running in |
| 113 // the background and removes its status bar icon. | 105 // the background and removes its status bar icon. |
| 114 void EndBackgroundMode(); | 106 void EndBackgroundMode(); |
| 115 | 107 |
| 116 // If --no-startup-window is passed, BackgroundModeManager will manually keep | 108 // 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 | 109 // 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 | 110 // longer need to do this (either because the user has chosen to exit chrome |
| 119 // manually, or all apps have been loaded). | 111 // manually, or all apps have been loaded). |
| 120 void EndKeepAliveForStartup(); | 112 void EndKeepAliveForStartup(); |
| 121 | 113 |
| 114 // Return an appropriate name for a Preferences menu entry. Preferences is |
| 115 // sometimes called Options or Settings. |
| 116 string16 GetPreferencesMenuLabel(); |
| 117 |
| 122 // Create a status tray icon to allow the user to shutdown Chrome when running | 118 // Create a status tray icon to allow the user to shutdown Chrome when running |
| 123 // in background mode. Virtual to enable testing. | 119 // in background mode. Virtual to enable testing. |
| 124 virtual void CreateStatusTrayIcon(); | 120 virtual void CreateStatusTrayIcon(); |
| 125 | 121 |
| 126 // Removes the status tray icon because we are exiting background mode. | 122 // Removes the status tray icon because we are exiting background mode. |
| 127 // Virtual to enable testing. | 123 // Virtual to enable testing. |
| 128 virtual void RemoveStatusTrayIcon(); | 124 virtual void RemoveStatusTrayIcon(); |
| 129 | 125 |
| 130 // Updates the status icon's context menu entry corresponding to |extension| | 126 // Updates the status icon's context menu entry corresponding to |extension| |
| 131 // to use the icon associated with |extension| in the | 127 // 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. | 171 // platform doesn't support status icons. |
| 176 StatusTray* status_tray_; | 172 StatusTray* status_tray_; |
| 177 | 173 |
| 178 // Reference to our status icon (if any) - owned by the StatusTray. | 174 // Reference to our status icon (if any) - owned by the StatusTray. |
| 179 StatusIcon* status_icon_; | 175 StatusIcon* status_icon_; |
| 180 | 176 |
| 181 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 177 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
| 182 }; | 178 }; |
| 183 | 179 |
| 184 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ | 180 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ |
| OLD | NEW |