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

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

Issue 1728193002: Support dragging texts into Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dead includes Created 4 years, 6 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"
11 #include "content/browser/renderer_host/render_view_host_factory.h" 11 #include "content/browser/renderer_host/render_view_host_factory.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/public/browser/render_widget_host.h" 14 #include "content/public/browser/render_widget_host.h"
15 #include "content/public/browser/web_contents_delegate.h" 15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/common/drop_data.h"
16 17
17 namespace content { 18 namespace content {
19
18 WebContentsView* CreateWebContentsView( 20 WebContentsView* CreateWebContentsView(
19 WebContentsImpl* web_contents, 21 WebContentsImpl* web_contents,
20 WebContentsViewDelegate* delegate, 22 WebContentsViewDelegate* delegate,
21 RenderViewHostDelegateView** render_view_host_delegate_view) { 23 RenderViewHostDelegateView** render_view_host_delegate_view) {
22 WebContentsViewAndroid* rv = new WebContentsViewAndroid( 24 WebContentsViewAndroid* rv = new WebContentsViewAndroid(
23 web_contents, delegate); 25 web_contents, delegate);
24 *render_view_host_delegate_view = rv; 26 *render_view_host_delegate_view = rv;
25 return rv; 27 return rv;
26 } 28 }
27 29
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 const gfx::ImageSkia& image, 194 const gfx::ImageSkia& image,
193 const gfx::Vector2d& image_offset, 195 const gfx::Vector2d& image_offset,
194 const DragEventSourceInfo& event_info) { 196 const DragEventSourceInfo& event_info) {
195 NOTIMPLEMENTED(); 197 NOTIMPLEMENTED();
196 } 198 }
197 199
198 void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) { 200 void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) {
199 NOTIMPLEMENTED(); 201 NOTIMPLEMENTED();
200 } 202 }
201 203
204 void WebContentsViewAndroid::OnDragEntered(
205 const std::vector<DropData::Metadata>& metadata,
206 std::vector<int> locations) {
207 const gfx::Point location(locations[0], locations[1]);
208 const gfx::Point screen_location(locations[2], locations[3]);
209
210 web_contents_->GetRenderViewHost()->DragTargetDragEnterWithMetaData(
211 metadata, location, screen_location, blink::WebDragOperationCopy, 0);
212 }
213 void WebContentsViewAndroid::OnDragUpdated(std::vector<int> locations) {
214 const gfx::Point location(locations[0], locations[1]);
215 const gfx::Point screen_location(locations[2], locations[3]);
216
217 web_contents_->GetRenderViewHost()->DragTargetDragOver(
218 location, screen_location, blink::WebDragOperationCopy, 0);
219 }
220
221 void WebContentsViewAndroid::OnDragExited() {
222 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
223 }
224
225 void WebContentsViewAndroid::OnPerformDrop(DropData& drop_data,
226 std::vector<int> locations) {
227 const gfx::Point location(locations[0], locations[1]);
228 const gfx::Point screen_location(locations[2], locations[3]);
229
230 web_contents_->GetRenderViewHost()->FilterDropData(&drop_data);
231 web_contents_->GetRenderViewHost()->DragTargetDrop(drop_data, location,
232 screen_location, 0);
233 }
234
202 void WebContentsViewAndroid::GotFocus() { 235 void WebContentsViewAndroid::GotFocus() {
203 // This is only used in the views FocusManager stuff but it bleeds through 236 // This is only used in the views FocusManager stuff but it bleeds through
204 // all subclasses. http://crbug.com/21875 237 // all subclasses. http://crbug.com/21875
205 } 238 }
206 239
207 // This is called when we the renderer asks us to take focus back (i.e., it has 240 // This is called when we the renderer asks us to take focus back (i.e., it has
208 // iterated past the last focusable element on the page). 241 // iterated past the last focusable element on the page).
209 void WebContentsViewAndroid::TakeFocus(bool reverse) { 242 void WebContentsViewAndroid::TakeFocus(bool reverse) {
210 if (web_contents_->GetDelegate() && 243 if (web_contents_->GetDelegate() &&
211 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) 244 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
212 return; 245 return;
213 web_contents_->GetRenderWidgetHostView()->Focus(); 246 web_contents_->GetRenderWidgetHostView()->Focus();
214 } 247 }
215 248
216 } // namespace content 249 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698