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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 11088043: browser-plugin: Allow accepting drag-n-drop events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 8 years, 2 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/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h"
11 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 11 #include "content/browser/browser_plugin/browser_plugin_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/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/common/browser_plugin_messages.h" 15 #include "content/common/browser_plugin_messages.h"
16 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
17 #include "content/port/browser/render_view_host_delegate_view.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/resource_request_details.h" 22 #include "content/public/browser/resource_request_details.h"
22 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
23 #include "content/public/common/result_codes.h" 24 #include "content/public/common/result_codes.h"
24 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 25 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
25 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
26 #include "ui/surface/transport_dib.h" 28 #include "ui/surface/transport_dib.h"
29 #include "webkit/glue/webdropdata.h"
27 #include "webkit/glue/resource_type.h" 30 #include "webkit/glue/resource_type.h"
28 31
29 namespace content { 32 namespace content {
30 33
31 // static 34 // static
32 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; 35 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL;
33 36
34 namespace { 37 namespace {
35 const int kGuestHangTimeoutMs = 5000; 38 const int kGuestHangTimeoutMs = 5000;
36 } 39 }
37 40
38 BrowserPluginGuest::BrowserPluginGuest(int instance_id, 41 BrowserPluginGuest::BrowserPluginGuest(int instance_id,
39 WebContentsImpl* web_contents, 42 WebContentsImpl* web_contents,
40 RenderViewHost* render_view_host) 43 RenderViewHost* render_view_host)
41 : WebContentsObserver(web_contents), 44 : WebContentsObserver(web_contents),
42 embedder_render_process_host_(NULL), 45 embedder_render_process_host_(NULL),
46 embedder_render_view_host_(NULL),
43 instance_id_(instance_id), 47 instance_id_(instance_id),
44 #if defined(OS_WIN) 48 #if defined(OS_WIN)
45 damage_buffer_size_(0), 49 damage_buffer_size_(0),
46 #endif 50 #endif
47 damage_buffer_scale_factor_(1.0f), 51 damage_buffer_scale_factor_(1.0f),
48 pending_update_counter_(0), 52 pending_update_counter_(0),
49 guest_hang_timeout_( 53 guest_hang_timeout_(
50 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)), 54 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)),
51 visible_(true) { 55 visible_(true) {
52 DCHECK(web_contents); 56 DCHECK(web_contents);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 141 }
138 142
139 void BrowserPluginGuest::SetVisibility(bool embedder_visible, bool visible) { 143 void BrowserPluginGuest::SetVisibility(bool embedder_visible, bool visible) {
140 visible_ = visible; 144 visible_ = visible;
141 if (embedder_visible && visible) 145 if (embedder_visible && visible)
142 web_contents()->WasShown(); 146 web_contents()->WasShown();
143 else 147 else
144 web_contents()->WasHidden(); 148 web_contents()->WasHidden();
145 } 149 }
146 150
151 void BrowserPluginGuest::DragStatusUpdate(WebKit::WebDragStatus drag_status,
152 const WebDropData& drop_data,
153 WebKit::WebDragOperationsMask mask,
154 const gfx::Point& location) {
155 RenderViewHost* host = web_contents()->GetRenderViewHost();
156 switch (drag_status) {
157 case WebKit::WebDragStatusEnter:
158 host->DragTargetDragEnter(drop_data, location, location, mask, 0);
159 break;
160 case WebKit::WebDragStatusOver:
161 host->DragTargetDragOver(location, location, mask, 0);
162 break;
163 case WebKit::WebDragStatusLeave:
164 host->DragTargetDragLeave();
165 break;
166 case WebKit::WebDragStatusDrop:
167 host->DragTargetDrop(location, location, 0);
168 break;
169 case WebKit::WebDragStatusUnknown:
170 NOTREACHED();
171 }
172 }
173
174 void BrowserPluginGuest::UpdateDragCursor(WebKit::WebDragOperation operation) {
175 if (embedder_render_view_host_) {
Charlie Reis 2012/10/11 18:02:52 I thought it wasn't possible for this to be invali
sadrul 2012/10/11 18:31:18 Sounds good. Done.
176 RenderViewHostDelegateView* view =
177 embedder_render_view_host_->GetDelegate()->GetDelegateView();
178 if (view)
179 view->UpdateDragCursor(operation);
180 }
181 }
182
147 WebContents* BrowserPluginGuest::GetWebContents() { 183 WebContents* BrowserPluginGuest::GetWebContents() {
148 return web_contents(); 184 return web_contents();
149 } 185 }
150 186
151 void BrowserPluginGuest::Terminate() { 187 void BrowserPluginGuest::Terminate() {
152 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate")); 188 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate"));
153 base::ProcessHandle process_handle = 189 base::ProcessHandle process_handle =
154 web_contents()->GetRenderProcessHost()->GetHandle(); 190 web_contents()->GetRenderProcessHost()->GetHandle();
155 base::KillProcess(process_handle, RESULT_CODE_KILLED, false); 191 base::KillProcess(process_handle, RESULT_CODE_KILLED, false);
156 } 192 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 break; 458 break;
423 } 459 }
424 } 460 }
425 461
426 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 462 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
427 DCHECK(embedder_render_process_host()); 463 DCHECK(embedder_render_process_host());
428 embedder_render_process_host()->Send(msg); 464 embedder_render_process_host()->Send(msg);
429 } 465 }
430 466
431 } // namespace content 467 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698