summaryrefslogtreecommitdiffstats
path: root/chrome/browser/background_mode_manager.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/background_mode_manager.h')
-rw-r--r--chrome/browser/background_mode_manager.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/chrome/browser/background_mode_manager.h b/chrome/browser/background_mode_manager.h
index e662ca7..666b4f7 100644
--- a/chrome/browser/background_mode_manager.h
+++ b/chrome/browser/background_mode_manager.h
@@ -8,12 +8,14 @@
#include "app/menus/simple_menu_model.h"
#include "base/gtest_prod_util.h"
+#include "chrome/browser/background_application_list_model.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/browser/status_icons/status_icon.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
class Browser;
+class CommandLine;
class Extension;
class PrefService;
class Profile;
@@ -36,13 +38,15 @@ class StatusTray;
// no open windows to allow apps with the "background" permission to run in the
// background.
class BackgroundModeManager
- : private NotificationObserver,
- private menus::SimpleMenuModel::Delegate {
+ : public NotificationObserver,
+ public menus::SimpleMenuModel::Delegate,
+ public BackgroundApplicationListModel::Observer {
public:
BackgroundModeManager(Profile* profile, CommandLine* command_line);
virtual ~BackgroundModeManager();
static void RegisterUserPrefs(PrefService* prefs);
+
private:
friend class TestBackgroundModeManager;
friend class BackgroundModeManagerTest;
@@ -69,6 +73,13 @@ class BackgroundModeManager
menus::Accelerator* accelerator);
virtual void ExecuteCommand(int command_id);
+ // Open an application in a new tab, opening a new window if needed.
+ virtual void ExecuteApplication(int application_id);
+
+ // BackgroundApplicationListModel::Observer implementation.
+ virtual void OnApplicationDataChanged(const Extension* extension);
+ virtual void OnApplicationListChanged();
+
// Called when an extension is loaded to manage count of background apps.
void OnBackgroundAppLoaded();
@@ -121,6 +132,16 @@ class BackgroundModeManager
// Virtual to enable testing.
virtual void RemoveStatusTrayIcon();
+ // Updates the status icon's context menu entry corresponding to |extension|
+ // to use the icon associated with |extension| in the
+ // BackgroundApplicationListModel.
+ void UpdateContextMenuEntryIcon(const Extension* extension);
+
+ // Create a context menu, or replace/update an existing context menu, for the
+ // status tray icon which, among other things, allows the user to shutdown
+ // Chrome when running in background mode.
+ virtual void UpdateStatusTrayIconContextMenu();
+
// Returns a browser window, or creates one if none are open. Used by
// operations (like displaying the preferences dialog) that require a Browser
// window.
@@ -131,9 +152,20 @@ class BackgroundModeManager
// The parent profile for this object.
Profile* profile_;
+ // The cached list of BackgroundApplications.
+ BackgroundApplicationListModel applications_;
+
// The number of background apps currently loaded.
int background_app_count_;
+ // Reference to our status icon's context menu (if any) - owned by the
+ // status_icon_
+ menus::SimpleMenuModel* context_menu_;
+
+ // Set to the position of the first application entry in the status icon's
+ // context menu.
+ int context_menu_application_offset_;
+
// Set to true when we are running in background mode. Allows us to track our
// current background state so we can take the appropriate action when the
// user disables/enables background mode via preferences.