Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/background/background_mode_manager.h

Issue 25603004: Leave apps running on Windows and Linux when quitting Chrome from the wrench menu. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/prefs/pref_change_registrar.h" 11 #include "base/prefs/pref_change_registrar.h"
12 #include "chrome/browser/background/background_application_list_model.h" 12 #include "chrome/browser/background/background_application_list_model.h"
13 #include "chrome/browser/profiles/profile_info_cache_observer.h" 13 #include "chrome/browser/profiles/profile_info_cache_observer.h"
14 #include "chrome/browser/status_icons/status_icon.h" 14 #include "chrome/browser/status_icons/status_icon.h"
15 #include "chrome/browser/status_icons/status_icon_menu_model.h" 15 #include "chrome/browser/status_icons/status_icon_menu_model.h"
16 #include "chrome/browser/ui/browser_list_observer.h"
16 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 17 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 20
20 class Browser; 21 class Browser;
21 class CommandLine; 22 class CommandLine;
22 class PrefRegistrySimple; 23 class PrefRegistrySimple;
23 class Profile; 24 class Profile;
24 class ProfileInfoCache; 25 class ProfileInfoCache;
25 class StatusIcon; 26 class StatusIcon;
(...skipping 12 matching lines...) Expand all
38 // installed/loaded extensions to ensure that Chrome enters/exits background 39 // installed/loaded extensions to ensure that Chrome enters/exits background
39 // mode at the appropriate time. 40 // mode at the appropriate time.
40 // 41 //
41 // When Chrome is in background mode, it will continue running even after the 42 // When Chrome is in background mode, it will continue running even after the
42 // last browser window is closed, until the user explicitly exits the app. 43 // last browser window is closed, until the user explicitly exits the app.
43 // Additionally, when in background mode, Chrome will launch on OS login with 44 // Additionally, when in background mode, Chrome will launch on OS login with
44 // no open windows to allow apps with the "background" permission to run in the 45 // no open windows to allow apps with the "background" permission to run in the
45 // background. 46 // background.
46 class BackgroundModeManager 47 class BackgroundModeManager
47 : public content::NotificationObserver, 48 : public content::NotificationObserver,
49 public chrome::BrowserListObserver,
48 public BackgroundApplicationListModel::Observer, 50 public BackgroundApplicationListModel::Observer,
49 public ProfileInfoCacheObserver, 51 public ProfileInfoCacheObserver,
50 public StatusIconMenuModel::Delegate { 52 public StatusIconMenuModel::Delegate {
51 public: 53 public:
52 BackgroundModeManager(CommandLine* command_line, 54 BackgroundModeManager(CommandLine* command_line,
53 ProfileInfoCache* profile_cache); 55 ProfileInfoCache* profile_cache);
54 virtual ~BackgroundModeManager(); 56 virtual ~BackgroundModeManager();
55 57
56 static void RegisterPrefs(PrefRegistrySimple* registry); 58 static void RegisterPrefs(PrefRegistrySimple* registry);
57 59
58 virtual void RegisterProfile(Profile* profile); 60 virtual void RegisterProfile(Profile* profile);
59 61
60 static void LaunchBackgroundApplication(Profile* profile, 62 static void LaunchBackgroundApplication(Profile* profile,
61 const extensions::Extension* extension); 63 const extensions::Extension* extension);
62 64
63 // Returns true if background mode is active. 65 // Returns true if background mode is active.
64 virtual bool IsBackgroundModeActive(); 66 virtual bool IsBackgroundModeActive();
65 67
68 // Suspends background mode until either ResumeBackgroundMode is called or
69 // Chrome is restarted. This has the same effect as ending background mode
70 // until for the current browser session.
benwells 2013/10/20 23:46:22 Nit: until for what?
Sam McNally 2013/10/21 04:31:03 Done.
71 virtual void SuspendBackgroundMode();
72
73 // Resumes background mode. This ends a suspension of background mode, but
74 // will not start it if it is not enabled.
75 virtual void ResumeBackgroundMode();
76
77 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
benwells 2013/10/20 23:46:22 Nit: Make private, and add comment for what interf
Sam McNally 2013/10/21 04:31:03 Done.
78
66 // For testing purposes. 79 // For testing purposes.
67 int NumberOfBackgroundModeData(); 80 int NumberOfBackgroundModeData();
68 81
69 private: 82 private:
70 friend class AppBackgroundPageApiTest; 83 friend class AppBackgroundPageApiTest;
71 friend class BackgroundModeManagerTest; 84 friend class BackgroundModeManagerTest;
72 friend class TestBackgroundModeManager; 85 friend class TestBackgroundModeManager;
73 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, 86 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest,
74 BackgroundAppLoadUnload); 87 BackgroundAppLoadUnload);
75 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, 88 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Set when we are keeping chrome running during the startup process - this 308 // Set when we are keeping chrome running during the startup process - this
296 // is required when running with the --no-startup-window flag, as otherwise 309 // is required when running with the --no-startup-window flag, as otherwise
297 // chrome would immediately exit due to having no open windows. 310 // chrome would immediately exit due to having no open windows.
298 bool keep_alive_for_startup_; 311 bool keep_alive_for_startup_;
299 312
300 // Set to true when Chrome is running with the --keep-alive-for-test flag 313 // Set to true when Chrome is running with the --keep-alive-for-test flag
301 // (used for testing background mode without having to install a background 314 // (used for testing background mode without having to install a background
302 // app). 315 // app).
303 bool keep_alive_for_test_; 316 bool keep_alive_for_test_;
304 317
318 // Set to true when background mode is suspended.
319 bool background_mode_suspended_;
320
305 // Provides a command id for each profile as they are created. 321 // Provides a command id for each profile as they are created.
306 int current_command_id_; 322 int current_command_id_;
307 323
308 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); 324 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
309 }; 325 };
310 326
311 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_ 327 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_MODE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698