OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tab_contents/web_contents_view_win.h" | 5 #include "chrome/browser/tab_contents/web_contents_view_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 9 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
10 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. | 10 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 WebContentsViewWin::~WebContentsViewWin() { | 60 WebContentsViewWin::~WebContentsViewWin() { |
61 // Makes sure to remove any stored view we may still have in the ViewStorage. | 61 // Makes sure to remove any stored view we may still have in the ViewStorage. |
62 // | 62 // |
63 // It is possible the view went away before us, so we only do this if the | 63 // It is possible the view went away before us, so we only do this if the |
64 // view is registered. | 64 // view is registered. |
65 views::ViewStorage* view_storage = views::ViewStorage::GetSharedInstance(); | 65 views::ViewStorage* view_storage = views::ViewStorage::GetSharedInstance(); |
66 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) | 66 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) |
67 view_storage->RemoveView(last_focused_view_storage_id_); | 67 view_storage->RemoveView(last_focused_view_storage_id_); |
68 } | 68 } |
69 | 69 |
70 WebContents* WebContentsViewWin::GetWebContents() { | |
71 return web_contents_; | |
72 } | |
73 | |
74 void WebContentsViewWin::CreateView() { | 70 void WebContentsViewWin::CreateView() { |
75 set_delete_on_destroy(false); | 71 set_delete_on_destroy(false); |
76 // Since we create these windows parented to the desktop window initially, we | 72 // Since we create these windows parented to the desktop window initially, we |
77 // don't want to create them initially visible. | 73 // don't want to create them initially visible. |
78 set_window_style(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); | 74 set_window_style(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); |
79 WidgetWin::Init(GetDesktopWindow(), gfx::Rect(), false); | 75 WidgetWin::Init(GetDesktopWindow(), gfx::Rect(), false); |
80 | 76 |
81 // Remove the root view drop target so we can register our own. | 77 // Remove the root view drop target so we can register our own. |
82 RevokeDragDrop(GetNativeView()); | 78 RevokeDragDrop(GetNativeView()); |
83 drop_target_ = new WebDropTarget(GetNativeView(), web_contents_); | 79 drop_target_ = new WebDropTarget(GetNativeView(), web_contents()); |
84 } | 80 } |
85 | 81 |
86 RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget( | 82 RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget( |
87 RenderWidgetHost* render_widget_host) { | 83 RenderWidgetHost* render_widget_host) { |
88 DCHECK(!render_widget_host->view()); | 84 DCHECK(!render_widget_host->view()); |
89 RenderWidgetHostViewWin* view = | 85 RenderWidgetHostViewWin* view = |
90 new RenderWidgetHostViewWin(render_widget_host); | 86 new RenderWidgetHostViewWin(render_widget_host); |
91 view->Create(GetNativeView()); | 87 view->Create(GetNativeView()); |
92 view->ShowWindow(SW_SHOW); | 88 view->ShowWindow(SW_SHOW); |
93 return view; | 89 return view; |
94 } | 90 } |
95 | 91 |
96 gfx::NativeView WebContentsViewWin::GetNativeView() const { | 92 gfx::NativeView WebContentsViewWin::GetNativeView() const { |
97 return WidgetWin::GetNativeView(); | 93 return WidgetWin::GetNativeView(); |
98 } | 94 } |
99 | 95 |
100 gfx::NativeView WebContentsViewWin::GetContentNativeView() const { | 96 gfx::NativeView WebContentsViewWin::GetContentNativeView() const { |
101 if (!web_contents_->render_widget_host_view()) | 97 if (!web_contents()->render_widget_host_view()) |
102 return NULL; | 98 return NULL; |
103 return web_contents_->render_widget_host_view()->GetPluginNativeView(); | 99 return web_contents()->render_widget_host_view()->GetPluginNativeView(); |
104 } | 100 } |
105 | 101 |
106 gfx::NativeWindow WebContentsViewWin::GetTopLevelNativeWindow() const { | 102 gfx::NativeWindow WebContentsViewWin::GetTopLevelNativeWindow() const { |
107 return ::GetAncestor(GetNativeView(), GA_ROOT); | 103 return ::GetAncestor(GetNativeView(), GA_ROOT); |
108 } | 104 } |
109 | 105 |
110 void WebContentsViewWin::GetContainerBounds(gfx::Rect* out) const { | 106 void WebContentsViewWin::GetContainerBounds(gfx::Rect* out) const { |
111 GetBounds(out, false); | 107 GetBounds(out, false); |
112 } | 108 } |
113 | 109 |
(...skipping 26 matching lines...) Expand all Loading... |
140 // but we do want to allow them to be added to the bookmarks bar | 136 // but we do want to allow them to be added to the bookmarks bar |
141 // (bookmarklets). | 137 // (bookmarklets). |
142 BookmarkDragData::Element bm_elt; | 138 BookmarkDragData::Element bm_elt; |
143 bm_elt.is_url = true; | 139 bm_elt.is_url = true; |
144 bm_elt.url = drop_data.url; | 140 bm_elt.url = drop_data.url; |
145 bm_elt.title = drop_data.url_title; | 141 bm_elt.title = drop_data.url_title; |
146 | 142 |
147 BookmarkDragData bm_drag_data; | 143 BookmarkDragData bm_drag_data; |
148 bm_drag_data.elements.push_back(bm_elt); | 144 bm_drag_data.elements.push_back(bm_elt); |
149 | 145 |
150 bm_drag_data.Write(web_contents_->profile(), data); | 146 bm_drag_data.Write(web_contents()->profile(), data); |
151 } else { | 147 } else { |
152 data->SetURL(drop_data.url, drop_data.url_title); | 148 data->SetURL(drop_data.url, drop_data.url_title); |
153 } | 149 } |
154 } | 150 } |
155 if (!drop_data.plain_text.empty()) | 151 if (!drop_data.plain_text.empty()) |
156 data->SetString(drop_data.plain_text); | 152 data->SetString(drop_data.plain_text); |
157 | 153 |
158 scoped_refptr<WebDragSource> drag_source( | 154 scoped_refptr<WebDragSource> drag_source( |
159 new WebDragSource(GetNativeView(), web_contents_->render_view_host())); | 155 new WebDragSource(GetNativeView(), web_contents()->render_view_host())); |
160 | 156 |
161 DWORD effects; | 157 DWORD effects; |
162 | 158 |
163 // We need to enable recursive tasks on the message loop so we can get | 159 // We need to enable recursive tasks on the message loop so we can get |
164 // updates while in the system DoDragDrop loop. | 160 // updates while in the system DoDragDrop loop. |
165 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 161 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
166 MessageLoop::current()->SetNestableTasksAllowed(true); | 162 MessageLoop::current()->SetNestableTasksAllowed(true); |
167 DoDragDrop(data, drag_source, DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); | 163 DoDragDrop(data, drag_source, DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); |
168 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 164 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
169 | 165 |
170 if (web_contents_->render_view_host()) | 166 if (web_contents()->render_view_host()) |
171 web_contents_->render_view_host()->DragSourceSystemDragEnded(); | 167 web_contents()->render_view_host()->DragSourceSystemDragEnded(); |
172 } | 168 } |
173 | 169 |
174 void WebContentsViewWin::OnContentsDestroy() { | 170 void WebContentsViewWin::OnContentsDestroy() { |
175 // TODO(brettw) this seems like maybe it can be moved into OnDestroy and this | 171 // TODO(brettw) this seems like maybe it can be moved into OnDestroy and this |
176 // function can be deleted? If you're adding more here, consider whether it | 172 // function can be deleted? If you're adding more here, consider whether it |
177 // can be moved into OnDestroy which is a Windows message handler as the | 173 // can be moved into OnDestroy which is a Windows message handler as the |
178 // window is being torn down. | 174 // window is being torn down. |
179 | 175 |
180 // When a tab is closed all its child plugin windows are destroyed | 176 // When a tab is closed all its child plugin windows are destroyed |
181 // automatically. This happens before plugins get any notification that its | 177 // automatically. This happens before plugins get any notification that its |
(...skipping 18 matching lines...) Expand all Loading... |
200 } | 196 } |
201 } | 197 } |
202 | 198 |
203 void WebContentsViewWin::SetPageTitle(const std::wstring& title) { | 199 void WebContentsViewWin::SetPageTitle(const std::wstring& title) { |
204 if (GetNativeView()) { | 200 if (GetNativeView()) { |
205 // It's possible to get this after the hwnd has been destroyed. | 201 // It's possible to get this after the hwnd has been destroyed. |
206 ::SetWindowText(GetNativeView(), title.c_str()); | 202 ::SetWindowText(GetNativeView(), title.c_str()); |
207 // TODO(brettw) this call seems messy the way it reaches into the widget | 203 // TODO(brettw) this call seems messy the way it reaches into the widget |
208 // view, and I'm not sure it's necessary. Maybe we should just remove it. | 204 // view, and I'm not sure it's necessary. Maybe we should just remove it. |
209 ::SetWindowText( | 205 ::SetWindowText( |
210 web_contents_->render_widget_host_view()->GetPluginNativeView(), | 206 web_contents()->render_widget_host_view()->GetPluginNativeView(), |
211 title.c_str()); | 207 title.c_str()); |
212 } | 208 } |
213 } | 209 } |
214 | 210 |
215 void WebContentsViewWin::Invalidate() { | 211 void WebContentsViewWin::Invalidate() { |
216 // Note that it's possible to get this message after the window was destroyed. | 212 // Note that it's possible to get this message after the window was destroyed. |
217 if (::IsWindow(GetNativeView())) | 213 if (::IsWindow(GetNativeView())) |
218 InvalidateRect(GetNativeView(), NULL, FALSE); | 214 InvalidateRect(GetNativeView(), NULL, FALSE); |
219 } | 215 } |
220 | 216 |
221 void WebContentsViewWin::SizeContents(const gfx::Size& size) { | 217 void WebContentsViewWin::SizeContents(const gfx::Size& size) { |
222 // TODO(brettw) this is a hack and should be removed. See web_contents_view.h. | 218 // TODO(brettw) this is a hack and should be removed. See web_contents_view.h. |
223 WasSized(size); | 219 WasSized(size); |
224 } | 220 } |
225 | 221 |
226 void WebContentsViewWin::SetInitialFocus() { | 222 void WebContentsViewWin::SetInitialFocus() { |
227 if (web_contents_->FocusLocationBarByDefault()) | 223 if (web_contents()->FocusLocationBarByDefault()) |
228 web_contents_->delegate()->SetFocusToLocationBar(); | 224 web_contents()->delegate()->SetFocusToLocationBar(); |
229 else | 225 else |
230 ::SetFocus(GetNativeView()); | 226 ::SetFocus(GetNativeView()); |
231 } | 227 } |
232 | 228 |
233 void WebContentsViewWin::StoreFocus() { | 229 void WebContentsViewWin::StoreFocus() { |
234 views::ViewStorage* view_storage = views::ViewStorage::GetSharedInstance(); | 230 views::ViewStorage* view_storage = views::ViewStorage::GetSharedInstance(); |
235 | 231 |
236 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) | 232 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) |
237 view_storage->RemoveView(last_focused_view_storage_id_); | 233 view_storage->RemoveView(last_focused_view_storage_id_); |
238 | 234 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 344 |
349 // Any unhandled keyboard/character messages should be defproced. | 345 // Any unhandled keyboard/character messages should be defproced. |
350 // This allows stuff like Alt+F4, etc to work correctly. | 346 // This allows stuff like Alt+F4, etc to work correctly. |
351 DefWindowProc(event.os_event.hwnd, | 347 DefWindowProc(event.os_event.hwnd, |
352 event.os_event.message, | 348 event.os_event.message, |
353 event.os_event.wParam, | 349 event.os_event.wParam, |
354 event.os_event.lParam); | 350 event.os_event.lParam); |
355 } | 351 } |
356 | 352 |
357 void WebContentsViewWin::ShowContextMenu(const ContextMenuParams& params) { | 353 void WebContentsViewWin::ShowContextMenu(const ContextMenuParams& params) { |
358 RenderViewContextMenuWin menu(web_contents_, | 354 RenderViewContextMenuWin menu(web_contents(), |
359 params, | 355 params, |
360 GetNativeView()); | 356 GetNativeView()); |
361 | 357 |
362 POINT screen_pt = { params.x, params.y }; | 358 POINT screen_pt = { params.x, params.y }; |
363 MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1); | 359 MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1); |
364 | 360 |
365 // Enable recursive tasks on the message loop so we can get updates while | 361 // Enable recursive tasks on the message loop so we can get updates while |
366 // the context menu is being displayed. | 362 // the context menu is being displayed. |
367 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 363 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
368 MessageLoop::current()->SetNestableTasksAllowed(true); | 364 MessageLoop::current()->SetNestableTasksAllowed(true); |
369 menu.RunMenuAt(screen_pt.x, screen_pt.y); | 365 menu.RunMenuAt(screen_pt.x, screen_pt.y); |
370 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 366 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
371 } | 367 } |
372 | 368 |
373 WebContents* WebContentsViewWin::CreateNewWindowInternal( | 369 WebContents* WebContentsViewWin::CreateNewWindowInternal( |
374 int route_id, | 370 int route_id, |
375 base::WaitableEvent* modal_dialog_event) { | 371 base::WaitableEvent* modal_dialog_event) { |
376 // Create the new web contents. This will automatically create the new | 372 // Create the new web contents. This will automatically create the new |
377 // WebContentsView. In the future, we may want to create the view separately. | 373 // WebContentsView. In the future, we may want to create the view separately. |
378 WebContents* new_contents = | 374 WebContents* new_contents = |
379 new WebContents(web_contents_->profile(), | 375 new WebContents(web_contents()->profile(), |
380 web_contents_->GetSiteInstance(), | 376 web_contents()->GetSiteInstance(), |
381 web_contents_->render_view_factory_, | 377 web_contents()->render_view_factory_, |
382 route_id, | 378 route_id, |
383 modal_dialog_event); | 379 modal_dialog_event); |
384 new_contents->SetupController(web_contents_->profile()); | 380 new_contents->SetupController(web_contents()->profile()); |
385 WebContentsView* new_view = new_contents->view(); | 381 WebContentsView* new_view = new_contents->view(); |
386 | 382 |
387 new_view->CreateView(); | 383 new_view->CreateView(); |
388 | 384 |
389 // TODO(brettw) it seems bogus that we have to call this function on the | 385 // TODO(brettw) it seems bogus that we have to call this function on the |
390 // newly created object and give it one of its own member variables. | 386 // newly created object and give it one of its own member variables. |
391 new_view->CreateViewForWidget(new_contents->render_view_host()); | 387 new_view->CreateViewForWidget(new_contents->render_view_host()); |
392 return new_contents; | 388 return new_contents; |
393 } | 389 } |
394 | 390 |
395 void WebContentsViewWin::ShowCreatedWindowInternal( | 391 void WebContentsViewWin::ShowCreatedWindowInternal( |
396 WebContents* new_web_contents, | 392 WebContents* new_web_contents, |
397 WindowOpenDisposition disposition, | 393 WindowOpenDisposition disposition, |
398 const gfx::Rect& initial_pos, | 394 const gfx::Rect& initial_pos, |
399 bool user_gesture) { | 395 bool user_gesture) { |
400 if (!new_web_contents->render_widget_host_view() || | 396 if (!new_web_contents->render_widget_host_view() || |
401 !new_web_contents->process()->channel()) { | 397 !new_web_contents->process()->channel()) { |
402 // The view has gone away or the renderer crashed. Nothing to do. | 398 // The view has gone away or the renderer crashed. Nothing to do. |
403 return; | 399 return; |
404 } | 400 } |
405 | 401 |
406 // TODO(brettw) this seems bogus to reach into here and initialize the host. | 402 // TODO(brettw) this seems bogus to reach into here and initialize the host. |
407 new_web_contents->render_view_host()->Init(); | 403 new_web_contents->render_view_host()->Init(); |
408 web_contents_->AddNewContents(new_web_contents, disposition, initial_pos, | 404 web_contents()->AddNewContents(new_web_contents, disposition, initial_pos, |
409 user_gesture); | 405 user_gesture); |
410 } | 406 } |
411 | 407 |
412 void WebContentsViewWin::OnHScroll(int scroll_type, short position, | 408 void WebContentsViewWin::OnHScroll(int scroll_type, short position, |
413 HWND scrollbar) { | 409 HWND scrollbar) { |
414 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); | 410 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); |
415 } | 411 } |
416 | 412 |
417 void WebContentsViewWin::OnMouseLeave() { | 413 void WebContentsViewWin::OnMouseLeave() { |
418 // Let our delegate know that the mouse moved (useful for resetting status | 414 // Let our delegate know that the mouse moved (useful for resetting status |
419 // bubble state). | 415 // bubble state). |
420 if (web_contents_->delegate()) | 416 if (web_contents()->delegate()) |
421 web_contents_->delegate()->ContentsMouseEvent(web_contents_, false); | 417 web_contents()->delegate()->ContentsMouseEvent(web_contents(), false); |
422 SetMsgHandled(FALSE); | 418 SetMsgHandled(FALSE); |
423 } | 419 } |
424 | 420 |
425 LRESULT WebContentsViewWin::OnMouseRange(UINT msg, | 421 LRESULT WebContentsViewWin::OnMouseRange(UINT msg, |
426 WPARAM w_param, LPARAM l_param) { | 422 WPARAM w_param, LPARAM l_param) { |
427 switch (msg) { | 423 switch (msg) { |
428 case WM_LBUTTONDOWN: | 424 case WM_LBUTTONDOWN: |
429 case WM_MBUTTONDOWN: | 425 case WM_MBUTTONDOWN: |
430 case WM_RBUTTONDOWN: { | 426 case WM_RBUTTONDOWN: { |
431 // Make sure this TabContents is activated when it is clicked on. | 427 // Make sure this TabContents is activated when it is clicked on. |
432 if (web_contents_->delegate()) | 428 if (web_contents()->delegate()) |
433 web_contents_->delegate()->ActivateContents(web_contents_); | 429 web_contents()->delegate()->ActivateContents(web_contents()); |
434 DownloadRequestManager* drm = | 430 DownloadRequestManager* drm = |
435 g_browser_process->download_request_manager(); | 431 g_browser_process->download_request_manager(); |
436 if (drm) | 432 if (drm) |
437 drm->OnUserGesture(web_contents_); | 433 drm->OnUserGesture(web_contents()); |
438 break; | 434 break; |
439 } | 435 } |
440 case WM_MOUSEMOVE: | 436 case WM_MOUSEMOVE: |
441 // Let our delegate know that the mouse moved (useful for resetting status | 437 // Let our delegate know that the mouse moved (useful for resetting status |
442 // bubble state). | 438 // bubble state). |
443 if (web_contents_->delegate()) { | 439 if (web_contents()->delegate()) { |
444 web_contents_->delegate()->ContentsMouseEvent(web_contents_, true); | 440 web_contents()->delegate()->ContentsMouseEvent(web_contents(), true); |
445 } | 441 } |
446 break; | 442 break; |
447 default: | 443 default: |
448 break; | 444 break; |
449 } | 445 } |
450 | 446 |
451 return 0; | 447 return 0; |
452 } | 448 } |
453 | 449 |
454 void WebContentsViewWin::OnPaint(HDC junk_dc) { | 450 void WebContentsViewWin::OnPaint(HDC junk_dc) { |
455 if (web_contents_->render_view_host() && | 451 if (web_contents()->render_view_host() && |
456 !web_contents_->render_view_host()->IsRenderViewLive()) { | 452 !web_contents()->render_view_host()->IsRenderViewLive()) { |
457 if (!sad_tab_.get()) | 453 if (!sad_tab_.get()) |
458 sad_tab_.reset(new SadTabView); | 454 sad_tab_.reset(new SadTabView); |
459 CRect cr; | 455 CRect cr; |
460 GetClientRect(&cr); | 456 GetClientRect(&cr); |
461 sad_tab_->SetBounds(gfx::Rect(cr)); | 457 sad_tab_->SetBounds(gfx::Rect(cr)); |
462 ChromeCanvasPaint canvas(GetNativeView(), true); | 458 ChromeCanvasPaint canvas(GetNativeView(), true); |
463 sad_tab_->ProcessPaint(&canvas); | 459 sad_tab_->ProcessPaint(&canvas); |
464 return; | 460 return; |
465 } | 461 } |
466 | 462 |
(...skipping 27 matching lines...) Expand all Loading... |
494 } | 490 } |
495 | 491 |
496 return 0; | 492 return 0; |
497 } | 493 } |
498 | 494 |
499 void WebContentsViewWin::OnSetFocus(HWND window) { | 495 void WebContentsViewWin::OnSetFocus(HWND window) { |
500 // TODO(jcampan): figure out why removing this prevents tabs opened in the | 496 // TODO(jcampan): figure out why removing this prevents tabs opened in the |
501 // background from properly taking focus. | 497 // background from properly taking focus. |
502 // We NULL-check the render_view_host_ here because Windows can send us | 498 // We NULL-check the render_view_host_ here because Windows can send us |
503 // messages during the destruction process after it has been destroyed. | 499 // messages during the destruction process after it has been destroyed. |
504 if (web_contents_->render_widget_host_view()) { | 500 if (web_contents()->render_widget_host_view()) { |
505 HWND inner_hwnd = | 501 HWND inner_hwnd = |
506 web_contents_->render_widget_host_view()->GetPluginNativeView(); | 502 web_contents()->render_widget_host_view()->GetPluginNativeView(); |
507 if (::IsWindow(inner_hwnd)) | 503 if (::IsWindow(inner_hwnd)) |
508 ::SetFocus(inner_hwnd); | 504 ::SetFocus(inner_hwnd); |
509 } | 505 } |
510 } | 506 } |
511 | 507 |
512 void WebContentsViewWin::OnVScroll(int scroll_type, short position, | 508 void WebContentsViewWin::OnVScroll(int scroll_type, short position, |
513 HWND scrollbar) { | 509 HWND scrollbar) { |
514 ScrollCommon(WM_VSCROLL, scroll_type, position, scrollbar); | 510 ScrollCommon(WM_VSCROLL, scroll_type, position, scrollbar); |
515 } | 511 } |
516 | 512 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 if (!ScrollZoom(scroll_type)) { | 565 if (!ScrollZoom(scroll_type)) { |
570 // Reflect scroll message to the view() to give it a chance | 566 // Reflect scroll message to the view() to give it a chance |
571 // to process scrolling. | 567 // to process scrolling. |
572 SendMessage(GetContentNativeView(), message, | 568 SendMessage(GetContentNativeView(), message, |
573 MAKELONG(scroll_type, position), | 569 MAKELONG(scroll_type, position), |
574 reinterpret_cast<LPARAM>(scrollbar)); | 570 reinterpret_cast<LPARAM>(scrollbar)); |
575 } | 571 } |
576 } | 572 } |
577 | 573 |
578 void WebContentsViewWin::WasHidden() { | 574 void WebContentsViewWin::WasHidden() { |
579 web_contents_->HideContents(); | 575 web_contents()->HideContents(); |
580 } | 576 } |
581 | 577 |
582 void WebContentsViewWin::WasShown() { | 578 void WebContentsViewWin::WasShown() { |
583 web_contents_->ShowContents(); | 579 web_contents()->ShowContents(); |
584 } | 580 } |
585 | 581 |
586 void WebContentsViewWin::WasSized(const gfx::Size& size) { | 582 void WebContentsViewWin::WasSized(const gfx::Size& size) { |
587 if (web_contents_->interstitial_page()) | 583 if (web_contents()->interstitial_page()) |
588 web_contents_->interstitial_page()->SetSize(size); | 584 web_contents()->interstitial_page()->SetSize(size); |
589 if (web_contents_->render_widget_host_view()) | 585 if (web_contents()->render_widget_host_view()) |
590 web_contents_->render_widget_host_view()->SetSize(size); | 586 web_contents()->render_widget_host_view()->SetSize(size); |
591 | 587 |
592 // TODO(brettw) this function can probably be moved to this class. | 588 // TODO(brettw) this function can probably be moved to this class. |
593 web_contents_->RepositionSupressedPopupsToFit(size); | 589 web_contents()->RepositionSupressedPopupsToFit(size); |
594 } | 590 } |
595 | 591 |
596 bool WebContentsViewWin::ScrollZoom(int scroll_type) { | 592 bool WebContentsViewWin::ScrollZoom(int scroll_type) { |
597 // If ctrl is held, zoom the UI. There are three issues with this: | 593 // If ctrl is held, zoom the UI. There are three issues with this: |
598 // 1) Should the event be eaten or forwarded to content? We eat the event, | 594 // 1) Should the event be eaten or forwarded to content? We eat the event, |
599 // which is like Firefox and unlike IE. | 595 // which is like Firefox and unlike IE. |
600 // 2) Should wheel up zoom in or out? We zoom in (increase font size), which | 596 // 2) Should wheel up zoom in or out? We zoom in (increase font size), which |
601 // is like IE and Google maps, but unlike Firefox. | 597 // is like IE and Google maps, but unlike Firefox. |
602 // 3) Should the mouse have to be over the content area? We zoom as long as | 598 // 3) Should the mouse have to be over the content area? We zoom as long as |
603 // content has focus, although FF and IE require that the mouse is over | 599 // content has focus, although FF and IE require that the mouse is over |
(...skipping 14 matching lines...) Expand all Loading... |
618 break; | 614 break; |
619 } | 615 } |
620 | 616 |
621 WheelZoom(distance); | 617 WheelZoom(distance); |
622 return true; | 618 return true; |
623 } | 619 } |
624 return false; | 620 return false; |
625 } | 621 } |
626 | 622 |
627 void WebContentsViewWin::WheelZoom(int distance) { | 623 void WebContentsViewWin::WheelZoom(int distance) { |
628 if (web_contents_->delegate()) { | 624 if (web_contents()->delegate()) { |
629 bool zoom_in = distance > 0; | 625 bool zoom_in = distance > 0; |
630 web_contents_->delegate()->ContentsZoomChange(zoom_in); | 626 web_contents()->delegate()->ContentsZoomChange(zoom_in); |
631 } | 627 } |
632 } | 628 } |
OLD | NEW |