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

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

Issue 26497003: Remove NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED from browser plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « content/browser/browser_plugin/test_browser_plugin_guest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test_browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/test_browser_plugin_guest.h"
6 6
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/browser_plugin/browser_plugin_messages.h" 10 #include "content/common/browser_plugin/browser_plugin_messages.h"
11 #include "content/public/browser/notification_types.h"
12 11
13 namespace content { 12 namespace content {
14 13
15 class BrowserPluginGuest; 14 class BrowserPluginGuest;
16 15
17 TestBrowserPluginGuest::TestBrowserPluginGuest( 16 TestBrowserPluginGuest::TestBrowserPluginGuest(
18 int instance_id, 17 int instance_id,
19 WebContentsImpl* web_contents) 18 WebContentsImpl* web_contents)
20 : BrowserPluginGuest(instance_id, web_contents, NULL, false), 19 : BrowserPluginGuest(instance_id, web_contents, NULL, false),
21 update_rect_count_(0), 20 update_rect_count_(0),
22 damage_buffer_call_count_(0), 21 damage_buffer_call_count_(0),
23 exit_observed_(false), 22 exit_observed_(false),
24 focus_observed_(false), 23 focus_observed_(false),
25 blur_observed_(false), 24 blur_observed_(false),
26 advance_focus_observed_(false), 25 advance_focus_observed_(false),
27 was_hidden_observed_(false), 26 was_hidden_observed_(false),
28 set_damage_buffer_observed_(false), 27 set_damage_buffer_observed_(false),
29 input_observed_(false), 28 input_observed_(false),
30 load_stop_observed_(false), 29 load_stop_observed_(false),
31 waiting_for_damage_buffer_with_size_(false), 30 waiting_for_damage_buffer_with_size_(false),
32 last_damage_buffer_size_(gfx::Size()) { 31 last_damage_buffer_size_(gfx::Size()) {
33 // Listen to visibility changes so that a test can wait for these changes.
34 notification_registrar_.Add(this,
35 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
36 Source<WebContents>(web_contents));
37 } 32 }
38 33
39 TestBrowserPluginGuest::~TestBrowserPluginGuest() { 34 TestBrowserPluginGuest::~TestBrowserPluginGuest() {
40 } 35 }
41 36
42 WebContentsImpl* TestBrowserPluginGuest::web_contents() const { 37 WebContentsImpl* TestBrowserPluginGuest::web_contents() const {
43 return static_cast<WebContentsImpl*>(BrowserPluginGuest::web_contents()); 38 return static_cast<WebContentsImpl*>(BrowserPluginGuest::web_contents());
44 } 39 }
45 40
46 void TestBrowserPluginGuest::Observe(int type,
47 const NotificationSource& source,
48 const NotificationDetails& details) {
49 switch (type) {
50 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: {
51 bool visible = *Details<bool>(details).ptr();
52 if (!visible) {
53 was_hidden_observed_ = true;
54 if (was_hidden_message_loop_runner_.get())
55 was_hidden_message_loop_runner_->Quit();
56 }
57 return;
58 }
59 }
60
61 BrowserPluginGuest::Observe(type, source, details);
62 }
63
64 void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 41 void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
65 if (msg->type() == BrowserPluginMsg_UpdateRect::ID) { 42 if (msg->type() == BrowserPluginMsg_UpdateRect::ID) {
66 update_rect_count_++; 43 update_rect_count_++;
67 int instance_id = 0; 44 int instance_id = 0;
68 BrowserPluginMsg_UpdateRect_Params params; 45 BrowserPluginMsg_UpdateRect_Params params;
69 BrowserPluginMsg_UpdateRect::Read(msg, &instance_id, &params); 46 BrowserPluginMsg_UpdateRect::Read(msg, &instance_id, &params);
70 last_view_size_observed_ = params.view_size; 47 last_view_size_observed_ = params.view_size;
71 if (!expected_auto_view_size_.IsEmpty() && 48 if (!expected_auto_view_size_.IsEmpty() &&
72 expected_auto_view_size_ == params.view_size) { 49 expected_auto_view_size_ == params.view_size) {
73 if (auto_view_size_message_loop_runner_.get()) 50 if (auto_view_size_message_loop_runner_.get())
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 217 }
241 218
242 void TestBrowserPluginGuest::DidStopLoading( 219 void TestBrowserPluginGuest::DidStopLoading(
243 RenderViewHost* render_view_host) { 220 RenderViewHost* render_view_host) {
244 BrowserPluginGuest::DidStopLoading(render_view_host); 221 BrowserPluginGuest::DidStopLoading(render_view_host);
245 load_stop_observed_ = true; 222 load_stop_observed_ = true;
246 if (load_stop_message_loop_runner_.get()) 223 if (load_stop_message_loop_runner_.get())
247 load_stop_message_loop_runner_->Quit(); 224 load_stop_message_loop_runner_->Quit();
248 } 225 }
249 226
227 void TestBrowserPluginGuest::WasHidden() {
228 was_hidden_observed_ = true;
229 if (was_hidden_message_loop_runner_.get())
230 was_hidden_message_loop_runner_->Quit();
231 }
232
250 } // namespace content 233 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/test_browser_plugin_guest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698