| 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 "content/browser/web_contents/web_contents_view_win.h" | 5 #include "content/browser/web_contents/web_contents_view_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/renderer_host/render_view_host_factory.h" | 8 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_win.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 void OnClose() { | 55 void OnClose() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 BEGIN_MSG_MAP_EX(WebContentsViewWin) | 58 BEGIN_MSG_MAP_EX(WebContentsViewWin) |
| 59 MSG_WM_CLOSE(OnClose) | 59 MSG_WM_CLOSE(OnClose) |
| 60 END_MSG_MAP() | 60 END_MSG_MAP() |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace namespace | 63 } // namespace namespace |
| 64 | 64 |
| 65 WebContentsViewWin::WebContentsViewWin(TabContents* tab_contents, | 65 WebContentsViewWin::WebContentsViewWin(WebContentsImpl* web_contents, |
| 66 WebContentsViewDelegate* delegate) | 66 WebContentsViewDelegate* delegate) |
| 67 : tab_contents_(tab_contents), | 67 : web_contents_(web_contents), |
| 68 view_(NULL), | 68 view_(NULL), |
| 69 delegate_(delegate), | 69 delegate_(delegate), |
| 70 close_tab_after_drag_ends_(false) { | 70 close_tab_after_drag_ends_(false) { |
| 71 } | 71 } |
| 72 | 72 |
| 73 WebContentsViewWin::~WebContentsViewWin() { | 73 WebContentsViewWin::~WebContentsViewWin() { |
| 74 if (IsWindow(hwnd())) | 74 if (IsWindow(hwnd())) |
| 75 DestroyWindow(hwnd()); | 75 DestroyWindow(hwnd()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void WebContentsViewWin::CreateView(const gfx::Size& initial_size) { | 78 void WebContentsViewWin::CreateView(const gfx::Size& initial_size) { |
| 79 initial_size_ = initial_size; | 79 initial_size_ = initial_size; |
| 80 | 80 |
| 81 set_window_style(WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); | 81 set_window_style(WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); |
| 82 | 82 |
| 83 Init(TempParent::Get()->hwnd(), gfx::Rect(initial_size_)); | 83 Init(TempParent::Get()->hwnd(), gfx::Rect(initial_size_)); |
| 84 | 84 |
| 85 // Remove the root view drop target so we can register our own. | 85 // Remove the root view drop target so we can register our own. |
| 86 RevokeDragDrop(GetNativeView()); | 86 RevokeDragDrop(GetNativeView()); |
| 87 drag_dest_ = new WebDragDest(hwnd(), tab_contents_); | 87 drag_dest_ = new WebDragDest(hwnd(), web_contents_); |
| 88 if (delegate_.get()) { | 88 if (delegate_.get()) { |
| 89 content::WebDragDestDelegate* delegate = delegate_->GetDragDestDelegate(); | 89 content::WebDragDestDelegate* delegate = delegate_->GetDragDestDelegate(); |
| 90 if (delegate) | 90 if (delegate) |
| 91 drag_dest_->set_delegate(delegate); | 91 drag_dest_->set_delegate(delegate); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget( | 95 RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget( |
| 96 content::RenderWidgetHost* render_widget_host) { | 96 content::RenderWidgetHost* render_widget_host) { |
| 97 if (render_widget_host->GetView()) { | 97 if (render_widget_host->GetView()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 view_->ShowWindow(SW_SHOW); | 110 view_->ShowWindow(SW_SHOW); |
| 111 view_->SetSize(initial_size_); | 111 view_->SetSize(initial_size_); |
| 112 return view_; | 112 return view_; |
| 113 } | 113 } |
| 114 | 114 |
| 115 gfx::NativeView WebContentsViewWin::GetNativeView() const { | 115 gfx::NativeView WebContentsViewWin::GetNativeView() const { |
| 116 return hwnd(); | 116 return hwnd(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 gfx::NativeView WebContentsViewWin::GetContentNativeView() const { | 119 gfx::NativeView WebContentsViewWin::GetContentNativeView() const { |
| 120 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 120 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 121 return rwhv ? rwhv->GetNativeView() : NULL; | 121 return rwhv ? rwhv->GetNativeView() : NULL; |
| 122 } | 122 } |
| 123 | 123 |
| 124 gfx::NativeWindow WebContentsViewWin::GetTopLevelNativeWindow() const { | 124 gfx::NativeWindow WebContentsViewWin::GetTopLevelNativeWindow() const { |
| 125 return GetParent(GetNativeView()); | 125 return GetParent(GetNativeView()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WebContentsViewWin::GetContainerBounds(gfx::Rect *out) const { | 128 void WebContentsViewWin::GetContainerBounds(gfx::Rect *out) const { |
| 129 // Copied from NativeWidgetWin::GetClientAreaScreenBounds(). | 129 // Copied from NativeWidgetWin::GetClientAreaScreenBounds(). |
| 130 RECT r; | 130 RECT r; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 | 149 |
| 150 void WebContentsViewWin::SizeContents(const gfx::Size& size) { | 150 void WebContentsViewWin::SizeContents(const gfx::Size& size) { |
| 151 gfx::Rect bounds; | 151 gfx::Rect bounds; |
| 152 GetContainerBounds(&bounds); | 152 GetContainerBounds(&bounds); |
| 153 if (bounds.size() != size) { | 153 if (bounds.size() != size) { |
| 154 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), | 154 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), |
| 155 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | 155 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); |
| 156 } else { | 156 } else { |
| 157 // Our size matches what we want but the renderers size may not match. | 157 // Our size matches what we want but the renderers size may not match. |
| 158 // Pretend we were resized so that the renderers size is updated too. | 158 // Pretend we were resized so that the renderers size is updated too. |
| 159 if (tab_contents_->GetInterstitialPage()) | 159 if (web_contents_->GetInterstitialPage()) |
| 160 tab_contents_->GetInterstitialPage()->SetSize(size); | 160 web_contents_->GetInterstitialPage()->SetSize(size); |
| 161 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 161 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 162 if (rwhv) | 162 if (rwhv) |
| 163 rwhv->SetSize(size); | 163 rwhv->SetSize(size); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 void WebContentsViewWin::RenderViewCreated(RenderViewHost* host) { | 167 void WebContentsViewWin::RenderViewCreated(RenderViewHost* host) { |
| 168 } | 168 } |
| 169 | 169 |
| 170 void WebContentsViewWin::Focus() { | 170 void WebContentsViewWin::Focus() { |
| 171 if (tab_contents_->GetInterstitialPage()) { | 171 if (web_contents_->GetInterstitialPage()) { |
| 172 tab_contents_->GetInterstitialPage()->Focus(); | 172 web_contents_->GetInterstitialPage()->Focus(); |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 if (delegate_.get() && delegate_->Focus()) | 176 if (delegate_.get() && delegate_->Focus()) |
| 177 return; | 177 return; |
| 178 | 178 |
| 179 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 179 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 180 if (rwhv) | 180 if (rwhv) |
| 181 rwhv->Focus(); | 181 rwhv->Focus(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void WebContentsViewWin::SetInitialFocus() { | 184 void WebContentsViewWin::SetInitialFocus() { |
| 185 if (tab_contents_->FocusLocationBarByDefault()) | 185 if (web_contents_->FocusLocationBarByDefault()) |
| 186 tab_contents_->SetFocusToLocationBar(false); | 186 web_contents_->SetFocusToLocationBar(false); |
| 187 else | 187 else |
| 188 Focus(); | 188 Focus(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void WebContentsViewWin::StoreFocus() { | 191 void WebContentsViewWin::StoreFocus() { |
| 192 if (delegate_.get()) | 192 if (delegate_.get()) |
| 193 delegate_->StoreFocus(); | 193 delegate_->StoreFocus(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void WebContentsViewWin::RestoreFocus() { | 196 void WebContentsViewWin::RestoreFocus() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 220 | 220 |
| 221 void WebContentsViewWin::GetViewBounds(gfx::Rect* out) const { | 221 void WebContentsViewWin::GetViewBounds(gfx::Rect* out) const { |
| 222 RECT r; | 222 RECT r; |
| 223 GetWindowRect(hwnd(), &r); | 223 GetWindowRect(hwnd(), &r); |
| 224 *out = gfx::Rect(r); | 224 *out = gfx::Rect(r); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void WebContentsViewWin::CreateNewWindow( | 227 void WebContentsViewWin::CreateNewWindow( |
| 228 int route_id, | 228 int route_id, |
| 229 const ViewHostMsg_CreateWindow_Params& params) { | 229 const ViewHostMsg_CreateWindow_Params& params) { |
| 230 web_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params); | 230 web_contents_view_helper_.CreateNewWindow(web_contents_, route_id, params); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void WebContentsViewWin::CreateNewWidget(int route_id, | 233 void WebContentsViewWin::CreateNewWidget(int route_id, |
| 234 WebKit::WebPopupType popup_type) { | 234 WebKit::WebPopupType popup_type) { |
| 235 web_contents_view_helper_.CreateNewWidget(tab_contents_, | 235 web_contents_view_helper_.CreateNewWidget(web_contents_, |
| 236 route_id, | 236 route_id, |
| 237 false, | 237 false, |
| 238 popup_type); | 238 popup_type); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void WebContentsViewWin::CreateNewFullscreenWidget(int route_id) { | 241 void WebContentsViewWin::CreateNewFullscreenWidget(int route_id) { |
| 242 web_contents_view_helper_.CreateNewWidget(tab_contents_, | 242 web_contents_view_helper_.CreateNewWidget(web_contents_, |
| 243 route_id, | 243 route_id, |
| 244 true, | 244 true, |
| 245 WebKit::WebPopupTypeNone); | 245 WebKit::WebPopupTypeNone); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void WebContentsViewWin::ShowCreatedWindow(int route_id, | 248 void WebContentsViewWin::ShowCreatedWindow(int route_id, |
| 249 WindowOpenDisposition disposition, | 249 WindowOpenDisposition disposition, |
| 250 const gfx::Rect& initial_pos, | 250 const gfx::Rect& initial_pos, |
| 251 bool user_gesture) { | 251 bool user_gesture) { |
| 252 web_contents_view_helper_.ShowCreatedWindow( | 252 web_contents_view_helper_.ShowCreatedWindow( |
| 253 tab_contents_, route_id, disposition, initial_pos, user_gesture); | 253 web_contents_, route_id, disposition, initial_pos, user_gesture); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void WebContentsViewWin::ShowCreatedWidget(int route_id, | 256 void WebContentsViewWin::ShowCreatedWidget(int route_id, |
| 257 const gfx::Rect& initial_pos) { | 257 const gfx::Rect& initial_pos) { |
| 258 web_contents_view_helper_.ShowCreatedWidget(tab_contents_, | 258 web_contents_view_helper_.ShowCreatedWidget(web_contents_, |
| 259 route_id, | 259 route_id, |
| 260 false, | 260 false, |
| 261 initial_pos); | 261 initial_pos); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void WebContentsViewWin::ShowCreatedFullscreenWidget(int route_id) { | 264 void WebContentsViewWin::ShowCreatedFullscreenWidget(int route_id) { |
| 265 web_contents_view_helper_.ShowCreatedWidget(tab_contents_, | 265 web_contents_view_helper_.ShowCreatedWidget(web_contents_, |
| 266 route_id, | 266 route_id, |
| 267 true, | 267 true, |
| 268 gfx::Rect()); | 268 gfx::Rect()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void WebContentsViewWin::ShowContextMenu( | 271 void WebContentsViewWin::ShowContextMenu( |
| 272 const content::ContextMenuParams& params) { | 272 const content::ContextMenuParams& params) { |
| 273 // Allow WebContentsDelegates to handle the context menu operation first. | 273 // Allow WebContentsDelegates to handle the context menu operation first. |
| 274 if (tab_contents_->GetDelegate() && | 274 if (web_contents_->GetDelegate() && |
| 275 tab_contents_->GetDelegate()->HandleContextMenu(params)) { | 275 web_contents_->GetDelegate()->HandleContextMenu(params)) { |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 | 278 |
| 279 if (delegate_.get()) | 279 if (delegate_.get()) |
| 280 delegate_->ShowContextMenu(params); | 280 delegate_->ShowContextMenu(params); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void WebContentsViewWin::ShowPopupMenu(const gfx::Rect& bounds, | 283 void WebContentsViewWin::ShowPopupMenu(const gfx::Rect& bounds, |
| 284 int item_height, | 284 int item_height, |
| 285 double item_font_size, | 285 double item_font_size, |
| 286 int selected_item, | 286 int selected_item, |
| 287 const std::vector<WebMenuItem>& items, | 287 const std::vector<WebMenuItem>& items, |
| 288 bool right_aligned) { | 288 bool right_aligned) { |
| 289 // External popup menus are only used on Mac. | 289 // External popup menus are only used on Mac. |
| 290 NOTIMPLEMENTED(); | 290 NOTIMPLEMENTED(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void WebContentsViewWin::StartDragging(const WebDropData& drop_data, | 293 void WebContentsViewWin::StartDragging(const WebDropData& drop_data, |
| 294 WebKit::WebDragOperationsMask operations, | 294 WebKit::WebDragOperationsMask operations, |
| 295 const SkBitmap& image, | 295 const SkBitmap& image, |
| 296 const gfx::Point& image_offset) { | 296 const gfx::Point& image_offset) { |
| 297 drag_handler_ = new WebContentsDragWin( | 297 drag_handler_ = new WebContentsDragWin( |
| 298 GetNativeView(), | 298 GetNativeView(), |
| 299 tab_contents_, | 299 web_contents_, |
| 300 drag_dest_, | 300 drag_dest_, |
| 301 base::Bind(&WebContentsViewWin::EndDragging, base::Unretained(this))); | 301 base::Bind(&WebContentsViewWin::EndDragging, base::Unretained(this))); |
| 302 drag_handler_->StartDragging(drop_data, operations, image, image_offset); | 302 drag_handler_->StartDragging(drop_data, operations, image, image_offset); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void WebContentsViewWin::UpdateDragCursor(WebKit::WebDragOperation operation) { | 305 void WebContentsViewWin::UpdateDragCursor(WebKit::WebDragOperation operation) { |
| 306 drag_dest_->set_drag_cursor(operation); | 306 drag_dest_->set_drag_cursor(operation); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void WebContentsViewWin::GotFocus() { | 309 void WebContentsViewWin::GotFocus() { |
| 310 if (tab_contents_->GetDelegate()) | 310 if (web_contents_->GetDelegate()) |
| 311 tab_contents_->GetDelegate()->WebContentsFocused(tab_contents_); | 311 web_contents_->GetDelegate()->WebContentsFocused(web_contents_); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void WebContentsViewWin::TakeFocus(bool reverse) { | 314 void WebContentsViewWin::TakeFocus(bool reverse) { |
| 315 if (tab_contents_->GetDelegate() && | 315 if (web_contents_->GetDelegate() && |
| 316 !tab_contents_->GetDelegate()->TakeFocus(reverse) && | 316 !web_contents_->GetDelegate()->TakeFocus(reverse) && |
| 317 delegate_.get()) { | 317 delegate_.get()) { |
| 318 delegate_->TakeFocus(reverse); | 318 delegate_->TakeFocus(reverse); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 | 321 |
| 322 void WebContentsViewWin::EndDragging() { | 322 void WebContentsViewWin::EndDragging() { |
| 323 drag_handler_ = NULL; | 323 drag_handler_ = NULL; |
| 324 if (close_tab_after_drag_ends_) { | 324 if (close_tab_after_drag_ends_) { |
| 325 close_tab_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(0), | 325 close_tab_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(0), |
| 326 this, &WebContentsViewWin::CloseTab); | 326 this, &WebContentsViewWin::CloseTab); |
| 327 } | 327 } |
| 328 tab_contents_->SystemDragEnded(); | 328 web_contents_->SystemDragEnded(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void WebContentsViewWin::CloseTab() { | 331 void WebContentsViewWin::CloseTab() { |
| 332 RenderViewHost* rvh = tab_contents_->GetRenderViewHost(); | 332 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 333 rvh->GetDelegate()->Close(rvh); | 333 rvh->GetDelegate()->Close(rvh); |
| 334 } | 334 } |
| 335 | 335 |
| 336 LRESULT WebContentsViewWin::OnDestroy( | 336 LRESULT WebContentsViewWin::OnDestroy( |
| 337 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 337 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 338 if (drag_dest_.get()) { | 338 if (drag_dest_.get()) { |
| 339 RevokeDragDrop(GetNativeView()); | 339 RevokeDragDrop(GetNativeView()); |
| 340 drag_dest_ = NULL; | 340 drag_dest_ = NULL; |
| 341 } | 341 } |
| 342 return 0; | 342 return 0; |
| 343 } | 343 } |
| 344 | 344 |
| 345 LRESULT WebContentsViewWin::OnWindowPosChanged( | 345 LRESULT WebContentsViewWin::OnWindowPosChanged( |
| 346 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 346 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 347 WINDOWPOS* window_pos = reinterpret_cast<WINDOWPOS*>(lparam); | 347 WINDOWPOS* window_pos = reinterpret_cast<WINDOWPOS*>(lparam); |
| 348 if (window_pos->flags & SWP_HIDEWINDOW) { | 348 if (window_pos->flags & SWP_HIDEWINDOW) { |
| 349 tab_contents_->HideContents(); | 349 web_contents_->HideContents(); |
| 350 return 0; | 350 return 0; |
| 351 } | 351 } |
| 352 | 352 |
| 353 // The TabContents was shown by a means other than the user selecting a | 353 // The WebContents was shown by a means other than the user selecting a |
| 354 // Tab, e.g. the window was minimized then restored. | 354 // Tab, e.g. the window was minimized then restored. |
| 355 if (window_pos->flags & SWP_SHOWWINDOW) | 355 if (window_pos->flags & SWP_SHOWWINDOW) |
| 356 tab_contents_->ShowContents(); | 356 web_contents_->ShowContents(); |
| 357 | 357 |
| 358 // Unless we were specifically told not to size, cause the renderer to be | 358 // Unless we were specifically told not to size, cause the renderer to be |
| 359 // sized to the new bounds, which forces a repaint. Not required for the | 359 // sized to the new bounds, which forces a repaint. Not required for the |
| 360 // simple minimize-restore case described above, for example, since the | 360 // simple minimize-restore case described above, for example, since the |
| 361 // size hasn't changed. | 361 // size hasn't changed. |
| 362 if (window_pos->flags & SWP_NOSIZE) | 362 if (window_pos->flags & SWP_NOSIZE) |
| 363 return 0; | 363 return 0; |
| 364 | 364 |
| 365 gfx::Size size(window_pos->cx, window_pos->cy); | 365 gfx::Size size(window_pos->cx, window_pos->cy); |
| 366 if (tab_contents_->GetInterstitialPage()) | 366 if (web_contents_->GetInterstitialPage()) |
| 367 tab_contents_->GetInterstitialPage()->SetSize(size); | 367 web_contents_->GetInterstitialPage()->SetSize(size); |
| 368 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 368 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 369 if (rwhv) | 369 if (rwhv) |
| 370 rwhv->SetSize(size); | 370 rwhv->SetSize(size); |
| 371 | 371 |
| 372 if (delegate_.get()) | 372 if (delegate_.get()) |
| 373 delegate_->SizeChanged(size); | 373 delegate_->SizeChanged(size); |
| 374 | 374 |
| 375 return 0; | 375 return 0; |
| 376 } | 376 } |
| 377 | 377 |
| 378 LRESULT WebContentsViewWin::OnMouseDown( | 378 LRESULT WebContentsViewWin::OnMouseDown( |
| 379 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 379 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 380 // Make sure this TabContents is activated when it is clicked on. | 380 // Make sure this WebContents is activated when it is clicked on. |
| 381 if (tab_contents_->GetDelegate()) | 381 if (web_contents_->GetDelegate()) |
| 382 tab_contents_->GetDelegate()->ActivateContents(tab_contents_); | 382 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
| 383 return 0; | 383 return 0; |
| 384 } | 384 } |
| 385 | 385 |
| 386 LRESULT WebContentsViewWin::OnMouseMove( | 386 LRESULT WebContentsViewWin::OnMouseMove( |
| 387 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 387 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 388 // Let our delegate know that the mouse moved (useful for resetting status | 388 // Let our delegate know that the mouse moved (useful for resetting status |
| 389 // bubble state). | 389 // bubble state). |
| 390 if (tab_contents_->GetDelegate()) { | 390 if (web_contents_->GetDelegate()) { |
| 391 tab_contents_->GetDelegate()->ContentsMouseEvent( | 391 web_contents_->GetDelegate()->ContentsMouseEvent( |
| 392 tab_contents_, gfx::Screen::GetCursorScreenPoint(), true); | 392 web_contents_, gfx::Screen::GetCursorScreenPoint(), true); |
| 393 } | 393 } |
| 394 return 0; | 394 return 0; |
| 395 } | 395 } |
| 396 | 396 |
| 397 LRESULT WebContentsViewWin::OnReflectedMessage( | 397 LRESULT WebContentsViewWin::OnReflectedMessage( |
| 398 UINT msg, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 398 UINT msg, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 399 MSG* message = reinterpret_cast<MSG*>(lparam); | 399 MSG* message = reinterpret_cast<MSG*>(lparam); |
| 400 switch (message->message) { | 400 switch (message->message) { |
| 401 case WM_MOUSEWHEEL: | 401 case WM_MOUSEWHEEL: |
| 402 // This message is reflected from the view() to this window. | 402 // This message is reflected from the view() to this window. |
| 403 if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) { | 403 if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) { |
| 404 tab_contents_->GetDelegate()->ContentsZoomChange( | 404 web_contents_->GetDelegate()->ContentsZoomChange( |
| 405 GET_WHEEL_DELTA_WPARAM(message->wParam) > 0); | 405 GET_WHEEL_DELTA_WPARAM(message->wParam) > 0); |
| 406 return 1; | 406 return 1; |
| 407 } | 407 } |
| 408 break; | 408 break; |
| 409 } | 409 } |
| 410 return 0; | 410 return 0; |
| 411 } | 411 } |
| 412 | 412 |
| 413 LRESULT WebContentsViewWin::OnNCCalcSize( | 413 LRESULT WebContentsViewWin::OnNCCalcSize( |
| 414 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 414 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 442 break; | 442 break; |
| 443 case SB_LINEDOWN: | 443 case SB_LINEDOWN: |
| 444 distance = -WHEEL_DELTA; | 444 distance = -WHEEL_DELTA; |
| 445 break; | 445 break; |
| 446 // TODO(joshia): Handle SB_PAGEUP, SB_PAGEDOWN, SB_THUMBPOSITION, | 446 // TODO(joshia): Handle SB_PAGEUP, SB_PAGEDOWN, SB_THUMBPOSITION, |
| 447 // and SB_THUMBTRACK for completeness | 447 // and SB_THUMBTRACK for completeness |
| 448 default: | 448 default: |
| 449 break; | 449 break; |
| 450 } | 450 } |
| 451 | 451 |
| 452 tab_contents_->GetDelegate()->ContentsZoomChange(distance > 0); | 452 web_contents_->GetDelegate()->ContentsZoomChange(distance > 0); |
| 453 return 0; | 453 return 0; |
| 454 } | 454 } |
| 455 | 455 |
| 456 // Reflect scroll message to the view() to give it a chance | 456 // Reflect scroll message to the view() to give it a chance |
| 457 // to process scrolling. | 457 // to process scrolling. |
| 458 SendMessage(GetContentNativeView(), message, wparam, lparam); | 458 SendMessage(GetContentNativeView(), message, wparam, lparam); |
| 459 return 0; | 459 return 0; |
| 460 } | 460 } |
| 461 | 461 |
| 462 LRESULT WebContentsViewWin::OnSize( | 462 LRESULT WebContentsViewWin::OnSize( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 476 si.nMin = 1; | 476 si.nMin = 1; |
| 477 si.nMax = 100; | 477 si.nMax = 100; |
| 478 si.nPage = 10; | 478 si.nPage = 10; |
| 479 si.nPos = 50; | 479 si.nPos = 50; |
| 480 | 480 |
| 481 ::SetScrollInfo(hwnd(), SB_HORZ, &si, FALSE); | 481 ::SetScrollInfo(hwnd(), SB_HORZ, &si, FALSE); |
| 482 ::SetScrollInfo(hwnd(), SB_VERT, &si, FALSE); | 482 ::SetScrollInfo(hwnd(), SB_VERT, &si, FALSE); |
| 483 | 483 |
| 484 return 1; | 484 return 1; |
| 485 } | 485 } |
| OLD | NEW |