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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/chrome_page_zoom.h" | 11 #include "chrome/browser/chrome_page_zoom.h" |
12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
13 #include "chrome/browser/extensions/window_controller.h" | 13 #include "chrome/browser/extensions/window_controller.h" |
14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
17 #include "chrome/browser/ui/browser_navigator.h" | 17 #include "chrome/browser/ui/browser_navigator.h" |
18 #include "chrome/browser/ui/panels/panel.h" | 18 #include "chrome/browser/ui/panels/panel.h" |
19 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 19 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 20 #include "chrome/browser/ui/zoom/zoom_controller.h" |
20 #include "content/public/browser/invalidate_type.h" | 21 #include "content/public/browser/invalidate_type.h" |
21 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
25 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/site_instance.h" | 27 #include "content/public/browser/site_instance.h" |
27 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "extensions/browser/view_type_utils.h" | 30 #include "extensions/browser/view_type_utils.h" |
(...skipping 17 matching lines...) Expand all Loading... |
47 | 48 |
48 void PanelHost::Init(const GURL& url) { | 49 void PanelHost::Init(const GURL& url) { |
49 if (url.is_empty()) | 50 if (url.is_empty()) |
50 return; | 51 return; |
51 | 52 |
52 content::WebContents::CreateParams create_params( | 53 content::WebContents::CreateParams create_params( |
53 profile_, content::SiteInstance::CreateForURL(profile_, url)); | 54 profile_, content::SiteInstance::CreateForURL(profile_, url)); |
54 web_contents_.reset(content::WebContents::Create(create_params)); | 55 web_contents_.reset(content::WebContents::Create(create_params)); |
55 extensions::SetViewType(web_contents_.get(), extensions::VIEW_TYPE_PANEL); | 56 extensions::SetViewType(web_contents_.get(), extensions::VIEW_TYPE_PANEL); |
56 web_contents_->SetDelegate(this); | 57 web_contents_->SetDelegate(this); |
| 58 // web_contents_ may be passed to chrome_page_zoom::Zoom(), so it needs |
| 59 // a ZoomController. |
| 60 ZoomController::CreateForWebContents(web_contents_.get()); |
57 content::WebContentsObserver::Observe(web_contents_.get()); | 61 content::WebContentsObserver::Observe(web_contents_.get()); |
58 | 62 |
59 // Needed to give the web contents a Tab ID. Extension APIs | 63 // Needed to give the web contents a Tab ID. Extension APIs |
60 // expect web contents to have a Tab ID. | 64 // expect web contents to have a Tab ID. |
61 SessionTabHelper::CreateForWebContents(web_contents_.get()); | 65 SessionTabHelper::CreateForWebContents(web_contents_.get()); |
62 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( | 66 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( |
63 panel_->session_id()); | 67 panel_->session_id()); |
64 | 68 |
65 FaviconTabHelper::CreateForWebContents(web_contents_.get()); | 69 FaviconTabHelper::CreateForWebContents(web_contents_.get()); |
66 PrefsTabHelper::CreateForWebContents(web_contents_.get()); | 70 PrefsTabHelper::CreateForWebContents(web_contents_.get()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 264 } |
261 | 265 |
262 void PanelHost::StopLoading() { | 266 void PanelHost::StopLoading() { |
263 content::RecordAction(UserMetricsAction("Stop")); | 267 content::RecordAction(UserMetricsAction("Stop")); |
264 web_contents_->Stop(); | 268 web_contents_->Stop(); |
265 } | 269 } |
266 | 270 |
267 void PanelHost::Zoom(content::PageZoom zoom) { | 271 void PanelHost::Zoom(content::PageZoom zoom) { |
268 chrome_page_zoom::Zoom(web_contents_.get(), zoom); | 272 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
269 } | 273 } |
OLD | NEW |