summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 23:32:23 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 23:32:23 +0000
commitc4dca5876da4e912fde959249de4a1d704884582 (patch)
treed624cc6a78a2307ed85db3c98eb8e3d9a9c9a070 /ash
parentc53ce46a3bff3f1990095588ad6764bfd4480cad (diff)
downloadchromium_src-c4dca5876da4e912fde959249de4a1d704884582.zip
chromium_src-c4dca5876da4e912fde959249de4a1d704884582.tar.gz
chromium_src-c4dca5876da4e912fde959249de4a1d704884582.tar.bz2
Revert 137059 - Better fix for closing uber tray when clicking on Desktop
Bug=None Test=Manual Review URL: https://chromiumcodereview.appspot.com/9877015 TBR=pkotwicz@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=137752 Review URL: https://chromiumcodereview.appspot.com/10383236 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/tray/system_tray_bubble.cc31
-rw-r--r--ash/system/tray/system_tray_bubble.h10
2 files changed, 40 insertions, 1 deletions
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc
index 38596dc..07e064a 100644
--- a/ash/system/tray/system_tray_bubble.cc
+++ b/ash/system/tray/system_tray_bubble.cc
@@ -12,6 +12,7 @@
#include "ash/system/tray/tray_constants.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_animations.h"
+#include "base/message_loop.h"
#include "grit/ash_strings.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -356,6 +357,10 @@ SystemTrayBubble::SystemTrayBubble(
}
SystemTrayBubble::~SystemTrayBubble() {
+ // The bubble may be closing without having been hidden first. So it may still
+ // be in the message-loop's observer list.
+ MessageLoopForUI::current()->RemoveObserver(this);
+
DestroyItemViews();
// Reset the host pointer in bubble_view_ in case its destruction is deferred.
if (bubble_view_)
@@ -509,11 +514,37 @@ void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) {
}
}
+base::EventStatus SystemTrayBubble::WillProcessEvent(
+ const base::NativeEvent& event) {
+ // Check if the user clicked outside of the bubble and close it if they did.
+ if (bubble_type_ != BUBBLE_TYPE_NOTIFICATION &&
+ ui::EventTypeFromNative(event) == ui::ET_MOUSE_PRESSED) {
+ gfx::Point cursor_in_view = ui::EventLocationFromNative(event);
+ views::View::ConvertPointFromScreen(bubble_view_, &cursor_in_view);
+ if (!bubble_view_->HitTest(cursor_in_view)) {
+ bubble_widget_->Close();
+ }
+ }
+ return base::EVENT_CONTINUE;
+}
+
+void SystemTrayBubble::DidProcessEvent(const base::NativeEvent& event) {
+}
+
void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) {
CHECK_EQ(bubble_widget_, widget);
+ MessageLoopForUI::current()->RemoveObserver(this);
bubble_widget_ = NULL;
tray_->RemoveBubble(this);
}
+void SystemTrayBubble::OnWidgetVisibilityChanged(views::Widget* widget,
+ bool visible) {
+ if (!visible)
+ MessageLoopForUI::current()->RemoveObserver(this);
+ else
+ MessageLoopForUI::current()->AddObserver(this);
+}
+
} // namespace internal
} // namespace ash
diff --git a/ash/system/tray/system_tray_bubble.h b/ash/system/tray/system_tray_bubble.h
index 63b749f..ed397b3 100644
--- a/ash/system/tray/system_tray_bubble.h
+++ b/ash/system/tray/system_tray_bubble.h
@@ -8,6 +8,7 @@
#include "ash/system/user/login_status.h"
#include "base/base_export.h"
+#include "base/message_pump_observer.h"
#include "base/timer.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/widget/widget.h"
@@ -57,7 +58,8 @@ class SystemTrayBubbleView : public views::BubbleDelegateView {
DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleView);
};
-class SystemTrayBubble : public views::Widget::Observer {
+class SystemTrayBubble : public base::MessagePumpObserver,
+ public views::Widget::Observer {
public:
enum BubbleType {
BUBBLE_TYPE_DEFAULT,
@@ -107,8 +109,14 @@ class SystemTrayBubble : public views::Widget::Observer {
private:
void CreateItemViews(user::LoginStatus login_status);
+ // Overridden from base::MessagePumpObserver.
+ virtual base::EventStatus WillProcessEvent(
+ const base::NativeEvent& event) OVERRIDE;
+ virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
// Overridden from views::Widget::Observer.
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
+ virtual void OnWidgetVisibilityChanged(views::Widget* widget,
+ bool visible) OVERRIDE;
ash::SystemTray* tray_;
SystemTrayBubbleView* bubble_view_;