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" | |
| 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 21 matching lines...) Expand all Loading... | |
| 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 static void RegisterUserPrefs(PrefService* prefs); |
| 48 | 49 |
| 49 static bool IsBackgroundModeEnabled(const CommandLine* command_line); | 50 static bool IsBackgroundModeEnabled(const CommandLine* command_line); |
| 50 | 51 |
| 51 private: | 52 private: |
| 53 class DisableLaunchOnStartupTask : public Task { | |
| 54 public: | |
| 55 explicit DisableLaunchOnStartupTask(BackgroundModeManager* manager) | |
| 56 : manager_(manager) { | |
|
Andrew T Wilson (Slow)
2010/12/03 02:06:59
I'm really nervous about passing the BackgroundMod
The wrong rickcam account
2010/12/04 02:08:04
Done. I've pushed the EnableLaunchOnStartup defin
| |
| 57 } | |
| 58 virtual void Run(); | |
| 59 private: | |
| 60 BackgroundModeManager* manager_; | |
| 61 }; | |
| 62 | |
| 63 class EnableLaunchOnStartupTask : public Task { | |
| 64 public: | |
| 65 explicit EnableLaunchOnStartupTask(BackgroundModeManager* manager) | |
| 66 : manager_(manager) { | |
| 67 } | |
| 68 virtual void Run(); | |
| 69 private: | |
| 70 BackgroundModeManager* manager_; | |
| 71 }; | |
| 72 | |
| 52 friend class TestBackgroundModeManager; | 73 friend class TestBackgroundModeManager; |
| 53 friend class BackgroundModeManagerTest; | 74 friend class BackgroundModeManagerTest; |
| 54 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 75 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 55 BackgroundAppLoadUnload); | 76 BackgroundAppLoadUnload); |
| 56 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 77 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 57 BackgroundAppInstallUninstall); | 78 BackgroundAppInstallUninstall); |
| 58 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 79 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 59 BackgroundPrefDisabled); | 80 BackgroundPrefDisabled); |
| 60 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, | 81 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, |
| 61 BackgroundPrefDynamicDisable); | 82 BackgroundPrefDynamicDisable); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 // Invoked to take Chrome out of KeepAlive mode - chrome stops running in | 133 // Invoked to take Chrome out of KeepAlive mode - chrome stops running in |
| 113 // the background and removes its status bar icon. | 134 // the background and removes its status bar icon. |
| 114 void EndBackgroundMode(); | 135 void EndBackgroundMode(); |
| 115 | 136 |
| 116 // If --no-startup-window is passed, BackgroundModeManager will manually keep | 137 // 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 | 138 // 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 | 139 // longer need to do this (either because the user has chosen to exit chrome |
| 119 // manually, or all apps have been loaded). | 140 // manually, or all apps have been loaded). |
| 120 void EndKeepAliveForStartup(); | 141 void EndKeepAliveForStartup(); |
| 121 | 142 |
| 143 // Add a Preferences (or Options, or Settings) entry to the Status Icon's | |
| 144 // context menu. | |
| 145 void AddPreferencesItem(menus::SimpleMenuModel* menu); | |
| 146 | |
| 122 // Create a status tray icon to allow the user to shutdown Chrome when running | 147 // Create a status tray icon to allow the user to shutdown Chrome when running |
| 123 // in background mode. Virtual to enable testing. | 148 // in background mode. Virtual to enable testing. |
| 124 virtual void CreateStatusTrayIcon(); | 149 virtual void CreateStatusTrayIcon(); |
| 125 | 150 |
| 126 // Removes the status tray icon because we are exiting background mode. | 151 // Removes the status tray icon because we are exiting background mode. |
| 127 // Virtual to enable testing. | 152 // Virtual to enable testing. |
| 128 virtual void RemoveStatusTrayIcon(); | 153 virtual void RemoveStatusTrayIcon(); |
| 129 | 154 |
| 130 // Updates the status icon's context menu entry corresponding to |extension| | 155 // Updates the status icon's context menu entry corresponding to |extension| |
| 131 // to use the icon associated with |extension| in the | 156 // 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. | 200 // platform doesn't support status icons. |
| 176 StatusTray* status_tray_; | 201 StatusTray* status_tray_; |
| 177 | 202 |
| 178 // Reference to our status icon (if any) - owned by the StatusTray. | 203 // Reference to our status icon (if any) - owned by the StatusTray. |
| 179 StatusIcon* status_icon_; | 204 StatusIcon* status_icon_; |
| 180 | 205 |
| 181 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 206 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
| 182 }; | 207 }; |
| 183 | 208 |
| 184 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ | 209 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ |
| OLD | NEW |