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" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 // Builds the profile specific parts of the menu. The menu passed in may | 133 // Builds the profile specific parts of the menu. The menu passed in may |
134 // be a submenu in the case of multi-profiles or the main menu in the case | 134 // be a submenu in the case of multi-profiles or the main menu in the case |
135 // of the single profile case. If containing_menu is valid, we will add | 135 // of the single profile case. If containing_menu is valid, we will add |
136 // menu as a submenu to it. | 136 // menu as a submenu to it. |
137 void BuildProfileMenu(StatusIconMenuModel* menu, | 137 void BuildProfileMenu(StatusIconMenuModel* menu, |
138 StatusIconMenuModel* containing_menu); | 138 StatusIconMenuModel* containing_menu); |
139 | 139 |
140 // Set the name associated with this background mode data for displaying in | 140 // Set the name associated with this background mode data for displaying in |
141 // the status tray. | 141 // the status tray. |
142 void SetName(const string16& new_profile_name); | 142 void SetName(const base::string16& new_profile_name); |
143 | 143 |
144 // The name associated with this background mode data. This should match | 144 // The name associated with this background mode data. This should match |
145 // the name in the ProfileInfoCache for this profile. | 145 // the name in the ProfileInfoCache for this profile. |
146 string16 name(); | 146 base::string16 name(); |
147 | 147 |
148 // Used for sorting BackgroundModeData*s. | 148 // Used for sorting BackgroundModeData*s. |
149 static bool BackgroundModeDataCompare(const BackgroundModeData* bmd1, | 149 static bool BackgroundModeDataCompare(const BackgroundModeData* bmd1, |
150 const BackgroundModeData* bmd2); | 150 const BackgroundModeData* bmd2); |
151 | 151 |
152 private: | 152 private: |
153 // Name associated with this profile which is used to label its submenu. | 153 // Name associated with this profile which is used to label its submenu. |
154 string16 name_; | 154 base::string16 name_; |
155 | 155 |
156 // The profile associated with this background app data. | 156 // The profile associated with this background app data. |
157 Profile* profile_; | 157 Profile* profile_; |
158 | 158 |
159 // Weak ref vector owned by BackgroundModeManager where the | 159 // Weak ref vector owned by BackgroundModeManager where the |
160 // indices correspond to Command IDs and values correspond to | 160 // indices correspond to Command IDs and values correspond to |
161 // extension indices. A value of -1 indicates no extension is associated | 161 // extension indices. A value of -1 indicates no extension is associated |
162 // with the index. | 162 // with the index. |
163 CommandIdExtensionVector* command_id_extension_vector_; | 163 CommandIdExtensionVector* command_id_extension_vector_; |
164 }; | 164 }; |
(...skipping 19 matching lines...) Expand all Loading... |
184 | 184 |
185 // BackgroundApplicationListModel::Observer implementation. | 185 // BackgroundApplicationListModel::Observer implementation. |
186 virtual void OnApplicationDataChanged(const extensions::Extension* extension, | 186 virtual void OnApplicationDataChanged(const extensions::Extension* extension, |
187 Profile* profile) OVERRIDE; | 187 Profile* profile) OVERRIDE; |
188 virtual void OnApplicationListChanged(Profile* profile) OVERRIDE; | 188 virtual void OnApplicationListChanged(Profile* profile) OVERRIDE; |
189 | 189 |
190 // Overrides from ProfileInfoCacheObserver | 190 // Overrides from ProfileInfoCacheObserver |
191 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; | 191 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; |
192 virtual void OnProfileWillBeRemoved( | 192 virtual void OnProfileWillBeRemoved( |
193 const base::FilePath& profile_path) OVERRIDE; | 193 const base::FilePath& profile_path) OVERRIDE; |
194 virtual void OnProfileNameChanged(const base::FilePath& profile_path, | 194 virtual void OnProfileNameChanged( |
195 const string16& old_profile_name) OVERRIDE; | 195 const base::FilePath& profile_path, |
| 196 const base::string16& old_profile_name) OVERRIDE; |
196 | 197 |
197 // Overrides from StatusIconMenuModel::Delegate implementation. | 198 // Overrides from StatusIconMenuModel::Delegate implementation. |
198 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 199 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
199 | 200 |
200 // chrome::BrowserListObserver implementation. | 201 // chrome::BrowserListObserver implementation. |
201 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 202 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
202 | 203 |
203 // Invoked when an extension is installed so we can ensure that | 204 // Invoked when an extension is installed so we can ensure that |
204 // launch-on-startup is enabled if appropriate. |extension| can be NULL when | 205 // launch-on-startup is enabled if appropriate. |extension| can be NULL when |
205 // called from unit tests. | 206 // called from unit tests. |
(...skipping 29 matching lines...) Expand all Loading... |
235 virtual void UpdateKeepAliveAndTrayIcon(); | 236 virtual void UpdateKeepAliveAndTrayIcon(); |
236 | 237 |
237 // If --no-startup-window is passed, BackgroundModeManager will manually keep | 238 // If --no-startup-window is passed, BackgroundModeManager will manually keep |
238 // chrome running while waiting for apps to load. This is called when we no | 239 // chrome running while waiting for apps to load. This is called when we no |
239 // longer need to do this (either because the user has chosen to exit chrome | 240 // longer need to do this (either because the user has chosen to exit chrome |
240 // manually, or all apps have been loaded). | 241 // manually, or all apps have been loaded). |
241 void EndKeepAliveForStartup(); | 242 void EndKeepAliveForStartup(); |
242 | 243 |
243 // Return an appropriate name for a Preferences menu entry. Preferences is | 244 // Return an appropriate name for a Preferences menu entry. Preferences is |
244 // sometimes called Options or Settings. | 245 // sometimes called Options or Settings. |
245 string16 GetPreferencesMenuLabel(); | 246 base::string16 GetPreferencesMenuLabel(); |
246 | 247 |
247 // Create a status tray icon to allow the user to shutdown Chrome when running | 248 // Create a status tray icon to allow the user to shutdown Chrome when running |
248 // in background mode. Virtual to enable testing. | 249 // in background mode. Virtual to enable testing. |
249 virtual void CreateStatusTrayIcon(); | 250 virtual void CreateStatusTrayIcon(); |
250 | 251 |
251 // Removes the status tray icon because we are exiting background mode. | 252 // Removes the status tray icon because we are exiting background mode. |
252 // Virtual to enable testing. | 253 // Virtual to enable testing. |
253 virtual void RemoveStatusTrayIcon(); | 254 virtual void RemoveStatusTrayIcon(); |
254 | 255 |
255 // Create a context menu, or replace/update an existing context menu, for the | 256 // Create a context menu, or replace/update an existing context menu, for the |
256 // status tray icon which, among other things, allows the user to shutdown | 257 // status tray icon which, among other things, allows the user to shutdown |
257 // Chrome when running in background mode. All profiles are listed under | 258 // Chrome when running in background mode. All profiles are listed under |
258 // the one context menu. | 259 // the one context menu. |
259 virtual void UpdateStatusTrayIconContextMenu(); | 260 virtual void UpdateStatusTrayIconContextMenu(); |
260 | 261 |
261 // Returns the BackgroundModeData associated with this profile. If it does | 262 // Returns the BackgroundModeData associated with this profile. If it does |
262 // not exist, returns NULL. | 263 // not exist, returns NULL. |
263 BackgroundModeManager::BackgroundModeData* GetBackgroundModeData( | 264 BackgroundModeManager::BackgroundModeData* GetBackgroundModeData( |
264 Profile* const profile) const; | 265 Profile* const profile) const; |
265 | 266 |
266 // Returns the iterator associated with a particular profile name. | 267 // Returns the iterator associated with a particular profile name. |
267 // This should not be used to iterate over the background mode data. It is | 268 // This should not be used to iterate over the background mode data. It is |
268 // used to efficiently delete an item from the background mode data map. | 269 // used to efficiently delete an item from the background mode data map. |
269 BackgroundModeInfoMap::iterator GetBackgroundModeIterator( | 270 BackgroundModeInfoMap::iterator GetBackgroundModeIterator( |
270 const string16& profile_name); | 271 const base::string16& profile_name); |
271 | 272 |
272 // Returns true if the "Let chrome run in the background" pref is checked. | 273 // Returns true if the "Let chrome run in the background" pref is checked. |
273 // (virtual to allow overriding in tests). | 274 // (virtual to allow overriding in tests). |
274 virtual bool IsBackgroundModePrefEnabled() const; | 275 virtual bool IsBackgroundModePrefEnabled() const; |
275 | 276 |
276 // Turns off background mode if it's currently enabled. | 277 // Turns off background mode if it's currently enabled. |
277 void DisableBackgroundMode(); | 278 void DisableBackgroundMode(); |
278 | 279 |
279 // Turns on background mode if it's currently disabled. | 280 // Turns on background mode if it's currently disabled. |
280 void EnableBackgroundMode(); | 281 void EnableBackgroundMode(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // Set to true when background mode is suspended. | 336 // Set to true when background mode is suspended. |
336 bool background_mode_suspended_; | 337 bool background_mode_suspended_; |
337 | 338 |
338 // Set to true when background mode is keeping Chrome alive. | 339 // Set to true when background mode is keeping Chrome alive. |
339 bool keeping_alive_; | 340 bool keeping_alive_; |
340 | 341 |
341 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); | 342 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); |
342 }; | 343 }; |
343 | 344 |
344 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ | 345 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ |
OLD | NEW |