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

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

Issue 11066032: Browser Plugin: Update Guest WebContents Visibility on BrowserPlugin Visiblity Change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits 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 "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 29 matching lines...) Expand all
40 RenderViewHost* render_view_host) 40 RenderViewHost* render_view_host)
41 : WebContentsObserver(web_contents), 41 : WebContentsObserver(web_contents),
42 embedder_render_process_host_(NULL), 42 embedder_render_process_host_(NULL),
43 instance_id_(instance_id), 43 instance_id_(instance_id),
44 #if defined(OS_WIN) 44 #if defined(OS_WIN)
45 damage_buffer_size_(0), 45 damage_buffer_size_(0),
46 #endif 46 #endif
47 damage_buffer_scale_factor_(1.0f), 47 damage_buffer_scale_factor_(1.0f),
48 pending_update_counter_(0), 48 pending_update_counter_(0),
49 guest_hang_timeout_( 49 guest_hang_timeout_(
50 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)) { 50 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)),
51 visible_(true) {
51 DCHECK(web_contents); 52 DCHECK(web_contents);
52 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. 53 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper.
53 new BrowserPluginGuestHelper(this, render_view_host); 54 new BrowserPluginGuestHelper(this, render_view_host);
54 55
55 notification_registrar_.Add( 56 notification_registrar_.Add(
56 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 57 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
57 content::Source<content::WebContents>(web_contents)); 58 content::Source<content::WebContents>(web_contents));
58 } 59 }
59 60
60 BrowserPluginGuest::~BrowserPluginGuest() { 61 BrowserPluginGuest::~BrowserPluginGuest() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 web_contents()->GetRenderProcessHost()->GetHandle(); 129 web_contents()->GetRenderProcessHost()->GetHandle();
129 base::KillProcess(process_handle, RESULT_CODE_HUNG, false); 130 base::KillProcess(process_handle, RESULT_CODE_HUNG, false);
130 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung")); 131 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Hung"));
131 } 132 }
132 133
133 void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) { 134 void BrowserPluginGuest::SetIsAcceptingTouchEvents(bool accept) {
134 SendMessageToEmbedder( 135 SendMessageToEmbedder(
135 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); 136 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept));
136 } 137 }
137 138
139 void BrowserPluginGuest::SetVisibility(bool embedder_visible, bool visible) {
140 visible_ = visible;
141 if (embedder_visible && visible)
142 web_contents()->WasShown();
143 else
144 web_contents()->WasHidden();
145 }
146
138 WebContents* BrowserPluginGuest::GetWebContents() { 147 WebContents* BrowserPluginGuest::GetWebContents() {
139 return web_contents(); 148 return web_contents();
140 } 149 }
141 150
142 void BrowserPluginGuest::Terminate() { 151 void BrowserPluginGuest::Terminate() {
143 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate")); 152 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Terminate"));
144 base::ProcessHandle process_handle = 153 base::ProcessHandle process_handle =
145 web_contents()->GetRenderProcessHost()->GetHandle(); 154 web_contents()->GetRenderProcessHost()->GetHandle();
146 base::KillProcess(process_handle, RESULT_CODE_KILLED, false); 155 base::KillProcess(process_handle, RESULT_CODE_KILLED, false);
147 } 156 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 break; 422 break;
414 } 423 }
415 } 424 }
416 425
417 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 426 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
418 DCHECK(embedder_render_process_host()); 427 DCHECK(embedder_render_process_host());
419 embedder_render_process_host()->Send(msg); 428 embedder_render_process_host()->Send(msg);
420 } 429 }
421 430
422 } // namespace content 431 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698