Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 351683002: Adds link disambiguation popup support to Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: responding to sky's last round of feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/files/file_util.h" 9 #include "base/files/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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 return; 804 return;
804 } 805 }
805 view->overscroll_controller()->set_delegate(this); 806 view->overscroll_controller()->set_delegate(this);
806 if (!navigation_overlay_) 807 if (!navigation_overlay_)
807 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); 808 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_));
808 } 809 }
809 810
810 void WebContentsViewAura::PrepareOverscrollWindow() { 811 void WebContentsViewAura::PrepareOverscrollWindow() {
811 // If there is an existing |overscroll_window_| which is in the middle of an 812 // If there is an existing |overscroll_window_| which is in the middle of an
812 // animation, then destroying the window here causes the animation to be 813 // animation, then destroying the window here causes the animation to be
813 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| 814 // completed immediately, which triggers |OnImplicitAnimationsCompleted()|
814 // callback, and that tries to reset |overscroll_window_| again, causing a 815 // callback, and that tries to reset |overscroll_window_| again, causing a
815 // double-free. So use a temporary variable here. 816 // double-free. So use a temporary variable here.
816 if (overscroll_window_) { 817 if (overscroll_window_) {
817 base::AutoReset<OverscrollMode> reset_state(&current_overscroll_gesture_, 818 base::AutoReset<OverscrollMode> reset_state(&current_overscroll_gesture_,
818 current_overscroll_gesture_); 819 current_overscroll_gesture_);
819 scoped_ptr<aura::Window> reset_window(overscroll_window_.release()); 820 scoped_ptr<aura::Window> reset_window(overscroll_window_.release());
820 } 821 }
821 822
822 OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate( 823 OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate(
823 web_contents_, 824 web_contents_,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura( 982 RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura(
982 web_contents_->GetRenderWidgetHostView()); 983 web_contents_->GetRenderWidgetHostView());
983 touch_editable_->AttachToView(rwhva); 984 touch_editable_->AttachToView(rwhva);
984 } 985 }
985 986
986 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(int delta_y) { 987 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(int delta_y) {
987 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) 988 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled())
988 web_contents_->GetDelegate()->OverscrollUpdate(delta_y); 989 web_contents_->GetDelegate()->OverscrollUpdate(delta_y);
989 } 990 }
990 991
992 void WebContentsViewAura::ProcessLinkDisambiguationGesture(
993 ui::GestureEvent* event) {
994 blink::WebGestureEvent web_gesture = content::MakeWebGestureEvent(event);
995 // If we fail to make a WebGestureEvent that is a Tap from the provided event,
996 // don't forward it to Blink.
997 if (web_gesture.type < blink::WebInputEvent::Type::GestureTap ||
998 web_gesture.type > blink::WebInputEvent::Type::GestureTapCancel)
999 return;
1000
1001 RenderWidgetHostViewAura* rwhva =
1002 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView());
1003 RenderWidgetHostImpl* host =
1004 RenderWidgetHostImpl::From(rwhva->GetRenderWidgetHost());
1005 host->ForwardGestureEvent(web_gesture);
1006 }
1007
991 //////////////////////////////////////////////////////////////////////////////// 1008 ////////////////////////////////////////////////////////////////////////////////
992 // WebContentsViewAura, WebContentsView implementation: 1009 // WebContentsViewAura, WebContentsView implementation:
993 1010
994 gfx::NativeView WebContentsViewAura::GetNativeView() const { 1011 gfx::NativeView WebContentsViewAura::GetNativeView() const {
995 return window_.get(); 1012 return window_.get();
996 } 1013 }
997 1014
998 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { 1015 gfx::NativeView WebContentsViewAura::GetContentNativeView() const {
999 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 1016 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
1000 return rwhv ? rwhv->GetNativeView() : NULL; 1017 return rwhv ? rwhv->GetNativeView() : NULL;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 } 1279 }
1263 1280
1264 void WebContentsViewAura::TakeFocus(bool reverse) { 1281 void WebContentsViewAura::TakeFocus(bool reverse) {
1265 if (web_contents_->GetDelegate() && 1282 if (web_contents_->GetDelegate() &&
1266 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && 1283 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) &&
1267 delegate_.get()) { 1284 delegate_.get()) {
1268 delegate_->TakeFocus(reverse); 1285 delegate_->TakeFocus(reverse);
1269 } 1286 }
1270 } 1287 }
1271 1288
1289 void WebContentsViewAura::ShowDisambiguationPopup(
1290 const gfx::Rect& target_rect,
1291 const SkBitmap& zoomed_bitmap) {
1292 if (delegate_) {
1293 delegate_->ShowDisambiguationPopup(
1294 target_rect,
1295 zoomed_bitmap,
1296 window_.get(),
1297 base::Bind(&WebContentsViewAura::ProcessLinkDisambiguationGesture,
1298 base::Unretained(this)));
sky 2014/09/11 14:53:43 Why the unretained here? How do you know the popup
luken 2014/09/17 00:00:48 Good point, I don't know one will outlive the othe
1299 }
1300 }
1301
1302 void WebContentsViewAura::HideDisambiguationPopup() {
1303 if (delegate_)
1304 delegate_->HideDisambiguationPopup();
1305 }
1306
1272 //////////////////////////////////////////////////////////////////////////////// 1307 ////////////////////////////////////////////////////////////////////////////////
1273 // WebContentsViewAura, OverscrollControllerDelegate implementation: 1308 // WebContentsViewAura, OverscrollControllerDelegate implementation:
1274 1309
1275 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { 1310 gfx::Rect WebContentsViewAura::GetVisibleBounds() const {
1276 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 1311 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
1277 if (!rwhv || !rwhv->IsShowing()) 1312 if (!rwhv || !rwhv->IsShowing())
1278 return gfx::Rect(); 1313 return gfx::Rect();
1279 1314
1280 return rwhv->GetViewBounds(); 1315 return rwhv->GetViewBounds();
1281 } 1316 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 if (visible) { 1652 if (visible) {
1618 if (!web_contents_->should_normally_be_visible()) 1653 if (!web_contents_->should_normally_be_visible())
1619 web_contents_->WasShown(); 1654 web_contents_->WasShown();
1620 } else { 1655 } else {
1621 if (web_contents_->should_normally_be_visible()) 1656 if (web_contents_->should_normally_be_visible())
1622 web_contents_->WasHidden(); 1657 web_contents_->WasHidden();
1623 } 1658 }
1624 } 1659 }
1625 1660
1626 } // namespace content 1661 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698