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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 friend class GuestViewBase; | 58 friend class GuestViewBase; |
59 friend class GuestWebContentsObserver; | 59 friend class GuestWebContentsObserver; |
60 friend class TestGuestViewManager; | 60 friend class TestGuestViewManager; |
61 FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove); | 61 FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove); |
62 | 62 |
63 void AddGuest(int guest_instance_id, | 63 void AddGuest(int guest_instance_id, |
64 content::WebContents* guest_web_contents); | 64 content::WebContents* guest_web_contents); |
65 | 65 |
66 void RemoveGuest(int guest_instance_id); | 66 void RemoveGuest(int guest_instance_id); |
67 | 67 |
68 void AddRenderProcessHostID(int render_process_host_id); | |
69 | |
70 content::SiteInstance* GetGuestSiteInstance( | 68 content::SiteInstance* GetGuestSiteInstance( |
71 const GURL& guest_site); | 69 const GURL& guest_site); |
72 | 70 |
73 content::WebContents* GetGuestByInstanceID( | 71 content::WebContents* GetGuestByInstanceID( |
74 int guest_instance_id, | 72 int guest_instance_id, |
75 int embedder_render_process_id); | 73 int embedder_render_process_id); |
76 | 74 |
77 bool CanEmbedderAccessInstanceIDMaybeKill( | 75 bool CanEmbedderAccessInstanceIDMaybeKill( |
78 int embedder_render_process_id, | 76 int embedder_render_process_id, |
79 int guest_instance_id); | 77 int guest_instance_id); |
80 | 78 |
81 bool CanEmbedderAccessInstanceID(int embedder_render_process_id, | 79 bool CanEmbedderAccessInstanceID(int embedder_render_process_id, |
82 int guest_instance_id); | 80 int guest_instance_id); |
83 | 81 |
84 // Returns true if |guest_instance_id| can be used to add a new guest to this | 82 // Returns true if |guest_instance_id| can be used to add a new guest to this |
85 // manager. | 83 // manager. |
86 // We disallow adding new guest with instance IDs that were previously removed | 84 // We disallow adding new guest with instance IDs that were previously removed |
87 // from this manager using RemoveGuest. | 85 // from this manager using RemoveGuest. |
88 bool CanUseGuestInstanceID(int guest_instance_id); | 86 bool CanUseGuestInstanceID(int guest_instance_id); |
89 | 87 |
90 static bool CanEmbedderAccessGuest(int embedder_render_process_id, | 88 static bool CanEmbedderAccessGuest(int embedder_render_process_id, |
91 GuestViewBase* guest); | 89 GuestViewBase* guest); |
92 | 90 |
93 // Counts RenderProcessHost IDs of GuestViewBases. | |
94 std::multiset<int> render_process_host_id_multiset_; | |
95 | |
96 // Contains guests' WebContents, mapping from their instance ids. | 91 // Contains guests' WebContents, mapping from their instance ids. |
97 typedef std::map<int, content::WebContents*> GuestInstanceMap; | 92 typedef std::map<int, content::WebContents*> GuestInstanceMap; |
98 GuestInstanceMap guest_web_contents_by_instance_id_; | 93 GuestInstanceMap guest_web_contents_by_instance_id_; |
99 | 94 |
100 int current_instance_id_; | 95 int current_instance_id_; |
101 | 96 |
102 // Any instance ID whose number not greater than this was removed via | 97 // Any instance ID whose number not greater than this was removed via |
103 // RemoveGuest. | 98 // RemoveGuest. |
104 // This is used so that we don't have store all removed instance IDs in | 99 // This is used so that we don't have store all removed instance IDs in |
105 // |removed_instance_ids_|. | 100 // |removed_instance_ids_|. |
106 int last_instance_id_removed_; | 101 int last_instance_id_removed_; |
107 // The remaining instance IDs that are greater than | 102 // The remaining instance IDs that are greater than |
108 // |last_instance_id_removed_| are kept here. | 103 // |last_instance_id_removed_| are kept here. |
109 std::set<int> removed_instance_ids_; | 104 std::set<int> removed_instance_ids_; |
110 | 105 |
111 content::BrowserContext* context_; | 106 content::BrowserContext* context_; |
112 | 107 |
113 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); | 108 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); |
114 }; | 109 }; |
115 | 110 |
116 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 111 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
OLD | NEW |