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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; | 35 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; |
36 | 36 |
37 namespace { | 37 namespace { |
38 const int kGuestHangTimeoutMs = 5000; | 38 const int kGuestHangTimeoutMs = 5000; |
39 } | 39 } |
40 | 40 |
41 BrowserPluginGuest::BrowserPluginGuest(int instance_id, | 41 BrowserPluginGuest::BrowserPluginGuest(int instance_id, |
42 WebContentsImpl* web_contents, | 42 WebContentsImpl* web_contents, |
43 RenderViewHost* render_view_host) | 43 RenderViewHost* render_view_host) |
44 : WebContentsObserver(web_contents), | 44 : WebContentsObserver(web_contents), |
45 embedder_render_process_host_(NULL), | 45 embedder_web_contents_(NULL), |
46 embedder_render_view_host_(NULL), | |
47 instance_id_(instance_id), | 46 instance_id_(instance_id), |
48 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
49 damage_buffer_size_(0), | 48 damage_buffer_size_(0), |
50 #endif | 49 #endif |
51 damage_buffer_scale_factor_(1.0f), | 50 damage_buffer_scale_factor_(1.0f), |
52 pending_update_counter_(0), | 51 pending_update_counter_(0), |
53 guest_hang_timeout_( | 52 guest_hang_timeout_( |
54 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)), | 53 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)), |
55 visible_(true) { | 54 visible_(true) { |
56 DCHECK(web_contents); | 55 DCHECK(web_contents); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return true; | 127 return true; |
129 } | 128 } |
130 | 129 |
131 void BrowserPluginGuest::RendererUnresponsive(WebContents* source) { | 130 void BrowserPluginGuest::RendererUnresponsive(WebContents* source) { |
132 base::ProcessHandle process_handle = | 131 base::ProcessHandle process_handle = |
133 web_contents()->GetRenderProcessHost()->GetHandle(); | 132 web_contents()->GetRenderProcessHost()->GetHandle(); |
134 base::KillProcess(process_handle, RESULT_CODE_HUNG, false); | 133 base::KillProcess(process_handle, RESULT_CODE_HUNG, false); |
135 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung")); | 134 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung")); |
136 } | 135 } |
137 | 136 |
| 137 void BrowserPluginGuest::RunFileChooser(WebContents* web_contents, |
| 138 const FileChooserParams& params) { |
| 139 embedder_web_contents_->GetDelegate()->RunFileChooser(web_contents, params); |
| 140 } |
| 141 |
138 void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) { | 142 void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) { |
139 SendMessageToEmbedder( | 143 SendMessageToEmbedder( |
140 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); | 144 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); |
141 } | 145 } |
142 | 146 |
143 void BrowserPluginGuest::SetVisibility(bool embedder_visible, bool visible) { | 147 void BrowserPluginGuest::SetVisibility(bool embedder_visible, bool visible) { |
144 visible_ = visible; | 148 visible_ = visible; |
145 if (embedder_visible && visible) | 149 if (embedder_visible && visible) |
146 web_contents()->WasShown(); | 150 web_contents()->WasShown(); |
147 else | 151 else |
(...skipping 17 matching lines...) Expand all Loading... |
165 break; | 169 break; |
166 case WebKit::WebDragStatusDrop: | 170 case WebKit::WebDragStatusDrop: |
167 host->DragTargetDrop(location, location, 0); | 171 host->DragTargetDrop(location, location, 0); |
168 break; | 172 break; |
169 case WebKit::WebDragStatusUnknown: | 173 case WebKit::WebDragStatusUnknown: |
170 NOTREACHED(); | 174 NOTREACHED(); |
171 } | 175 } |
172 } | 176 } |
173 | 177 |
174 void BrowserPluginGuest::UpdateDragCursor(WebKit::WebDragOperation operation) { | 178 void BrowserPluginGuest::UpdateDragCursor(WebKit::WebDragOperation operation) { |
175 CHECK(embedder_render_view_host_); | 179 RenderViewHostImpl* embedder_render_view_host = |
| 180 static_cast<RenderViewHostImpl*>( |
| 181 embedder_web_contents_->GetRenderViewHost()); |
| 182 CHECK(embedder_render_view_host); |
176 RenderViewHostDelegateView* view = | 183 RenderViewHostDelegateView* view = |
177 embedder_render_view_host_->GetDelegate()->GetDelegateView(); | 184 embedder_render_view_host->GetDelegate()->GetDelegateView(); |
178 if (view) | 185 if (view) |
179 view->UpdateDragCursor(operation); | 186 view->UpdateDragCursor(operation); |
180 } | 187 } |
181 | 188 |
182 WebContents* BrowserPluginGuest::GetWebContents() { | 189 WebContents* BrowserPluginGuest::GetWebContents() { |
183 return web_contents(); | 190 return web_contents(); |
184 } | 191 } |
185 | 192 |
186 void BrowserPluginGuest::Terminate() { | 193 void BrowserPluginGuest::Terminate() { |
187 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate")); | 194 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate")); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 break; | 463 break; |
457 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 464 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
458 RecordAction(UserMetricsAction("BrowserPlugin.Guest.AbnormalDeath")); | 465 RecordAction(UserMetricsAction("BrowserPlugin.Guest.AbnormalDeath")); |
459 break; | 466 break; |
460 default: | 467 default: |
461 break; | 468 break; |
462 } | 469 } |
463 } | 470 } |
464 | 471 |
465 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 472 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
466 DCHECK(embedder_render_process_host()); | 473 embedder_web_contents_->GetRenderProcessHost()->Send(msg); |
467 embedder_render_process_host()->Send(msg); | |
468 } | 474 } |
469 | 475 |
470 } // namespace content | 476 } // namespace content |
OLD | NEW |