OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/lazy_instance.h" |
| 11 #include "base/macros.h" |
| 12 #include "content/public/browser/browser_plugin_guest_manager_delegate.h" |
| 13 #include "content/public/browser/site_instance.h" |
| 14 #include "content/public/browser/web_contents.h" |
| 15 |
| 16 class GuestViewBase; |
| 17 class GuestWebContentsObserver; |
| 18 class GURL; |
| 19 |
| 20 namespace content { |
| 21 class BrowserContext; |
| 22 } // namespace content |
| 23 |
| 24 class GuestViewManager : public content::BrowserPluginGuestManagerDelegate, |
| 25 public base::SupportsUserData::Data { |
| 26 public: |
| 27 explicit GuestViewManager(content::BrowserContext* context); |
| 28 virtual ~GuestViewManager(); |
| 29 |
| 30 static GuestViewManager* FromBrowserContext(content::BrowserContext* context); |
| 31 |
| 32 // BrowserPluginGuestManagerDelegate implementation. |
| 33 virtual int GetNextInstanceID() OVERRIDE; |
| 34 virtual void AddGuest(int guest_instance_id, |
| 35 content::WebContents* guest_web_contents) OVERRIDE; |
| 36 virtual void RemoveGuest(int guest_instance_id) OVERRIDE; |
| 37 virtual content::WebContents* GetGuestByInstanceID( |
| 38 int guest_instance_id, |
| 39 int embedder_render_process_id) OVERRIDE; |
| 40 virtual bool CanEmbedderAccessInstanceIDMaybeKill( |
| 41 int embedder_render_process_id, |
| 42 int guest_instance_id) OVERRIDE; |
| 43 virtual bool CanEmbedderAccessInstanceID(int embedder_render_process_id, |
| 44 int guest_instance_id) OVERRIDE; |
| 45 virtual content::SiteInstance* GetGuestSiteInstance( |
| 46 const GURL& guest_site) OVERRIDE; |
| 47 virtual bool ForEachGuest(content::WebContents* embedder_web_contents, |
| 48 const GuestCallback& callback) OVERRIDE; |
| 49 |
| 50 private: |
| 51 friend class GuestWebContentsObserver; |
| 52 |
| 53 void AddRenderProcessHostID(int render_process_host_id); |
| 54 |
| 55 static bool CanEmbedderAccessGuest(int embedder_render_process_id, |
| 56 GuestViewBase* guest); |
| 57 |
| 58 // Counts RenderProcessHost IDs of GuestViewBases. |
| 59 std::multiset<int> render_process_host_id_multiset_; |
| 60 |
| 61 // Contains guests' WebContents, mapping from their instance ids. |
| 62 typedef std::map<int, content::WebContents*> GuestInstanceMap; |
| 63 GuestInstanceMap guest_web_contents_by_instance_id_; |
| 64 |
| 65 int current_instance_id_; |
| 66 content::BrowserContext* context_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); |
| 69 }; |
| 70 |
| 71 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
OLD | NEW |