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

Side by Side Diff: ui/views/controls/webview/webview.cc

Issue 11444013: Get drag and drop working for win aura. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move DropTargetWin to DesktopDragDropClientWin Created 8 years 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 "ui/views/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/navigation_controller.h" 8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_details.h" 9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
11 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
12 #include "content/public/browser/notification_types.h" 12 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/render_widget_host_view.h" 14 #include "content/public/browser/render_widget_host_view.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_view.h"
16 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
17 #include "ui/base/accessibility/accessibility_types.h" 18 #include "ui/base/accessibility/accessibility_types.h"
18 #include "ui/base/accessibility/accessible_view_state.h" 19 #include "ui/base/accessibility/accessible_view_state.h"
19 #include "ui/base/events/event.h" 20 #include "ui/base/events/event.h"
20 #include "ui/views/controls/native/native_view_host.h" 21 #include "ui/views/controls/native/native_view_host.h"
21 #include "ui/views/focus/focus_manager.h" 22 #include "ui/views/focus/focus_manager.h"
22 #include "ui/views/views_delegate.h" 23 #include "ui/views/views_delegate.h"
23 24
25 #if defined(USE_AURA)
26 #include "ui/aura/client/drag_drop_client.h"
27 #include "ui/aura/client/drag_drop_delegate.h"
28 #endif
29
24 namespace views { 30 namespace views {
25 31
26 // static 32 // static
27 const char WebView::kViewClassName[] = 33 const char WebView::kViewClassName[] =
28 "ui/views/WebView"; 34 "ui/views/WebView";
29 35
30 //////////////////////////////////////////////////////////////////////////////// 36 ////////////////////////////////////////////////////////////////////////////////
31 // WebView, public: 37 // WebView, public:
32 38
33 WebView::WebView(content::BrowserContext* browser_context) 39 WebView::WebView(content::BrowserContext* browser_context)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return View::GetNativeViewAccessible(); 149 return View::GetNativeViewAccessible();
144 } 150 }
145 151
146 gfx::Size WebView::GetPreferredSize() { 152 gfx::Size WebView::GetPreferredSize() {
147 if (preferred_size_ == gfx::Size()) 153 if (preferred_size_ == gfx::Size())
148 return View::GetPreferredSize(); 154 return View::GetPreferredSize();
149 else 155 else
150 return preferred_size_; 156 return preferred_size_;
151 } 157 }
152 158
159 #if defined(USE_AURA)
160 bool WebView::CanDrop(const ui::OSExchangeData& data) {
161 return true;
162 }
163
164 void WebView::OnDragEntered(const ui::DropTargetEvent& event) {
165 aura::Window* window = web_contents_->GetView()->GetContentNativeView();
166 aura::client::DragDropDelegate* dnd_delegate =
167 aura::client::GetDragDropDelegate(window);
168 if (dnd_delegate)
169 dnd_delegate->OnDragEntered(event);
170 }
171
172 int WebView::OnDragUpdated(const ui::DropTargetEvent& event) {
173 aura::Window* window = web_contents_->GetView()->GetContentNativeView();
174 aura::client::DragDropDelegate* dnd_delegate =
175 aura::client::GetDragDropDelegate(window);
176 if (dnd_delegate)
177 return dnd_delegate->OnDragUpdated(event);
178 return ui::DragDropTypes::DRAG_NONE;
179 }
180
181 void WebView::OnDragExited() {
182 aura::Window* window = web_contents_->GetView()->GetContentNativeView();
183 aura::client::DragDropDelegate* dnd_delegate =
184 aura::client::GetDragDropDelegate(window);
185 if (dnd_delegate)
186 dnd_delegate->OnDragExited();
187 }
188
189 int WebView::OnPerformDrop(const ui::DropTargetEvent& event) {
190 aura::Window* window = web_contents_->GetView()->GetContentNativeView();
191 aura::client::DragDropDelegate* dnd_delegate =
192 aura::client::GetDragDropDelegate(window);
193 if (dnd_delegate)
194 return dnd_delegate->OnPerformDrop(event);
195 return ui::DragDropTypes::DRAG_NONE;
196 }
197
198 #endif
199
153 //////////////////////////////////////////////////////////////////////////////// 200 ////////////////////////////////////////////////////////////////////////////////
154 // WebView, content::NotificationObserver implementation: 201 // WebView, content::NotificationObserver implementation:
155 202
156 void WebView::Observe(int type, 203 void WebView::Observe(int type,
157 const content::NotificationSource& source, 204 const content::NotificationSource& source,
158 const content::NotificationDetails& details) { 205 const content::NotificationDetails& details) {
159 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { 206 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
160 std::pair<content::RenderViewHost*, content::RenderViewHost*>* 207 std::pair<content::RenderViewHost*, content::RenderViewHost*>*
161 switched_details = 208 switched_details =
162 content::Details<std::pair<content::RenderViewHost*, 209 content::Details<std::pair<content::RenderViewHost*,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return content::WebContents::Create(browser_context, 301 return content::WebContents::Create(browser_context,
255 site_instance, 302 site_instance,
256 MSG_ROUTING_NONE, 303 MSG_ROUTING_NONE,
257 NULL); 304 NULL);
258 } 305 }
259 306
260 return contents; 307 return contents;
261 } 308 }
262 309
263 } // namespace views 310 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698