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 void WebContentsViewAura::ProcessLinkDisambiguationGesture( | |
jam
2014/07/30 20:29:03
this should be behind the ifdef as well?
luken
2014/07/31 01:41:47
Done.
| |
994 ui::GestureEvent* event) { | |
995 blink::WebGestureEvent web_gesture = content::MakeWebGestureEvent(event); | |
996 // If we fail to make a WebGestureEvent that is a Tap from the provided event, | |
997 // don't forward it to Blink. | |
998 if (web_gesture.type < blink::WebInputEvent::Type::GestureTap || | |
999 web_gesture.type > blink::WebInputEvent::Type::GestureTapCancel) | |
1000 return; | |
1001 | |
1002 RenderWidgetHostViewAura* rwhva = | |
1003 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); | |
1004 RenderWidgetHostImpl* host = | |
1005 RenderWidgetHostImpl::From(rwhva->GetRenderWidgetHost()); | |
1006 host->ForwardGestureEvent(web_gesture); | |
1007 } | |
1008 | |
992 //////////////////////////////////////////////////////////////////////////////// | 1009 //////////////////////////////////////////////////////////////////////////////// |
993 // WebContentsViewAura, WebContentsView implementation: | 1010 // WebContentsViewAura, WebContentsView implementation: |
994 | 1011 |
995 gfx::NativeView WebContentsViewAura::GetNativeView() const { | 1012 gfx::NativeView WebContentsViewAura::GetNativeView() const { |
996 return window_.get(); | 1013 return window_.get(); |
997 } | 1014 } |
998 | 1015 |
999 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { | 1016 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { |
1000 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 1017 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
1001 return rwhv ? rwhv->GetNativeView() : NULL; | 1018 return rwhv ? rwhv->GetNativeView() : NULL; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1263 } | 1280 } |
1264 | 1281 |
1265 void WebContentsViewAura::TakeFocus(bool reverse) { | 1282 void WebContentsViewAura::TakeFocus(bool reverse) { |
1266 if (web_contents_->GetDelegate() && | 1283 if (web_contents_->GetDelegate() && |
1267 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && | 1284 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && |
1268 delegate_.get()) { | 1285 delegate_.get()) { |
1269 delegate_->TakeFocus(reverse); | 1286 delegate_->TakeFocus(reverse); |
1270 } | 1287 } |
1271 } | 1288 } |
1272 | 1289 |
1290 #if defined(OS_WIN) | |
1291 void WebContentsViewAura::ShowDisambiguationPopup( | |
1292 const gfx::Rect& target_rect, | |
1293 const SkBitmap& zoomed_bitmap) { | |
1294 if (delegate_) { | |
1295 delegate_->ShowLinkDisambiguationPopup( | |
1296 target_rect, | |
1297 zoomed_bitmap, | |
1298 window_.get(), | |
1299 base::Bind(&WebContentsViewAura::ProcessLinkDisambiguationGesture, | |
1300 base::Unretained(this))); | |
1301 } | |
1302 } | |
1303 #endif | |
1304 | |
1273 //////////////////////////////////////////////////////////////////////////////// | 1305 //////////////////////////////////////////////////////////////////////////////// |
1274 // WebContentsViewAura, OverscrollControllerDelegate implementation: | 1306 // WebContentsViewAura, OverscrollControllerDelegate implementation: |
1275 | 1307 |
1276 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { | 1308 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { |
1277 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 1309 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
1278 if (!rwhv || !rwhv->IsShowing()) | 1310 if (!rwhv || !rwhv->IsShowing()) |
1279 return gfx::Rect(); | 1311 return gfx::Rect(); |
1280 | 1312 |
1281 return rwhv->GetViewBounds(); | 1313 return rwhv->GetViewBounds(); |
1282 } | 1314 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1617 if (visible) { | 1649 if (visible) { |
1618 if (!web_contents_->should_normally_be_visible()) | 1650 if (!web_contents_->should_normally_be_visible()) |
1619 web_contents_->WasShown(); | 1651 web_contents_->WasShown(); |
1620 } else { | 1652 } else { |
1621 if (web_contents_->should_normally_be_visible()) | 1653 if (web_contents_->should_normally_be_visible()) |
1622 web_contents_->WasHidden(); | 1654 web_contents_->WasHidden(); |
1623 } | 1655 } |
1624 } | 1656 } |
1625 | 1657 |
1626 } // namespace content | 1658 } // namespace content |
OLD | NEW |