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/panels/panel_host.h" | 5 #include "chrome/browser/ui/panels/panel_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/chrome_page_zoom.h" | 10 #include "chrome/browser/chrome_page_zoom.h" |
11 #include "chrome/browser/extensions/window_controller.h" | 11 #include "chrome/browser/extensions/window_controller.h" |
12 #include "chrome/browser/favicon/favicon_tab_helper.h" | 12 #include "chrome/browser/favicon/favicon_tab_helper.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/sessions/session_tab_helper.h" | 14 #include "chrome/browser/sessions/session_tab_helper.h" |
15 #include "chrome/browser/ui/browser_navigator.h" | 15 #include "chrome/browser/ui/browser_navigator.h" |
16 #include "chrome/browser/ui/panels/panel.h" | 16 #include "chrome/browser/ui/panels/panel.h" |
17 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 17 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
18 #include "chrome/browser/view_type_utils.h" | |
19 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/extensions/extension_messages.h" | 19 #include "chrome/common/extensions/extension_messages.h" |
21 #include "content/public/browser/invalidate_type.h" | 20 #include "content/public/browser/invalidate_type.h" |
22 #include "content/public/browser/navigation_controller.h" | 21 #include "content/public/browser/navigation_controller.h" |
23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
25 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
26 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/site_instance.h" | 26 #include "content/public/browser/site_instance.h" |
28 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
29 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "extensions/browser/view_type_utils.h" |
30 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
31 #include "ipc/ipc_message.h" | 31 #include "ipc/ipc_message.h" |
32 #include "ipc/ipc_message_macros.h" | 32 #include "ipc/ipc_message_macros.h" |
33 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
34 #include "ui/gfx/rect.h" | 34 #include "ui/gfx/rect.h" |
35 | 35 |
36 using content::UserMetricsAction; | 36 using content::UserMetricsAction; |
37 | 37 |
38 PanelHost::PanelHost(Panel* panel, Profile* profile) | 38 PanelHost::PanelHost(Panel* panel, Profile* profile) |
39 : panel_(panel), | 39 : panel_(panel), |
40 profile_(profile), | 40 profile_(profile), |
41 extension_function_dispatcher_(profile, this), | 41 extension_function_dispatcher_(profile, this), |
42 weak_factory_(this) { | 42 weak_factory_(this) { |
43 } | 43 } |
44 | 44 |
45 PanelHost::~PanelHost() { | 45 PanelHost::~PanelHost() { |
46 } | 46 } |
47 | 47 |
48 void PanelHost::Init(const GURL& url) { | 48 void PanelHost::Init(const GURL& url) { |
49 if (url.is_empty()) | 49 if (url.is_empty()) |
50 return; | 50 return; |
51 | 51 |
52 content::WebContents::CreateParams create_params( | 52 content::WebContents::CreateParams create_params( |
53 profile_, content::SiteInstance::CreateForURL(profile_, url)); | 53 profile_, content::SiteInstance::CreateForURL(profile_, url)); |
54 web_contents_.reset(content::WebContents::Create(create_params)); | 54 web_contents_.reset(content::WebContents::Create(create_params)); |
55 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); | 55 extensions::SetViewType(web_contents_.get(), extensions::VIEW_TYPE_PANEL); |
56 web_contents_->SetDelegate(this); | 56 web_contents_->SetDelegate(this); |
57 content::WebContentsObserver::Observe(web_contents_.get()); | 57 content::WebContentsObserver::Observe(web_contents_.get()); |
58 | 58 |
59 // Needed to give the web contents a Tab ID. Extension APIs | 59 // Needed to give the web contents a Tab ID. Extension APIs |
60 // expect web contents to have a Tab ID. | 60 // expect web contents to have a Tab ID. |
61 SessionTabHelper::CreateForWebContents(web_contents_.get()); | 61 SessionTabHelper::CreateForWebContents(web_contents_.get()); |
62 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( | 62 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( |
63 panel_->session_id()); | 63 panel_->session_id()); |
64 | 64 |
65 FaviconTabHelper::CreateForWebContents(web_contents_.get()); | 65 FaviconTabHelper::CreateForWebContents(web_contents_.get()); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 | 250 |
251 void PanelHost::StopLoading() { | 251 void PanelHost::StopLoading() { |
252 content::RecordAction(UserMetricsAction("Stop")); | 252 content::RecordAction(UserMetricsAction("Stop")); |
253 web_contents_->Stop(); | 253 web_contents_->Stop(); |
254 } | 254 } |
255 | 255 |
256 void PanelHost::Zoom(content::PageZoom zoom) { | 256 void PanelHost::Zoom(content::PageZoom zoom) { |
257 chrome_page_zoom::Zoom(web_contents_.get(), zoom); | 257 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
258 } | 258 } |
OLD | NEW |