Commit 527089be authored by vandebo@chromium.org's avatar vandebo@chromium.org

Revert 86724 - Modifying the BackgroundModeManager to handle multiple profiles.

The background mode manager is now owned by the broser
The status tray is also owned by the browser process since there is only one per browser. Previously it was owned by the profile, but now that there are multiple profiles, it makes sense to have the browser process own it.

Note: This CL does not unify the status tray into one icon.

TEST=unittests (added BackgroundModeManagerTest::MultiProfile)
BUG=80069,82215
Review URL: http://codereview.chromium.org/6914021

TBR=rlp@chromium.org
Review URL: http://codereview.chromium.org/7068025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86726 0039d316-1c4b-4281-b951-d872f2087c98
parent 354016f8
......@@ -96,12 +96,11 @@ bool HasBackgroundAppPermission(
void
BackgroundApplicationListModel::Observer::OnApplicationDataChanged(
const Extension* extension, Profile* profile) {
const Extension* extension) {
}
void
BackgroundApplicationListModel::Observer::OnApplicationListChanged(
Profile* profile) {
BackgroundApplicationListModel::Observer::OnApplicationListChanged() {
}
BackgroundApplicationListModel::Observer::~Observer() {
......@@ -126,7 +125,7 @@ void BackgroundApplicationListModel::Application::OnImageLoaded(
if (!image)
return;
icon_.reset(new SkBitmap(*image));
model_->SendApplicationDataChangedNotifications(extension_);
model_->OnApplicationDataChanged(extension_);
}
void BackgroundApplicationListModel::Application::RequestIcon(
......@@ -264,10 +263,9 @@ void BackgroundApplicationListModel::Observe(
}
}
void BackgroundApplicationListModel::SendApplicationDataChangedNotifications(
void BackgroundApplicationListModel::OnApplicationDataChanged(
const Extension* extension) {
FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension,
profile_));
FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension));
}
void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) {
......@@ -312,6 +310,6 @@ void BackgroundApplicationListModel::Update() {
}
if (old_cursor != extensions_.end() || new_cursor != extensions.end()) {
extensions_ = extensions;
FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_));
FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged());
}
}
......@@ -32,12 +32,11 @@ class BackgroundApplicationListModel : public NotificationObserver {
public:
// Invoked when data that the model associates with the extension, such as
// the Icon, has changed.
virtual void OnApplicationDataChanged(const Extension* extension,
Profile* profile);
virtual void OnApplicationDataChanged(const Extension* extension);
// Invoked when the model detects a previously unknown extension and/or when
// it no longer detects a previously known extension.
virtual void OnApplicationListChanged(Profile* profile);
virtual void OnApplicationListChanged();
protected:
virtual ~Observer();
......@@ -111,11 +110,11 @@ class BackgroundApplicationListModel : public NotificationObserver {
// Notifies observers that some of the data associated with this background
// application, e. g. the Icon, has changed.
void SendApplicationDataChangedNotifications(const Extension* extension);
void OnApplicationDataChanged(const Extension* extension);
// Notifies observers that at least one background application has been added
// or removed.
void SendApplicationListChangedNotifications();
void OnApplicationListChanged();
// Invoked by Observe for EXTENSION_LOADED notifications.
void OnExtensionLoaded(Extension* extension);
......
This diff is collapsed.
......@@ -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 @@ class StatusTray;
// 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 @@ class BackgroundModeManager
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 @@ class BackgroundModeManager
// 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 @@ class BackgroundModeManager
// 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 @@ class BackgroundModeManager
// 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 @@ class BackgroundModeManager
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 @@ class BackgroundModeManager
// 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);
};
......
......@@ -79,8 +79,7 @@ void EnableLaunchOnStartupTask::Run() {
}
void BackgroundModeManager::DisplayAppInstalledNotification(
const Extension* extension,
Profile* profile) {
const Extension* extension) {
// TODO(atwilson): Display a platform-appropriate notification here.
// http://crbug.com/74970
}
......
......@@ -86,8 +86,7 @@ void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) {
}
void BackgroundModeManager::DisplayAppInstalledNotification(
const Extension* extension,
Profile* profile) {
const Extension* extension) {
// TODO(atwilson): Display a platform-appropriate notification here.
// http://crbug.com/74970
}
......
......@@ -13,7 +13,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using testing::_;
using testing::AtLeast;
using testing::InSequence;
using testing::Return;
......@@ -30,12 +29,12 @@ class BackgroundModeManagerTest : public TestingBrowserProcessTest {
class TestBackgroundModeManager : public BackgroundModeManager {
public:
explicit TestBackgroundModeManager(CommandLine* command_line)
: BackgroundModeManager(command_line),
TestBackgroundModeManager(Profile* profile, CommandLine* cl)
: BackgroundModeManager(profile, cl),
enabled_(true) {}
MOCK_METHOD1(EnableLaunchOnStartup, void(bool));
MOCK_METHOD1(CreateStatusTrayIcon, void(Profile*)); // NOLINT
MOCK_METHOD1(RemoveStatusTrayIcon, void(Profile*)); // NOLINT
MOCK_METHOD0(CreateStatusTrayIcon, void());
MOCK_METHOD0(RemoveStatusTrayIcon, void());
virtual bool IsBackgroundModePrefEnabled() { return enabled_; }
void SetEnabled(bool enabled) { enabled_ = enabled; }
private:
......@@ -45,14 +44,12 @@ class TestBackgroundModeManager : public BackgroundModeManager {
TEST_F(BackgroundModeManagerTest, BackgroundAppLoadUnload) {
InSequence s;
TestingProfile profile;
TestBackgroundModeManager manager(command_line_.get());
manager.RegisterProfile(&profile);
EXPECT_CALL(manager, RemoveStatusTrayIcon(_));
TestBackgroundModeManager manager(&profile, command_line_.get());
EXPECT_CALL(manager, CreateStatusTrayIcon());
EXPECT_CALL(manager, RemoveStatusTrayIcon());
EXPECT_FALSE(BrowserList::WillKeepAlive());
// Call to AppLoaded() will not cause the status tray to be created,
// because no apps have been installed. However the call to AppUnloaded()
// will result in a call RemoveStatusTrayIcon since it will try to unload
// all icons now that there are no apps.
// Call to AppLoaded() will cause the status tray to be created, then call to
// unloaded will result in call to remove the icon.
manager.OnBackgroundAppLoaded();
EXPECT_TRUE(BrowserList::WillKeepAlive());
manager.OnBackgroundAppUnloaded();
......@@ -62,37 +59,35 @@ TEST_F(BackgroundModeManagerTest, BackgroundAppLoadUnload) {
TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstall) {
InSequence s;
TestingProfile profile;
TestBackgroundModeManager manager(command_line_.get());
manager.RegisterProfile(&profile);
TestBackgroundModeManager manager(&profile, command_line_.get());
// Call to AppInstalled() will cause chrome to be set to launch on startup,
// and call to AppUninstalled() set chrome to not launch on startup.
EXPECT_CALL(manager, EnableLaunchOnStartup(true));
EXPECT_CALL(manager, CreateStatusTrayIcon(_));
EXPECT_CALL(manager, RemoveStatusTrayIcon(_)).Times(2);
EXPECT_CALL(manager, CreateStatusTrayIcon());
EXPECT_CALL(manager, RemoveStatusTrayIcon());
EXPECT_CALL(manager, EnableLaunchOnStartup(false));
manager.OnBackgroundAppInstalled(NULL, &profile);
manager.OnBackgroundAppInstalled(NULL);
manager.OnBackgroundAppLoaded();
manager.OnBackgroundAppUnloaded();
manager.OnBackgroundAppUninstalled(&profile);}
manager.OnBackgroundAppUninstalled();
}
// App installs while disabled should do nothing.
TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstallWhileDisabled) {
InSequence s;
TestingProfile profile;
TestBackgroundModeManager manager(command_line_.get());
manager.RegisterProfile(&profile);
TestBackgroundModeManager manager(&profile, command_line_.get());
// Turn off background mode.
EXPECT_CALL(manager, RemoveStatusTrayIcon(_));
manager.SetEnabled(false);
manager.DisableBackgroundMode();
// Status tray icons will not be created, launch on startup status will be set
// to "do not launch on startup".
EXPECT_CALL(manager, EnableLaunchOnStartup(false));
manager.OnBackgroundAppInstalled(NULL, &profile);
manager.OnBackgroundAppInstalled(NULL);
manager.OnBackgroundAppLoaded();
manager.OnBackgroundAppUnloaded();
manager.OnBackgroundAppUninstalled(&profile);
manager.OnBackgroundAppUninstalled();
// Re-enable background mode.
manager.SetEnabled(true);
......@@ -104,77 +99,29 @@ TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstallWhileDisabled) {
TEST_F(BackgroundModeManagerTest, EnableAfterBackgroundAppInstall) {
InSequence s;
TestingProfile profile;
TestBackgroundModeManager manager(command_line_.get());
manager.RegisterProfile(&profile);
TestBackgroundModeManager manager(&profile, command_line_.get());
EXPECT_CALL(manager, EnableLaunchOnStartup(true));
EXPECT_CALL(manager, CreateStatusTrayIcon(_));
EXPECT_CALL(manager, RemoveStatusTrayIcon(_));
EXPECT_CALL(manager, CreateStatusTrayIcon());
EXPECT_CALL(manager, RemoveStatusTrayIcon());
EXPECT_CALL(manager, EnableLaunchOnStartup(false));
EXPECT_CALL(manager, CreateStatusTrayIcon());
EXPECT_CALL(manager, EnableLaunchOnStartup(true));
EXPECT_CALL(manager, RemoveStatusTrayIcon(_)).Times(2);
EXPECT_CALL(manager, RemoveStatusTrayIcon());
EXPECT_CALL(manager, EnableLaunchOnStartup(false));
// Install app, should show status tray icon.
manager.OnBackgroundAppInstalled(NULL, &profile);
// OnBackgroundAppInstalled does not actually add an app to the
// BackgroundApplicationListModel which would result in another
// call to CreateStatusTray.
manager.OnBackgroundAppInstalled(NULL);
manager.OnBackgroundAppLoaded();
// Turn off background mode - should hide status tray icon.
manager.SetEnabled(false);
manager.DisableBackgroundMode();
// Turn back on background mode - again, no status tray icon
// will show up since we didn't actually add anything to the list.
// Turn back on background mode - should show status tray icon.
manager.SetEnabled(true);
manager.EnableBackgroundMode();
// Uninstall app, should hide status tray icon again.
manager.OnBackgroundAppUnloaded();
manager.OnBackgroundAppUninstalled(&profile);
}
TEST_F(BackgroundModeManagerTest, MultiProfile) {
InSequence s;
TestingProfile profile1;
TestingProfile profile2;
TestBackgroundModeManager manager(command_line_.get());
manager.RegisterProfile(&profile1);
manager.RegisterProfile(&profile2);
EXPECT_CALL(manager, EnableLaunchOnStartup(true));
EXPECT_CALL(manager, CreateStatusTrayIcon(_)).Times(2);
EXPECT_CALL(manager, RemoveStatusTrayIcon(_)).Times(2);
EXPECT_CALL(manager, EnableLaunchOnStartup(false));
EXPECT_CALL(manager, EnableLaunchOnStartup(true));
EXPECT_CALL(manager, RemoveStatusTrayIcon(_)).Times(4);
EXPECT_CALL(manager, EnableLaunchOnStartup(false));
EXPECT_FALSE(BrowserList::WillKeepAlive());
// Install app, should show status tray icon.
manager.OnBackgroundAppInstalled(NULL, &profile1);
// OnBackgroundAppInstalled does not actually add an app to the
// BackgroundApplicationListModel which would result in another
// call to CreateStatusTray.
manager.OnBackgroundAppLoaded();
// Install app for other profile, hsould show other status tray icon.
manager.OnBackgroundAppInstalled(NULL, &profile2);
manager.OnBackgroundAppLoaded();
// Should hide both status tray icons.
manager.SetEnabled(false);
manager.DisableBackgroundMode();
// Turn back on background mode - should show both status tray icons.
manager.SetEnabled(true);
manager.EnableBackgroundMode();
manager.OnBackgroundAppUnloaded();
manager.OnBackgroundAppUninstalled(&profile1);
// There is still one background app alive
EXPECT_TRUE(BrowserList::WillKeepAlive());
manager.OnBackgroundAppUnloaded();
manager.OnBackgroundAppUninstalled(&profile2);
EXPECT_FALSE(BrowserList::WillKeepAlive());
manager.OnBackgroundAppUninstalled();
}
......@@ -88,12 +88,11 @@ void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) {
}
void BackgroundModeManager::DisplayAppInstalledNotification(
const Extension* extension,
Profile* profile) {
const Extension* extension) {
// Create a status tray notification balloon explaining to the user that
// a background app has been installed.
CreateStatusTrayIcon(profile);
background_mode_data_[profile]->status_icon_->DisplayBalloon(
CreateStatusTrayIcon();
status_icon_->DisplayBalloon(
l10n_util::GetStringUTF16(IDS_BACKGROUND_APP_INSTALLED_BALLOON_TITLE),
l10n_util::GetStringFUTF16(
IDS_BACKGROUND_APP_INSTALLED_BALLOON_BODY,
......
......@@ -24,7 +24,6 @@ namespace safe_browsing {
class ClientSideDetectionService;
}
class BackgroundModeManager;
class ChromeNetLog;
class DevToolsManager;
class DownloadRequestLimiter;
......@@ -40,7 +39,6 @@ class PrefService;
class ProfileManager;
class ResourceDispatcherHost;
class SidebarManager;
class StatusTray;
class TabCloseableStateWatcher;
class ThumbnailGenerator;
class WatchDogThread;
......@@ -205,14 +203,6 @@ class BrowserProcess {
// Returns the object that watches for changes in the closeable state of tab.
virtual TabCloseableStateWatcher* tab_closeable_state_watcher() = 0;
// Returns the object that manages background applications.
virtual BackgroundModeManager* background_mode_manager() = 0;
// Returns the StatusTray, which provides an API for displaying status icons
// in the system status tray. Returns NULL if status icons are not supported
// on this platform (or this is a unit test).
virtual StatusTray* status_tray() = 0;
// Returns an object which handles communication with the SafeBrowsing
// client-side detection servers.
virtual safe_browsing::ClientSideDetectionService*
......
......@@ -16,7 +16,6 @@
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/automation/automation_provider_list.h"
#include "chrome/browser/background_mode_manager.h"
#include "chrome/browser/browser_main.h"
#include "chrome/browser/browser_process_sub_thread.h"
#include "chrome/browser/browser_trial.h"
......@@ -56,7 +55,6 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/sidebar/sidebar_manager.h"
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/tab_closeable_state_watcher.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_constants.h"
......@@ -639,20 +637,6 @@ TabCloseableStateWatcher* BrowserProcessImpl::tab_closeable_state_watcher() {
return tab_closeable_state_watcher_.get();
}
BackgroundModeManager* BrowserProcessImpl::background_mode_manager() {
DCHECK(CalledOnValidThread());
if (!background_mode_manager_.get())
CreateBackgroundModeManager();
return background_mode_manager_.get();
}
StatusTray* BrowserProcessImpl::status_tray() {
DCHECK(CalledOnValidThread());
if (!status_tray_.get())
CreateStatusTray();
return status_tray_.get();
}
safe_browsing::ClientSideDetectionService*
BrowserProcessImpl::safe_browsing_detection_service() {
DCHECK(CalledOnValidThread());
......@@ -1005,17 +989,6 @@ void BrowserProcessImpl::CreateTabCloseableStateWatcher() {
tab_closeable_state_watcher_.reset(TabCloseableStateWatcher::Create());
}
void BrowserProcessImpl::CreateBackgroundModeManager() {
DCHECK(background_mode_manager_.get() == NULL);
background_mode_manager_.reset(
new BackgroundModeManager(CommandLine::ForCurrentProcess()));
}
void BrowserProcessImpl::CreateStatusTray() {
DCHECK(status_tray_.get() == NULL);
status_tray_.reset(StatusTray::Create());
}
void BrowserProcessImpl::CreatePrintPreviewTabController() {
DCHECK(print_preview_tab_controller_.get() == NULL);
print_preview_tab_controller_ = new printing::PrintPreviewTabController();
......
......@@ -97,8 +97,6 @@ class BrowserProcessImpl : public BrowserProcess,
virtual DownloadStatusUpdater* download_status_updater();
virtual base::WaitableEvent* shutdown_event();
virtual TabCloseableStateWatcher* tab_closeable_state_watcher();
virtual BackgroundModeManager* background_mode_manager();
virtual StatusTray* status_tray();
virtual safe_browsing::ClientSideDetectionService*
safe_browsing_detection_service();
virtual bool plugin_finder_disabled() const;
......@@ -157,8 +155,6 @@ class BrowserProcessImpl : public BrowserProcess,
void CreatePrintPreviewTabController();
void CreateBackgroundPrintingManager();
void CreateSafeBrowsingDetectionService();
void CreateStatusTray();
void CreateBackgroundModeManager();
bool IsSafeBrowsingDetectionServiceEnabled();
......@@ -249,10 +245,6 @@ class BrowserProcessImpl : public BrowserProcess,
scoped_ptr<TabCloseableStateWatcher> tab_closeable_state_watcher_;
scoped_ptr<BackgroundModeManager> background_mode_manager_;
scoped_ptr<StatusTray> status_tray_;
bool created_safe_browsing_detection_service_;
scoped_ptr<safe_browsing::ClientSideDetectionService>
safe_browsing_detection_service_;
......
......@@ -294,6 +294,10 @@ class OffTheRecordProfileImpl : public Profile,
return GetOriginalProfile()->GetExtensionService();
}
virtual StatusTray* GetStatusTray() {
return GetOriginalProfile()->GetStatusTray();
}
virtual UserScriptMaster* GetUserScriptMaster() {
return GetOriginalProfile()->GetUserScriptMaster();
}
......
......@@ -86,6 +86,7 @@ class SQLitePersistentCookieStore;
class SSLConfigServiceManager;
class SSLHostState;
class SpellCheckHost;
class StatusTray;
class TemplateURLFetcher;
class TemplateURLModel;
class TokenService;
......@@ -450,6 +451,11 @@ class Profile {
// Returns the WebKitContext assigned to this profile.
virtual WebKitContext* GetWebKitContext() = 0;
// Returns the StatusTray, which provides an API for displaying status icons
// in the system status tray. Returns NULL if status icons are not supported
// on this platform (or this is a unit test).
virtual StatusTray* GetStatusTray() = 0;
// Marks the profile as cleanly shutdown.
//
// NOTE: this is invoked internally on a normal shutdown, but is public so
......
......@@ -17,7 +17,7 @@
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/background_contents_service_factory.h"
#include "chrome/browser/background_mode_manager.h"
#include "chrome/browser/background_mode_manager_factory.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_signin.h"
......@@ -62,6 +62,7 @@
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/spellcheck_host.h"
#include "chrome/browser/ssl/ssl_host_state.h"
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/sync/profile_sync_factory_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/tabs/pinned_tab_service_factory.h"
......@@ -362,8 +363,7 @@ void ProfileImpl::DoFinalInit() {
// ChromeOS because Chrome is always running (no need for special keep-alive
// or launch-on-startup support).
#if !defined(OS_CHROMEOS)
if (g_browser_process->background_mode_manager())
g_browser_process->background_mode_manager()->RegisterProfile(this);
BackgroundModeManagerFactory::GetForProfile(this);
#endif
BackgroundContentsServiceFactory::GetForProfile(this);
......@@ -748,6 +748,12 @@ ExtensionService* ProfileImpl::GetExtensionService() {
return extension_service_.get();
}
StatusTray* ProfileImpl::GetStatusTray() {
if (!status_tray_.get())
status_tray_.reset(StatusTray::Create());
return status_tray_.get();
}
UserScriptMaster* ProfileImpl::GetUserScriptMaster() {
return user_script_master_.get();
}
......
......@@ -109,6 +109,7 @@ class ProfileImpl : public Profile,
virtual SpellCheckHost* GetSpellCheckHost();
virtual void ReinitializeSpellCheckHost(bool force);
virtual WebKitContext* GetWebKitContext();
virtual StatusTray* GetStatusTray();
virtual void MarkAsCleanShutdown();
virtual void InitExtensions(bool extensions_enabled);
virtual void InitPromoResources();
......@@ -240,6 +241,7 @@ class ProfileImpl : public Profile,
scoped_refptr<WebDataService> web_data_service_;
scoped_refptr<PasswordStore> password_store_;
scoped_refptr<WebKitContext> webkit_context_;
scoped_ptr<StatusTray> status_tray_;
scoped_refptr<PersonalDataManager> personal_data_manager_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
scoped_ptr<BrowserSignin> browser_signin_;
......
......@@ -257,6 +257,8 @@
'browser/background_mode_manager.cc',
'browser/background_mode_manager.h',
'browser/background_mode_manager_chromeos.cc',
'browser/background_mode_manager_factory.cc',
'browser/background_mode_manager_factory.h',
'browser/background_mode_manager_linux.cc',
'browser/background_mode_manager_mac.mm',
'browser/background_mode_manager_win.cc',
......
......@@ -124,14 +124,6 @@ TabCloseableStateWatcher* TestingBrowserProcess::tab_closeable_state_watcher() {
return NULL;
}
BackgroundModeManager* TestingBrowserProcess::background_mode_manager() {
return NULL;
}
StatusTray* TestingBrowserProcess::status_tray() {
return NULL;
}
safe_browsing::ClientSideDetectionService*
TestingBrowserProcess::safe_browsing_detection_service() {
return NULL;
......
......@@ -18,7 +18,6 @@
#include "chrome/browser/browser_process.h"
#include "content/common/notification_service.h"
class BackgroundModeManager;
class IOThread;
class GoogleURLTracker;
class NotificationUIManager;
......@@ -88,10 +87,6 @@ class TestingBrowserProcess : public BrowserProcess {
virtual TabCloseableStateWatcher* tab_closeable_state_watcher();
virtual BackgroundModeManager* background_mode_manager();
virtual StatusTray* status_tray();
virtual safe_browsing::ClientSideDetectionService*
safe_browsing_detection_service();
......
......@@ -677,6 +677,10 @@ NTPResourceCache* TestingProfile::GetNTPResourceCache() {
return ntp_resource_cache_.get();
}
StatusTray* TestingProfile::GetStatusTray() {
return NULL;
}
FilePath TestingProfile::last_selected_directory() {
return last_selected_directory_;
}
......
......@@ -249,6 +249,7 @@ class TestingProfile : public Profile {
virtual void InitRegisteredProtocolHandlers() {}
virtual NTPResourceCache* GetNTPResourceCache();
virtual StatusTray* GetStatusTray();
virtual FilePath last_selected_directory();
virtual void set_last_selected_directory(const FilePath& path);
#if defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment