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/view_type_utils.h" | 14 #include "chrome/browser/view_type_utils.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/extensions/extension_messages.h" | 16 #include "chrome/common/extensions/extension_messages.h" |
17 #include "content/public/browser/invalidate_type.h" | 17 #include "content/public/browser/invalidate_type.h" |
18 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/site_instance.h" | 23 #include "content/public/browser/site_instance.h" |
24 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
27 #include "ipc/ipc_message.h" | 27 #include "ipc/ipc_message.h" |
28 #include "ipc/ipc_message_macros.h" | 28 #include "ipc/ipc_message_macros.h" |
29 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "ui/gfx/image/image.h" |
30 #include "ui/gfx/rect.h" | 30 #include "ui/gfx/rect.h" |
31 | 31 |
32 using content::UserMetricsAction; | 32 using content::UserMetricsAction; |
33 | 33 |
34 PanelHost::PanelHost(Panel* panel, Profile* profile) | 34 PanelHost::PanelHost(Panel* panel, Profile* profile) |
35 : panel_(panel), | 35 : panel_(panel), |
36 profile_(profile), | 36 profile_(profile), |
37 extension_function_dispatcher_(profile, this), | 37 extension_function_dispatcher_(profile, this), |
38 weak_factory_(this) { | 38 weak_factory_(this) { |
39 } | 39 } |
(...skipping 16 matching lines...) Expand all Loading... |
56 | 56 |
57 web_contents_->GetController().LoadURL( | 57 web_contents_->GetController().LoadURL( |
58 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 58 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
59 } | 59 } |
60 | 60 |
61 void PanelHost::DestroyWebContents() { | 61 void PanelHost::DestroyWebContents() { |
62 web_contents_.reset(); | 62 web_contents_.reset(); |
63 favicon_tab_helper_.reset(); | 63 favicon_tab_helper_.reset(); |
64 } | 64 } |
65 | 65 |
66 SkBitmap PanelHost::GetPageIcon() const { | 66 gfx::Image PanelHost::GetPageIcon() const { |
67 // TODO: Make this function return gfx::Image. | |
68 return favicon_tab_helper_.get() ? | 67 return favicon_tab_helper_.get() ? |
69 favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap(); | 68 favicon_tab_helper_->GetFavicon() : gfx::Image(); |
70 } | 69 } |
71 | 70 |
72 void PanelHost::NavigationStateChanged(const content::WebContents* source, | 71 void PanelHost::NavigationStateChanged(const content::WebContents* source, |
73 unsigned changed_flags) { | 72 unsigned changed_flags) { |
74 // Only need to update the title if the title changed while not loading, | 73 // Only need to update the title if the title changed while not loading, |
75 // because the title is also updated when loading state changes. | 74 // because the title is also updated when loading state changes. |
76 if ((changed_flags & content::INVALIDATE_TYPE_TAB) || | 75 if ((changed_flags & content::INVALIDATE_TYPE_TAB) || |
77 ((changed_flags & content::INVALIDATE_TYPE_TITLE) && | 76 ((changed_flags & content::INVALIDATE_TYPE_TITLE) && |
78 !source->IsLoading())) | 77 !source->IsLoading())) |
79 panel_->UpdateTitleBar(); | 78 panel_->UpdateTitleBar(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 183 } |
185 | 184 |
186 void PanelHost::StopLoading() { | 185 void PanelHost::StopLoading() { |
187 content::RecordAction(UserMetricsAction("Stop")); | 186 content::RecordAction(UserMetricsAction("Stop")); |
188 web_contents_->Stop(); | 187 web_contents_->Stop(); |
189 } | 188 } |
190 | 189 |
191 void PanelHost::Zoom(content::PageZoom zoom) { | 190 void PanelHost::Zoom(content::PageZoom zoom) { |
192 chrome_page_zoom::Zoom(web_contents_.get(), zoom); | 191 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
193 } | 192 } |
OLD | NEW |