| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 11 #include "chrome/browser/ui/views/extensions/extension_view_views.h" | 11 #include "chrome/browser/ui/views/extensions/extension_view_views.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "ui/views/bubble/bubble_delegate.h" | 14 #include "ui/views/bubble/bubble_delegate.h" |
| 15 #include "ui/wm/public/activation_change_observer.h" | |
| 16 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 17 | 16 |
| 18 | 17 |
| 19 class Browser; | 18 class Browser; |
| 20 namespace views { | 19 namespace views { |
| 21 class Widget; | 20 class Widget; |
| 22 } | 21 } |
| 23 | 22 |
| 24 namespace content { | 23 namespace content { |
| 25 class DevToolsAgentHost; | 24 class DevToolsAgentHost; |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace extensions { | 27 namespace extensions { |
| 29 class ExtensionViewHost; | 28 class ExtensionViewHost; |
| 30 } | 29 } |
| 31 | 30 |
| 32 class ExtensionPopup : public views::BubbleDelegateView, | 31 class ExtensionPopup : public views::BubbleDelegateView, |
| 33 public aura::client::ActivationChangeObserver, | |
| 34 public ExtensionViewViews::Container, | 32 public ExtensionViewViews::Container, |
| 35 public content::NotificationObserver, | 33 public content::NotificationObserver, |
| 36 public TabStripModelObserver { | 34 public TabStripModelObserver { |
| 37 public: | 35 public: |
| 38 enum ShowAction { | 36 enum ShowAction { |
| 39 SHOW, | 37 SHOW, |
| 40 SHOW_AND_INSPECT, | 38 SHOW_AND_INSPECT, |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 ~ExtensionPopup() override; | 41 ~ExtensionPopup() override; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 66 | 64 |
| 67 // ExtensionViewViews::Container overrides. | 65 // ExtensionViewViews::Container overrides. |
| 68 void OnExtensionSizeChanged(ExtensionViewViews* view) override; | 66 void OnExtensionSizeChanged(ExtensionViewViews* view) override; |
| 69 | 67 |
| 70 // views::View overrides. | 68 // views::View overrides. |
| 71 gfx::Size GetPreferredSize() const override; | 69 gfx::Size GetPreferredSize() const override; |
| 72 void ViewHierarchyChanged( | 70 void ViewHierarchyChanged( |
| 73 const ViewHierarchyChangedDetails& details) override; | 71 const ViewHierarchyChangedDetails& details) override; |
| 74 | 72 |
| 75 // views::WidgetObserver overrides. | 73 // views::WidgetObserver overrides. |
| 76 void OnWidgetDestroying(views::Widget* widget) override; | |
| 77 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; | 74 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; |
| 78 | 75 |
| 79 // aura::client::ActivationChangeObserver overrides. | |
| 80 void OnWindowActivated(aura::Window* gained_active, | |
| 81 aura::Window* lost_active) override; | |
| 82 | |
| 83 // TabStripModelObserver overrides. | 76 // TabStripModelObserver overrides. |
| 84 void ActiveTabChanged(content::WebContents* old_contents, | 77 void ActiveTabChanged(content::WebContents* old_contents, |
| 85 content::WebContents* new_contents, | 78 content::WebContents* new_contents, |
| 86 int index, | 79 int index, |
| 87 int reason) override; | 80 int reason) override; |
| 88 | 81 |
| 89 // The min/max height of popups. | 82 // The min/max height of popups. |
| 90 static const int kMinWidth; | 83 static const int kMinWidth; |
| 91 static const int kMinHeight; | 84 static const int kMinHeight; |
| 92 static const int kMaxWidth; | 85 static const int kMaxWidth; |
| 93 static const int kMaxHeight; | 86 static const int kMaxHeight; |
| 94 | 87 |
| 95 private: | 88 protected: |
| 96 ExtensionPopup(extensions::ExtensionViewHost* host, | 89 ExtensionPopup(extensions::ExtensionViewHost* host, |
| 97 views::View* anchor_view, | 90 views::View* anchor_view, |
| 98 views::BubbleBorder::Arrow arrow, | 91 views::BubbleBorder::Arrow arrow, |
| 99 ShowAction show_action); | 92 ShowAction show_action); |
| 100 | 93 |
| 94 // Called on anchor window activation (ie. user clicked the browser window). |
| 95 void OnAnchorWindowActivation(); |
| 96 |
| 97 private: |
| 98 static ExtensionPopup* Create(extensions::ExtensionViewHost* host, |
| 99 views::View* anchor_view, |
| 100 views::BubbleBorder::Arrow arrow, |
| 101 ShowAction show_action); |
| 102 |
| 101 // Show the bubble, focus on its content, and register listeners. | 103 // Show the bubble, focus on its content, and register listeners. |
| 102 void ShowBubble(); | 104 void ShowBubble(); |
| 103 | 105 |
| 104 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); | 106 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); |
| 105 | 107 |
| 106 // The contained host for the view. | 108 // The contained host for the view. |
| 107 scoped_ptr<extensions::ExtensionViewHost> host_; | 109 scoped_ptr<extensions::ExtensionViewHost> host_; |
| 108 | 110 |
| 109 // Flag used to indicate if the pop-up should open a devtools window once | 111 // Flag used to indicate if the pop-up should open a devtools window once |
| 110 // it is shown inspecting it. | 112 // it is shown inspecting it. |
| 111 bool inspect_with_devtools_; | 113 bool inspect_with_devtools_; |
| 112 | 114 |
| 113 content::NotificationRegistrar registrar_; | 115 content::NotificationRegistrar registrar_; |
| 114 | 116 |
| 115 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; | 117 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; |
| 116 | 118 |
| 117 bool widget_initialized_; | 119 bool widget_initialized_; |
| 118 | 120 |
| 119 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); | 121 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); |
| 120 }; | 122 }; |
| 121 | 123 |
| 122 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 124 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| OLD | NEW |