| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // Returns the guest WebContents associated with the given |guest_instance_id| | 32 // Returns the guest WebContents associated with the given |guest_instance_id| |
| 33 // if the provided |embedder_render_process_id| is allowed to access it. | 33 // if the provided |embedder_render_process_id| is allowed to access it. |
| 34 // If the embedder is not allowed access, the embedder will be killed, and | 34 // If the embedder is not allowed access, the embedder will be killed, and |
| 35 // this method will return NULL. If no WebContents exists with the given | 35 // this method will return NULL. If no WebContents exists with the given |
| 36 // instance ID, then NULL will also be returned. | 36 // instance ID, then NULL will also be returned. |
| 37 content::WebContents* GetGuestByInstanceIDSafely( | 37 content::WebContents* GetGuestByInstanceIDSafely( |
| 38 int guest_instance_id, | 38 int guest_instance_id, |
| 39 int embedder_render_process_id); | 39 int embedder_render_process_id); |
| 40 | 40 |
| 41 // BrowserPluginGuestManagerDelegate implementation. | 41 // BrowserPluginGuestManagerDelegate implementation. |
| 42 virtual content::WebContents* CreateGuest( |
| 43 content::SiteInstance* embedder_site_instance, |
| 44 int instance_id, |
| 45 const std::string& storage_partition_id, |
| 46 bool persist_storage, |
| 47 scoped_ptr<base::DictionaryValue> extra_params) OVERRIDE; |
| 42 virtual int GetNextInstanceID() OVERRIDE; | 48 virtual int GetNextInstanceID() OVERRIDE; |
| 43 virtual void AddGuest(int guest_instance_id, | |
| 44 content::WebContents* guest_web_contents) OVERRIDE; | |
| 45 virtual void RemoveGuest(int guest_instance_id) OVERRIDE; | |
| 46 virtual void MaybeGetGuestByInstanceIDOrKill( | 49 virtual void MaybeGetGuestByInstanceIDOrKill( |
| 47 int guest_instance_id, | 50 int guest_instance_id, |
| 48 int embedder_render_process_id, | 51 int embedder_render_process_id, |
| 49 const GuestByInstanceIDCallback& callback) OVERRIDE; | 52 const GuestByInstanceIDCallback& callback) OVERRIDE; |
| 50 virtual content::SiteInstance* GetGuestSiteInstance( | |
| 51 const GURL& guest_site) OVERRIDE; | |
| 52 virtual bool ForEachGuest(content::WebContents* embedder_web_contents, | 53 virtual bool ForEachGuest(content::WebContents* embedder_web_contents, |
| 53 const GuestCallback& callback) OVERRIDE; | 54 const GuestCallback& callback) OVERRIDE; |
| 54 | 55 |
| 55 private: | 56 private: |
| 57 friend class GuestViewBase; |
| 56 friend class GuestWebContentsObserver; | 58 friend class GuestWebContentsObserver; |
| 57 | 59 |
| 60 void AddGuest(int guest_instance_id, |
| 61 content::WebContents* guest_web_contents); |
| 62 |
| 63 void RemoveGuest(int guest_instance_id); |
| 64 |
| 58 void AddRenderProcessHostID(int render_process_host_id); | 65 void AddRenderProcessHostID(int render_process_host_id); |
| 59 | 66 |
| 67 content::SiteInstance* GetGuestSiteInstance( |
| 68 const GURL& guest_site); |
| 69 |
| 60 content::WebContents* GetGuestByInstanceID( | 70 content::WebContents* GetGuestByInstanceID( |
| 61 int guest_instance_id, | 71 int guest_instance_id, |
| 62 int embedder_render_process_id); | 72 int embedder_render_process_id); |
| 63 | 73 |
| 64 bool CanEmbedderAccessInstanceIDMaybeKill( | 74 bool CanEmbedderAccessInstanceIDMaybeKill( |
| 65 int embedder_render_process_id, | 75 int embedder_render_process_id, |
| 66 int guest_instance_id); | 76 int guest_instance_id); |
| 67 | 77 |
| 68 bool CanEmbedderAccessInstanceID(int embedder_render_process_id, | 78 bool CanEmbedderAccessInstanceID(int embedder_render_process_id, |
| 69 int guest_instance_id); | 79 int guest_instance_id); |
| 70 | 80 |
| 71 static bool CanEmbedderAccessGuest(int embedder_render_process_id, | 81 static bool CanEmbedderAccessGuest(int embedder_render_process_id, |
| 72 GuestViewBase* guest); | 82 GuestViewBase* guest); |
| 73 | 83 |
| 74 // Counts RenderProcessHost IDs of GuestViewBases. | 84 // Counts RenderProcessHost IDs of GuestViewBases. |
| 75 std::multiset<int> render_process_host_id_multiset_; | 85 std::multiset<int> render_process_host_id_multiset_; |
| 76 | 86 |
| 77 // Contains guests' WebContents, mapping from their instance ids. | 87 // Contains guests' WebContents, mapping from their instance ids. |
| 78 typedef std::map<int, content::WebContents*> GuestInstanceMap; | 88 typedef std::map<int, content::WebContents*> GuestInstanceMap; |
| 79 GuestInstanceMap guest_web_contents_by_instance_id_; | 89 GuestInstanceMap guest_web_contents_by_instance_id_; |
| 80 | 90 |
| 81 int current_instance_id_; | 91 int current_instance_id_; |
| 82 content::BrowserContext* context_; | 92 content::BrowserContext* context_; |
| 83 | 93 |
| 84 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); | 94 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); |
| 85 }; | 95 }; |
| 86 | 96 |
| 87 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 97 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| OLD | NEW |