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

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

Issue 2135493002: Support dragging texts out of webview/Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support dragging texts out of webview/Chrome. Created 4 years, 5 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_android.h" 5 #include "content/browser/web_contents/web_contents_view_android.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/android/content_view_core_impl.h" 8 #include "content/browser/android/content_view_core_impl.h"
9 #include "content/browser/frame_host/interstitial_page_impl.h" 9 #include "content/browser/frame_host/interstitial_page_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_view_android.h" 10 #include "content/browser/renderer_host/render_widget_host_view_android.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (content_view_core_) 187 if (content_view_core_)
188 content_view_core_->HideSelectPopupMenu(); 188 content_view_core_->HideSelectPopupMenu();
189 } 189 }
190 190
191 void WebContentsViewAndroid::StartDragging( 191 void WebContentsViewAndroid::StartDragging(
192 const DropData& drop_data, 192 const DropData& drop_data,
193 blink::WebDragOperationsMask allowed_ops, 193 blink::WebDragOperationsMask allowed_ops,
194 const gfx::ImageSkia& image, 194 const gfx::ImageSkia& image,
195 const gfx::Vector2d& image_offset, 195 const gfx::Vector2d& image_offset,
196 const DragEventSourceInfo& event_info) { 196 const DragEventSourceInfo& event_info) {
197 NOTIMPLEMENTED(); 197 if (drop_data.text.is_null())
198 return;
199 base::string16 dragged_text = drop_data.text.string();
200 content_view_core_->StartDragging(dragged_text, image);
198 } 201 }
199 202
200 void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) { 203 void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) {
201 // Intentional no-op because Android does not have cursor. 204 // Intentional no-op because Android does not have cursor.
202 } 205 }
203 206
204 void WebContentsViewAndroid::OnDragEntered( 207 void WebContentsViewAndroid::OnDragEntered(
205 const std::vector<DropData::Metadata>& metadata, 208 const std::vector<DropData::Metadata>& metadata,
206 const gfx::Point& location, 209 const gfx::Point& location,
207 const gfx::Point& screen_location) { 210 const gfx::Point& screen_location) {
211 blink::WebDragOperationsMask allowed_ops =
212 static_cast<blink::WebDragOperationsMask>(blink::WebDragOperationCopy |
213 blink::WebDragOperationMove);
dcheng 2016/07/08 06:30:30 Out of curiosity, why did we change this from Copy
hush (inactive) 2016/07/08 18:23:24 The move operation is to support dragging texts wi
208 web_contents_->GetRenderViewHost()->DragTargetDragEnterWithMetaData( 214 web_contents_->GetRenderViewHost()->DragTargetDragEnterWithMetaData(
209 metadata, location, screen_location, blink::WebDragOperationCopy, 0); 215 metadata, location, screen_location, allowed_ops, 0);
210 } 216 }
211 217
212 void WebContentsViewAndroid::OnDragUpdated(const gfx::Point& location, 218 void WebContentsViewAndroid::OnDragUpdated(const gfx::Point& location,
213 const gfx::Point& screen_location) { 219 const gfx::Point& screen_location) {
220 blink::WebDragOperationsMask allowed_ops =
221 static_cast<blink::WebDragOperationsMask>(blink::WebDragOperationCopy |
222 blink::WebDragOperationMove);
214 web_contents_->GetRenderViewHost()->DragTargetDragOver( 223 web_contents_->GetRenderViewHost()->DragTargetDragOver(
215 location, screen_location, blink::WebDragOperationCopy, 0); 224 location, screen_location, allowed_ops, 0);
216 } 225 }
217 226
218 void WebContentsViewAndroid::OnDragExited() { 227 void WebContentsViewAndroid::OnDragExited() {
219 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); 228 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
220 } 229 }
221 230
222 void WebContentsViewAndroid::OnPerformDrop(DropData* drop_data, 231 void WebContentsViewAndroid::OnPerformDrop(DropData* drop_data,
223 const gfx::Point& location, 232 const gfx::Point& location,
224 const gfx::Point& screen_location) { 233 const gfx::Point& screen_location) {
225 web_contents_->GetRenderViewHost()->FilterDropData(drop_data); 234 web_contents_->GetRenderViewHost()->FilterDropData(drop_data);
226 web_contents_->GetRenderViewHost()->DragTargetDrop(*drop_data, location, 235 web_contents_->GetRenderViewHost()->DragTargetDrop(*drop_data, location,
227 screen_location, 0); 236 screen_location, 0);
228 } 237 }
229 238
239 void WebContentsViewAndroid::OnDragEnded() {
240 web_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();
241 }
242
230 void WebContentsViewAndroid::GotFocus() { 243 void WebContentsViewAndroid::GotFocus() {
231 // This is only used in the views FocusManager stuff but it bleeds through 244 // This is only used in the views FocusManager stuff but it bleeds through
232 // all subclasses. http://crbug.com/21875 245 // all subclasses. http://crbug.com/21875
233 } 246 }
234 247
235 // This is called when we the renderer asks us to take focus back (i.e., it has 248 // This is called when we the renderer asks us to take focus back (i.e., it has
236 // iterated past the last focusable element on the page). 249 // iterated past the last focusable element on the page).
237 void WebContentsViewAndroid::TakeFocus(bool reverse) { 250 void WebContentsViewAndroid::TakeFocus(bool reverse) {
238 if (web_contents_->GetDelegate() && 251 if (web_contents_->GetDelegate() &&
239 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) 252 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
240 return; 253 return;
241 web_contents_->GetRenderWidgetHostView()->Focus(); 254 web_contents_->GetRenderWidgetHostView()->Focus();
242 } 255 }
243 256
244 } // namespace content 257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698