| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_TEST_GUEST_MANAGER_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_TEST_GUEST_MANAGER_DELEGATE_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_TEST_GUEST_MANAGER_DELEGATE_H_ | 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_TEST_GUEST_MANAGER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "content/public/browser/browser_plugin_guest_manager_delegate.h" | 11 #include "content/public/browser/browser_plugin_guest_manager_delegate.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 class MessageLoopRunner; |
| 16 class WebContentsImpl; |
| 17 |
| 15 // This class is temporary until BrowserPluginHostTest.* tests are entirely | 18 // This class is temporary until BrowserPluginHostTest.* tests are entirely |
| 16 // moved out of content. | 19 // moved out of content. |
| 17 class TestGuestManagerDelegate : public BrowserPluginGuestManagerDelegate { | 20 class TestGuestManagerDelegate : public BrowserPluginGuestManagerDelegate { |
| 18 public: | 21 public: |
| 19 virtual ~TestGuestManagerDelegate(); | 22 virtual ~TestGuestManagerDelegate(); |
| 20 | 23 |
| 21 static TestGuestManagerDelegate* GetInstance(); | 24 static TestGuestManagerDelegate* GetInstance(); |
| 22 | 25 |
| 23 void AddGuest(int guest_instance_id, WebContents* guest_web_contents); | 26 void AddGuest(int guest_instance_id, WebContents* guest_web_contents); |
| 24 void RemoveGuest(int guest_instance_id); | 27 void RemoveGuest(int guest_instance_id); |
| 25 SiteInstance* GetGuestSiteInstance(const GURL& guest_site); | 28 SiteInstance* GetGuestSiteInstance(const GURL& guest_site); |
| 26 | 29 |
| 30 // Waits until at least one guest is added to this guest manager. |
| 31 WebContentsImpl* WaitForGuestAdded(); |
| 32 |
| 27 // BrowserPluginGuestManagerDelegate implementation. | 33 // BrowserPluginGuestManagerDelegate implementation. |
| 28 virtual content::WebContents* CreateGuest( | 34 virtual content::WebContents* CreateGuest( |
| 29 content::SiteInstance* embedder_site_instance, | 35 content::SiteInstance* embedder_site_instance, |
| 30 int instance_id, | 36 int instance_id, |
| 31 const std::string& storage_partition_id, | 37 const std::string& storage_partition_id, |
| 32 bool persist_storage, | 38 bool persist_storage, |
| 33 scoped_ptr<base::DictionaryValue> extra_params) OVERRIDE; | 39 scoped_ptr<base::DictionaryValue> extra_params) OVERRIDE; |
| 34 virtual int GetNextInstanceID() OVERRIDE; | 40 virtual int GetNextInstanceID() OVERRIDE; |
| 35 virtual void MaybeGetGuestByInstanceIDOrKill( | 41 virtual void MaybeGetGuestByInstanceIDOrKill( |
| 36 int guest_instance_id, | 42 int guest_instance_id, |
| 37 int embedder_render_process_id, | 43 int embedder_render_process_id, |
| 38 const GuestByInstanceIDCallback& callback) OVERRIDE; | 44 const GuestByInstanceIDCallback& callback) OVERRIDE; |
| 39 virtual bool ForEachGuest(WebContents* embedder_web_contents, | 45 virtual bool ForEachGuest(WebContents* embedder_web_contents, |
| 40 const GuestCallback& callback) OVERRIDE; | 46 const GuestCallback& callback) OVERRIDE; |
| 41 | 47 |
| 42 private: | 48 private: |
| 43 friend struct DefaultSingletonTraits<TestGuestManagerDelegate>; | 49 friend struct DefaultSingletonTraits<TestGuestManagerDelegate>; |
| 44 TestGuestManagerDelegate(); | 50 TestGuestManagerDelegate(); |
| 51 |
| 45 // Contains guests' WebContents, mapping from their instance ids. | 52 // Contains guests' WebContents, mapping from their instance ids. |
| 46 typedef std::map<int, WebContents*> GuestInstanceMap; | 53 typedef std::map<int, WebContents*> GuestInstanceMap; |
| 47 GuestInstanceMap guest_web_contents_by_instance_id_; | 54 GuestInstanceMap guest_web_contents_by_instance_id_; |
| 48 | 55 WebContentsImpl* last_guest_added_; |
| 49 int next_instance_id_; | 56 int next_instance_id_; |
| 57 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 50 | 58 |
| 51 DISALLOW_COPY_AND_ASSIGN(TestGuestManagerDelegate); | 59 DISALLOW_COPY_AND_ASSIGN(TestGuestManagerDelegate); |
| 52 }; | 60 }; |
| 53 | 61 |
| 54 } // namespace content | 62 } // namespace content |
| 55 | 63 |
| 56 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_TEST_GUEST_MANAGER_DELEGATE_H_ | 64 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_TEST_GUEST_MANAGER_DELEGATE_H_ |
| OLD | NEW |