Chromium Code Reviews| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 12 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 13 #include "content/browser/download/drag_download_util.h" | 13 #include "content/browser/download/drag_download_util.h" |
| 14 #include "content/browser/frame_host/interstitial_page_impl.h" | 14 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 15 #include "content/browser/frame_host/navigation_entry_impl.h" | 15 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 16 #include "content/browser/renderer_host/dip_util.h" | 16 #include "content/browser/renderer_host/dip_util.h" |
| 17 #include "content/browser/renderer_host/overscroll_controller.h" | 17 #include "content/browser/renderer_host/overscroll_controller.h" |
| 18 #include "content/browser/renderer_host/render_view_host_factory.h" | 18 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 21 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 22 #include "content/browser/renderer_host/web_input_event_aura.h" | |
| 22 #include "content/browser/web_contents/aura/gesture_nav_simple.h" | 23 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
| 23 #include "content/browser/web_contents/aura/image_window_delegate.h" | 24 #include "content/browser/web_contents/aura/image_window_delegate.h" |
| 24 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" | 25 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
| 25 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" | 26 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
| 26 #include "content/browser/web_contents/aura/window_slider.h" | 27 #include "content/browser/web_contents/aura/window_slider.h" |
| 27 #include "content/browser/web_contents/touch_editable_impl_aura.h" | 28 #include "content/browser/web_contents/touch_editable_impl_aura.h" |
| 28 #include "content/browser/web_contents/web_contents_impl.h" | 29 #include "content/browser/web_contents/web_contents_impl.h" |
| 29 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
| 30 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
| 31 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 return; | 805 return; |
| 805 } | 806 } |
| 806 view->overscroll_controller()->set_delegate(this); | 807 view->overscroll_controller()->set_delegate(this); |
| 807 if (!navigation_overlay_) | 808 if (!navigation_overlay_) |
| 808 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); | 809 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); |
| 809 } | 810 } |
| 810 | 811 |
| 811 void WebContentsViewAura::PrepareOverscrollWindow() { | 812 void WebContentsViewAura::PrepareOverscrollWindow() { |
| 812 // If there is an existing |overscroll_window_| which is in the middle of an | 813 // If there is an existing |overscroll_window_| which is in the middle of an |
| 813 // animation, then destroying the window here causes the animation to be | 814 // animation, then destroying the window here causes the animation to be |
| 814 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| | 815 // completed immediately, which triggers |OnImplicitAnimationsCompleted()| |
| 815 // callback, and that tries to reset |overscroll_window_| again, causing a | 816 // callback, and that tries to reset |overscroll_window_| again, causing a |
| 816 // double-free. So use a temporary variable here. | 817 // double-free. So use a temporary variable here. |
| 817 if (overscroll_window_) { | 818 if (overscroll_window_) { |
| 818 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, | 819 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, |
| 819 current_overscroll_gesture_); | 820 current_overscroll_gesture_); |
| 820 scoped_ptr<aura::Window> reset_window(overscroll_window_.release()); | 821 scoped_ptr<aura::Window> reset_window(overscroll_window_.release()); |
| 821 } | 822 } |
| 822 | 823 |
| 823 OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate( | 824 OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate( |
| 824 web_contents_, | 825 web_contents_, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 982 RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura( | 983 RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura( |
| 983 web_contents_->GetRenderWidgetHostView()); | 984 web_contents_->GetRenderWidgetHostView()); |
| 984 touch_editable_->AttachToView(rwhva); | 985 touch_editable_->AttachToView(rwhva); |
| 985 } | 986 } |
| 986 | 987 |
| 987 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(int delta_y) { | 988 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(int delta_y) { |
| 988 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) | 989 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) |
| 989 web_contents_->GetDelegate()->OverscrollUpdate(delta_y); | 990 web_contents_->GetDelegate()->OverscrollUpdate(delta_y); |
| 990 } | 991 } |
| 991 | 992 |
| 993 #if defined(OS_WIN) | |
|
sky
2014/08/04 20:05:20
No ifdefs here.
luken
2014/09/11 01:07:28
Done.
| |
| 994 void WebContentsViewAura::ProcessLinkDisambiguationGesture( | |
| 995 ui::GestureEvent* event) { | |
| 996 blink::WebGestureEvent web_gesture = content::MakeWebGestureEvent(event); | |
| 997 // If we fail to make a WebGestureEvent that is a Tap from the provided event, | |
| 998 // don't forward it to Blink. | |
| 999 if (web_gesture.type < blink::WebInputEvent::Type::GestureTap || | |
| 1000 web_gesture.type > blink::WebInputEvent::Type::GestureTapCancel) | |
| 1001 return; | |
| 1002 | |
| 1003 RenderWidgetHostViewAura* rwhva = | |
| 1004 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); | |
| 1005 RenderWidgetHostImpl* host = | |
| 1006 RenderWidgetHostImpl::From(rwhva->GetRenderWidgetHost()); | |
| 1007 host->ForwardGestureEvent(web_gesture); | |
| 1008 } | |
| 1009 #endif | |
| 1010 | |
| 992 //////////////////////////////////////////////////////////////////////////////// | 1011 //////////////////////////////////////////////////////////////////////////////// |
| 993 // WebContentsViewAura, WebContentsView implementation: | 1012 // WebContentsViewAura, WebContentsView implementation: |
| 994 | 1013 |
| 995 gfx::NativeView WebContentsViewAura::GetNativeView() const { | 1014 gfx::NativeView WebContentsViewAura::GetNativeView() const { |
| 996 return window_.get(); | 1015 return window_.get(); |
| 997 } | 1016 } |
| 998 | 1017 |
| 999 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { | 1018 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { |
| 1000 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 1019 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 1001 return rwhv ? rwhv->GetNativeView() : NULL; | 1020 return rwhv ? rwhv->GetNativeView() : NULL; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1263 } | 1282 } |
| 1264 | 1283 |
| 1265 void WebContentsViewAura::TakeFocus(bool reverse) { | 1284 void WebContentsViewAura::TakeFocus(bool reverse) { |
| 1266 if (web_contents_->GetDelegate() && | 1285 if (web_contents_->GetDelegate() && |
| 1267 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && | 1286 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && |
| 1268 delegate_.get()) { | 1287 delegate_.get()) { |
| 1269 delegate_->TakeFocus(reverse); | 1288 delegate_->TakeFocus(reverse); |
| 1270 } | 1289 } |
| 1271 } | 1290 } |
| 1272 | 1291 |
| 1292 #if defined(OS_WIN) | |
|
sky
2014/08/04 20:05:20
No ifdefs here.
luken
2014/09/11 01:07:27
Done.
| |
| 1293 void WebContentsViewAura::ShowDisambiguationPopup( | |
| 1294 const gfx::Rect& target_rect, | |
| 1295 const SkBitmap& zoomed_bitmap) { | |
| 1296 if (delegate_) { | |
| 1297 delegate_->ShowDisambiguationPopup( | |
| 1298 target_rect, | |
| 1299 zoomed_bitmap, | |
| 1300 window_.get(), | |
| 1301 base::Bind(&WebContentsViewAura::ProcessLinkDisambiguationGesture, | |
| 1302 base::Unretained(this))); | |
| 1303 } | |
| 1304 } | |
| 1305 | |
| 1306 void WebContentsViewAura::HideDisambiguationPopup() { | |
| 1307 if (delegate_) | |
| 1308 delegate_->HideDisambiguationPopup(); | |
| 1309 } | |
| 1310 #endif | |
| 1311 | |
| 1273 //////////////////////////////////////////////////////////////////////////////// | 1312 //////////////////////////////////////////////////////////////////////////////// |
| 1274 // WebContentsViewAura, OverscrollControllerDelegate implementation: | 1313 // WebContentsViewAura, OverscrollControllerDelegate implementation: |
| 1275 | 1314 |
| 1276 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { | 1315 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { |
| 1277 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 1316 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 1278 if (!rwhv || !rwhv->IsShowing()) | 1317 if (!rwhv || !rwhv->IsShowing()) |
| 1279 return gfx::Rect(); | 1318 return gfx::Rect(); |
| 1280 | 1319 |
| 1281 return rwhv->GetViewBounds(); | 1320 return rwhv->GetViewBounds(); |
| 1282 } | 1321 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1617 if (visible) { | 1656 if (visible) { |
| 1618 if (!web_contents_->should_normally_be_visible()) | 1657 if (!web_contents_->should_normally_be_visible()) |
| 1619 web_contents_->WasShown(); | 1658 web_contents_->WasShown(); |
| 1620 } else { | 1659 } else { |
| 1621 if (web_contents_->should_normally_be_visible()) | 1660 if (web_contents_->should_normally_be_visible()) |
| 1622 web_contents_->WasHidden(); | 1661 web_contents_->WasHidden(); |
| 1623 } | 1662 } |
| 1624 } | 1663 } |
| 1625 | 1664 |
| 1626 } // namespace content | 1665 } // namespace content |
| OLD | NEW |