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

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: BrowserPluginHostMsg_AutoSize_Params had an int instead of bool for enable: fixed 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 auto_size_(params.auto_size.enable),
60 max_height_(params.auto_size.max_height),
61 max_width_(params.auto_size.max_width),
62 min_height_(params.auto_size.min_height),
63 min_width_(params.auto_size.min_width) {
59 DCHECK(web_contents); 64 DCHECK(web_contents);
60 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. 65 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper.
61 new BrowserPluginGuestHelper(this, render_view_host); 66 new BrowserPluginGuestHelper(this, render_view_host);
62 67
63 notification_registrar_.Add( 68 notification_registrar_.Add(
64 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 69 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
65 content::Source<content::WebContents>(web_contents)); 70 content::Source<content::WebContents>(web_contents));
66 } 71 }
67 72
68 BrowserPluginGuest::~BrowserPluginGuest() { 73 BrowserPluginGuest::~BrowserPluginGuest() {
69 } 74 }
70 75
71 // static 76 // static
72 BrowserPluginGuest* BrowserPluginGuest::Create( 77 BrowserPluginGuest* BrowserPluginGuest::Create(
73 int instance_id, 78 int instance_id,
74 WebContentsImpl* web_contents, 79 WebContentsImpl* web_contents,
75 content::RenderViewHost* render_view_host, 80 content::RenderViewHost* render_view_host,
76 bool focused, 81 const BrowserPluginHostMsg_CreateGuest_Params& params) {
77 bool visible) {
78 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create")); 82 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create"));
79 if (factory_) { 83 if (factory_) {
80 return factory_->CreateBrowserPluginGuest(instance_id, 84 return factory_->CreateBrowserPluginGuest(instance_id,
81 web_contents, 85 web_contents,
82 render_view_host, 86 render_view_host,
83 focused, 87 params);
84 visible);
85 } 88 }
86 return new BrowserPluginGuest( 89 return new BrowserPluginGuest(
87 instance_id, web_contents, render_view_host, focused, visible); 90 instance_id, web_contents, render_view_host, params);
88 } 91 }
89 92
90 void BrowserPluginGuest::Observe(int type, 93 void BrowserPluginGuest::Observe(int type,
91 const NotificationSource& source, 94 const NotificationSource& source,
92 const NotificationDetails& details) { 95 const NotificationDetails& details) {
93 switch (type) { 96 switch (type) {
94 case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { 97 case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: {
95 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents()); 98 DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents());
96 ResourceRedirectDetails* resource_redirect_details = 99 ResourceRedirectDetails* resource_redirect_details =
97 Details<ResourceRedirectDetails>(details).ptr(); 100 Details<ResourceRedirectDetails>(details).ptr();
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 default: 506 default:
504 break; 507 break;
505 } 508 }
506 } 509 }
507 510
508 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 511 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
509 embedder_web_contents_->GetRenderProcessHost()->Send(msg); 512 embedder_web_contents_->GetRenderProcessHost()->Send(msg);
510 } 513 }
511 514
512 } // namespace content 515 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698