Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1979)

Unified Diff: ash/system/tray/system_tray_bubble.cc

Issue 10383236: Revert 137059 - Better fix for closing uber tray when clicking on Desktop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/system_tray_bubble.h ('k') | ui/views/bubble/bubble_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray_bubble.cc
===================================================================
--- ash/system/tray/system_tray_bubble.cc (revision 137750)
+++ ash/system/tray/system_tray_bubble.cc (working copy)
@@ -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() {
+ // 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 @@
}
}
+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
« no previous file with comments | « ash/system/tray/system_tray_bubble.h ('k') | ui/views/bubble/bubble_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698