| 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 "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 12 #include "chrome/browser/ui/views/extensions/extension_view_views.h" | 12 #include "chrome/browser/ui/views/extensions/extension_view_views.h" |
| 13 #include "content/public/browser/devtools_agent_host_observer.h" |
| 13 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 15 #include "ui/views/bubble/bubble_dialog_delegate.h" | 16 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 | 19 |
| 19 class Browser; | 20 class Browser; |
| 20 namespace views { | 21 namespace views { |
| 21 class Widget; | 22 class Widget; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class DevToolsAgentHost; | 26 class DevToolsAgentHost; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace extensions { | 29 namespace extensions { |
| 29 class ExtensionViewHost; | 30 class ExtensionViewHost; |
| 30 } | 31 } |
| 31 | 32 |
| 32 // The bubble used for hosting a browser-action popup provided by an extension. | 33 // The bubble used for hosting a browser-action popup provided by an extension. |
| 33 class ExtensionPopup : public views::BubbleDialogDelegateView, | 34 class ExtensionPopup : public views::BubbleDialogDelegateView, |
| 34 public ExtensionViewViews::Container, | 35 public ExtensionViewViews::Container, |
| 35 public content::NotificationObserver, | 36 public content::NotificationObserver, |
| 36 public TabStripModelObserver { | 37 public TabStripModelObserver, |
| 38 public content::DevToolsAgentHostObserver { |
| 37 public: | 39 public: |
| 38 enum ShowAction { | 40 enum ShowAction { |
| 39 SHOW, | 41 SHOW, |
| 40 SHOW_AND_INSPECT, | 42 SHOW_AND_INSPECT, |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 ~ExtensionPopup() override; | 45 ~ExtensionPopup() override; |
| 44 | 46 |
| 45 // Create and show a popup with the given |host| positioned adjacent to | 47 // Create and show a popup with the given |host| positioned adjacent to |
| 46 // |anchor_view|. | 48 // |anchor_view|. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 102 |
| 101 private: | 103 private: |
| 102 static ExtensionPopup* Create(extensions::ExtensionViewHost* host, | 104 static ExtensionPopup* Create(extensions::ExtensionViewHost* host, |
| 103 views::View* anchor_view, | 105 views::View* anchor_view, |
| 104 views::BubbleBorder::Arrow arrow, | 106 views::BubbleBorder::Arrow arrow, |
| 105 ShowAction show_action); | 107 ShowAction show_action); |
| 106 | 108 |
| 107 // Show the bubble, focus on its content, and register listeners. | 109 // Show the bubble, focus on its content, and register listeners. |
| 108 void ShowBubble(); | 110 void ShowBubble(); |
| 109 | 111 |
| 110 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); | 112 // content::DevToolsAgentHostObserver overrides. |
| 113 void DevToolsAgentHostAttached( |
| 114 content::DevToolsAgentHost* agent_host) override; |
| 115 void DevToolsAgentHostDetached( |
| 116 content::DevToolsAgentHost* agent_host) override; |
| 111 | 117 |
| 112 // The contained host for the view. | 118 // The contained host for the view. |
| 113 std::unique_ptr<extensions::ExtensionViewHost> host_; | 119 std::unique_ptr<extensions::ExtensionViewHost> host_; |
| 114 | 120 |
| 115 // Flag used to indicate if the pop-up should open a devtools window once | 121 // Flag used to indicate if the pop-up should open a devtools window once |
| 116 // it is shown inspecting it. | 122 // it is shown inspecting it. |
| 117 bool inspect_with_devtools_; | 123 bool inspect_with_devtools_; |
| 118 | 124 |
| 119 content::NotificationRegistrar registrar_; | 125 content::NotificationRegistrar registrar_; |
| 120 | 126 |
| 121 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; | |
| 122 | |
| 123 bool widget_initialized_; | 127 bool widget_initialized_; |
| 124 | 128 |
| 125 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); | 129 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); |
| 126 }; | 130 }; |
| 127 | 131 |
| 128 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 132 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| OLD | NEW |