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

Unified Diff: chrome/browser/background_mode_manager.h

Issue 7068025: Revert 86724 - Modifying the BackgroundModeManager to handle multiple profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/background_application_list_model.cc ('k') | chrome/browser/background_mode_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background_mode_manager.h
===================================================================
--- chrome/browser/background_mode_manager.h (revision 86725)
+++ chrome/browser/background_mode_manager.h (working copy)
@@ -6,8 +6,6 @@
#define CHROME_BROWSER_BACKGROUND_MODE_MANAGER_H_
#pragma once
-#include <map>
-
#include "base/gtest_prod_util.h"
#include "chrome/browser/background_application_list_model.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
@@ -41,16 +39,15 @@
// background.
class BackgroundModeManager
: public NotificationObserver,
+ public ui::SimpleMenuModel::Delegate,
public BackgroundApplicationListModel::Observer,
public ProfileKeyedService {
public:
- explicit BackgroundModeManager(CommandLine* command_line);
+ BackgroundModeManager(Profile* profile, CommandLine* command_line);
virtual ~BackgroundModeManager();
static void RegisterPrefs(PrefService* prefs);
- virtual void RegisterProfile(Profile* profile);
-
private:
friend class TestBackgroundModeManager;
friend class BackgroundModeManagerTest;
@@ -62,80 +59,25 @@
BackgroundAppInstallUninstallWhileDisabled);
FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest,
EnableAfterBackgroundAppInstall);
- FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest,
- MultiProfile);
- class BackgroundModeData : public ui::SimpleMenuModel::Delegate {
- public:
- explicit BackgroundModeData(
- Profile* profile,
- BackgroundModeManager* background_mode_manager);
- virtual ~BackgroundModeData();
-
- // The cached list of BackgroundApplications.
- scoped_ptr<BackgroundApplicationListModel> applications_;
-
- // Reference to our status icon (if any) - owned by the StatusTray.
- StatusIcon* status_icon_;
-
- // Reference to our status icon's context menu (if any) - owned by the
- // status_icon_
- ui::SimpleMenuModel* context_menu_;
-
- // Set to the position of the first application entry in the status icon's
- // context menu.
- int context_menu_application_offset_;
-
- // The profile associated with this background app data.
- Profile* profile_;
-
- // The background mode manager which owns this BackgroundModeData
- BackgroundModeManager* background_mode_manager_;
-
- // Overrides from SimpleMenuModel::Delegate implementation.
- virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
- virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
- virtual bool GetAcceleratorForCommandId(int command_id,
- ui::Accelerator* accelerator)
- OVERRIDE;
- virtual void ExecuteCommand(int command_id) OVERRIDE;
-
- // Returns a browser window, or creates one if none are open. Used by
- // operations (like displaying the preferences dialog) that require a
- // Browser window.
- Browser* GetBrowserWindow();
-
- // Open an application in a new tab, opening a new window if needed.
- virtual void ExecuteApplication(int application_id);
-
- // Updates the status icon's context menu entry corresponding to
- // |extension| to use the icon associated with |extension| in the
- // BackgroundApplicationListModel.
- // TODO(rlp): Remove after creating one status icon.
- void UpdateContextMenuEntryIcon(const Extension* extension);
-
- // Returns whether any of the extensions are background apps.
- bool HasBackgroundApp();
- };
-
- // Ideally we would want our BackgroundModeData to be scoped_ptrs,
- // but since maps copy their entries, we can't used scoped_ptrs.
- // Similarly, we can't just have a map of BackgroundModeData objects,
- // since BackgroundModeData contains a scoped_ptr which once again
- // can't be copied. So rather than using BackgroundModeData* which
- // we'd have to remember to delete, we use the ref-counted linked_ptr
- // which is similar to a shared_ptr.
- typedef linked_ptr<BackgroundModeData> BackgroundModeInfo;
-
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
- const NotificationDetails& details) OVERRIDE;
+ const NotificationDetails& details);
+ // SimpleMenuModel::Delegate implementation.
+ virtual bool IsCommandIdChecked(int command_id) const;
+ virtual bool IsCommandIdEnabled(int command_id) const;
+ virtual bool GetAcceleratorForCommandId(int command_id,
+ ui::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,
- Profile* profile) OVERRIDE;
- virtual void OnApplicationListChanged(Profile* profile) OVERRIDE;
+ virtual void OnApplicationDataChanged(const Extension* extension);
+ virtual void OnApplicationListChanged();
// Called when an extension is loaded to manage count of background apps.
void OnBackgroundAppLoaded();
@@ -146,11 +88,11 @@
// Invoked when an extension is installed so we can ensure that
// launch-on-startup is enabled if appropriate. |extension| can be NULL when
// called from unit tests.
- void OnBackgroundAppInstalled(const Extension* extension, Profile* profile);
+ void OnBackgroundAppInstalled(const Extension* extension);
// Invoked when an extension is uninstalled so we can ensure that
// launch-on-startup is disabled if appropriate.
- void OnBackgroundAppUninstalled(Profile* profile);
+ void OnBackgroundAppUninstalled();
// Called to make sure that our launch-on-startup mode is properly set.
// (virtual so we can override for tests).
@@ -158,17 +100,12 @@
// Invoked when a background app is installed so we can display a
// platform-specific notification to the user.
- void DisplayAppInstalledNotification(const Extension* extension,
- Profile* profile);
+ void DisplayAppInstalledNotification(const Extension* extension);
// Invoked to put Chrome in KeepAlive mode - chrome runs in the background
// and has a status bar icon.
void StartBackgroundMode();
- // Invoked to create status icons for any profiles currently running
- // background apps so that there is a way to exit Chrome.
- void InitStatusTrayIcons();
-
// Invoked to take Chrome out of KeepAlive mode - chrome stops running in
// the background and removes its status bar icon.
void EndBackgroundMode();
@@ -185,26 +122,26 @@
// Create a status tray icon to allow the user to shutdown Chrome when running
// in background mode. Virtual to enable testing.
- virtual void CreateStatusTrayIcon(Profile* profile);
+ virtual void CreateStatusTrayIcon();
// Removes the status tray icon because we are exiting background mode.
// Virtual to enable testing.
- virtual void RemoveStatusTrayIcon(Profile* profile);
+ 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, Profile* profile);
+ 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(Profile* profile);
+ virtual void UpdateStatusTrayIconContextMenu();
- // Returns the BackgroundModeInfo associated with this profile. If it does
- // not exist, returns an empty BackgroundModeInfo.
- BackgroundModeManager::BackgroundModeInfo GetBackgroundModeInfo(
- Profile* profile);
+ // Returns a browser window, or creates one if none are open. Used by
+ // operations (like displaying the preferences dialog) that require a Browser
+ // window.
+ Browser* GetBrowserWindow();
// Returns true if the "Let chrome run in the background" pref is checked.
// (virtual to allow overriding in tests).
@@ -225,17 +162,23 @@
NotificationRegistrar registrar_;
PrefChangeRegistrar pref_registrar_;
- // The profile-keyed data for this background mode manager. Keyed on profile.
- std::map<Profile*, BackgroundModeInfo> background_mode_data_;
+ // The parent profile for this object.
+ Profile* profile_;
- // Reference to our status tray. If null, the platform doesn't support status
- // icons.
- StatusTray* status_tray_;
+ // The cached list of BackgroundApplications.
+ BackgroundApplicationListModel applications_;
- // The number of background apps currently loaded. This is the total over
- // all profiles.
+ // 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_
+ ui::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.
@@ -246,6 +189,13 @@
// chrome would immediately exit due to having no open windows.
bool keep_alive_for_startup_;
+ // Reference to our status tray (owned by our parent profile). If null, the
+ // platform doesn't support status icons.
+ StatusTray* status_tray_;
+
+ // Reference to our status icon (if any) - owned by the StatusTray.
+ StatusIcon* status_icon_;
+
DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
};
« no previous file with comments | « chrome/browser/background_application_list_model.cc ('k') | chrome/browser/background_mode_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698