X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fash%2Fsystem%2Ftray%2Fsystem_tray.cc;h=d8ac9a539b725728c8e5676d2f14fc7e1607c18d;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=5c1189d259fda1bd6ceb9c5c4fef5b5949b09d51;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ash/system/tray/system_tray.cc b/src/ash/system/tray/system_tray.cc index 5c1189d..d8ac9a5 100644 --- a/src/ash/system/tray/system_tray.cc +++ b/src/ash/system/tray/system_tray.cc @@ -53,6 +53,7 @@ #include "ash/system/chromeos/network/tray_sms.h" #include "ash/system/chromeos/network/tray_vpn.h" #include "ash/system/chromeos/power/tray_power.h" +#include "ash/system/chromeos/rotation/tray_rotation_lock.h" #include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" #include "ash/system/chromeos/screen_security/screen_share_tray_item.h" #include "ash/system/chromeos/session/tray_session_length_limit.h" @@ -60,6 +61,7 @@ #include "ash/system/chromeos/tray_caps_lock.h" #include "ash/system/chromeos/tray_display.h" #include "ash/system/chromeos/tray_tracing.h" +#include "ash/system/tray/media_security/multi_profile_media_tray_item.h" #include "ui/message_center/message_center.h" #elif defined(OS_WIN) #include "ash/system/win/audio/tray_audio_win.h" @@ -73,18 +75,14 @@ namespace ash { // The minimum width of the system tray menu width. const int kMinimumSystemTrayMenuWidth = 300; -namespace internal { - // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper // instances for a bubble. class SystemBubbleWrapper { public: // Takes ownership of |bubble|. - explicit SystemBubbleWrapper(internal::SystemTrayBubble* bubble) - : bubble_(bubble), - is_persistent_(false) { - } + explicit SystemBubbleWrapper(SystemTrayBubble* bubble) + : bubble_(bubble), is_persistent_(false) {} // Initializes the bubble view and creates |bubble_wrapper_|. void InitView(TrayBackgroundView* tray, @@ -95,13 +93,10 @@ class SystemBubbleWrapper { user::LoginStatus login_status = Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); bubble_->InitView(anchor, login_status, init_params); - bubble_wrapper_.reset( - new internal::TrayBubbleWrapper(tray, bubble_->bubble_view())); - if (ash::switches::UseAlternateShelfLayout()) { - // The system bubble should not have an arrow. - bubble_->bubble_view()->SetArrowPaintType( - views::BubbleBorder::PAINT_NONE); - } + bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); + // The system bubble should not have an arrow. + bubble_->bubble_view()->SetArrowPaintType( + views::BubbleBorder::PAINT_NONE); is_persistent_ = is_persistent; // If ChromeVox is enabled, focus the default item if no item is focused. @@ -120,21 +115,18 @@ class SystemBubbleWrapper { bool is_persistent() const { return is_persistent_; } private: - scoped_ptr bubble_; - scoped_ptr bubble_wrapper_; + scoped_ptr bubble_; + scoped_ptr bubble_wrapper_; bool is_persistent_; DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); }; -} // namespace internal // SystemTray -using internal::SystemTrayBubble; - -SystemTray::SystemTray(internal::StatusAreaWidget* status_area_widget) - : internal::TrayBackgroundView(status_area_widget), +SystemTray::SystemTray(StatusAreaWidget* status_area_widget) + : TrayBackgroundView(status_area_widget), items_(), default_bubble_height_(0), hide_notifications_(false), @@ -156,13 +148,13 @@ SystemTray::~SystemTray() { } void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { - internal::TrayBackgroundView::Initialize(); + TrayBackgroundView::Initialize(); CreateItems(delegate); } void SystemTray::CreateItems(SystemTrayDelegate* delegate) { #if defined(OS_CHROMEOS) - AddTrayItem(new internal::TraySessionLengthLimit(this)); + AddTrayItem(new TraySessionLengthLimit(this)); #endif #if !defined(OS_WIN) // Create user items for each possible user. @@ -170,52 +162,53 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { int maximum_user_profiles = shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers(); for (int i = 0; i < maximum_user_profiles; i++) - AddTrayItem(new internal::TrayUser(this, i)); + AddTrayItem(new TrayUser(this, i)); if (maximum_user_profiles > 1) { // Add a special double line separator between users and the rest of the // menu if more then one user is logged in. - AddTrayItem(new internal::TrayUserSeparator(this)); + AddTrayItem(new TrayUserSeparator(this)); } #endif - tray_accessibility_ = new internal::TrayAccessibility(this); - tray_date_ = new internal::TrayDate(this); + tray_accessibility_ = new TrayAccessibility(this); + tray_date_ = new TrayDate(this); #if defined(OS_CHROMEOS) - AddTrayItem(new internal::TrayEnterprise(this)); - AddTrayItem(new internal::TrayLocallyManagedUser(this)); - AddTrayItem(new internal::TrayIME(this)); + AddTrayItem(new TrayEnterprise(this)); + AddTrayItem(new TrayLocallyManagedUser(this)); + AddTrayItem(new TrayIME(this)); AddTrayItem(tray_accessibility_); - AddTrayItem(new internal::TrayTracing(this)); - AddTrayItem( - new internal::TrayPower(this, message_center::MessageCenter::Get())); - AddTrayItem(new internal::TrayNetwork(this)); - AddTrayItem(new internal::TrayVPN(this)); - AddTrayItem(new internal::TraySms(this)); - AddTrayItem(new internal::TrayBluetooth(this)); - AddTrayItem(new internal::TrayDrive(this)); - AddTrayItem(new internal::TrayDisplay(this)); - AddTrayItem(new internal::ScreenCaptureTrayItem(this)); - AddTrayItem(new internal::ScreenShareTrayItem(this)); - AddTrayItem(new internal::TrayAudioChromeOs(this)); - AddTrayItem(new internal::TrayBrightness(this)); - AddTrayItem(new internal::TrayCapsLock(this)); - AddTrayItem(new internal::TraySettings(this)); - AddTrayItem(new internal::TrayUpdate(this)); + AddTrayItem(new TrayTracing(this)); + AddTrayItem(new TrayPower(this, message_center::MessageCenter::Get())); + AddTrayItem(new TrayNetwork(this)); + AddTrayItem(new TrayVPN(this)); + AddTrayItem(new TraySms(this)); + AddTrayItem(new TrayBluetooth(this)); + AddTrayItem(new TrayDrive(this)); + AddTrayItem(new TrayDisplay(this)); + AddTrayItem(new ScreenCaptureTrayItem(this)); + AddTrayItem(new ScreenShareTrayItem(this)); + AddTrayItem(new MultiProfileMediaTrayItem(this)); + AddTrayItem(new TrayAudioChromeOs(this)); + AddTrayItem(new TrayBrightness(this)); + AddTrayItem(new TrayCapsLock(this)); + AddTrayItem(new TraySettings(this)); + AddTrayItem(new TrayUpdate(this)); + AddTrayItem(new TrayRotationLock(this)); AddTrayItem(tray_date_); #elif defined(OS_WIN) AddTrayItem(tray_accessibility_); if (media::CoreAudioUtil::IsSupported()) - AddTrayItem(new internal::TrayAudioWin(this)); - AddTrayItem(new internal::TrayUpdate(this)); + AddTrayItem(new TrayAudioWin(this)); + AddTrayItem(new TrayUpdate(this)); AddTrayItem(tray_date_); #elif defined(OS_LINUX) - AddTrayItem(new internal::TrayIME(this)); + AddTrayItem(new TrayIME(this)); AddTrayItem(tray_accessibility_); - AddTrayItem(new internal::TrayBluetooth(this)); - AddTrayItem(new internal::TrayDrive(this)); - AddTrayItem(new internal::TrayUpdate(this)); + AddTrayItem(new TrayBluetooth(this)); + AddTrayItem(new TrayDrive(this)); + AddTrayItem(new TrayUpdate(this)); AddTrayItem(tray_date_); #endif @@ -266,8 +259,14 @@ void SystemTray::ShowDetailedView(SystemTrayItem* item, bool activate, BubbleCreationType creation_type) { std::vector items; + // The detailed view with timeout means a UI to show the current system state, + // like the audio level or brightness. Such UI should behave as persistent and + // keep its own logic for the appearance. + bool persistent = ( + !activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW); items.push_back(item); - ShowItems(items, true, activate, creation_type, GetTrayXOffset(item), false); + ShowItems( + items, true, activate, creation_type, GetTrayXOffset(item), persistent); if (system_bubble_) system_bubble_->bubble()->StartAutoCloseTimer(close_delay); } @@ -348,7 +347,7 @@ bool SystemTray::HasNotificationBubble() const { return notification_bubble_.get() != NULL; } -internal::SystemTrayBubble* SystemTray::GetSystemBubble() { +SystemTrayBubble* SystemTray::GetSystemBubble() { if (!system_bubble_) return NULL; return system_bubble_->bubble(); @@ -482,8 +481,7 @@ void SystemTray::ShowItems(const std::vector& items, menu_width, kTrayPopupMaxWidth); init_params.can_activate = can_activate; - init_params.first_item_has_no_margin = - ash::switches::UseAlternateShelfLayout(); + init_params.first_item_has_no_margin = true; if (detailed) { // This is the case where a volume control or brightness control bubble // is created. @@ -501,7 +499,7 @@ void SystemTray::ShowItems(const std::vector& items, if (items.size() == 1 && items[0]->ShouldHideArrow()) init_params.arrow_paint_type = views::BubbleBorder::PAINT_TRANSPARENT; SystemTrayBubble* bubble = new SystemTrayBubble(this, items, bubble_type); - system_bubble_.reset(new internal::SystemBubbleWrapper(bubble)); + system_bubble_.reset(new SystemBubbleWrapper(bubble)); system_bubble_->InitView(this, tray_container(), &init_params, persistent); } // Save height of default view for creating detailed views directly. @@ -554,12 +552,10 @@ void SystemTray::UpdateNotificationBubble() { GetAnchorAlignment(), kTrayPopupMinWidth, kTrayPopupMaxWidth); - init_params.first_item_has_no_margin = - ash::switches::UseAlternateShelfLayout(); + init_params.first_item_has_no_margin = true; init_params.arrow_color = kBackgroundColor; init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); - notification_bubble_.reset( - new internal::SystemBubbleWrapper(notification_bubble)); + notification_bubble_.reset(new SystemBubbleWrapper(notification_bubble)); notification_bubble_->InitView(this, anchor, &init_params, false); if (notification_bubble->bubble_view()->child_count() == 0) { @@ -598,7 +594,7 @@ void SystemTray::UpdateWebNotifications() { void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { if (alignment == shelf_alignment()) return; - internal::TrayBackgroundView::SetShelfAlignment(alignment); + TrayBackgroundView::SetShelfAlignment(alignment); UpdateAfterShelfAlignmentChange(alignment); // Destroy any existing bubble so that it is rebuilt correctly. CloseSystemBubbleAndDeactivateSystemTray(); @@ -686,9 +682,7 @@ views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { return it == tray_item_map_.end() ? NULL : it->second; } -internal::TrayDate* SystemTray::GetTrayDateForTesting() const { - return tray_date_; -} +TrayDate* SystemTray::GetTrayDateForTesting() const { return tray_date_; } bool SystemTray::PerformAction(const ui::Event& event) { // If we're already showing the default view, hide it; otherwise, show it