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

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

Issue 12321005: Enable touch based selection and editing for webpages behind a flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 8 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 | Annotate | Revision Log
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/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/renderer_host/dip_util.h" 10 #include "content/browser/renderer_host/dip_util.h"
11 #include "content/browser/renderer_host/overscroll_controller.h" 11 #include "content/browser/renderer_host/overscroll_controller.h"
12 #include "content/browser/renderer_host/render_view_host_factory.h" 12 #include "content/browser/renderer_host/render_view_host_factory.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 14 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 15 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
16 #include "content/browser/web_contents/interstitial_page_impl.h" 16 #include "content/browser/web_contents/interstitial_page_impl.h"
17 #include "content/browser/web_contents/navigation_entry_impl.h" 17 #include "content/browser/web_contents/navigation_entry_impl.h"
18 #include "content/browser/web_contents/touch_editable_impl_aura.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
22 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
23 #include "content/public/browser/overscroll_configuration.h" 24 #include "content/public/browser/overscroll_configuration.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/render_widget_host.h" 26 #include "content/public/browser/render_widget_host.h"
26 #include "content/public/browser/render_widget_host_view.h" 27 #include "content/public/browser/render_widget_host_view.h"
27 #include "content/public/browser/web_contents_delegate.h" 28 #include "content/public/browser/web_contents_delegate.h"
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 WebContentsImpl* web_contents, 870 WebContentsImpl* web_contents,
870 WebContentsViewDelegate* delegate) 871 WebContentsViewDelegate* delegate)
871 : web_contents_(web_contents), 872 : web_contents_(web_contents),
872 delegate_(delegate), 873 delegate_(delegate),
873 current_drag_op_(WebKit::WebDragOperationNone), 874 current_drag_op_(WebKit::WebDragOperationNone),
874 drag_dest_delegate_(NULL), 875 drag_dest_delegate_(NULL),
875 current_rvh_for_drag_(NULL), 876 current_rvh_for_drag_(NULL),
876 content_container_(NULL), 877 content_container_(NULL),
877 overscroll_change_brightness_(false), 878 overscroll_change_brightness_(false),
878 current_overscroll_gesture_(OVERSCROLL_NONE), 879 current_overscroll_gesture_(OVERSCROLL_NONE),
879 completed_overscroll_gesture_(OVERSCROLL_NONE) { 880 completed_overscroll_gesture_(OVERSCROLL_NONE),
881 touch_editable_(TouchEditableImplAura::Create()) {
880 } 882 }
881 883
882 //////////////////////////////////////////////////////////////////////////////// 884 ////////////////////////////////////////////////////////////////////////////////
883 // WebContentsViewAura, private: 885 // WebContentsViewAura, private:
884 886
885 WebContentsViewAura::~WebContentsViewAura() { 887 WebContentsViewAura::~WebContentsViewAura() {
886 if (!window_) 888 if (!window_)
887 return; 889 return;
888 890
889 window_observer_.reset(); 891 window_observer_.reset();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 ratio = 1.f - ratio; 1109 ratio = 1.f - ratio;
1108 float brightness = current_overscroll_gesture_ == OVERSCROLL_WEST ? 1110 float brightness = current_overscroll_gesture_ == OVERSCROLL_WEST ?
1109 kBrightnessMin + ratio * (kBrightnessMax - kBrightnessMin) : 1111 kBrightnessMin + ratio * (kBrightnessMax - kBrightnessMin) :
1110 kBrightnessMax - ratio * (kBrightnessMax - kBrightnessMin); 1112 kBrightnessMax - ratio * (kBrightnessMax - kBrightnessMin);
1111 brightness = std::max(kBrightnessMin, brightness); 1113 brightness = std::max(kBrightnessMin, brightness);
1112 brightness = std::min(kBrightnessMax, brightness); 1114 brightness = std::min(kBrightnessMax, brightness);
1113 aura::Window* window = GetWindowToAnimateForOverscroll(); 1115 aura::Window* window = GetWindowToAnimateForOverscroll();
1114 window->layer()->SetLayerBrightness(brightness); 1116 window->layer()->SetLayerBrightness(brightness);
1115 } 1117 }
1116 1118
1119 void WebContentsViewAura::AttachTouchEditableToRenderView() {
1120 if (!touch_editable_)
1121 return;
1122 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
1123 web_contents_->GetRenderWidgetHostView());
1124 touch_editable_->AttachToView(rwhva);
1125 }
1126
1117 //////////////////////////////////////////////////////////////////////////////// 1127 ////////////////////////////////////////////////////////////////////////////////
1118 // WebContentsViewAura, WebContentsView implementation: 1128 // WebContentsViewAura, WebContentsView implementation:
1119 1129
1120 gfx::NativeView WebContentsViewAura::GetNativeView() const { 1130 gfx::NativeView WebContentsViewAura::GetNativeView() const {
1121 return window_.get(); 1131 return window_.get();
1122 } 1132 }
1123 1133
1124 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { 1134 gfx::NativeView WebContentsViewAura::GetContentNativeView() const {
1125 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 1135 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
1126 return rwhv ? rwhv->GetNativeView() : NULL; 1136 return rwhv ? rwhv->GetNativeView() : NULL;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 1277
1268 RenderWidgetHostImpl* host_impl = 1278 RenderWidgetHostImpl* host_impl =
1269 RenderWidgetHostImpl::From(render_widget_host); 1279 RenderWidgetHostImpl::From(render_widget_host);
1270 if (host_impl->overscroll_controller() && web_contents_->GetDelegate() && 1280 if (host_impl->overscroll_controller() && web_contents_->GetDelegate() &&
1271 web_contents_->GetDelegate()->CanOverscrollContent()) { 1281 web_contents_->GetDelegate()->CanOverscrollContent()) {
1272 host_impl->overscroll_controller()->set_delegate(this); 1282 host_impl->overscroll_controller()->set_delegate(this);
1273 if (!navigation_overlay_.get()) 1283 if (!navigation_overlay_.get())
1274 navigation_overlay_.reset(new OverscrollNavigationOverlay()); 1284 navigation_overlay_.reset(new OverscrollNavigationOverlay());
1275 } 1285 }
1276 1286
1287 AttachTouchEditableToRenderView();
1277 return view; 1288 return view;
1278 } 1289 }
1279 1290
1280 RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget( 1291 RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget(
1281 RenderWidgetHost* render_widget_host) { 1292 RenderWidgetHost* render_widget_host) {
1282 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); 1293 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
1283 } 1294 }
1284 1295
1285 void WebContentsViewAura::SetPageTitle(const string16& title) { 1296 void WebContentsViewAura::SetPageTitle(const string16& title) {
1286 window_->set_title(title); 1297 window_->set_title(title);
1287 } 1298 }
1288 1299
1289 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { 1300 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) {
1290 } 1301 }
1291 1302
1292 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { 1303 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) {
1293 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { 1304 if (navigation_overlay_.get() && navigation_overlay_->has_window()) {
1294 navigation_overlay_->StartObservingView(static_cast< 1305 navigation_overlay_->StartObservingView(static_cast<
1295 RenderWidgetHostViewAura*>(host->GetView())); 1306 RenderWidgetHostViewAura*>(host->GetView()));
1296 } 1307 }
1308 AttachTouchEditableToRenderView();
1297 } 1309 }
1298 1310
1299 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { 1311 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) {
1300 RenderViewHostImpl* host = static_cast<RenderViewHostImpl*>( 1312 RenderViewHostImpl* host = static_cast<RenderViewHostImpl*>(
1301 web_contents_->GetRenderViewHost()); 1313 web_contents_->GetRenderViewHost());
1302 if (host) { 1314 if (host) {
1303 host->SetOverscrollControllerEnabled(enabled); 1315 host->SetOverscrollControllerEnabled(enabled);
1304 if (enabled) 1316 if (enabled)
1305 host->overscroll_controller()->set_delegate(this); 1317 host->overscroll_controller()->set_delegate(this);
1306 } 1318 }
1307 } 1319 }
1308 1320
1309 //////////////////////////////////////////////////////////////////////////////// 1321 ////////////////////////////////////////////////////////////////////////////////
1310 // WebContentsViewAura, RenderViewHostDelegateView implementation: 1322 // WebContentsViewAura, RenderViewHostDelegateView implementation:
1311 1323
1312 void WebContentsViewAura::ShowContextMenu( 1324 void WebContentsViewAura::ShowContextMenu(
1313 const ContextMenuParams& params, 1325 const ContextMenuParams& params,
1314 ContextMenuSourceType type) { 1326 ContextMenuSourceType type) {
1315 if (delegate_.get()) 1327 if (delegate_.get())
1316 delegate_->ShowContextMenu(params, type); 1328 delegate_->ShowContextMenu(params, type);
1329 if (touch_editable_)
1330 touch_editable_->EndTouchEditing();
1331
1317 } 1332 }
1318 1333
1319 void WebContentsViewAura::ShowPopupMenu(const gfx::Rect& bounds, 1334 void WebContentsViewAura::ShowPopupMenu(const gfx::Rect& bounds,
1320 int item_height, 1335 int item_height,
1321 double item_font_size, 1336 double item_font_size,
1322 int selected_item, 1337 int selected_item,
1323 const std::vector<WebMenuItem>& items, 1338 const std::vector<WebMenuItem>& items,
1324 bool right_aligned, 1339 bool right_aligned,
1325 bool allow_multiple_selection) { 1340 bool allow_multiple_selection) {
1326 // External popup menus are only used on Mac and Android. 1341 // External popup menus are only used on Mac and Android.
1327 NOTIMPLEMENTED(); 1342 NOTIMPLEMENTED();
1328 } 1343 }
1329 1344
1330 void WebContentsViewAura::StartDragging( 1345 void WebContentsViewAura::StartDragging(
1331 const WebDropData& drop_data, 1346 const WebDropData& drop_data,
1332 WebKit::WebDragOperationsMask operations, 1347 WebKit::WebDragOperationsMask operations,
1333 const gfx::ImageSkia& image, 1348 const gfx::ImageSkia& image,
1334 const gfx::Vector2d& image_offset, 1349 const gfx::Vector2d& image_offset,
1335 const DragEventSourceInfo& event_info) { 1350 const DragEventSourceInfo& event_info) {
1336 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 1351 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
1337 if (!aura::client::GetDragDropClient(root_window)) { 1352 if (!aura::client::GetDragDropClient(root_window)) {
1338 web_contents_->SystemDragEnded(); 1353 web_contents_->SystemDragEnded();
1339 return; 1354 return;
1340 } 1355 }
1341 1356
1357 if (touch_editable_)
1358 touch_editable_->EndTouchEditing();
1359
1342 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider(); 1360 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider();
1343 PrepareDragData(drop_data, provider); 1361 PrepareDragData(drop_data, provider);
1344 1362
1345 ui::OSExchangeData data(provider); // takes ownership of |provider|. 1363 ui::OSExchangeData data(provider); // takes ownership of |provider|.
1346 1364
1347 if (!image.isNull()) { 1365 if (!image.isNull()) {
1348 drag_utils::SetDragImageOnDataObject(image, 1366 drag_utils::SetDragImageOnDataObject(image,
1349 gfx::Size(image.width(), image.height()), image_offset, &data); 1367 gfx::Size(image.width(), image.height()), image_offset, &data);
1350 } 1368 }
1351 1369
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 event.location(), 1680 event.location(),
1663 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), 1681 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
1664 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 1682 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
1665 if (drag_dest_delegate_) 1683 if (drag_dest_delegate_)
1666 drag_dest_delegate_->OnDrop(); 1684 drag_dest_delegate_->OnDrop();
1667 current_drop_data_.reset(); 1685 current_drop_data_.reset();
1668 return current_drag_op_; 1686 return current_drag_op_;
1669 } 1687 }
1670 1688
1671 } // namespace content 1689 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698