summaryrefslogtreecommitdiffstats
path: root/ash/system/tray/system_tray.cc
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 01:11:00 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 01:11:00 +0000
commit83b2b84c1e4bc8434630f58e88bcf1a93b33ded6 (patch)
treee6612ff5286a73ed99df758ee600f331396e51d6 /ash/system/tray/system_tray.cc
parentd8f1004bcf08a2c0d629198a3695808b3a400487 (diff)
downloadchromium_src-83b2b84c1e4bc8434630f58e88bcf1a93b33ded6.zip
chromium_src-83b2b84c1e4bc8434630f58e88bcf1a93b33ded6.tar.gz
chromium_src-83b2b84c1e4bc8434630f58e88bcf1a93b33ded6.tar.bz2
Add SystemTrayObservers
Once there is more than one SystemTray instance, we will need to support observer lists so that multiple tray items can be notified. Hosting the observer lists in a separate class owned by ass::SystemTrayDelegate seemed like the most forward approach. BUG=159543 For ash.gyp: TBR=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/11312139 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/tray/system_tray.cc')
-rw-r--r--ash/system/tray/system_tray.cc91
1 files changed, 38 insertions, 53 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index e7d8385..9ba7800 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -18,12 +18,12 @@
#include "ash/system/locale/tray_locale.h"
#include "ash/system/logout_button/tray_logout_button.h"
#include "ash/system/monitor/tray_monitor.h"
-#include "ash/system/power/power_status_observer.h"
#include "ash/system/power/power_supply_status.h"
#include "ash/system/power/tray_power.h"
#include "ash/system/settings/tray_settings.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray/tray_bubble_wrapper.h"
#include "ash/system/tray/tray_constants.h"
@@ -107,23 +107,6 @@ using internal::SystemTrayBubble;
SystemTray::SystemTray(internal::StatusAreaWidget* status_area_widget)
: internal::TrayBackgroundView(status_area_widget),
items_(),
- accessibility_observer_(NULL),
- audio_observer_(NULL),
- bluetooth_observer_(NULL),
- brightness_observer_(NULL),
- caps_lock_observer_(NULL),
- clock_observer_(NULL),
- drive_observer_(NULL),
- ime_observer_(NULL),
- locale_observer_(NULL),
- logout_button_observer_(NULL),
-#if defined(OS_CHROMEOS)
- network_observer_(NULL),
- vpn_observer_(NULL),
- sms_observer_(NULL),
-#endif
- update_observer_(NULL),
- user_observer_(NULL),
default_bubble_height_(0),
hide_notifications_(false) {
SetContentsBackground();
@@ -140,47 +123,54 @@ SystemTray::~SystemTray() {
}
}
-void SystemTray::CreateItems() {
+void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) {
+ internal::TrayBackgroundView::Initialize();
+ CreateItems(delegate);
+}
+
+void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
internal::TrayVolume* tray_volume = new internal::TrayVolume();
internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth();
internal::TrayBrightness* tray_brightness = new internal::TrayBrightness();
internal::TrayDate* tray_date = new internal::TrayDate();
internal::TrayPower* tray_power = new internal::TrayPower();
- internal::TrayIME* tray_ime = new internal::TrayIME;
- internal::TrayUser* tray_user = new internal::TrayUser;
+ internal::TrayIME* tray_ime = new internal::TrayIME();
+ internal::TrayUser* tray_user = new internal::TrayUser();
internal::TrayAccessibility* tray_accessibility =
- new internal::TrayAccessibility;
- internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock;
- internal::TrayDrive* tray_drive = new internal::TrayDrive;
- internal::TrayLocale* tray_locale = new internal::TrayLocale;
+ new internal::TrayAccessibility();
+ internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock();
+ internal::TrayDrive* tray_drive = new internal::TrayDrive();
+ internal::TrayLocale* tray_locale = new internal::TrayLocale();
internal::TrayLogoutButton* tray_logout_button =
new internal::TrayLogoutButton();
- internal::TrayUpdate* tray_update = new internal::TrayUpdate;
+ internal::TrayUpdate* tray_update = new internal::TrayUpdate();
internal::TraySettings* tray_settings = new internal::TraySettings();
-
- accessibility_observer_ = tray_accessibility;
- audio_observer_ = tray_volume;
- bluetooth_observer_ = tray_bluetooth;
- brightness_observer_ = tray_brightness;
- caps_lock_observer_ = tray_caps_lock;
- clock_observer_ = tray_date;
- drive_observer_ = tray_drive;
- ime_observer_ = tray_ime;
- locale_observer_ = tray_locale;
- logout_button_observer_ = tray_logout_button;
- power_status_observers_.AddObserver(tray_power);
- power_status_observers_.AddObserver(tray_settings);
- update_observer_ = tray_update;
- user_observer_ = tray_user;
-
#if defined(OS_CHROMEOS)
- internal::TrayDisplay* tray_display = new internal::TrayDisplay;
- internal::TrayNetwork* tray_network = new internal::TrayNetwork;
- internal::TrayVPN* tray_vpn = new internal::TrayVPN;
+ internal::TrayDisplay* tray_display = new internal::TrayDisplay();
+ internal::TrayNetwork* tray_network = new internal::TrayNetwork();
+ internal::TrayVPN* tray_vpn = new internal::TrayVPN();
internal::TraySms* tray_sms = new internal::TraySms();
- network_observer_ = tray_network;
- vpn_observer_ = tray_vpn;
- sms_observer_ = tray_sms;
+#endif
+
+ SystemTrayNotifier* notifier = Shell::GetInstance()->system_tray_notifier();
+ notifier->AddAccessibilityObserver(tray_accessibility);
+ notifier->AddAudioObserver(tray_volume);
+ notifier->AddBluetoothObserver(tray_bluetooth);
+ notifier->AddBrightnessObserver(tray_brightness);
+ notifier->AddCapsLockObserver(tray_caps_lock);
+ notifier->AddClockObserver(tray_date);
+ notifier->AddDriveObserver(tray_drive);
+ notifier->AddIMEObserver(tray_ime);
+ notifier->AddLocaleObserver(tray_locale);
+ notifier->AddLogoutButtonObserver(tray_logout_button);
+ notifier->AddPowerStatusObserver(tray_power);
+ notifier->AddPowerStatusObserver(tray_settings);
+ notifier->AddUpdateObserver(tray_update);
+ notifier->AddUserObserver(tray_user);
+#if defined(OS_CHROMEOS)
+ notifier->AddNetworkObserver(tray_network);
+ notifier->AddVpnObserver(tray_vpn);
+ notifier->AddSmsObserver(tray_sms);
#endif
AddTrayItem(tray_logout_button);
@@ -498,11 +488,6 @@ void SystemTray::UpdateNotificationBubble() {
status_area_widget()->SetHideWebNotifications(true);
}
-void SystemTray::Initialize() {
- internal::TrayBackgroundView::Initialize();
- CreateItems();
-}
-
void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
if (alignment == shelf_alignment())
return;