summaryrefslogtreecommitdiffstats
path: root/chrome/browser/background_mode_manager.h
diff options
context:
space:
mode:
authorrickcam@chromium.org <rickcam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 23:16:50 +0000
committerrickcam@chromium.org <rickcam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 23:16:50 +0000
commitaa0508126d9ff21ad91f61e5caf745bb19894b15 (patch)
treeb49f9c61646dd4d6596fb93cbf3340f84f3ba922 /chrome/browser/background_mode_manager.h
parenta89b125b999dffd43455ad14819d583d5df3273b (diff)
downloadchromium_src-aa0508126d9ff21ad91f61e5caf745bb19894b15.zip
chromium_src-aa0508126d9ff21ad91f61e5caf745bb19894b15.tar.gz
chromium_src-aa0508126d9ff21ad91f61e5caf745bb19894b15.tar.bz2
Added Status Icon support for Window and Linux
This patch extends the existing Status Icon support to include Background Application launch entries. This is implemented by introducing the BackgroundApplicationListModel class. The BackgroundModeManager creates and observes an instance of this class which calls back into the BackgroundModeManager using OnApplicationAdded, OnApplicationRemoved, and OnApplicationDataChanged. BUG=59223 TEST=None Review URL: http://codereview.chromium.org/3822003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65449 0039d316-1c4b-4281-b951-d872f2087c98
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 e662ca75..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.