Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/extension_popup.cc |
| diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc |
| index fabbcddf729cfe35ad10f6d35b70209de90cae2a..6b7c85009ac1ff515c9f56e58d668c5816dd438d 100644 |
| --- a/chrome/browser/ui/views/extensions/extension_popup.cc |
| +++ b/chrome/browser/ui/views/extensions/extension_popup.cc |
| @@ -16,13 +16,9 @@ |
| #include "content/public/browser/notification_source.h" |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/web_contents.h" |
| -#include "ui/aura/window.h" |
| #include "ui/gfx/geometry/insets.h" |
| #include "ui/views/layout/fill_layout.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" |
| namespace { |
| @@ -40,6 +36,18 @@ const int ExtensionPopup::kMinHeight = 25; |
| const int ExtensionPopup::kMaxWidth = 800; |
| const int ExtensionPopup::kMaxHeight = 600; |
| +#if !defined(USE_AURA) |
| +// static |
| +ExtensionPopup* ExtensionPopup::Create(extensions::ExtensionViewHost* host, |
| + views::View* anchor_view, |
| + views::BubbleBorder::Arrow arrow, |
| + ShowAction show_action) { |
| + auto popup = new ExtensionPopup(host, anchor_view, arrow, show_action); |
| + views::BubbleDelegateView::CreateBubble(popup); |
| + return popup; |
| +} |
| +#endif |
| + |
| ExtensionPopup::ExtensionPopup(extensions::ExtensionViewHost* host, |
| views::View* anchor_view, |
| views::BubbleBorder::Arrow arrow, |
| @@ -138,53 +146,29 @@ void ExtensionPopup::ViewHierarchyChanged( |
| CHECK(GetWidget() || !widget_initialized_); |
| } |
| -void ExtensionPopup::OnWidgetDestroying(views::Widget* widget) { |
| - BubbleDelegateView::OnWidgetDestroying(widget); |
| - aura::Window* bubble_window = GetWidget()->GetNativeWindow(); |
| - aura::client::ActivationClient* activation_client = |
| - aura::client::GetActivationClient(bubble_window->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 ExtensionPopup::OnWidgetActivationChanged(views::Widget* widget, |
| bool active) { |
| - // TODO(msw): Find any remaining crashes related to http://crbug.com/327776 |
| - // No calls are expected if the widget isn't initialized or no longer exists. |
| - CHECK(widget_initialized_); |
| - CHECK(GetWidget()); |
| + if (active && widget == anchor_widget()) |
|
msw
2015/03/06 19:26:49
I feel like I had to explicitly check the NativeWi
Andre
2015/03/07 00:56:26
Ack, thanks!
|
| + OnAnchorWindowActivation(); |
| +} |
| - // Close on anchor window activation (ie. user clicked the browser window). |
| - if (!inspect_with_devtools_ && widget && active && |
| - widget->GetNativeWindow() == anchor_widget()->GetNativeWindow()) |
| - GetWidget()->Close(); |
| +void ExtensionPopup::ActiveTabChanged(content::WebContents* old_contents, |
| + content::WebContents* new_contents, |
| + int index, |
| + int reason) { |
| + GetWidget()->Close(); |
| } |
| -void ExtensionPopup::OnWindowActivated(aura::Window* gained_active, |
| - aura::Window* lost_active) { |
| +void ExtensionPopup::OnAnchorWindowActivation() { |
| // TODO(msw): Find any remaining crashes related to http://crbug.com/327776 |
| // No calls are expected if the widget isn't initialized or no longer exists. |
| CHECK(widget_initialized_); |
| CHECK(GetWidget()); |
| - // 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 (!inspect_with_devtools_ && |
| - gained_active == anchor_widget()->GetNativeWindow()) |
| + if (!inspect_with_devtools_) |
| GetWidget()->Close(); |
| } |
| -void ExtensionPopup::ActiveTabChanged(content::WebContents* old_contents, |
| - content::WebContents* new_contents, |
| - int index, |
| - int reason) { |
| - GetWidget()->Close(); |
| -} |
| - |
| // static |
| ExtensionPopup* ExtensionPopup::ShowPopup(const GURL& url, |
| Browser* browser, |
| @@ -193,25 +177,13 @@ ExtensionPopup* ExtensionPopup::ShowPopup(const GURL& url, |
| ShowAction show_action) { |
| extensions::ExtensionViewHost* host = |
| extensions::ExtensionViewHostFactory::CreatePopupHost(url, browser); |
| - ExtensionPopup* popup = new ExtensionPopup(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); |
| + auto popup = ExtensionPopup::Create(host, anchor_view, arrow, show_action); |
| // If the host had somehow finished loading, then we'd miss the notification |
| // and not show. This seems to happen in single-process mode. |
| if (host->did_stop_loading()) |
| popup->ShowBubble(); |
| - aura::Window* bubble_window = popup->GetWidget()->GetNativeWindow(); |
| - aura::client::ActivationClient* activation_client = |
| - aura::client::GetActivationClient(bubble_window->GetRootWindow()); |
| - activation_client->AddObserver(popup); |
| - |
| return popup; |
| } |