| 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/ui/browser_navigator.h" | 15 #include "chrome/browser/ui/browser_navigator.h" |
| 15 #include "chrome/browser/ui/panels/panel.h" | 16 #include "chrome/browser/ui/panels/panel.h" |
| 16 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 17 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/view_type_utils.h" | 19 #include "chrome/browser/view_type_utils.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/extension_messages.h" | 21 #include "chrome/common/extensions/extension_messages.h" |
| 21 #include "content/public/browser/invalidate_type.h" | 22 #include "content/public/browser/invalidate_type.h" |
| 22 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 if (url.is_empty()) | 50 if (url.is_empty()) |
| 50 return; | 51 return; |
| 51 | 52 |
| 52 web_contents_.reset(content::WebContents::Create( | 53 web_contents_.reset(content::WebContents::Create( |
| 53 profile_, content::SiteInstance::CreateForURL(profile_, url), | 54 profile_, content::SiteInstance::CreateForURL(profile_, url), |
| 54 MSG_ROUTING_NONE, NULL)); | 55 MSG_ROUTING_NONE, NULL)); |
| 55 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); | 56 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); |
| 56 web_contents_->SetDelegate(this); | 57 web_contents_->SetDelegate(this); |
| 57 content::WebContentsObserver::Observe(web_contents_.get()); | 58 content::WebContentsObserver::Observe(web_contents_.get()); |
| 58 | 59 |
| 60 // Needed to give the web contents a Tab ID. Extension APIs |
| 61 // expect web contents to have a Tab ID. |
| 62 SessionTabHelper::CreateForWebContents(web_contents_.get()); |
| 63 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( |
| 64 panel_->session_id()); |
| 65 |
| 59 favicon_tab_helper_.reset(new FaviconTabHelper(web_contents_.get())); | 66 favicon_tab_helper_.reset(new FaviconTabHelper(web_contents_.get())); |
| 60 prefs_tab_helper_.reset(new PrefsTabHelper(web_contents_.get())); | 67 prefs_tab_helper_.reset(new PrefsTabHelper(web_contents_.get())); |
| 61 | 68 |
| 62 web_contents_->GetController().LoadURL( | 69 web_contents_->GetController().LoadURL( |
| 63 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 70 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
| 64 } | 71 } |
| 65 | 72 |
| 66 void PanelHost::DestroyWebContents() { | 73 void PanelHost::DestroyWebContents() { |
| 67 favicon_tab_helper_.reset(); | 74 favicon_tab_helper_.reset(); |
| 68 prefs_tab_helper_.reset(); | 75 prefs_tab_helper_.reset(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 253 } |
| 247 | 254 |
| 248 void PanelHost::StopLoading() { | 255 void PanelHost::StopLoading() { |
| 249 content::RecordAction(UserMetricsAction("Stop")); | 256 content::RecordAction(UserMetricsAction("Stop")); |
| 250 web_contents_->Stop(); | 257 web_contents_->Stop(); |
| 251 } | 258 } |
| 252 | 259 |
| 253 void PanelHost::Zoom(content::PageZoom zoom) { | 260 void PanelHost::Zoom(content::PageZoom zoom) { |
| 254 chrome_page_zoom::Zoom(web_contents_.get(), zoom); | 261 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
| 255 } | 262 } |
| OLD | NEW |