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

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

Issue 11361052: Browser Plugin: Implement autosize (Embedder-side code) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_embedder.h" 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
(...skipping 21 matching lines...) Expand all
32 32
33 namespace content { 33 namespace content {
34 34
35 // static 35 // static
36 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; 36 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL;
37 37
38 namespace { 38 namespace {
39 const int kGuestHangTimeoutMs = 5000; 39 const int kGuestHangTimeoutMs = 5000;
40 } 40 }
41 41
42 BrowserPluginGuest::BrowserPluginGuest(int instance_id, 42 BrowserPluginGuest::BrowserPluginGuest(
43 WebContentsImpl* web_contents, 43 int instance_id,
44 RenderViewHost* render_view_host, 44 WebContentsImpl* web_contents,
45 bool focused, 45 RenderViewHost* render_view_host,
46 bool visible) 46 const BrowserPluginHostMsg_CreateGuest_Params& params)
47 : WebContentsObserver(web_contents), 47 : WebContentsObserver(web_contents),
48 embedder_web_contents_(NULL), 48 embedder_web_contents_(NULL),
49 instance_id_(instance_id), 49 instance_id_(instance_id),
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 damage_buffer_size_(0), 51 damage_buffer_size_(0),
52 #endif 52 #endif
53 damage_buffer_scale_factor_(1.0f), 53 damage_buffer_scale_factor_(1.0f),
54 pending_update_counter_(0), 54 pending_update_counter_(0),
55 guest_hang_timeout_( 55 guest_hang_timeout_(
56 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)), 56 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)),
57 focused_(focused), 57 focused_(params.focused),
58 visible_(visible) { 58 visible_(params.visible) {
59 DCHECK(web_contents); 59 DCHECK(web_contents);
60 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. 60 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper.
61 new BrowserPluginGuestHelper(this, render_view_host); 61 new BrowserPluginGuestHelper(this, render_view_host);
62 62
63 notification_registrar_.Add( 63 notification_registrar_.Add(
64 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 64 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
65 content::Source<content::WebContents>(web_contents)); 65 content::Source<content::WebContents>(web_contents));
66 } 66 }
67 67
68 BrowserPluginGuest::~BrowserPluginGuest() { 68 BrowserPluginGuest::~BrowserPluginGuest() {
69 } 69 }
70 70
71 // static 71 // static
72 BrowserPluginGuest* BrowserPluginGuest::Create( 72 BrowserPluginGuest* BrowserPluginGuest::Create(
73 int instance_id, 73 int instance_id,
74 WebContentsImpl* web_contents, 74 WebContentsImpl* web_contents,
75 content::RenderViewHost* render_view_host, 75 content::RenderViewHost* render_view_host,
76 bool focused, 76 const BrowserPluginHostMsg_CreateGuest_Params& params) {
77 bool visible) {
78 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create")); 77 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create"));
79 if (factory_) { 78 if (factory_) {
80 return factory_->CreateBrowserPluginGuest(instance_id, 79 return factory_->CreateBrowserPluginGuest(instance_id,
81 web_contents, 80 web_contents,
82 render_view_host, 81 render_view_host,
83 focused, 82 params);
84 visible);
85 } 83 }
86 return new BrowserPluginGuest( 84 return new BrowserPluginGuest(
87 instance_id, web_contents, render_view_host, focused, visible); 85 instance_id, web_contents, render_view_host, params);
88 } 86 }
89 87
90 void BrowserPluginGuest::Observe(int type, 88 void BrowserPluginGuest::Observe(int type,
91 const NotificationSource& source, 89 const NotificationSource& source,
92 const NotificationDetails& details) { 90 const NotificationDetails& details) {
93 switch (type) { 91 switch (type) {
94 case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { 92 case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: {
95 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents()); 93 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents());
96 ResourceRedirectDetails* resource_redirect_details = 94 ResourceRedirectDetails* resource_redirect_details =
97 Details<ResourceRedirectDetails>(details).ptr(); 95 Details<ResourceRedirectDetails>(details).ptr();
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 default: 501 default:
504 break; 502 break;
505 } 503 }
506 } 504 }
507 505
508 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 506 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
509 embedder_web_contents_->GetRenderProcessHost()->Send(msg); 507 embedder_web_contents_->GetRenderProcessHost()->Send(msg);
510 } 508 }
511 509
512 } // namespace content 510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698