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 EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ |
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ |
7 | 7 |
8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
9 #include "content/public/test/browser_test_utils.h" | 9 #include "content/public/test/browser_test_utils.h" |
10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
11 #include "extensions/browser/guest_view/guest_view_manager.h" | 11 #include "extensions/browser/guest_view/guest_view_manager.h" |
12 #include "extensions/browser/guest_view/guest_view_manager_factory.h" | 12 #include "extensions/browser/guest_view/guest_view_manager_factory.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 class TestGuestViewManager : public GuestViewManager { | 16 class TestGuestViewManager : public GuestViewManager { |
17 public: | 17 public: |
18 explicit TestGuestViewManager(content::BrowserContext* context); | 18 TestGuestViewManager( |
| 19 content::BrowserContext* context, |
| 20 scoped_ptr<guestview::GuestViewManagerDelegate> delegate); |
19 ~TestGuestViewManager() override; | 21 ~TestGuestViewManager() override; |
20 | 22 |
21 void WaitForAllGuestsDeleted(); | 23 void WaitForAllGuestsDeleted(); |
22 content::WebContents* WaitForSingleGuestCreated(); | 24 content::WebContents* WaitForSingleGuestCreated(); |
23 | 25 |
24 content::WebContents* GetLastGuestCreated(); | 26 content::WebContents* GetLastGuestCreated(); |
25 | 27 |
| 28 // Returns the number of guests currently still alive at the time of calling |
| 29 // this method. |
| 30 int GetNumGuestsActive() const; |
| 31 |
| 32 // Reutnrs the number of guests that have been created since the creation of |
| 33 // this GuestViewManager. |
| 34 int num_guests_created() const { return num_guests_created_; } |
| 35 |
26 private: | 36 private: |
27 // GuestViewManager override: | 37 // GuestViewManager override: |
28 void AddGuest(int guest_instance_id, | 38 void AddGuest(int guest_instance_id, |
29 content::WebContents* guest_web_contents) override; | 39 content::WebContents* guest_web_contents) override; |
30 void RemoveGuest(int guest_instance_id) override; | 40 void RemoveGuest(int guest_instance_id) override; |
31 | 41 |
32 int GetNumGuests() const; | |
33 void WaitForGuestCreated(); | 42 void WaitForGuestCreated(); |
34 | 43 |
| 44 int num_guests_created_; |
| 45 |
35 std::vector<linked_ptr<content::WebContentsDestroyedWatcher>> | 46 std::vector<linked_ptr<content::WebContentsDestroyedWatcher>> |
36 guest_web_contents_watchers_; | 47 guest_web_contents_watchers_; |
37 scoped_refptr<content::MessageLoopRunner> created_message_loop_runner_; | 48 scoped_refptr<content::MessageLoopRunner> created_message_loop_runner_; |
38 | 49 |
39 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManager); | 50 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManager); |
40 }; | 51 }; |
41 | 52 |
42 // Test factory for creating test instances of GuestViewManager. | 53 // Test factory for creating test instances of GuestViewManager. |
43 class TestGuestViewManagerFactory : public GuestViewManagerFactory { | 54 class TestGuestViewManagerFactory : public GuestViewManagerFactory { |
44 public: | 55 public: |
45 TestGuestViewManagerFactory(); | 56 TestGuestViewManagerFactory(); |
46 ~TestGuestViewManagerFactory() override; | 57 ~TestGuestViewManagerFactory() override; |
47 | 58 |
48 GuestViewManager* CreateGuestViewManager( | 59 GuestViewManager* CreateGuestViewManager( |
49 content::BrowserContext* context) override; | 60 content::BrowserContext* context, |
50 | 61 scoped_ptr<guestview::GuestViewManagerDelegate> delegate) override; |
51 TestGuestViewManager* GetManager(content::BrowserContext* context); | |
52 | 62 |
53 private: | 63 private: |
54 TestGuestViewManager* test_guest_view_manager_; | 64 TestGuestViewManager* test_guest_view_manager_; |
55 | 65 |
56 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManagerFactory); | 66 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManagerFactory); |
57 }; | 67 }; |
58 | 68 |
59 } // namespace extensions | 69 } // namespace extensions |
60 | 70 |
61 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ | 71 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ |
OLD | NEW |