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