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

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

Issue 2097733002: Revert of mash: Convert TrayBackgroundView to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/tray_bubble_wrapper.h ('k') | ash/system/tray/tray_event_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_bubble_wrapper.cc
diff --git a/ash/system/tray/tray_bubble_wrapper.cc b/ash/system/tray/tray_bubble_wrapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..848b568dc82714e222a481b53489cf6b5b6117a9
--- /dev/null
+++ b/ash/system/tray/tray_bubble_wrapper.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/tray/tray_bubble_wrapper.h"
+
+#include "ash/common/wm_lookup.h"
+#include "ash/common/wm_window.h"
+#include "ash/system/tray/tray_background_view.h"
+#include "ash/system/tray/tray_event_filter.h"
+#include "ui/views/bubble/tray_bubble_view.h"
+#include "ui/views/widget/widget.h"
+
+namespace ash {
+
+TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray,
+ views::TrayBubbleView* bubble_view)
+ : tray_(tray),
+ bubble_view_(bubble_view) {
+ bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_);
+ bubble_widget_->AddObserver(this);
+
+ TrayBackgroundView::InitializeBubbleAnimations(bubble_widget_);
+ tray_->UpdateBubbleViewArrow(bubble_view_);
+ bubble_view_->InitializeAndShowBubble();
+
+ tray->tray_event_filter()->AddWrapper(this);
+}
+
+TrayBubbleWrapper::~TrayBubbleWrapper() {
+ tray_->tray_event_filter()->RemoveWrapper(this);
+ if (bubble_widget_) {
+ bubble_widget_->RemoveObserver(this);
+ bubble_widget_->Close();
+ }
+}
+
+void TrayBubbleWrapper::OnWidgetDestroying(views::Widget* widget) {
+ CHECK_EQ(bubble_widget_, widget);
+ bubble_widget_->RemoveObserver(this);
+ bubble_widget_ = NULL;
+
+ // Although the bubble is already closed, the next mouse release event
+ // will invoke PerformAction which reopens the bubble again. To prevent the
+ // reopen, the mouse capture of |tray_| has to be released.
+ // See crbug.com/177075
+ WmLookup::Get()->GetWindowForWidget(tray_->GetWidget())->ReleaseCapture();
+
+ tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_|
+}
+
+void TrayBubbleWrapper::OnWidgetBoundsChanged(views::Widget* widget,
+ const gfx::Rect& new_bounds) {
+ DCHECK_EQ(bubble_widget_, widget);
+ tray_->BubbleResized(bubble_view_);
+}
+
+} // namespace ash
« no previous file with comments | « ash/system/tray/tray_bubble_wrapper.h ('k') | ash/system/tray/tray_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698