Index: chrome/browser/ui/views/extensions/extension_popup_aura.cc |
diff --git a/chrome/browser/ui/views/extensions/extension_popup_aura.cc b/chrome/browser/ui/views/extensions/extension_popup_aura.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d6740c8d9b34806533b92ede7ae3ed5151935b7c |
--- /dev/null |
+++ b/chrome/browser/ui/views/extensions/extension_popup_aura.cc |
@@ -0,0 +1,71 @@ |
+// Copyright 2015 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 "chrome/browser/ui/views/extensions/extension_popup_aura.h" |
+ |
+#include "ui/aura/window.h" |
+#include "ui/views/widget/widget.h" |
+#include "ui/wm/core/window_animations.h" |
+#include "ui/wm/core/window_util.h" |
+#include "ui/wm/public/activation_client.h" |
+ |
+// static |
+ExtensionPopup* ExtensionPopup::Create(extensions::ExtensionViewHost* host, |
+ views::View* anchor_view, |
+ views::BubbleBorder::Arrow arrow, |
+ ShowAction show_action) { |
+ auto popup = new ExtensionPopupAura(host, anchor_view, arrow, show_action); |
+ views::BubbleDelegateView::CreateBubble(popup); |
+ |
+ gfx::NativeView native_view = popup->GetWidget()->GetNativeView(); |
+ wm::SetWindowVisibilityAnimationType( |
+ native_view, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); |
+ wm::SetWindowVisibilityAnimationVerticalPosition(native_view, -3.0f); |
+ |
+ return popup; |
+} |
+ |
+ExtensionPopupAura::ExtensionPopupAura(extensions::ExtensionViewHost* host, |
+ views::View* anchor_view, |
+ views::BubbleBorder::Arrow arrow, |
+ ShowAction show_action) |
+ : ExtensionPopup(host, anchor_view, arrow, show_action) { |
+} |
+ |
+ExtensionPopupAura::~ExtensionPopupAura() { |
+} |
+ |
+void ExtensionPopupAura::OnWidgetDestroying(views::Widget* widget) { |
+ ExtensionPopup::OnWidgetDestroying(widget); |
+ |
+ if (widget == GetWidget()) { |
Andre
2015/03/06 00:59:39
This check was not there, but seems like it should
msw
2015/03/06 19:26:49
Probably, unless this was also observing the ancho
|
+ auto activation_client = aura::client::GetActivationClient( |
+ widget->GetNativeWindow()->GetRootWindow()); |
+ // If the popup was being inspected with devtools and the browser window |
+ // was closed, then the root window and activation client are already |
+ // destroyed. |
+ if (activation_client) |
+ activation_client->RemoveObserver(this); |
+ } |
+} |
+ |
+void ExtensionPopupAura::OnWidgetActivationChanged(views::Widget* widget, |
+ bool active) { |
+ ExtensionPopup::OnWidgetActivationChanged(widget, active); |
+ |
+ if (active && widget == GetWidget()) { |
+ aura::Window* root_window = widget->GetNativeWindow()->GetRootWindow(); |
+ aura::client::GetActivationClient(root_window)->AddObserver(this); |
Andre
2015/03/06 00:59:39
This moved here from ExtensionPopup::ShowPopup().
msw
2015/03/06 19:26:49
Is it okay that this will call AddObserver multipl
Andre
2015/03/07 00:56:26
Good point. I moved it to Create() above.
|
+ } |
+} |
+ |
+void ExtensionPopupAura::OnWindowActivated(aura::Window* gained_active, |
+ aura::Window* lost_active) { |
+ // Close on anchor window activation (ie. user clicked the browser window). |
+ // DesktopNativeWidgetAura does not trigger the expected browser widget |
+ // [de]activation events when activating widgets in its own root window. |
+ // This additional check handles those cases. See: http://crbug.com/320889 |
+ if (gained_active == anchor_widget()->GetNativeWindow()) |
+ OnAnchorWindowActivation(); |
+} |