| 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/web_contents_view_win.h" | 5 #include "chrome/browser/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" | 10 #include "chrome/browser/browser.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 HWND new_view_parent_window = ::GetAncestor(GetContainerHWND(), GA_ROOT); | 371 HWND new_view_parent_window = ::GetAncestor(GetContainerHWND(), GA_ROOT); |
| 372 new_view->CreateView(new_view_parent_window, gfx::Rect()); | 372 new_view->CreateView(new_view_parent_window, gfx::Rect()); |
| 373 | 373 |
| 374 // TODO(brettw) it seems bogus that we have to call this function on the | 374 // TODO(brettw) it seems bogus that we have to call this function on the |
| 375 // newly created object and give it one of its own member variables. | 375 // newly created object and give it one of its own member variables. |
| 376 new_view->CreateViewForWidget(new_contents->render_view_host()); | 376 new_view->CreateViewForWidget(new_contents->render_view_host()); |
| 377 return new_contents; | 377 return new_contents; |
| 378 } | 378 } |
| 379 | 379 |
| 380 RenderWidgetHostView* WebContentsViewWin::CreateNewWidgetInternal( | 380 RenderWidgetHostView* WebContentsViewWin::CreateNewWidgetInternal( |
| 381 int route_id) { | 381 int route_id, |
| 382 bool focus_on_show) { |
| 382 // Create the widget and its associated view. | 383 // Create the widget and its associated view. |
| 383 // TODO(brettw) can widget creation be cross-platform? | 384 // TODO(brettw) can widget creation be cross-platform? |
| 384 RenderWidgetHost* widget_host = | 385 RenderWidgetHost* widget_host = |
| 385 new RenderWidgetHost(web_contents_->process(), route_id); | 386 new RenderWidgetHost(web_contents_->process(), route_id); |
| 386 RenderWidgetHostViewWin* widget_view = | 387 RenderWidgetHostViewWin* widget_view = |
| 387 new RenderWidgetHostViewWin(widget_host); | 388 new RenderWidgetHostViewWin(widget_host); |
| 388 | 389 |
| 389 // We set the parent HWDN explicitly as pop-up HWNDs are parented and owned by | 390 // We set the parent HWDN explicitly as pop-up HWNDs are parented and owned by |
| 390 // the first non-child HWND of the HWND that was specified to the CreateWindow | 391 // the first non-child HWND of the HWND that was specified to the CreateWindow |
| 391 // call. | 392 // call. |
| 392 // TODO(brettw) this should not need to get the current RVHView from the | 393 // TODO(brettw) this should not need to get the current RVHView from the |
| 393 // WebContents. We should have it somewhere ourselves. | 394 // WebContents. We should have it somewhere ourselves. |
| 394 widget_view->set_parent_hwnd( | 395 widget_view->set_parent_hwnd( |
| 395 web_contents_->render_widget_host_view()->GetPluginHWND()); | 396 web_contents_->render_widget_host_view()->GetPluginHWND()); |
| 396 widget_view->set_close_on_deactivate(true); | 397 widget_view->set_close_on_deactivate(true); |
| 398 widget_view->set_focus_on_show(focus_on_show); |
| 397 | 399 |
| 398 return widget_view; | 400 return widget_view; |
| 399 } | 401 } |
| 400 | 402 |
| 401 void WebContentsViewWin::ShowCreatedWindowInternal( | 403 void WebContentsViewWin::ShowCreatedWindowInternal( |
| 402 WebContents* new_web_contents, | 404 WebContents* new_web_contents, |
| 403 WindowOpenDisposition disposition, | 405 WindowOpenDisposition disposition, |
| 404 const gfx::Rect& initial_pos, | 406 const gfx::Rect& initial_pos, |
| 405 bool user_gesture) { | 407 bool user_gesture) { |
| 406 if (!new_web_contents->render_widget_host_view() || | 408 if (!new_web_contents->render_widget_host_view() || |
| (...skipping 24 matching lines...) Expand all Loading... |
| 431 } | 433 } |
| 432 | 434 |
| 433 // This logic should be implemented by RenderWidgetHostHWND (as mentioned | 435 // This logic should be implemented by RenderWidgetHostHWND (as mentioned |
| 434 // above) in the ::Init function, which should take a parent and some initial | 436 // above) in the ::Init function, which should take a parent and some initial |
| 435 // bounds. | 437 // bounds. |
| 436 widget_host_view_win->Create(GetContainerHWND(), NULL, NULL, | 438 widget_host_view_win->Create(GetContainerHWND(), NULL, NULL, |
| 437 WS_POPUP, WS_EX_TOOLWINDOW); | 439 WS_POPUP, WS_EX_TOOLWINDOW); |
| 438 widget_host_view_win->MoveWindow(initial_pos.x(), initial_pos.y(), | 440 widget_host_view_win->MoveWindow(initial_pos.x(), initial_pos.y(), |
| 439 initial_pos.width(), initial_pos.height(), | 441 initial_pos.width(), initial_pos.height(), |
| 440 TRUE); | 442 TRUE); |
| 441 widget_host_view_win->ShowWindow(SW_SHOW); | 443 widget_host_view_win->ShowWindow(widget_host_view_win->focus_on_show() ? |
| 444 SW_SHOW : SW_SHOWNOACTIVATE); |
| 442 widget_host->Init(); | 445 widget_host->Init(); |
| 443 } | 446 } |
| 444 | 447 |
| 445 void WebContentsViewWin::OnHScroll(int scroll_type, short position, | 448 void WebContentsViewWin::OnHScroll(int scroll_type, short position, |
| 446 HWND scrollbar) { | 449 HWND scrollbar) { |
| 447 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); | 450 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); |
| 448 } | 451 } |
| 449 | 452 |
| 450 void WebContentsViewWin::OnMouseLeave() { | 453 void WebContentsViewWin::OnMouseLeave() { |
| 451 // Let our delegate know that the mouse moved (useful for resetting status | 454 // Let our delegate know that the mouse moved (useful for resetting status |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 666 } |
| 664 return false; | 667 return false; |
| 665 } | 668 } |
| 666 | 669 |
| 667 void WebContentsViewWin::WheelZoom(int distance) { | 670 void WebContentsViewWin::WheelZoom(int distance) { |
| 668 if (web_contents_->delegate()) { | 671 if (web_contents_->delegate()) { |
| 669 bool zoom_in = distance > 0; | 672 bool zoom_in = distance > 0; |
| 670 web_contents_->delegate()->ContentsZoomChange(zoom_in); | 673 web_contents_->delegate()->ContentsZoomChange(zoom_in); |
| 671 } | 674 } |
| 672 } | 675 } |
| OLD | NEW |