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/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 Loading... |
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 CHECK(embedder_render_view_host_); |
| 176 RenderViewHostDelegateView* view = |
| 177 embedder_render_view_host_->GetDelegate()->GetDelegateView(); |
| 178 if (view) |
| 179 view->UpdateDragCursor(operation); |
| 180 } |
| 181 |
147 WebContents* BrowserPluginGuest::GetWebContents() { | 182 WebContents* BrowserPluginGuest::GetWebContents() { |
148 return web_contents(); | 183 return web_contents(); |
149 } | 184 } |
150 | 185 |
151 void BrowserPluginGuest::Terminate() { | 186 void BrowserPluginGuest::Terminate() { |
152 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate")); | 187 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate")); |
153 base::ProcessHandle process_handle = | 188 base::ProcessHandle process_handle = |
154 web_contents()->GetRenderProcessHost()->GetHandle(); | 189 web_contents()->GetRenderProcessHost()->GetHandle(); |
155 base::KillProcess(process_handle, RESULT_CODE_KILLED, false); | 190 base::KillProcess(process_handle, RESULT_CODE_KILLED, false); |
156 } | 191 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 break; | 460 break; |
426 } | 461 } |
427 } | 462 } |
428 | 463 |
429 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 464 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
430 DCHECK(embedder_render_process_host()); | 465 DCHECK(embedder_render_process_host()); |
431 embedder_render_process_host()->Send(msg); | 466 embedder_render_process_host()->Send(msg); |
432 } | 467 } |
433 | 468 |
434 } // namespace content | 469 } // namespace content |
OLD | NEW |