OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_manager.h" | 5 #include "content/browser/browser_plugin/test_browser_plugin_guest_manager.h" |
6 | 6 |
7 #include "content/browser/web_contents/web_contents_impl.h" | 7 #include "content/browser/web_contents/web_contents_impl.h" |
8 #include "content/public/test/test_utils.h" | 8 #include "content/public/test/test_utils.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 TestBrowserPluginGuestManager::TestBrowserPluginGuestManager() { | 12 TestBrowserPluginGuestManager::TestBrowserPluginGuestManager( |
| 13 BrowserContext* context) |
| 14 : BrowserPluginGuestManager(context), |
| 15 last_guest_added_(NULL) { |
13 } | 16 } |
14 | 17 |
15 TestBrowserPluginGuestManager::~TestBrowserPluginGuestManager() { | 18 TestBrowserPluginGuestManager::~TestBrowserPluginGuestManager() { |
16 } | 19 } |
17 | 20 |
18 void TestBrowserPluginGuestManager::AddGuest( | 21 void TestBrowserPluginGuestManager::AddGuest( |
19 int instance_id, | 22 int instance_id, |
20 WebContentsImpl* guest_web_contents) { | 23 WebContents* guest_web_contents) { |
21 BrowserPluginGuestManager::AddGuest(instance_id, guest_web_contents); | 24 BrowserPluginGuestManager::AddGuest(instance_id, guest_web_contents); |
22 if (message_loop_runner_) | 25 last_guest_added_ = guest_web_contents; |
| 26 if (message_loop_runner_.get()) |
23 message_loop_runner_->Quit(); | 27 message_loop_runner_->Quit(); |
24 } | 28 } |
25 | 29 |
26 void TestBrowserPluginGuestManager::WaitForGuestAdded() { | 30 WebContents* TestBrowserPluginGuestManager::WaitForGuestAdded() { |
27 // Check if guests were already created. | 31 // Check if guests were already created. |
28 if (guest_web_contents_by_instance_id_.size() > 0) | 32 if (last_guest_added_) { |
29 return; | 33 WebContents* last_guest_added = last_guest_added_; |
| 34 last_guest_added_ = NULL; |
| 35 return last_guest_added; |
| 36 } |
30 // Wait otherwise. | 37 // Wait otherwise. |
31 message_loop_runner_ = new MessageLoopRunner(); | 38 message_loop_runner_ = new MessageLoopRunner(); |
32 message_loop_runner_->Run(); | 39 message_loop_runner_->Run(); |
| 40 WebContents* last_guest_added = last_guest_added_; |
| 41 last_guest_added_ = NULL; |
| 42 return last_guest_added; |
33 } | 43 } |
34 | 44 |
35 } // namespace content | 45 } // namespace content |
OLD | NEW |