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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 new_view->CreateView(); | 341 new_view->CreateView(); |
342 | 342 |
343 // TODO(brettw) it seems bogus that we have to call this function on the | 343 // TODO(brettw) it seems bogus that we have to call this function on the |
344 // newly created object and give it one of its own member variables. | 344 // newly created object and give it one of its own member variables. |
345 new_view->CreateViewForWidget(new_contents->render_view_host()); | 345 new_view->CreateViewForWidget(new_contents->render_view_host()); |
346 return new_contents; | 346 return new_contents; |
347 } | 347 } |
348 | 348 |
349 RenderWidgetHostView* WebContentsViewWin::CreateNewWidgetInternal( | 349 RenderWidgetHostView* WebContentsViewWin::CreateNewWidgetInternal( |
350 int route_id, | 350 int route_id, |
351 bool focus_on_show) { | 351 bool activatable) { |
352 // Create the widget and its associated view. | 352 // Create the widget and its associated view. |
353 // TODO(brettw) can widget creation be cross-platform? | 353 // TODO(brettw) can widget creation be cross-platform? |
354 RenderWidgetHost* widget_host = | 354 RenderWidgetHost* widget_host = |
355 new RenderWidgetHost(web_contents_->process(), route_id); | 355 new RenderWidgetHost(web_contents_->process(), route_id); |
356 RenderWidgetHostViewWin* widget_view = | 356 RenderWidgetHostViewWin* widget_view = |
357 new RenderWidgetHostViewWin(widget_host); | 357 new RenderWidgetHostViewWin(widget_host); |
358 | 358 |
359 // We set the parent HWDN explicitly as pop-up HWNDs are parented and owned by | 359 // We set the parent HWDN explicitly as pop-up HWNDs are parented and owned by |
360 // the first non-child HWND of the HWND that was specified to the CreateWindow | 360 // the first non-child HWND of the HWND that was specified to the CreateWindow |
361 // call. | 361 // call. |
362 // TODO(brettw) this should not need to get the current RVHView from the | 362 // TODO(brettw) this should not need to get the current RVHView from the |
363 // WebContents. We should have it somewhere ourselves. | 363 // WebContents. We should have it somewhere ourselves. |
364 widget_view->set_parent_hwnd( | 364 widget_view->set_parent_hwnd( |
365 web_contents_->render_widget_host_view()->GetPluginHWND()); | 365 web_contents_->render_widget_host_view()->GetPluginHWND()); |
366 widget_view->set_close_on_deactivate(true); | 366 widget_view->set_close_on_deactivate(true); |
367 widget_view->set_focus_on_show(focus_on_show); | 367 widget_view->set_activatable(activatable); |
368 | 368 |
369 return widget_view; | 369 return widget_view; |
370 } | 370 } |
371 | 371 |
372 void WebContentsViewWin::ShowCreatedWindowInternal( | 372 void WebContentsViewWin::ShowCreatedWindowInternal( |
373 WebContents* new_web_contents, | 373 WebContents* new_web_contents, |
374 WindowOpenDisposition disposition, | 374 WindowOpenDisposition disposition, |
375 const gfx::Rect& initial_pos, | 375 const gfx::Rect& initial_pos, |
376 bool user_gesture) { | 376 bool user_gesture) { |
377 if (!new_web_contents->render_widget_host_view() || | 377 if (!new_web_contents->render_widget_host_view() || |
(...skipping 24 matching lines...) Expand all Loading... |
402 } | 402 } |
403 | 403 |
404 // This logic should be implemented by RenderWidgetHostHWND (as mentioned | 404 // This logic should be implemented by RenderWidgetHostHWND (as mentioned |
405 // above) in the ::Init function, which should take a parent and some initial | 405 // above) in the ::Init function, which should take a parent and some initial |
406 // bounds. | 406 // bounds. |
407 widget_host_view_win->Create(GetContainerHWND(), NULL, NULL, | 407 widget_host_view_win->Create(GetContainerHWND(), NULL, NULL, |
408 WS_POPUP, WS_EX_TOOLWINDOW); | 408 WS_POPUP, WS_EX_TOOLWINDOW); |
409 widget_host_view_win->MoveWindow(initial_pos.x(), initial_pos.y(), | 409 widget_host_view_win->MoveWindow(initial_pos.x(), initial_pos.y(), |
410 initial_pos.width(), initial_pos.height(), | 410 initial_pos.width(), initial_pos.height(), |
411 TRUE); | 411 TRUE); |
412 widget_host_view_win->ShowWindow(widget_host_view_win->focus_on_show() ? | 412 widget_host_view_win->ShowWindow(widget_host_view_win->activatable() ? |
413 SW_SHOW : SW_SHOWNOACTIVATE); | 413 SW_SHOW : SW_SHOWNA); |
414 widget_host->Init(); | 414 widget_host->Init(); |
415 } | 415 } |
416 | 416 |
417 void WebContentsViewWin::OnHScroll(int scroll_type, short position, | 417 void WebContentsViewWin::OnHScroll(int scroll_type, short position, |
418 HWND scrollbar) { | 418 HWND scrollbar) { |
419 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); | 419 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); |
420 } | 420 } |
421 | 421 |
422 void WebContentsViewWin::OnMouseLeave() { | 422 void WebContentsViewWin::OnMouseLeave() { |
423 // Let our delegate know that the mouse moved (useful for resetting status | 423 // Let our delegate know that the mouse moved (useful for resetting status |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 637 } |
638 return false; | 638 return false; |
639 } | 639 } |
640 | 640 |
641 void WebContentsViewWin::WheelZoom(int distance) { | 641 void WebContentsViewWin::WheelZoom(int distance) { |
642 if (web_contents_->delegate()) { | 642 if (web_contents_->delegate()) { |
643 bool zoom_in = distance > 0; | 643 bool zoom_in = distance > 0; |
644 web_contents_->delegate()->ContentsZoomChange(zoom_in); | 644 web_contents_->delegate()->ContentsZoomChange(zoom_in); |
645 } | 645 } |
646 } | 646 } |
OLD | NEW |