| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/chrome_page_zoom.h" |
| 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 10 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/panels/panel.h" | 12 #include "chrome/browser/ui/panels/panel.h" |
| 12 #include "chrome/browser/view_type_utils.h" | 13 #include "chrome/browser/view_type_utils.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/extensions/extension_messages.h" | 15 #include "chrome/common/extensions/extension_messages.h" |
| 15 #include "content/public/browser/invalidate_type.h" | 16 #include "content/public/browser/invalidate_type.h" |
| 16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/site_instance.h" | 22 #include "content/public/browser/site_instance.h" |
| 23 #include "content/public/browser/user_metrics.h" |
| 22 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 23 #include "ipc/ipc_message.h" | 25 #include "ipc/ipc_message.h" |
| 24 #include "ipc/ipc_message_macros.h" | 26 #include "ipc/ipc_message_macros.h" |
| 25 #include "third_party/skia/include/core/SkBitmap.h" | 27 #include "third_party/skia/include/core/SkBitmap.h" |
| 26 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
| 27 | 29 |
| 30 using content::UserMetricsAction; |
| 31 |
| 28 PanelHost::PanelHost(Panel* panel, Profile* profile) | 32 PanelHost::PanelHost(Panel* panel, Profile* profile) |
| 29 : panel_(panel), | 33 : panel_(panel), |
| 30 profile_(profile), | 34 profile_(profile), |
| 31 extension_function_dispatcher_(profile, this), | 35 extension_function_dispatcher_(profile, this), |
| 32 weak_factory_(this) { | 36 weak_factory_(this) { |
| 33 } | 37 } |
| 34 | 38 |
| 35 PanelHost::~PanelHost() { | 39 PanelHost::~PanelHost() { |
| 36 } | 40 } |
| 37 | 41 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 93 |
| 90 void PanelHost::MoveContents(content::WebContents* source, | 94 void PanelHost::MoveContents(content::WebContents* source, |
| 91 const gfx::Rect& pos) { | 95 const gfx::Rect& pos) { |
| 92 panel_->SetBounds(pos); | 96 panel_->SetBounds(pos); |
| 93 } | 97 } |
| 94 | 98 |
| 95 bool PanelHost::IsPopupOrPanel(const content::WebContents* source) const { | 99 bool PanelHost::IsPopupOrPanel(const content::WebContents* source) const { |
| 96 return true; | 100 return true; |
| 97 } | 101 } |
| 98 | 102 |
| 103 void PanelHost::ContentsZoomChange(bool zoom_in) { |
| 104 Zoom(zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT); |
| 105 } |
| 106 |
| 99 bool PanelHost::IsApplication() const { | 107 bool PanelHost::IsApplication() const { |
| 100 return true; | 108 return true; |
| 101 } | 109 } |
| 102 | 110 |
| 111 bool PanelHost::HandleContextMenu(const content::ContextMenuParams& params) { |
| 112 return true; // Disallow context menu. |
| 113 } |
| 114 |
| 115 void PanelHost::HandleKeyboardEvent( |
| 116 const content::NativeWebKeyboardEvent& event) { |
| 117 return panel_->HandleKeyboardEvent(event); |
| 118 } |
| 119 |
| 103 void PanelHost::ResizeDueToAutoResize(content::WebContents* web_contents, | 120 void PanelHost::ResizeDueToAutoResize(content::WebContents* web_contents, |
| 104 const gfx::Size& new_size) { | 121 const gfx::Size& new_size) { |
| 105 panel_->OnContentsAutoResized(new_size); | 122 panel_->OnContentsAutoResized(new_size); |
| 106 } | 123 } |
| 107 | 124 |
| 108 void PanelHost::RenderViewGone(base::TerminationStatus status) { | 125 void PanelHost::RenderViewGone(base::TerminationStatus status) { |
| 109 CloseContents(web_contents_.get()); | 126 CloseContents(web_contents_.get()); |
| 110 } | 127 } |
| 111 | 128 |
| 112 void PanelHost::WebContentsDestroyed(content::WebContents* web_contents) { | 129 void PanelHost::WebContentsDestroyed(content::WebContents* web_contents) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 139 web_contents_->GetRenderViewHost()); | 156 web_contents_->GetRenderViewHost()); |
| 140 } | 157 } |
| 141 | 158 |
| 142 ExtensionWindowController* PanelHost::GetExtensionWindowController() const { | 159 ExtensionWindowController* PanelHost::GetExtensionWindowController() const { |
| 143 return panel_->extension_window_controller(); | 160 return panel_->extension_window_controller(); |
| 144 } | 161 } |
| 145 | 162 |
| 146 content::WebContents* PanelHost::GetAssociatedWebContents() const { | 163 content::WebContents* PanelHost::GetAssociatedWebContents() const { |
| 147 return web_contents_.get(); | 164 return web_contents_.get(); |
| 148 } | 165 } |
| 166 |
| 167 void PanelHost::Reload() { |
| 168 content::RecordAction(UserMetricsAction("Reload")); |
| 169 web_contents_->GetController().Reload(true); |
| 170 } |
| 171 |
| 172 void PanelHost::ReloadIgnoringCache() { |
| 173 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
| 174 web_contents_->GetController().ReloadIgnoringCache(true); |
| 175 } |
| 176 |
| 177 void PanelHost::StopLoading() { |
| 178 content::RecordAction(UserMetricsAction("Stop")); |
| 179 web_contents_->Stop(); |
| 180 } |
| 181 |
| 182 void PanelHost::Zoom(content::PageZoom zoom) { |
| 183 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
| 184 } |
| OLD | NEW |