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 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 5 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/devtools/devtools_window.h" | 9 #include "chrome/browser/devtools/devtools_window.h" |
10 #include "chrome/browser/extensions/extension_view_host.h" | 10 #include "chrome/browser/extensions/extension_view_host.h" |
11 #include "chrome/browser/extensions/extension_view_host_factory.h" | 11 #include "chrome/browser/extensions/extension_view_host_factory.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
| 15 #include "content/public/browser/devtools_manager.h" |
15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
20 #include "ui/gfx/insets.h" | 21 #include "ui/gfx/insets.h" |
21 #include "ui/views/layout/fill_layout.h" | 22 #include "ui/views/layout/fill_layout.h" |
22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
23 #include "ui/wm/core/window_animations.h" | 24 #include "ui/wm/core/window_animations.h" |
24 #include "ui/wm/core/window_util.h" | 25 #include "ui/wm/core/window_util.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 // Wait to show the popup until the contained host finishes loading. | 63 // Wait to show the popup until the contained host finishes loading. |
63 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 64 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
64 content::Source<content::WebContents>(host->host_contents())); | 65 content::Source<content::WebContents>(host->host_contents())); |
65 | 66 |
66 // Listen for the containing view calling window.close(); | 67 // Listen for the containing view calling window.close(); |
67 registrar_.Add( | 68 registrar_.Add( |
68 this, | 69 this, |
69 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 70 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
70 content::Source<content::BrowserContext>(host->browser_context())); | 71 content::Source<content::BrowserContext>(host->browser_context())); |
71 content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_); | 72 content::DevToolsManager::GetInstance()->AddAgentStateCallback( |
| 73 devtools_callback_); |
72 | 74 |
73 GetExtensionView(host)->GetBrowser()->tab_strip_model()->AddObserver(this); | 75 GetExtensionView(host)->GetBrowser()->tab_strip_model()->AddObserver(this); |
74 } | 76 } |
75 | 77 |
76 ExtensionPopup::~ExtensionPopup() { | 78 ExtensionPopup::~ExtensionPopup() { |
77 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_); | 79 content::DevToolsManager::GetInstance()->RemoveAgentStateCallback( |
| 80 devtools_callback_); |
78 | 81 |
79 GetExtensionView( | 82 GetExtensionView( |
80 host_.get())->GetBrowser()->tab_strip_model()->RemoveObserver(this); | 83 host_.get())->GetBrowser()->tab_strip_model()->RemoveObserver(this); |
81 } | 84 } |
82 | 85 |
83 void ExtensionPopup::Observe(int type, | 86 void ExtensionPopup::Observe(int type, |
84 const content::NotificationSource& source, | 87 const content::NotificationSource& source, |
85 const content::NotificationDetails& details) { | 88 const content::NotificationDetails& details) { |
86 switch (type) { | 89 switch (type) { |
87 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: | 90 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 GetWidget()->Show(); | 222 GetWidget()->Show(); |
220 | 223 |
221 // Focus on the host contents when the bubble is first shown. | 224 // Focus on the host contents when the bubble is first shown. |
222 host()->host_contents()->Focus(); | 225 host()->host_contents()->Focus(); |
223 | 226 |
224 if (inspect_with_devtools_) { | 227 if (inspect_with_devtools_) { |
225 DevToolsWindow::OpenDevToolsWindow(host()->host_contents(), | 228 DevToolsWindow::OpenDevToolsWindow(host()->host_contents(), |
226 DevToolsToggleAction::ShowConsole()); | 229 DevToolsToggleAction::ShowConsole()); |
227 } | 230 } |
228 } | 231 } |
OLD | NEW |