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