summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/focus_cycler_unittest.cc2
-rw-r--r--ash/root_window_controller.cc8
-rw-r--r--ash/shell.cc23
-rw-r--r--ash/shell.h9
-rw-r--r--ash/shell/shell_delegate_impl.cc3
-rw-r--r--ash/shell/shell_delegate_impl.h3
-rw-r--r--ash/shell_delegate.h3
-rw-r--r--ash/system/status_area_widget.cc291
-rw-r--r--ash/system/status_area_widget.h9
-rw-r--r--ash/system/tray/system_tray.h28
-rw-r--r--ash/system/tray/system_tray_delegate.cc9
-rw-r--r--ash/system/tray/system_tray_delegate.h5
-rw-r--r--ash/system/tray/test_system_tray_delegate.cc287
-rw-r--r--ash/system/tray/test_system_tray_delegate.h109
-rw-r--r--ash/test/test_shell_delegate.cc3
-rw-r--r--ash/test/test_shell_delegate.h2
-rw-r--r--chrome/browser/chromeos/system/ash_system_tray_delegate.cc95
-rw-r--r--chrome/browser/chromeos/system/ash_system_tray_delegate.h2
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.cc5
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h3
21 files changed, 520 insertions, 381 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index b7af253..2e11d2e 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -209,6 +209,8 @@
'system/tray/system_tray_delegate.h',
'system/tray/system_tray_item.cc',
'system/tray/system_tray_item.h',
+ 'system/tray/test_system_tray_delegate.cc',
+ 'system/tray/test_system_tray_delegate.h',
'system/tray/tray_background_view.cc',
'system/tray/tray_background_view.h',
'system/tray/tray_bubble_wrapper.cc',
diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc
index 2ba405a..0c33b9f 100644
--- a/ash/focus_cycler_unittest.cc
+++ b/ash/focus_cycler_unittest.cc
@@ -71,7 +71,7 @@ class FocusCyclerTest : public AshTestBase {
GetContainer(ash::internal::kShellWindowId_StatusContainer);
internal::StatusAreaWidget* widget = new internal::StatusAreaWidget(parent);
- widget->CreateTrayViews(NULL);
+ widget->CreateTrayViews();
widget->Show();
tray_.reset(widget->system_tray());
if (!tray_->GetWidget())
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 30b1253..f4b3f5b 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -243,14 +243,14 @@ void RootWindowController::InitLayoutManagers() {
void RootWindowController::InitForPrimaryDisplay() {
DCHECK(!status_area_widget_);
- ShellDelegate* delegate = Shell::GetInstance()->delegate();
aura::Window* status_container =
GetContainer(ash::internal::kShellWindowId_StatusContainer);
// Initialize Primary RootWindow specific items.
status_area_widget_ = new internal::StatusAreaWidget(status_container);
- status_area_widget_->CreateTrayViews(delegate);
+ status_area_widget_->CreateTrayViews();
// Login screen manages status area visibility by itself.
- if (delegate && delegate->IsSessionStarted())
+ ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
+ if (shell_delegate && shell_delegate->IsSessionStarted())
status_area_widget_->Show();
Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_);
@@ -281,7 +281,7 @@ void RootWindowController::InitForPrimaryDisplay() {
panel_container, panel_layout_manager_));
panel_container->SetLayoutManager(panel_layout_manager_);
- if (!delegate || delegate->IsUserLoggedIn())
+ if (!shell_delegate || shell_delegate->IsUserLoggedIn())
CreateLauncher();
}
diff --git a/ash/shell.cc b/ash/shell.cc
index 851228f..aeec91e 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -27,6 +27,7 @@
#include "ash/shell_factory.h"
#include "ash/shell_window_ids.h"
#include "ash/system/status_area_widget.h"
+#include "ash/system/tray/system_tray_delegate.h"
#include "ash/tooltips/tooltip_controller.h"
#include "ash/touch/touch_observer_hud.h"
#include "ash/wm/activation_controller.h"
@@ -246,6 +247,9 @@ Shell::~Shell() {
// TODO(xiyuan): Move it back when app list container is no longer needed.
app_list_controller_.reset();
+ // Destroy SystemTrayDelegate before destroying the status area(s).
+ system_tray_delegate_.reset();
+
// Destroy all child windows including widgets.
display_controller_->CloseChildWindows();
@@ -487,8 +491,18 @@ void Shell::Init() {
shadow_controller_.reset(new internal::ShadowController());
}
+ // Initialize system_tray_delegate_ before initializing StatusAreaWidget.
+ if (delegate_.get())
+ system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate());
+ if (!system_tray_delegate_.get())
+ system_tray_delegate_.reset(SystemTrayDelegate::CreateDummyDelegate());
+
+ // Creates StatusAreaWidget.
root_window_controller->InitForPrimaryDisplay();
+ // Initialize system_tray_delegate_ after StatusAreaWidget is created.
+ system_tray_delegate_->Initialize();
+
display_controller_->InitSecondaryDisplays();
// Force Layout
@@ -725,15 +739,6 @@ internal::StatusAreaWidget* Shell::status_area_widget() {
return GetPrimaryRootWindowController()->status_area_widget();
}
-SystemTrayDelegate* Shell::tray_delegate() {
- // TODO(oshima): Decouple system tray and its delegate.
- // We assume in throughout the code that this will not return NULL. If code
- // triggers this for valid reasons, it should test status_area_widget first.
- internal::StatusAreaWidget* status_area = status_area_widget();
- CHECK(status_area);
- return status_area->system_tray_delegate();
-}
-
SystemTray* Shell::system_tray() {
// We assume in throughout the code that this will not return NULL. If code
// triggers this for valid reasons, it should test status_area_widget first.
diff --git a/ash/shell.h b/ash/shell.h
index 78a81af..41ce0dd2 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -72,8 +72,8 @@ class ScreenAsh;
class SessionStateController;
class ShellDelegate;
class ShellObserver;
-class SystemTrayDelegate;
class SystemTray;
+class SystemTrayDelegate;
class UserActivityDetector;
class UserWallpaperDelegate;
class VideoDetector;
@@ -370,9 +370,13 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
// status_area_widget() has been destroyed; check status_area_widget()
// before calling these in destructors.
internal::StatusAreaWidget* status_area_widget();
- SystemTrayDelegate* tray_delegate();
SystemTray* system_tray();
+ // TODO(stevenjb): Rename to system_tray_delegate().
+ SystemTrayDelegate* tray_delegate() {
+ return system_tray_delegate_.get();
+ }
+
static void set_initially_hide_cursor(bool hide) {
initially_hide_cursor_ = hide;
}
@@ -458,6 +462,7 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
#endif // !defined(OS_MACOSX)
scoped_ptr<ShellDelegate> delegate_;
+ scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_;
scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 8873565..380af07 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -127,8 +127,7 @@ ash::LauncherDelegate* ShellDelegateImpl::CreateLauncherDelegate(
return launcher_delegate_;
}
-ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate(
- ash::SystemTray* tray) {
+ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
return NULL;
}
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index ff9360b19..987c7af 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -45,8 +45,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual ash::LauncherDelegate* CreateLauncherDelegate(
ash::LauncherModel* model) OVERRIDE;
- virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate(
- ash::SystemTray* tray) OVERRIDE;
+ virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate() OVERRIDE;
virtual ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE;
virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index c1991c3..5f69459 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -39,7 +39,6 @@ class CapsLockDelegate;
class LauncherDelegate;
class LauncherModel;
struct LauncherItem;
-class SystemTray;
class SystemTrayDelegate;
class UserWallpaperDelegate;
@@ -142,7 +141,7 @@ class ASH_EXPORT ShellDelegate {
ash::LauncherModel* model) = 0;
// Creates a system-tray delegate. Shell takes ownership of the delegate.
- virtual SystemTrayDelegate* CreateSystemTrayDelegate(SystemTray* tray) = 0;
+ virtual SystemTrayDelegate* CreateSystemTrayDelegate() = 0;
// Creates a user wallpaper delegate. Shell takes ownership of the delegate.
virtual UserWallpaperDelegate* CreateUserWallpaperDelegate() = 0;
diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc
index f358e62..b487de5 100644
--- a/ash/system/status_area_widget.cc
+++ b/ash/system/status_area_widget.cc
@@ -13,288 +13,14 @@
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/web_notification/web_notification_tray.h"
-#include "ash/volume_control_delegate.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "base/i18n/time_formatting.h"
-#include "base/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"
namespace ash {
-namespace {
-
-class DummyVolumeControlDelegate : public VolumeControlDelegate {
- public:
- DummyVolumeControlDelegate() {}
- virtual ~DummyVolumeControlDelegate() {}
-
- virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE {
- return true;
- }
- virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE {
- return true;
- }
- virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE {
- return true;
- }
- virtual void SetVolumePercent(double percent) OVERRIDE {
- }
- virtual bool IsAudioMuted() const OVERRIDE {
- return true;
- }
- virtual void SetAudioMuted(bool muted) OVERRIDE {
- }
- virtual float GetVolumeLevel() const OVERRIDE {
- return 0.0;
- }
- virtual void SetVolumeLevel(float level) OVERRIDE {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DummyVolumeControlDelegate);
-};
-
-class DummySystemTrayDelegate : public SystemTrayDelegate {
- public:
- DummySystemTrayDelegate()
- : wifi_enabled_(true),
- cellular_enabled_(true),
- bluetooth_enabled_(true),
- caps_lock_enabled_(false),
- volume_control_delegate_(
- ALLOW_THIS_IN_INITIALIZER_LIST(new DummyVolumeControlDelegate)) {
- }
-
- virtual ~DummySystemTrayDelegate() {}
-
- private:
- virtual bool GetTrayVisibilityOnStartup() OVERRIDE { return true; }
-
- // Overridden from SystemTrayDelegate:
- virtual const string16 GetUserDisplayName() const OVERRIDE {
- return UTF8ToUTF16("Über tray Über tray Über tray Über tray");
- }
-
- virtual const std::string GetUserEmail() const OVERRIDE {
- return "über@tray";
- }
-
- virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE {
- return null_image_;
- }
-
- virtual user::LoginStatus GetUserLoginStatus() const OVERRIDE {
- return Shell::GetInstance()->IsScreenLocked() ? user::LOGGED_IN_LOCKED :
- user::LOGGED_IN_USER;
- }
-
- virtual bool SystemShouldUpgrade() const OVERRIDE {
- return true;
- }
-
- virtual base::HourClockType GetHourClockType() const OVERRIDE {
- return base::k24HourClock;
- }
-
- virtual PowerSupplyStatus GetPowerSupplyStatus() const OVERRIDE {
- return PowerSupplyStatus();
- }
-
- virtual void RequestStatusUpdate() const OVERRIDE {
- }
-
- virtual void ShowSettings() OVERRIDE {
- }
-
- virtual void ShowDateSettings() OVERRIDE {
- }
-
- virtual void ShowNetworkSettings() OVERRIDE {
- }
-
- virtual void ShowBluetoothSettings() OVERRIDE {
- }
-
- virtual void ShowDisplaySettings() OVERRIDE {
- }
-
- virtual void ShowDriveSettings() OVERRIDE {
- }
-
- virtual void ShowIMESettings() OVERRIDE {
- }
-
- virtual void ShowHelp() OVERRIDE {
- }
-
- virtual void ShutDown() OVERRIDE {
- MessageLoop::current()->Quit();
- }
-
- virtual void SignOut() OVERRIDE {
- MessageLoop::current()->Quit();
- }
-
- virtual void RequestLockScreen() OVERRIDE {}
-
- virtual void RequestRestart() OVERRIDE {}
-
- virtual void GetAvailableBluetoothDevices(
- BluetoothDeviceList* list) OVERRIDE {
- }
-
- virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE {
- }
-
- virtual void GetCurrentIME(IMEInfo* info) OVERRIDE {
- }
-
- virtual void GetAvailableIMEList(IMEInfoList* list) OVERRIDE {
- }
-
- virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) OVERRIDE {
- }
-
- virtual void SwitchIME(const std::string& ime_id) OVERRIDE {
- }
-
- virtual void ActivateIMEProperty(const std::string& key) OVERRIDE {
- }
-
- virtual void CancelDriveOperation(const FilePath&) OVERRIDE {
- }
-
- virtual void GetDriveOperationStatusList(
- ash::DriveOperationStatusList*) OVERRIDE {
- }
-
- virtual void GetMostRelevantNetworkIcon(NetworkIconInfo* info,
- bool large) OVERRIDE {
- }
-
- virtual void GetVirtualNetworkIcon(ash::NetworkIconInfo* info) OVERRIDE {
- }
-
- virtual void GetAvailableNetworks(
- std::vector<NetworkIconInfo>* list) OVERRIDE {
- }
-
- virtual void GetVirtualNetworks(std::vector<NetworkIconInfo>* list) OVERRIDE {
- }
-
- virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE {
- }
-
- virtual void GetNetworkAddresses(std::string* ip_address,
- std::string* ethernet_mac_address,
- std::string* wifi_mac_address) OVERRIDE {
- *ip_address = "127.0.0.1";
- *ethernet_mac_address = "00:11:22:33:44:55";
- *wifi_mac_address = "66:77:88:99:00:11";
- }
-
- virtual void RequestNetworkScan() OVERRIDE {
- }
-
- virtual void AddBluetoothDevice() OVERRIDE {
- }
-
- virtual void ToggleAirplaneMode() OVERRIDE {
- }
-
- virtual void ToggleWifi() OVERRIDE {
- wifi_enabled_ = !wifi_enabled_;
- }
-
- virtual void ToggleMobile() OVERRIDE {
- cellular_enabled_ = !cellular_enabled_;
- }
-
- virtual void ToggleBluetooth() OVERRIDE {
- bluetooth_enabled_ = !bluetooth_enabled_;
- }
-
- virtual bool IsBluetoothDiscovering() OVERRIDE {
- return false;
- }
-
- virtual void ShowOtherWifi() OVERRIDE {
- }
-
- virtual void ShowOtherVPN() OVERRIDE {
- }
-
- virtual void ShowOtherCellular() OVERRIDE {
- }
-
- virtual bool IsNetworkConnected() OVERRIDE {
- return true;
- }
-
- virtual bool GetWifiAvailable() OVERRIDE {
- return true;
- }
-
- virtual bool GetMobileAvailable() OVERRIDE {
- return true;
- }
-
- virtual bool GetBluetoothAvailable() OVERRIDE {
- return true;
- }
-
- virtual bool GetWifiEnabled() OVERRIDE {
- return wifi_enabled_;
- }
-
- virtual bool GetMobileEnabled() OVERRIDE {
- return cellular_enabled_;
- }
-
- virtual bool GetBluetoothEnabled() OVERRIDE {
- return bluetooth_enabled_;
- }
-
- virtual bool GetMobileScanSupported() OVERRIDE {
- return true;
- }
-
- virtual bool GetCellularCarrierInfo(std::string* carrier_id,
- std::string* topup_url,
- std::string* setup_url) OVERRIDE {
- return false;
- }
-
- virtual void ShowCellularURL(const std::string& url) OVERRIDE {
- }
-
- virtual void ChangeProxySettings() OVERRIDE {
- }
-
- virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE {
- return volume_control_delegate_.get();
- }
-
- virtual void SetVolumeControlDelegate(
- scoped_ptr<VolumeControlDelegate> delegate) OVERRIDE {
- volume_control_delegate_.swap(delegate);
- }
-
-
- bool wifi_enabled_;
- bool cellular_enabled_;
- bool bluetooth_enabled_;
- bool caps_lock_enabled_;
- gfx::ImageSkia null_image_;
- scoped_ptr<VolumeControlDelegate> volume_control_delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate);
-};
-
-} // namespace
-
namespace internal {
StatusAreaWidget::StatusAreaWidget(aura::Window* status_container)
@@ -317,22 +43,22 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container)
StatusAreaWidget::~StatusAreaWidget() {
}
-void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) {
- AddSystemTray(shell_delegate);
+void StatusAreaWidget::CreateTrayViews() {
+ AddSystemTray();
AddWebNotificationTray();
// Initialize() must be called after all trays have been created.
if (system_tray_)
system_tray_->Initialize();
if (web_notification_tray_)
web_notification_tray_->Initialize();
- UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
+ UpdateAfterLoginStatusChange(
+ ash::Shell::GetInstance()->tray_delegate()->GetUserLoginStatus());
}
void StatusAreaWidget::Shutdown() {
// Destroy the trays early, causing them to be removed from the view
// hierarchy. Do not used scoped pointers since we don't want to destroy them
// in the destructor if Shutdown() is not called (e.g. in tests).
- system_tray_delegate_.reset();
delete web_notification_tray_;
web_notification_tray_ = NULL;
delete system_tray_;
@@ -361,16 +87,9 @@ bool StatusAreaWidget::IsMessageBubbleShown() const {
web_notification_tray_->IsMessageCenterBubbleVisible()));
}
-void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
+void StatusAreaWidget::AddSystemTray() {
system_tray_ = new SystemTray(this);
status_area_widget_delegate_->AddTray(system_tray_);
-
- if (shell_delegate) {
- system_tray_delegate_.reset(
- shell_delegate->CreateSystemTrayDelegate(system_tray_));
- }
- if (!system_tray_delegate_.get())
- system_tray_delegate_.reset(new DummySystemTrayDelegate());
}
void StatusAreaWidget::AddWebNotificationTray() {
diff --git a/ash/system/status_area_widget.h b/ash/system/status_area_widget.h
index 5e00e82..2800595 100644
--- a/ash/system/status_area_widget.h
+++ b/ash/system/status_area_widget.h
@@ -15,7 +15,6 @@ namespace ash {
class ShellDelegate;
class SystemTray;
-class SystemTrayDelegate;
class WebNotificationTray;
namespace internal {
@@ -28,7 +27,7 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
virtual ~StatusAreaWidget();
// Creates the SystemTray and the WebNotificationTray.
- void CreateTrayViews(ShellDelegate* shell_delegate);
+ void CreateTrayViews();
// Destroys the system tray and web notification tray. Called before
// tearing down the windows to avoid shutdown ordering issues.
@@ -60,9 +59,6 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
return status_area_widget_delegate_;
}
SystemTray* system_tray() { return system_tray_; }
- SystemTrayDelegate* system_tray_delegate() {
- return system_tray_delegate_.get();
- }
WebNotificationTray* web_notification_tray() {
return web_notification_tray_;
}
@@ -78,10 +74,9 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
bool IsMessageBubbleShown() const;
private:
- void AddSystemTray(ShellDelegate* shell_delegate);
+ void AddSystemTray();
void AddWebNotificationTray();
- scoped_ptr<SystemTrayDelegate> system_tray_delegate_;
// Weak pointers to View classes that are parented to StatusAreaWidget:
internal::StatusAreaWidgetDelegate* status_area_widget_delegate_;
SystemTray* system_tray_;
diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h
index 9cd7969..ae6fc04 100644
--- a/ash/system/tray/system_tray.h
+++ b/ash/system/tray/system_tray.h
@@ -117,51 +117,51 @@ class ASH_EXPORT SystemTray : public internal::TrayBackgroundView,
// Returns true if the mouse is inside the notification bubble.
bool IsMouseInNotificationBubble() const;
- AccessibilityObserver* accessibility_observer() const {
+ AccessibilityObserver* accessibility_observer() {
return accessibility_observer_;
}
- AudioObserver* audio_observer() const {
+ AudioObserver* audio_observer() {
return audio_observer_;
}
- BluetoothObserver* bluetooth_observer() const {
+ BluetoothObserver* bluetooth_observer() {
return bluetooth_observer_;
}
- BrightnessObserver* brightness_observer() const {
+ BrightnessObserver* brightness_observer() {
return brightness_observer_;
}
- CapsLockObserver* caps_lock_observer() const {
+ CapsLockObserver* caps_lock_observer() {
return caps_lock_observer_;
}
- ClockObserver* clock_observer() const {
+ ClockObserver* clock_observer() {
return clock_observer_;
}
- DriveObserver* drive_observer() const {
+ DriveObserver* drive_observer() {
return drive_observer_;
}
- IMEObserver* ime_observer() const {
+ IMEObserver* ime_observer() {
return ime_observer_;
}
- LocaleObserver* locale_observer() const {
+ LocaleObserver* locale_observer() {
return locale_observer_;
}
#if defined(OS_CHROMEOS)
- NetworkObserver* network_observer() const {
+ NetworkObserver* network_observer() {
return network_observer_;
}
- NetworkObserver* vpn_observer() const {
+ NetworkObserver* vpn_observer() {
return vpn_observer_;
}
- SmsObserver* sms_observer() const {
+ SmsObserver* sms_observer() {
return sms_observer_;
}
#endif
ObserverList<PowerStatusObserver>& power_status_observers() {
return power_status_observers_;
}
- UpdateObserver* update_observer() const {
+ UpdateObserver* update_observer() {
return update_observer_;
}
- UserObserver* user_observer() const {
+ UserObserver* user_observer() {
return user_observer_;
}
diff --git a/ash/system/tray/system_tray_delegate.cc b/ash/system/tray/system_tray_delegate.cc
index 9293a54..8bea2e7 100644
--- a/ash/system/tray/system_tray_delegate.cc
+++ b/ash/system/tray/system_tray_delegate.cc
@@ -4,6 +4,8 @@
#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/test_system_tray_delegate.h"
+
namespace ash {
NetworkIconInfo::NetworkIconInfo()
@@ -43,4 +45,11 @@ IMEPropertyInfo::IMEPropertyInfo()
IMEPropertyInfo::~IMEPropertyInfo() {
}
+// TODO(stevenjb/oshima): Remove this once Shell::delegate_ is guaranteed
+// to not be NULL and move TestSystemTrayDelegate -> ash/test. crbug.com/159693
+// static
+SystemTrayDelegate* SystemTrayDelegate::CreateDummyDelegate() {
+ return new test::TestSystemTrayDelegate;
+}
+
} // namespace ash
diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h
index a40dfd1..b8c7f3e 100644
--- a/ash/system/tray/system_tray_delegate.h
+++ b/ash/system/tray/system_tray_delegate.h
@@ -104,6 +104,9 @@ class SystemTrayDelegate {
public:
virtual ~SystemTrayDelegate() {}
+ // Called after SystemTray has been instantiated.
+ virtual void Initialize() = 0;
+
// Returns true if system tray should be visible on startup.
virtual bool GetTrayVisibilityOnStartup() = 0;
@@ -286,6 +289,8 @@ class SystemTrayDelegate {
virtual void SetVolumeControlDelegate(
scoped_ptr<VolumeControlDelegate> delegate) = 0;
+ // Creates a dummy delegate for testing.
+ static SystemTrayDelegate* CreateDummyDelegate();
};
} // namespace ash
diff --git a/ash/system/tray/test_system_tray_delegate.cc b/ash/system/tray/test_system_tray_delegate.cc
new file mode 100644
index 0000000..7602c4f
--- /dev/null
+++ b/ash/system/tray/test_system_tray_delegate.cc
@@ -0,0 +1,287 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/tray/test_system_tray_delegate.h"
+
+#include "ash/shell.h"
+#include "ash/volume_control_delegate.h"
+#include "base/utf_string_conversions.h"
+#include "base/message_loop.h"
+
+namespace ash {
+namespace test {
+
+namespace {
+
+class TestVolumeControlDelegate : public VolumeControlDelegate {
+ public:
+ TestVolumeControlDelegate() {}
+ virtual ~TestVolumeControlDelegate() {}
+
+ virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE {
+ return true;
+ }
+ virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE {
+ return true;
+ }
+ virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE {
+ return true;
+ }
+ virtual void SetVolumePercent(double percent) OVERRIDE {
+ }
+ virtual bool IsAudioMuted() const OVERRIDE {
+ return true;
+ }
+ virtual void SetAudioMuted(bool muted) OVERRIDE {
+ }
+ virtual float GetVolumeLevel() const OVERRIDE {
+ return 0.0;
+ }
+ virtual void SetVolumeLevel(float level) OVERRIDE {
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestVolumeControlDelegate);
+};
+
+} // namespace
+
+TestSystemTrayDelegate::TestSystemTrayDelegate()
+ : wifi_enabled_(true),
+ cellular_enabled_(true),
+ bluetooth_enabled_(true),
+ caps_lock_enabled_(false),
+ volume_control_delegate_(
+ ALLOW_THIS_IN_INITIALIZER_LIST(new TestVolumeControlDelegate)) {
+}
+
+TestSystemTrayDelegate::~TestSystemTrayDelegate() {
+}
+
+void TestSystemTrayDelegate::Initialize() {
+}
+
+bool TestSystemTrayDelegate::GetTrayVisibilityOnStartup() {
+ return true;
+}
+
+// Overridden from SystemTrayDelegate:
+const string16 TestSystemTrayDelegate::GetUserDisplayName() const {
+ return UTF8ToUTF16("Über tray Über tray Über tray Über tray");
+}
+
+const std::string TestSystemTrayDelegate::GetUserEmail() const {
+ return "über@tray";
+}
+
+const gfx::ImageSkia& TestSystemTrayDelegate::GetUserImage() const {
+ return null_image_;
+}
+
+user::LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const {
+ return Shell::GetInstance()->IsScreenLocked() ? user::LOGGED_IN_LOCKED :
+ user::LOGGED_IN_USER;
+}
+
+bool TestSystemTrayDelegate::SystemShouldUpgrade() const {
+ return true;
+}
+
+base::HourClockType TestSystemTrayDelegate::GetHourClockType() const {
+ return base::k24HourClock;
+}
+
+PowerSupplyStatus TestSystemTrayDelegate::GetPowerSupplyStatus() const {
+ return PowerSupplyStatus();
+}
+
+void TestSystemTrayDelegate::RequestStatusUpdate() const {
+}
+
+void TestSystemTrayDelegate::ShowSettings() {
+}
+
+void TestSystemTrayDelegate::ShowDateSettings() {
+}
+
+void TestSystemTrayDelegate::ShowNetworkSettings() {
+}
+
+void TestSystemTrayDelegate::ShowBluetoothSettings() {
+}
+
+void TestSystemTrayDelegate::ShowDisplaySettings() {
+}
+
+void TestSystemTrayDelegate::ShowDriveSettings() {
+}
+
+void TestSystemTrayDelegate::ShowIMESettings() {
+}
+
+void TestSystemTrayDelegate::ShowHelp() {
+}
+
+void TestSystemTrayDelegate::ShutDown() {
+ MessageLoop::current()->Quit();
+}
+
+void TestSystemTrayDelegate::SignOut() {
+ MessageLoop::current()->Quit();
+}
+
+void TestSystemTrayDelegate::RequestLockScreen() {
+}
+
+void TestSystemTrayDelegate::RequestRestart() {
+}
+
+void TestSystemTrayDelegate::GetAvailableBluetoothDevices(
+ BluetoothDeviceList* list) {
+}
+
+void TestSystemTrayDelegate::ToggleBluetoothConnection(
+ const std::string& address) {
+}
+
+void TestSystemTrayDelegate::GetCurrentIME(IMEInfo* info) {
+}
+
+void TestSystemTrayDelegate::GetAvailableIMEList(IMEInfoList* list) {
+}
+
+void TestSystemTrayDelegate::GetCurrentIMEProperties(
+ IMEPropertyInfoList* list) {
+}
+
+void TestSystemTrayDelegate::SwitchIME(const std::string& ime_id) {
+}
+
+void TestSystemTrayDelegate::ActivateIMEProperty(const std::string& key) {
+}
+
+void TestSystemTrayDelegate::CancelDriveOperation(const FilePath&) {
+}
+
+void TestSystemTrayDelegate::GetDriveOperationStatusList(
+ ash::DriveOperationStatusList*) {
+}
+
+void TestSystemTrayDelegate::GetMostRelevantNetworkIcon(NetworkIconInfo* info,
+ bool large) {
+}
+
+void TestSystemTrayDelegate::GetVirtualNetworkIcon(ash::NetworkIconInfo* info) {
+}
+
+void TestSystemTrayDelegate::GetAvailableNetworks(
+ std::vector<NetworkIconInfo>* list) {
+}
+
+void TestSystemTrayDelegate::GetVirtualNetworks(
+ std::vector<NetworkIconInfo>* list) {
+}
+
+void TestSystemTrayDelegate::ConnectToNetwork(const std::string& network_id) {
+}
+
+void TestSystemTrayDelegate::GetNetworkAddresses(
+ std::string* ip_address,
+ std::string* ethernet_mac_address,
+ std::string* wifi_mac_address) {
+ *ip_address = "127.0.0.1";
+ *ethernet_mac_address = "00:11:22:33:44:55";
+ *wifi_mac_address = "66:77:88:99:00:11";
+}
+
+void TestSystemTrayDelegate::RequestNetworkScan() {
+}
+
+void TestSystemTrayDelegate::AddBluetoothDevice() {
+}
+
+void TestSystemTrayDelegate::ToggleAirplaneMode() {
+}
+
+void TestSystemTrayDelegate::ToggleWifi() {
+ wifi_enabled_ = !wifi_enabled_;
+}
+
+void TestSystemTrayDelegate::ToggleMobile() {
+ cellular_enabled_ = !cellular_enabled_;
+}
+
+void TestSystemTrayDelegate::ToggleBluetooth() {
+ bluetooth_enabled_ = !bluetooth_enabled_;
+}
+
+bool TestSystemTrayDelegate::IsBluetoothDiscovering() {
+ return false;
+}
+
+void TestSystemTrayDelegate::ShowOtherWifi() {
+}
+
+void TestSystemTrayDelegate::ShowOtherVPN() {
+}
+
+void TestSystemTrayDelegate::ShowOtherCellular() {
+}
+
+bool TestSystemTrayDelegate::IsNetworkConnected() {
+ return true;
+}
+
+bool TestSystemTrayDelegate::GetWifiAvailable() {
+ return true;
+}
+
+bool TestSystemTrayDelegate::GetMobileAvailable() {
+ return true;
+}
+
+bool TestSystemTrayDelegate::GetBluetoothAvailable() {
+ return true;
+}
+
+bool TestSystemTrayDelegate::GetWifiEnabled() {
+ return wifi_enabled_;
+}
+
+bool TestSystemTrayDelegate::GetMobileEnabled() {
+ return cellular_enabled_;
+}
+
+bool TestSystemTrayDelegate::GetBluetoothEnabled() {
+ return bluetooth_enabled_;
+}
+
+bool TestSystemTrayDelegate::GetMobileScanSupported() {
+ return true;
+}
+
+bool TestSystemTrayDelegate::GetCellularCarrierInfo(std::string* carrier_id,
+ std::string* topup_url,
+ std::string* setup_url) {
+ return false;
+}
+
+void TestSystemTrayDelegate::ShowCellularURL(const std::string& url) {
+}
+
+void TestSystemTrayDelegate::ChangeProxySettings() {
+}
+
+VolumeControlDelegate* TestSystemTrayDelegate::GetVolumeControlDelegate()
+ const {
+ return volume_control_delegate_.get();
+}
+
+void TestSystemTrayDelegate::SetVolumeControlDelegate(
+ scoped_ptr<VolumeControlDelegate> delegate) {
+ volume_control_delegate_ = delegate.Pass();
+}
+
+} // namespace test
+} // namespace ash
diff --git a/ash/system/tray/test_system_tray_delegate.h b/ash/system/tray/test_system_tray_delegate.h
new file mode 100644
index 0000000..a49b307
--- /dev/null
+++ b/ash/system/tray/test_system_tray_delegate.h
@@ -0,0 +1,109 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_
+#define ASH_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_
+
+#include "ash/system/tray/system_tray_delegate.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+
+// TODO(oshima/stevenjb): Move this to ash/test. crbug.com/159693.
+
+namespace ash {
+namespace test {
+
+class TestSystemTrayDelegate : public SystemTrayDelegate {
+ public:
+ TestSystemTrayDelegate();
+
+ virtual ~TestSystemTrayDelegate();
+
+ public:
+ virtual void Initialize() OVERRIDE;
+ virtual bool GetTrayVisibilityOnStartup() OVERRIDE;
+
+ // Overridden from SystemTrayDelegate:
+ virtual const string16 GetUserDisplayName() const OVERRIDE;
+ virtual const std::string GetUserEmail() const OVERRIDE;
+ virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE;
+ virtual user::LoginStatus GetUserLoginStatus() const OVERRIDE;
+ virtual bool SystemShouldUpgrade() const OVERRIDE;
+ virtual base::HourClockType GetHourClockType() const OVERRIDE;
+ virtual PowerSupplyStatus GetPowerSupplyStatus() const OVERRIDE;
+ virtual void RequestStatusUpdate() const OVERRIDE;
+ virtual void ShowSettings() OVERRIDE;
+ virtual void ShowDateSettings() OVERRIDE;
+ virtual void ShowNetworkSettings() OVERRIDE;
+ virtual void ShowBluetoothSettings() OVERRIDE;
+ virtual void ShowDisplaySettings() OVERRIDE;
+ virtual void ShowDriveSettings() OVERRIDE;
+ virtual void ShowIMESettings() OVERRIDE;
+ virtual void ShowHelp() OVERRIDE;
+ virtual void ShutDown() OVERRIDE;
+ virtual void SignOut() OVERRIDE;
+ virtual void RequestLockScreen() OVERRIDE;
+ virtual void RequestRestart() OVERRIDE;
+ virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* list) OVERRIDE;
+ virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE;
+ virtual void GetCurrentIME(IMEInfo* info) OVERRIDE;
+ virtual void GetAvailableIMEList(IMEInfoList* list) OVERRIDE;
+ virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) OVERRIDE;
+ virtual void SwitchIME(const std::string& ime_id) OVERRIDE;
+ virtual void ActivateIMEProperty(const std::string& key) OVERRIDE;
+ virtual void CancelDriveOperation(const FilePath&) OVERRIDE;
+ virtual void GetDriveOperationStatusList(
+ ash::DriveOperationStatusList*) OVERRIDE;
+ virtual void GetMostRelevantNetworkIcon(NetworkIconInfo* info,
+ bool large) OVERRIDE;
+ virtual void GetVirtualNetworkIcon(ash::NetworkIconInfo* info) OVERRIDE;
+ virtual void GetAvailableNetworks(
+ std::vector<NetworkIconInfo>* list) OVERRIDE;
+ virtual void GetVirtualNetworks(std::vector<NetworkIconInfo>* list) OVERRIDE;
+ virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE;
+ virtual void GetNetworkAddresses(std::string* ip_address,
+ std::string* ethernet_mac_address,
+ std::string* wifi_mac_address) OVERRIDE;
+ virtual void RequestNetworkScan() OVERRIDE;
+ virtual void AddBluetoothDevice() OVERRIDE;
+ virtual void ToggleAirplaneMode() OVERRIDE;
+ virtual void ToggleWifi() OVERRIDE;
+ virtual void ToggleMobile() OVERRIDE;
+ virtual void ToggleBluetooth() OVERRIDE;
+ virtual bool IsBluetoothDiscovering() OVERRIDE;
+ virtual void ShowOtherWifi() OVERRIDE;
+ virtual void ShowOtherVPN() OVERRIDE;
+ virtual void ShowOtherCellular() OVERRIDE;
+ virtual bool IsNetworkConnected() OVERRIDE;
+ virtual bool GetWifiAvailable() OVERRIDE;
+ virtual bool GetMobileAvailable() OVERRIDE;
+ virtual bool GetBluetoothAvailable() OVERRIDE;
+ virtual bool GetWifiEnabled() OVERRIDE;
+ virtual bool GetMobileEnabled() OVERRIDE;
+ virtual bool GetBluetoothEnabled() OVERRIDE;
+ virtual bool GetMobileScanSupported() OVERRIDE;
+ virtual bool GetCellularCarrierInfo(std::string* carrier_id,
+ std::string* topup_url,
+ std::string* setup_url) OVERRIDE;
+ virtual void ShowCellularURL(const std::string& url) OVERRIDE;
+ virtual void ChangeProxySettings() OVERRIDE;
+ virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE;
+ virtual void SetVolumeControlDelegate(
+ scoped_ptr<VolumeControlDelegate> delegate) OVERRIDE;
+
+ private:
+ bool wifi_enabled_;
+ bool cellular_enabled_;
+ bool bluetooth_enabled_;
+ bool caps_lock_enabled_;
+ gfx::ImageSkia null_image_;
+ scoped_ptr<VolumeControlDelegate> volume_control_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestSystemTrayDelegate);
+};
+
+} // namespace test
+} // namespace ash
+
+#endif // ASH_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 28b09b3..8575d6b 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -113,8 +113,7 @@ LauncherDelegate* TestShellDelegate::CreateLauncherDelegate(
return new TestLauncherDelegate(model);
}
-SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate(
- SystemTray* tray) {
+SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() {
return NULL;
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 989dbe1..76b48b1 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -42,7 +42,7 @@ class TestShellDelegate : public ShellDelegate {
virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual LauncherDelegate* CreateLauncherDelegate(
ash::LauncherModel* model) OVERRIDE;
- virtual SystemTrayDelegate* CreateSystemTrayDelegate(SystemTray* t) OVERRIDE;
+ virtual SystemTrayDelegate* CreateSystemTrayDelegate() OVERRIDE;
virtual UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE;
virtual CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index 040078b..1474c3c 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -161,9 +161,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
public SystemKeyEventListener::CapsLockObserver,
public ash::NetworkTrayDelegate {
public:
- explicit SystemTrayDelegate(ash::SystemTray* tray)
- : tray_(tray),
- ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
+ SystemTrayDelegate()
+ : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
new base::WeakPtrFactory<SystemTrayDelegate>(this))),
network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
@@ -177,24 +176,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
data_promo_notification_(new DataPromoNotification()),
volume_control_delegate_(ALLOW_THIS_IN_INITIALIZER_LIST(
new VolumeController)) {
- AudioHandler::GetInstance()->AddVolumeObserver(this);
- DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
- DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(
- PowerManagerClient::UPDATE_INITIAL);
- DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
-
- NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
- crosnet->AddNetworkManagerObserver(this);
- OnNetworkManagerChanged(crosnet);
- crosnet->AddCellularDataPlanObserver(this);
-
- input_method::InputMethodManager::GetInstance()->AddObserver(this);
-
- system::TimezoneSettings::GetInstance()->AddObserver(this);
-
- if (SystemKeyEventListener::GetInstance())
- SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this);
-
+ // Register notifications on construction so that events such as
+ // PROFILE_CREATED do not get missed if they happen before Initialize().
registrar_.Add(this,
chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
content::NotificationService::AllSources());
@@ -213,6 +196,27 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
content::NotificationService::AllSources());
+ }
+
+ virtual void Initialize() OVERRIDE {
+ AudioHandler::GetInstance()->AddVolumeObserver(this);
+ DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
+ DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(
+ PowerManagerClient::UPDATE_INITIAL);
+ DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
+
+ NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
+ crosnet->AddNetworkManagerObserver(this);
+ OnNetworkManagerChanged(crosnet);
+ crosnet->AddCellularDataPlanObserver(this);
+
+ input_method::InputMethodManager::GetInstance()->AddObserver(this);
+
+ system::TimezoneSettings::GetInstance()->AddObserver(this);
+
+ if (SystemKeyEventListener::GetInstance())
+ SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this);
+
accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled,
g_browser_process->local_state(), this);
@@ -621,7 +625,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
virtual void ToggleWifi() OVERRIDE {
- tray_->network_observer()->OnWillToggleWifi();
+ GetSystemTray()->network_observer()->OnWillToggleWifi();
network_menu_->ToggleWifi();
}
@@ -729,7 +733,12 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
scoped_ptr<ash::VolumeControlDelegate> delegate) OVERRIDE {
volume_control_delegate_.swap(delegate);
}
+
private:
+ ash::SystemTray* GetSystemTray() {
+ return ash::Shell::GetInstance()->system_tray();
+ }
+
// Returns the last active browser. If there is no such browser, creates a new
// browser window with an empty tab and returns it.
Browser* GetAppropriateBrowser() {
@@ -759,19 +768,19 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
void UpdateClockType(PrefService* service) {
clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ?
base::k24HourClock : base::k12HourClock;
- ash::ClockObserver* observer = tray_->clock_observer();
+ ash::ClockObserver* observer = GetSystemTray()->clock_observer();
if (observer)
observer->OnDateFormatChanged();
}
void NotifyRefreshClock() {
- ash::ClockObserver* observer = tray_->clock_observer();
+ ash::ClockObserver* observer = GetSystemTray()->clock_observer();
if (observer)
observer->Refresh();
}
void NotifyRefreshNetwork() {
- ash::NetworkObserver* observer = tray_->network_observer();
+ ash::NetworkObserver* observer = GetSystemTray()->network_observer();
chromeos::NetworkLibrary* crosnet =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
if (observer) {
@@ -781,7 +790,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
observer->OnNetworkRefresh(info);
}
- ash::NetworkObserver* vpn_observer = tray_->vpn_observer();
+ ash::NetworkObserver* vpn_observer = GetSystemTray()->vpn_observer();
if (vpn_observer) {
ash::NetworkIconInfo info;
info.image = network_icon_->GetIconAndText(&info.description);
@@ -818,25 +827,25 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
void NotifyRefreshBluetooth() {
- ash::BluetoothObserver* observer = tray_->bluetooth_observer();
+ ash::BluetoothObserver* observer = GetSystemTray()->bluetooth_observer();
if (observer)
observer->OnBluetoothRefresh();
}
void NotifyBluetoothDiscoveringChanged() {
- ash::BluetoothObserver* observer = tray_->bluetooth_observer();
+ ash::BluetoothObserver* observer = GetSystemTray()->bluetooth_observer();
if (observer)
observer->OnBluetoothDiscoveringChanged();
}
void NotifyRefreshIME(bool show_message) {
- ash::IMEObserver* observer = tray_->ime_observer();
+ ash::IMEObserver* observer = GetSystemTray()->ime_observer();
if (observer)
observer->OnIMERefresh(show_message);
}
void NotifyRefreshDrive(ash::DriveOperationStatusList& list) {
- ash::DriveObserver* observer = tray_->drive_observer();
+ ash::DriveObserver* observer = GetSystemTray()->drive_observer();
if (observer)
observer->OnDriveRefresh(list);
}
@@ -962,24 +971,25 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
// Overridden from AudioHandler::VolumeObserver.
virtual void OnVolumeChanged() OVERRIDE {
float level = AudioHandler::GetInstance()->GetVolumePercent() / 100.f;
- tray_->audio_observer()->OnVolumeChanged(level);
+ GetSystemTray()->audio_observer()->OnVolumeChanged(level);
}
// Overridden from AudioHandler::VolumeObserver.
virtual void OnMuteToggled() OVERRIDE {
- tray_->audio_observer()->OnMuteToggled();
+ GetSystemTray()->audio_observer()->OnMuteToggled();
}
// Overridden from PowerManagerClient::Observer.
virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE {
- tray_->brightness_observer()->
+ GetSystemTray()->brightness_observer()->
OnBrightnessChanged(static_cast<double>(level), user_initiated);
}
virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE {
power_supply_status_ = power_status;
- FOR_EACH_OBSERVER(ash::PowerStatusObserver, tray_->power_status_observers(),
- OnPowerStatusChanged(power_status));
+ FOR_EACH_OBSERVER(ash::PowerStatusObserver,
+ GetSystemTray()->power_status_observers(),
+ OnPowerStatusChanged(power_status));
}
virtual void SystemResumed() OVERRIDE {
@@ -1028,7 +1038,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
RefreshNetworkObserver(crosnet);
RefreshNetworkDeviceObserver(crosnet);
data_promo_notification_->ShowOptionalMobileDataPromoNotification(
- crosnet, tray_, this);
+ crosnet, GetSystemTray(), this);
NotifyRefreshNetwork();
}
@@ -1072,7 +1082,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
severity = ash::UpdateObserver::UPDATE_NORMAL;
break;
}
- ash::UpdateObserver* observer = tray_->update_observer();
+ ash::UpdateObserver* observer = GetSystemTray()->update_observer();
if (observer)
observer->OnUpdateRecommended(severity);
break;
@@ -1081,7 +1091,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
// This notification is also sent on login screen when user avatar
// is loaded from file.
if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE) {
- ash::UserObserver* observer = tray_->user_observer();
+ ash::UserObserver* observer = GetSystemTray()->user_observer();
if (observer)
observer->OnUserUpdate();
}
@@ -1119,7 +1129,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
service->GetInteger(prefs::kLanguageRemapSearchKeyTo);
} else if (pref == prefs::kSpokenFeedbackEnabled) {
ash::AccessibilityObserver* observer =
- tray_->accessibility_observer();
+ GetSystemTray()->accessibility_observer();
if (observer) {
observer->OnAccessibilityModeChanged(
service->GetBoolean(prefs::kSpokenFeedbackEnabled));
@@ -1234,7 +1244,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
search_key_mapped_to_ == input_method::kCapsLockKey)
search_mapped_to_caps_lock = true;
- ash::CapsLockObserver* observer = tray_->caps_lock_observer();
+ ash::CapsLockObserver* observer = GetSystemTray()->caps_lock_observer();
if (observer)
observer->OnCapsLockChanged(enabled, search_mapped_to_caps_lock);
}
@@ -1274,7 +1284,6 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
}
- ash::SystemTray* tray_;
scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
scoped_ptr<NetworkMenuIcon> network_icon_;
scoped_ptr<NetworkMenuIcon> network_icon_dark_;
@@ -1305,8 +1314,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
} // namespace
-ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) {
- return new chromeos::SystemTrayDelegate(tray);
+ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
+ return new chromeos::SystemTrayDelegate();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.h b/chrome/browser/chromeos/system/ash_system_tray_delegate.h
index 2f3168c..e59728a 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.h
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.h
@@ -11,7 +11,7 @@ class SystemTrayDelegate;
}
namespace chromeos {
-ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray);
+ash::SystemTrayDelegate* CreateSystemTrayDelegate();
}
#endif // CHROME_BROWSER_CHROMEOS_SYSTEM_ASH_SYSTEM_TRAY_DELEGATE_H_
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index fb14af0..bb354bc 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -343,10 +343,9 @@ ash::LauncherDelegate* ChromeShellDelegate::CreateLauncherDelegate(
return launcher_delegate_;
}
-ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate(
- ash::SystemTray* tray) {
+ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() {
#if defined(OS_CHROMEOS)
- return chromeos::CreateSystemTrayDelegate(tray);
+ return chromeos::CreateSystemTrayDelegate();
#else
return NULL;
#endif
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index fae36da..3795833 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -60,8 +60,7 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual ash::LauncherDelegate* CreateLauncherDelegate(
ash::LauncherModel* model) OVERRIDE;
- virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate(
- ash::SystemTray* tray) OVERRIDE;
+ virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate() OVERRIDE;
virtual ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE;
virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;