| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "components/ui/zoom/page_zoom.h" | 23 #include "components/ui/zoom/page_zoom.h" |
| 24 #include "components/ui/zoom/zoom_controller.h" | 24 #include "components/ui/zoom/zoom_controller.h" |
| 25 #include "content/public/browser/invalidate_type.h" | 25 #include "content/public/browser/invalidate_type.h" |
| 26 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
| 27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 29 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| 30 #include "content/public/browser/site_instance.h" | 30 #include "content/public/browser/site_instance.h" |
| 31 #include "content/public/browser/user_metrics.h" | 31 #include "content/public/browser/user_metrics.h" |
| 32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/browser/web_contents_source.h" |
| 33 #include "extensions/browser/view_type_utils.h" | 34 #include "extensions/browser/view_type_utils.h" |
| 34 #include "ipc/ipc_message.h" | 35 #include "ipc/ipc_message.h" |
| 35 #include "ipc/ipc_message_macros.h" | 36 #include "ipc/ipc_message_macros.h" |
| 36 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
| 37 #include "ui/gfx/image/image.h" | 38 #include "ui/gfx/image/image.h" |
| 38 | 39 |
| 39 using base::UserMetricsAction; | 40 using base::UserMetricsAction; |
| 40 | 41 |
| 41 PanelHost::PanelHost(Panel* panel, Profile* profile) | 42 PanelHost::PanelHost(Panel* panel, Profile* profile) |
| 42 : panel_(panel), | 43 : panel_(panel), |
| 43 profile_(profile), | 44 profile_(profile), |
| 44 weak_factory_(this) { | 45 weak_factory_(this) { |
| 45 } | 46 } |
| 46 | 47 |
| 47 PanelHost::~PanelHost() { | 48 PanelHost::~PanelHost() { |
| 48 } | 49 } |
| 49 | 50 |
| 50 void PanelHost::Init(const GURL& url) { | 51 void PanelHost::Init(const GURL& url) { |
| 51 if (url.is_empty()) | 52 if (url.is_empty()) |
| 52 return; | 53 return; |
| 53 | 54 |
| 54 content::WebContents::CreateParams create_params( | 55 content::WebContents::CreateParams create_params( |
| 55 profile_, content::SiteInstance::CreateForURL(profile_, url)); | 56 profile_, content::SiteInstance::CreateForURL(profile_, url)); |
| 56 web_contents_.reset(content::WebContents::Create(create_params)); | 57 web_contents_.reset(content::WebContents::Create(create_params)); |
| 58 WebContentsSource::CreateForWebContentsAndLocation(web_contents_.get(), |
| 59 FROM_HERE); |
| 57 extensions::SetViewType(web_contents_.get(), extensions::VIEW_TYPE_PANEL); | 60 extensions::SetViewType(web_contents_.get(), extensions::VIEW_TYPE_PANEL); |
| 58 web_contents_->SetDelegate(this); | 61 web_contents_->SetDelegate(this); |
| 59 // web_contents_ may be passed to PageZoom::Zoom(), so it needs | 62 // web_contents_ may be passed to PageZoom::Zoom(), so it needs |
| 60 // a ZoomController. | 63 // a ZoomController. |
| 61 ui_zoom::ZoomController::CreateForWebContents(web_contents_.get()); | 64 ui_zoom::ZoomController::CreateForWebContents(web_contents_.get()); |
| 62 content::WebContentsObserver::Observe(web_contents_.get()); | 65 content::WebContentsObserver::Observe(web_contents_.get()); |
| 63 | 66 |
| 64 // Needed to give the web contents a Tab ID. Extension APIs | 67 // Needed to give the web contents a Tab ID. Extension APIs |
| 65 // expect web contents to have a Tab ID. | 68 // expect web contents to have a Tab ID. |
| 66 SessionTabHelper::CreateForWebContents(web_contents_.get()); | 69 SessionTabHelper::CreateForWebContents(web_contents_.get()); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 239 } |
| 237 | 240 |
| 238 void PanelHost::StopLoading() { | 241 void PanelHost::StopLoading() { |
| 239 content::RecordAction(UserMetricsAction("Stop")); | 242 content::RecordAction(UserMetricsAction("Stop")); |
| 240 web_contents_->Stop(); | 243 web_contents_->Stop(); |
| 241 } | 244 } |
| 242 | 245 |
| 243 void PanelHost::Zoom(content::PageZoom zoom) { | 246 void PanelHost::Zoom(content::PageZoom zoom) { |
| 244 ui_zoom::PageZoom::Zoom(web_contents_.get(), zoom); | 247 ui_zoom::PageZoom::Zoom(web_contents_.get(), zoom); |
| 245 } | 248 } |
| OLD | NEW |