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

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

Issue 10941042: Browser plugin: Implement loadStart and loadAbort events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed extra space 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 "content/browser/browser_plugin/browser_plugin_guest_helper.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h"
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 11 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/common/browser_plugin_messages.h" 15 #include "content/common/browser_plugin_messages.h"
15 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
16 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
19 #include "content/public/common/result_codes.h" 20 #include "content/public/common/result_codes.h"
20 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 21 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
22 #include "net/base/net_errors.h"
21 #include "ui/surface/transport_dib.h" 23 #include "ui/surface/transport_dib.h"
22 24
23 namespace content { 25 namespace content {
24 26
25 // static 27 // static
26 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; 28 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL;
27 29
28 namespace { 30 namespace {
29 const int kGuestHangTimeoutMs = 5000; 31 const int kGuestHangTimeoutMs = 5000;
30 } 32 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bool BrowserPluginGuest::ViewTakeFocus(bool reverse) { 69 bool BrowserPluginGuest::ViewTakeFocus(bool reverse) {
68 SendMessageToEmbedder( 70 SendMessageToEmbedder(
69 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); 71 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse));
70 return true; 72 return true;
71 } 73 }
72 74
73 void BrowserPluginGuest::Go(int relative_index) { 75 void BrowserPluginGuest::Go(int relative_index) {
74 web_contents()->GetController().GoToOffset(relative_index); 76 web_contents()->GetController().GoToOffset(relative_index);
75 } 77 }
76 78
79 bool BrowserPluginGuest::CanDownload(RenderViewHost* render_view_host,
80 int request_id,
81 const std::string& request_method) {
82 // TODO(fsamuel): We disable downloads in guests for now, but we will later
83 // expose API to allow embedders to handle them.
84 // Note: it seems content_shell ignores this. This should be fixed
85 // for debugging and test purposes.
86 return false;
87 }
88
77 void BrowserPluginGuest::RendererUnresponsive(WebContents* source) { 89 void BrowserPluginGuest::RendererUnresponsive(WebContents* source) {
78 base::ProcessHandle process_handle = 90 base::ProcessHandle process_handle =
79 web_contents()->GetRenderProcessHost()->GetHandle(); 91 web_contents()->GetRenderProcessHost()->GetHandle();
80 base::KillProcess(process_handle, RESULT_CODE_HUNG, false); 92 base::KillProcess(process_handle, RESULT_CODE_HUNG, false);
81 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung")); 93 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung"));
82 } 94 }
83 95
84 void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) { 96 void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) {
85 SendMessageToEmbedder( 97 SendMessageToEmbedder(
86 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); 98 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept));
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 gfx::Rect screen_pos(initial_pos); 276 gfx::Rect screen_pos(initial_pos);
265 screen_pos.Offset(guest_rect_.origin()); 277 screen_pos.Offset(guest_rect_.origin());
266 static_cast<WebContentsImpl*>(web_contents())->ShowCreatedWidget(route_id, 278 static_cast<WebContentsImpl*>(web_contents())->ShowCreatedWidget(route_id,
267 screen_pos); 279 screen_pos);
268 } 280 }
269 281
270 void BrowserPluginGuest::SetCursor(const WebCursor& cursor) { 282 void BrowserPluginGuest::SetCursor(const WebCursor& cursor) {
271 cursor_ = cursor; 283 cursor_ = cursor;
272 } 284 }
273 285
286 void BrowserPluginGuest::DidStartProvisionalLoadForFrame(
287 int64 frame_id,
288 bool is_main_frame,
289 const GURL& validated_url,
290 bool is_error_page,
291 RenderViewHost* render_view_host) {
292 // Inform the embedder of the loadStart.
293 SendMessageToEmbedder(
294 new BrowserPluginMsg_LoadStart(instance_id(),
295 validated_url,
296 is_main_frame));
297 }
298
299 void BrowserPluginGuest::DidFailProvisionalLoad(
300 int64 frame_id,
301 bool is_main_frame,
302 const GURL& validated_url,
303 int error_code,
304 const string16& error_description,
305 RenderViewHost* render_view_host) {
306 // Translate the |error_code| into an error string.
307 std::string error_type;
308 RemoveChars(net::ErrorToString(error_code), "net::", &error_type);
309 // Inform the embedder of the loadAbort.
310 SendMessageToEmbedder(
311 new BrowserPluginMsg_LoadAbort(instance_id(),
312 validated_url,
313 is_main_frame,
314 error_type));
315 }
316
274 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame( 317 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
275 int64 frame_id, 318 int64 frame_id,
276 bool is_main_frame, 319 bool is_main_frame,
277 const GURL& url, 320 const GURL& url,
278 PageTransition transition_type, 321 PageTransition transition_type,
279 RenderViewHost* render_view_host) { 322 RenderViewHost* render_view_host) {
280 // Inform its embedder of the updated URL. 323 // Inform its embedder of the updated URL.
281 if (is_main_frame) { 324 if (is_main_frame) {
282 SendMessageToEmbedder( 325 SendMessageToEmbedder(
283 new BrowserPluginMsg_DidNavigate( 326 new BrowserPluginMsg_DidNavigate(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 break; 360 break;
318 } 361 }
319 } 362 }
320 363
321 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 364 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
322 DCHECK(embedder_render_process_host()); 365 DCHECK(embedder_render_process_host());
323 embedder_render_process_host()->Send(msg); 366 embedder_render_process_host()->Send(msg);
324 } 367 }
325 368
326 } // namespace content 369 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698