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

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

Issue 3189003: Added support for context menus to status icons. (Closed)
Patch Set: Final version. Created 10 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/background_mode_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
10 #include "chrome/browser/status_icons/status_icon.h" 11 #include "chrome/browser/status_icons/status_icon.h"
11 #include "chrome/common/notification_observer.h" 12 #include "chrome/common/notification_observer.h"
12 #include "chrome/common/notification_registrar.h" 13 #include "chrome/common/notification_registrar.h"
13 14
14 class Extension; 15 class Extension;
15 class PrefService; 16 class PrefService;
16 class Profile; 17 class Profile;
17 class StatusIcon; 18 class StatusIcon;
18 class StatusTray; 19 class StatusTray;
19 20
20 // BackgroundModeManager is responsible for switching Chrome into and out of 21 // BackgroundModeManager is responsible for switching Chrome into and out of
21 // "background mode" and for providing UI for the user to exit Chrome when there 22 // "background mode" and for providing UI for the user to exit Chrome when there
22 // are no open browser windows. 23 // are no open browser windows.
23 // 24 //
24 // Chrome enters background mode whenever there is an application with the 25 // Chrome enters background mode whenever there is an application with the
25 // "background" permission installed and the appropriate user preference is 26 // "background" permission installed and the appropriate user preference is
26 // set (kBackgroundModeEnabled). This class monitors the set of installed/loaded 27 // set (kBackgroundModeEnabled). This class monitors the set of installed/loaded
27 // extensions to ensure that Chrome enters/exits background mode at the 28 // extensions to ensure that Chrome enters/exits background mode at the
28 // appropriate time. 29 // appropriate time.
29 // 30 //
30 // When Chrome is in background mode, it will continue running even after the 31 // When Chrome is in background mode, it will continue running even after the
31 // last browser window is closed, until the user explicitly exits the app. 32 // last browser window is closed, until the user explicitly exits the app.
32 // Additionally, when in background mode, Chrome will launch on OS login with 33 // Additionally, when in background mode, Chrome will launch on OS login with
33 // no open windows to allow apps with the "background" permission to run in the 34 // no open windows to allow apps with the "background" permission to run in the
34 // background. 35 // background.
35 class BackgroundModeManager 36 class BackgroundModeManager
36 : private NotificationObserver, 37 : private NotificationObserver,
37 private StatusIcon::Observer { 38 private menus::SimpleMenuModel::Delegate {
38 public: 39 public:
39 explicit BackgroundModeManager(Profile* profile); 40 explicit BackgroundModeManager(Profile* profile);
40 virtual ~BackgroundModeManager(); 41 virtual ~BackgroundModeManager();
41 42
42 static void RegisterUserPrefs(PrefService* prefs); 43 static void RegisterUserPrefs(PrefService* prefs);
43 private: 44 private:
44 friend class TestBackgroundModeManager; 45 friend class TestBackgroundModeManager;
45 friend class BackgroundModeManagerTest; 46 friend class BackgroundModeManagerTest;
46 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, 47 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest,
47 BackgroundAppLoadUnload); 48 BackgroundAppLoadUnload);
48 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, 49 FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest,
49 BackgroundAppInstallUninstall); 50 BackgroundAppInstallUninstall);
50 51
51 // NotificationObserver implementation. 52 // NotificationObserver implementation.
52 virtual void Observe(NotificationType type, 53 virtual void Observe(NotificationType type,
53 const NotificationSource& source, 54 const NotificationSource& source,
54 const NotificationDetails& details); 55 const NotificationDetails& details);
55 56
56 // StatusIcon::Observer implementation. 57 // SimpleMenuModel::Delegate implementation.
57 virtual void OnClicked(); 58 virtual bool IsCommandIdChecked(int command_id) const;
59 virtual bool IsCommandIdEnabled(int command_id) const;
60 virtual bool GetAcceleratorForCommandId(int command_id,
61 menus::Accelerator* accelerator);
62 virtual void ExecuteCommand(int command_id);
58 63
59 // Called when an extension is loaded to manage count of background apps. 64 // Called when an extension is loaded to manage count of background apps.
60 void OnBackgroundAppLoaded(); 65 void OnBackgroundAppLoaded();
61 66
62 // Called when an extension is unloaded to manage count of background apps. 67 // Called when an extension is unloaded to manage count of background apps.
63 void OnBackgroundAppUnloaded(); 68 void OnBackgroundAppUnloaded();
64 69
65 // Invoked when an extension is installed so we can ensure that 70 // Invoked when an extension is installed so we can ensure that
66 // launch-on-startup is enabled if appropriate. 71 // launch-on-startup is enabled if appropriate.
67 void OnBackgroundAppInstalled(); 72 void OnBackgroundAppInstalled();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // platform doesn't support status icons. 113 // platform doesn't support status icons.
109 StatusTray* status_tray_; 114 StatusTray* status_tray_;
110 115
111 // Reference to our status icon (if any) - owned by the StatusTray. 116 // Reference to our status icon (if any) - owned by the StatusTray.
112 StatusIcon* status_icon_; 117 StatusIcon* status_icon_;
113 118
114 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); 119 DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
115 }; 120 };
116 121
117 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_ 122 #endif // CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/background_mode_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698