summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-09 20:12:44 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-09 20:12:44 +0000
commit6cf6209313945db183394729a553be8097f1affd (patch)
tree53c1fd9951e9e293256bbb6ef1565bc12ff50c6c /ash
parentefacfe3516e3064810fa9c085e9920fbb6e21968 (diff)
downloadchromium_src-6cf6209313945db183394729a553be8097f1affd.zip
chromium_src-6cf6209313945db183394729a553be8097f1affd.tar.gz
chromium_src-6cf6209313945db183394729a553be8097f1affd.tar.bz2
ash: Do not activate volume/bubble popups, and fix a crash.
When volume/brightness is changed from the keyboard (or by other means), the popup that shows up should not be activated/focused. Also, when a volume popup shows up to replace a brightness popup (or vice versa), it should not crash. BUG=110130 TEST=none Review URL: https://chromiumcodereview.appspot.com/9669002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/audio/tray_volume.cc2
-rw-r--r--ash/system/brightness/tray_brightness.cc2
-rw-r--r--ash/system/tray/system_tray.cc27
-rw-r--r--ash/system/tray/system_tray.h12
-rw-r--r--ash/system/tray/system_tray_item.cc4
-rw-r--r--ash/system/tray/system_tray_item.h2
6 files changed, 34 insertions, 15 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index c52ec7e..485b3a4 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -182,7 +182,7 @@ void TrayVolume::OnVolumeChanged(float percent) {
return;
}
- PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds);
+ PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
}
} // namespace internal
diff --git a/ash/system/brightness/tray_brightness.cc b/ash/system/brightness/tray_brightness.cc
index 0b60d9e..2335ab4 100644
--- a/ash/system/brightness/tray_brightness.cc
+++ b/ash/system/brightness/tray_brightness.cc
@@ -120,7 +120,7 @@ void TrayBrightness::OnBrightnessChanged(float percent, bool user_initiated) {
}
if (!user_initiated)
return;
- PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds);
+ PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
}
} // namespace internal
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 667f3c8..3c9bb71 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -195,6 +195,7 @@ class SystemTrayBubble : public views::BubbleDelegateView {
tray_(tray),
items_(items),
detailed_(detailed),
+ can_activate_(true),
autoclose_delay_(0) {
set_margin(0);
set_parent_window(ash::Shell::GetInstance()->GetContainer(
@@ -213,6 +214,8 @@ class SystemTrayBubble : public views::BubbleDelegateView {
}
}
+ void set_can_activate(bool activate) { can_activate_ = activate; }
+
void StartAutoCloseTimer(int seconds) {
autoclose_.Stop();
autoclose_delay_ = seconds;
@@ -247,6 +250,10 @@ class SystemTrayBubble : public views::BubbleDelegateView {
}
}
+ virtual bool CanActivate() const OVERRIDE {
+ return can_activate_;
+ }
+
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
autoclose_.Stop();
}
@@ -263,6 +270,7 @@ class SystemTrayBubble : public views::BubbleDelegateView {
ash::SystemTray* tray_;
std::vector<ash::SystemTrayItem*> items_;
bool detailed_;
+ bool can_activate_;
int autoclose_delay_;
base::OneShotTimer<SystemTrayBubble> autoclose_;
@@ -312,15 +320,19 @@ void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
NOTIMPLEMENTED();
}
-void SystemTray::ShowDetailedView(SystemTrayItem* item, int close_delay) {
- if (popup_)
+void SystemTray::ShowDetailedView(SystemTrayItem* item,
+ int close_delay,
+ bool activate) {
+ if (popup_) {
+ popup_->RemoveObserver(this);
popup_->Close();
+ }
popup_ = NULL;
bubble_ = NULL;
std::vector<SystemTrayItem*> items;
items.push_back(item);
- ShowItems(items, true);
+ ShowItems(items, true, activate);
bubble_->StartAutoCloseTimer(close_delay);
}
@@ -345,10 +357,13 @@ void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) {
PreferredSizeChanged();
}
-void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) {
+void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items,
+ bool detailed,
+ bool activate) {
CHECK(!popup_);
CHECK(!bubble_);
bubble_ = new internal::SystemTrayBubble(this, container_, items, detailed);
+ bubble_->set_can_activate(activate);
popup_ = views::BubbleDelegateView::CreateBubble(bubble_);
bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
popup_->non_client_view()->frame_view()->set_background(NULL);
@@ -358,7 +373,7 @@ void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) {
// Setup animation.
ash::SetWindowVisibilityAnimationType(popup_->GetNativeWindow(),
- ash::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
+ ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
ash::SetWindowVisibilityAnimationTransition(popup_->GetNativeWindow(),
ash::ANIMATE_BOTH);
ash::SetWindowVisibilityAnimationDuration(popup_->GetNativeWindow(),
@@ -371,7 +386,7 @@ bool SystemTray::OnMousePressed(const views::MouseEvent& event) {
if (popup_)
popup_->Hide();
else
- ShowItems(items_, false);
+ ShowItems(items_, false, true);
return true;
}
diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h
index bc4b400..fd811f5 100644
--- a/ash/system/tray/system_tray.h
+++ b/ash/system/tray/system_tray.h
@@ -34,9 +34,11 @@ class ASH_EXPORT SystemTray : public views::View,
// Removes an existing tray item.
void RemoveTrayItem(SystemTrayItem* item);
- // Shows details of a particular item. If |close_delay| is non-zero, then the
- // view is automatically closed after the specified time.
- void ShowDetailedView(SystemTrayItem* item, int close_delay_in_seconds);
+ // Shows details of a particular item. If |close_delay_in_seconds| is
+ // non-zero, then the view is automatically closed after the specified time.
+ void ShowDetailedView(SystemTrayItem* item,
+ int close_delay_in_seconds,
+ bool activate);
// Updates the items when the login status of the system changes.
void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
@@ -44,7 +46,9 @@ class ASH_EXPORT SystemTray : public views::View,
const std::vector<SystemTrayItem*>& items() const { return items_; }
private:
- void ShowItems(std::vector<SystemTrayItem*>& items, bool details);
+ void ShowItems(std::vector<SystemTrayItem*>& items,
+ bool details,
+ bool activate);
// Overridden from views::View.
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
diff --git a/ash/system/tray/system_tray_item.cc b/ash/system/tray/system_tray_item.cc
index 3232f2bc..ad705e4 100644
--- a/ash/system/tray/system_tray_item.cc
+++ b/ash/system/tray/system_tray_item.cc
@@ -16,8 +16,8 @@ SystemTrayItem::SystemTrayItem() {
SystemTrayItem::~SystemTrayItem() {
}
-void SystemTrayItem::PopupDetailedView(int for_seconds) {
- Shell::GetInstance()->tray()->ShowDetailedView(this, for_seconds);
+void SystemTrayItem::PopupDetailedView(int for_seconds, bool activate) {
+ Shell::GetInstance()->tray()->ShowDetailedView(this, for_seconds, activate);
}
} // namespace ash
diff --git a/ash/system/tray/system_tray_item.h b/ash/system/tray/system_tray_item.h
index e1c2b44..23c6ff3 100644
--- a/ash/system/tray/system_tray_item.h
+++ b/ash/system/tray/system_tray_item.h
@@ -45,7 +45,7 @@ class ASH_EXPORT SystemTrayItem {
// something, e.g. volume, network availability etc. changes). If
// |for_seconds| is non-zero, then the popup is closed after the specified
// time.
- void PopupDetailedView(int for_seconds);
+ void PopupDetailedView(int for_seconds, bool activate);
private: