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_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 "base/pickle.h" |
| 9 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/android/content_view_core_impl.h" | 10 #include "content/browser/android/content_view_core_impl.h" |
9 #include "content/browser/frame_host/interstitial_page_impl.h" | 11 #include "content/browser/frame_host/interstitial_page_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 12 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
11 #include "content/browser/renderer_host/render_view_host_factory.h" | 13 #include "content/browser/renderer_host/render_view_host_factory.h" |
12 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
13 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
14 #include "content/public/browser/render_widget_host.h" | 16 #include "content/public/browser/render_widget_host.h" |
15 #include "content/public/browser/web_contents_delegate.h" | 17 #include "content/public/browser/web_contents_delegate.h" |
| 18 #include "content/public/common/drop_data.h" |
| 19 #include "ui/base/dragdrop/drag_drop_types.h" |
| 20 #include "ui/base/dragdrop/drop_target_event.h" |
| 21 #include "ui/base/dragdrop/os_exchange_data.h" |
16 | 22 |
17 namespace content { | 23 namespace content { |
| 24 |
| 25 namespace { |
| 26 |
| 27 void PrepareDropData(DropData* drop_data, const ui::OSExchangeData& data) { |
| 28 // TODO(hush): support dragging files here. |
| 29 drop_data->did_originate_from_renderer = data.DidOriginateFromRenderer(); |
| 30 |
| 31 base::string16 plain_text; |
| 32 bool has_string = data.GetString(&plain_text); |
| 33 if (has_string) |
| 34 drop_data->text = base::NullableString16(plain_text, false); |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
18 WebContentsView* CreateWebContentsView( | 39 WebContentsView* CreateWebContentsView( |
19 WebContentsImpl* web_contents, | 40 WebContentsImpl* web_contents, |
20 WebContentsViewDelegate* delegate, | 41 WebContentsViewDelegate* delegate, |
21 RenderViewHostDelegateView** render_view_host_delegate_view) { | 42 RenderViewHostDelegateView** render_view_host_delegate_view) { |
22 WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 43 WebContentsViewAndroid* rv = new WebContentsViewAndroid( |
23 web_contents, delegate); | 44 web_contents, delegate); |
24 *render_view_host_delegate_view = rv; | 45 *render_view_host_delegate_view = rv; |
25 return rv; | 46 return rv; |
26 } | 47 } |
27 | 48 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 const gfx::ImageSkia& image, | 213 const gfx::ImageSkia& image, |
193 const gfx::Vector2d& image_offset, | 214 const gfx::Vector2d& image_offset, |
194 const DragEventSourceInfo& event_info) { | 215 const DragEventSourceInfo& event_info) { |
195 NOTIMPLEMENTED(); | 216 NOTIMPLEMENTED(); |
196 } | 217 } |
197 | 218 |
198 void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) { | 219 void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) { |
199 NOTIMPLEMENTED(); | 220 NOTIMPLEMENTED(); |
200 } | 221 } |
201 | 222 |
| 223 void WebContentsViewAndroid::OnDragEntered(const ui::DropTargetEvent& event) { |
| 224 current_drop_data_.reset(new DropData()); |
| 225 PrepareDropData(current_drop_data_.get(), event.data()); |
| 226 |
| 227 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
| 228 *current_drop_data_.get(), event.location(), event.root_location(), |
| 229 blink::WebDragOperationCopy, 0); |
| 230 } |
| 231 |
| 232 void WebContentsViewAndroid::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 233 if (!current_drop_data_) |
| 234 return; |
| 235 |
| 236 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
| 237 event.location(), event.root_location(), blink::WebDragOperationCopy, 0); |
| 238 } |
| 239 |
| 240 void WebContentsViewAndroid::OnDragExited() { |
| 241 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); |
| 242 current_drop_data_.reset(); |
| 243 } |
| 244 |
| 245 void WebContentsViewAndroid::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 246 current_drop_data_.reset(new DropData()); |
| 247 PrepareDropData(current_drop_data_.get(), event.data()); |
| 248 |
| 249 web_contents_->GetRenderViewHost()->DragTargetDropWithData( |
| 250 *current_drop_data_.get(), event.location(), event.root_location(), 0); |
| 251 } |
| 252 |
202 void WebContentsViewAndroid::GotFocus() { | 253 void WebContentsViewAndroid::GotFocus() { |
203 // This is only used in the views FocusManager stuff but it bleeds through | 254 // This is only used in the views FocusManager stuff but it bleeds through |
204 // all subclasses. http://crbug.com/21875 | 255 // all subclasses. http://crbug.com/21875 |
205 } | 256 } |
206 | 257 |
207 // This is called when we the renderer asks us to take focus back (i.e., it has | 258 // 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). | 259 // iterated past the last focusable element on the page). |
209 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 260 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
210 if (web_contents_->GetDelegate() && | 261 if (web_contents_->GetDelegate() && |
211 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 262 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) |
212 return; | 263 return; |
213 web_contents_->GetRenderWidgetHostView()->Focus(); | 264 web_contents_->GetRenderWidgetHostView()->Focus(); |
214 } | 265 } |
215 | 266 |
216 } // namespace content | 267 } // namespace content |
OLD | NEW |