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/favicon/favicon_tab_helper.h" | 11 #include "chrome/browser/favicon/favicon_tab_helper.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/panels/panel.h" | 13 #include "chrome/browser/ui/panels/panel.h" |
| 14 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
14 #include "chrome/browser/view_type_utils.h" | 15 #include "chrome/browser/view_type_utils.h" |
15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/extensions/extension_messages.h" | 17 #include "chrome/common/extensions/extension_messages.h" |
17 #include "content/public/browser/invalidate_type.h" | 18 #include "content/public/browser/invalidate_type.h" |
18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/site_instance.h" | 24 #include "content/public/browser/site_instance.h" |
(...skipping 22 matching lines...) Expand all Loading... |
46 return; | 47 return; |
47 | 48 |
48 web_contents_.reset(content::WebContents::Create( | 49 web_contents_.reset(content::WebContents::Create( |
49 profile_, content::SiteInstance::CreateForURL(profile_, url), | 50 profile_, content::SiteInstance::CreateForURL(profile_, url), |
50 MSG_ROUTING_NONE, NULL, NULL)); | 51 MSG_ROUTING_NONE, NULL, NULL)); |
51 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); | 52 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); |
52 web_contents_->SetDelegate(this); | 53 web_contents_->SetDelegate(this); |
53 content::WebContentsObserver::Observe(web_contents_.get()); | 54 content::WebContentsObserver::Observe(web_contents_.get()); |
54 | 55 |
55 favicon_tab_helper_.reset(new FaviconTabHelper(web_contents_.get())); | 56 favicon_tab_helper_.reset(new FaviconTabHelper(web_contents_.get())); |
| 57 prefs_tab_helper_.reset(new PrefsTabHelper(web_contents_.get())); |
56 | 58 |
57 web_contents_->GetController().LoadURL( | 59 web_contents_->GetController().LoadURL( |
58 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 60 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
59 } | 61 } |
60 | 62 |
61 void PanelHost::DestroyWebContents() { | 63 void PanelHost::DestroyWebContents() { |
| 64 favicon_tab_helper_.reset(); |
| 65 prefs_tab_helper_.reset(); |
62 web_contents_.reset(); | 66 web_contents_.reset(); |
63 favicon_tab_helper_.reset(); | |
64 } | 67 } |
65 | 68 |
66 SkBitmap PanelHost::GetPageIcon() const { | 69 SkBitmap PanelHost::GetPageIcon() const { |
67 // TODO: Make this function return gfx::Image. | 70 // TODO: Make this function return gfx::Image. |
68 return favicon_tab_helper_.get() ? | 71 return favicon_tab_helper_.get() ? |
69 favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap(); | 72 favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap(); |
70 } | 73 } |
71 | 74 |
72 void PanelHost::NavigationStateChanged(const content::WebContents* source, | 75 void PanelHost::NavigationStateChanged(const content::WebContents* source, |
73 unsigned changed_flags) { | 76 unsigned changed_flags) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 188 } |
186 | 189 |
187 void PanelHost::StopLoading() { | 190 void PanelHost::StopLoading() { |
188 content::RecordAction(UserMetricsAction("Stop")); | 191 content::RecordAction(UserMetricsAction("Stop")); |
189 web_contents_->Stop(); | 192 web_contents_->Stop(); |
190 } | 193 } |
191 | 194 |
192 void PanelHost::Zoom(content::PageZoom zoom) { | 195 void PanelHost::Zoom(content::PageZoom zoom) { |
193 chrome_page_zoom::Zoom(web_contents_.get(), zoom); | 196 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
194 } | 197 } |
OLD | NEW |