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_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.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/web_contents/interstitial_page_impl.h" | 9 #include "content/browser/web_contents/interstitial_page_impl.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 *out = window_->GetBoundsInRootWindow(); | 294 *out = window_->GetBoundsInRootWindow(); |
295 } | 295 } |
296 | 296 |
297 void WebContentsViewAura::SetPageTitle(const string16& title) { | 297 void WebContentsViewAura::SetPageTitle(const string16& title) { |
298 window_->set_title(title); | 298 window_->set_title(title); |
299 } | 299 } |
300 | 300 |
301 void WebContentsViewAura::OnTabCrashed(base::TerminationStatus status, | 301 void WebContentsViewAura::OnTabCrashed(base::TerminationStatus status, |
302 int error_code) { | 302 int error_code) { |
303 view_ = NULL; | 303 view_ = NULL; |
| 304 // Set the focus to the parent because neither the view window nor this |
| 305 // window can handle key events. |
| 306 if (window_->HasFocus() && window_->parent()) |
| 307 window_->parent()->Focus(); |
304 } | 308 } |
305 | 309 |
306 void WebContentsViewAura::SizeContents(const gfx::Size& size) { | 310 void WebContentsViewAura::SizeContents(const gfx::Size& size) { |
307 gfx::Rect bounds = window_->bounds(); | 311 gfx::Rect bounds = window_->bounds(); |
308 if (bounds.size() != size) { | 312 if (bounds.size() != size) { |
309 bounds.set_size(size); | 313 bounds.set_size(size); |
310 window_->SetBounds(bounds); | 314 window_->SetBounds(bounds); |
311 } else { | 315 } else { |
312 // Our size matches what we want but the renderers size may not match. | 316 // Our size matches what we want but the renderers size may not match. |
313 // Pretend we were resized so that the renderers size is updated too. | 317 // Pretend we were resized so that the renderers size is updated too. |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 ui::TouchStatus WebContentsViewAura::OnTouchEvent(aura::TouchEvent* event) { | 566 ui::TouchStatus WebContentsViewAura::OnTouchEvent(aura::TouchEvent* event) { |
563 return ui::TOUCH_STATUS_UNKNOWN; | 567 return ui::TOUCH_STATUS_UNKNOWN; |
564 } | 568 } |
565 | 569 |
566 ui::GestureStatus WebContentsViewAura::OnGestureEvent( | 570 ui::GestureStatus WebContentsViewAura::OnGestureEvent( |
567 aura::GestureEvent* event) { | 571 aura::GestureEvent* event) { |
568 return ui::GESTURE_STATUS_UNKNOWN; | 572 return ui::GESTURE_STATUS_UNKNOWN; |
569 } | 573 } |
570 | 574 |
571 bool WebContentsViewAura::CanFocus() { | 575 bool WebContentsViewAura::CanFocus() { |
572 return true; | 576 // Do not take the focus if |view_| is gone because neither the view window |
| 577 // nor this window can handle key events. |
| 578 return view_ != NULL; |
573 } | 579 } |
574 | 580 |
575 void WebContentsViewAura::OnCaptureLost() { | 581 void WebContentsViewAura::OnCaptureLost() { |
576 } | 582 } |
577 | 583 |
578 void WebContentsViewAura::OnPaint(gfx::Canvas* canvas) { | 584 void WebContentsViewAura::OnPaint(gfx::Canvas* canvas) { |
579 } | 585 } |
580 | 586 |
581 void WebContentsViewAura::OnDeviceScaleFactorChanged( | 587 void WebContentsViewAura::OnDeviceScaleFactorChanged( |
582 float device_scale_factor) { | 588 float device_scale_factor) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 OnDragEntered(event); | 658 OnDragEntered(event); |
653 | 659 |
654 web_contents_->GetRenderViewHost()->DragTargetDrop( | 660 web_contents_->GetRenderViewHost()->DragTargetDrop( |
655 event.location(), | 661 event.location(), |
656 GetNativeView()->GetRootWindow()->last_mouse_location(), | 662 GetNativeView()->GetRootWindow()->last_mouse_location(), |
657 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 663 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
658 if (drag_dest_delegate_) | 664 if (drag_dest_delegate_) |
659 drag_dest_delegate_->OnDrop(); | 665 drag_dest_delegate_->OnDrop(); |
660 return current_drag_op_; | 666 return current_drag_op_; |
661 } | 667 } |
OLD | NEW |