| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/browser_plugin/test_browser_plugin_guest_manager.h" | |
| 6 | |
| 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" | |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | |
| 9 #include "content/public/test/test_utils.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 TestBrowserPluginGuestManager::TestBrowserPluginGuestManager( | |
| 14 BrowserContext* context) | |
| 15 : BrowserPluginGuestManager(context), | |
| 16 last_guest_added_(NULL) { | |
| 17 } | |
| 18 | |
| 19 TestBrowserPluginGuestManager::~TestBrowserPluginGuestManager() { | |
| 20 } | |
| 21 | |
| 22 BrowserPluginGuest* TestBrowserPluginGuestManager::CreateGuest( | |
| 23 SiteInstance* embedder_site_instance, | |
| 24 int instance_id, | |
| 25 const StorageInfo& storage_info, | |
| 26 scoped_ptr<base::DictionaryValue> extra_params) { | |
| 27 BrowserPluginGuest* guest = BrowserPluginGuestManager::CreateGuest( | |
| 28 embedder_site_instance, | |
| 29 instance_id, | |
| 30 storage_info, | |
| 31 extra_params.Pass()); | |
| 32 last_guest_added_ = guest->GetWebContents(); | |
| 33 if (message_loop_runner_.get()) | |
| 34 message_loop_runner_->Quit(); | |
| 35 return guest; | |
| 36 } | |
| 37 | |
| 38 WebContents* TestBrowserPluginGuestManager::WaitForGuestAdded() { | |
| 39 // Check if guests were already created. | |
| 40 if (last_guest_added_) { | |
| 41 WebContents* last_guest_added = last_guest_added_; | |
| 42 last_guest_added_ = NULL; | |
| 43 return last_guest_added; | |
| 44 } | |
| 45 // Wait otherwise. | |
| 46 message_loop_runner_ = new MessageLoopRunner(); | |
| 47 message_loop_runner_->Run(); | |
| 48 WebContents* last_guest_added = last_guest_added_; | |
| 49 last_guest_added_ = NULL; | |
| 50 return last_guest_added; | |
| 51 } | |
| 52 | |
| 53 } // namespace content | |
| OLD | NEW |