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