OLD | NEW |
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_messages.h" | 10 #include "content/common/browser_plugin_messages.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 damage_buffer_call_count_(0), | 23 damage_buffer_call_count_(0), |
24 crash_observed_(false), | 24 crash_observed_(false), |
25 focus_observed_(false), | 25 focus_observed_(false), |
26 advance_focus_observed_(false), | 26 advance_focus_observed_(false), |
27 was_hidden_observed_(false), | 27 was_hidden_observed_(false), |
28 stop_observed_(false), | 28 stop_observed_(false), |
29 reload_observed_(false), | 29 reload_observed_(false), |
30 waiting_for_damage_buffer_with_size_(false), | 30 waiting_for_damage_buffer_with_size_(false), |
31 last_damage_buffer_size_(gfx::Size()) { | 31 last_damage_buffer_size_(gfx::Size()) { |
32 // Listen to visibility changes so that a test can wait for these changes. | 32 // Listen to visibility changes so that a test can wait for these changes. |
33 registrar_.Add(this, | 33 notification_registrar_.Add(this, |
34 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 34 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
35 Source<WebContents>(web_contents)); | 35 Source<WebContents>(web_contents)); |
36 } | 36 } |
37 | 37 |
38 TestBrowserPluginGuest::~TestBrowserPluginGuest() { | 38 TestBrowserPluginGuest::~TestBrowserPluginGuest() { |
39 } | 39 } |
40 | 40 |
41 WebContentsImpl* TestBrowserPluginGuest::web_contents() const { | 41 WebContentsImpl* TestBrowserPluginGuest::web_contents() const { |
42 return static_cast<WebContentsImpl*>(BrowserPluginGuest::web_contents()); | 42 return static_cast<WebContentsImpl*>(BrowserPluginGuest::web_contents()); |
43 } | 43 } |
44 | 44 |
45 void TestBrowserPluginGuest::Observe(int type, | 45 void TestBrowserPluginGuest::Observe(int type, |
46 const NotificationSource& source, | 46 const NotificationSource& source, |
47 const NotificationDetails& details) { | 47 const NotificationDetails& details) { |
48 switch (type) { | 48 switch (type) { |
49 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { | 49 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { |
50 bool visible = *Details<bool>(details).ptr(); | 50 bool visible = *Details<bool>(details).ptr(); |
51 if (!visible) { | 51 if (!visible) { |
52 was_hidden_observed_ = true; | 52 was_hidden_observed_ = true; |
53 if (was_hidden_message_loop_runner_) | 53 if (was_hidden_message_loop_runner_) |
54 was_hidden_message_loop_runner_->Quit(); | 54 was_hidden_message_loop_runner_->Quit(); |
55 } | 55 } |
56 break; | 56 return; |
57 } | 57 } |
58 default: | |
59 NOTREACHED() << "Unexpected notification type: " << type; | |
60 } | 58 } |
| 59 |
| 60 BrowserPluginGuest::Observe(type, source, details); |
61 } | 61 } |
62 | 62 |
63 void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 63 void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
64 if (msg->type() == BrowserPluginMsg_UpdateRect::ID) { | 64 if (msg->type() == BrowserPluginMsg_UpdateRect::ID) { |
65 update_rect_count_++; | 65 update_rect_count_++; |
66 if (send_message_loop_runner_) | 66 if (send_message_loop_runner_) |
67 send_message_loop_runner_->Quit(); | 67 send_message_loop_runner_->Quit(); |
68 } | 68 } |
69 BrowserPluginGuest::SendMessageToEmbedder(msg); | 69 BrowserPluginGuest::SendMessageToEmbedder(msg); |
70 } | 70 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 BrowserPluginGuest::SetDamageBuffer( | 203 BrowserPluginGuest::SetDamageBuffer( |
204 damage_buffer, | 204 damage_buffer, |
205 #if defined(OS_WIN) | 205 #if defined(OS_WIN) |
206 damage_buffer_size, | 206 damage_buffer_size, |
207 #endif | 207 #endif |
208 damage_view_size, | 208 damage_view_size, |
209 scale_factor); | 209 scale_factor); |
210 } | 210 } |
211 | 211 |
212 } // namespace content | 212 } // namespace content |
OLD | NEW |