| 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" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "content/public/browser/browser_plugin_guest_manager.h" | 13 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 14 #include "content/public/browser/site_instance.h" | 14 #include "content/public/browser/site_instance.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 | 16 |
| 17 class GuestViewBase; | 17 class GuestViewBase; |
| 18 class GuestViewManagerFactory; | 18 class GuestViewManagerFactory; |
| 19 class GURL; | 19 class GURL; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 class BrowserContext; | 22 class BrowserContext; |
| 23 class WebContents; |
| 23 } // namespace content | 24 } // namespace content |
| 24 | 25 |
| 25 class GuestViewManager : public content::BrowserPluginGuestManager, | 26 class GuestViewManager : public content::BrowserPluginGuestManager, |
| 26 public base::SupportsUserData::Data { | 27 public base::SupportsUserData::Data { |
| 27 public: | 28 public: |
| 28 explicit GuestViewManager(content::BrowserContext* context); | 29 explicit GuestViewManager(content::BrowserContext* context); |
| 29 virtual ~GuestViewManager(); | 30 virtual ~GuestViewManager(); |
| 30 | 31 |
| 31 static GuestViewManager* FromBrowserContext(content::BrowserContext* context); | 32 static GuestViewManager* FromBrowserContext(content::BrowserContext* context); |
| 32 | 33 |
| 33 // Overrides factory for testing. Default (NULL) value indicates regular | 34 // Overrides factory for testing. Default (NULL) value indicates regular |
| 34 // (non-test) environment. | 35 // (non-test) environment. |
| 35 static void set_factory_for_testing(GuestViewManagerFactory* factory) { | 36 static void set_factory_for_testing(GuestViewManagerFactory* factory) { |
| 36 GuestViewManager::factory_ = factory; | 37 GuestViewManager::factory_ = factory; |
| 37 } | 38 } |
| 38 // Returns the guest WebContents associated with the given |guest_instance_id| | 39 // Returns the guest WebContents associated with the given |guest_instance_id| |
| 39 // if the provided |embedder_render_process_id| is allowed to access it. | 40 // if the provided |embedder_render_process_id| is allowed to access it. |
| 40 // If the embedder is not allowed access, the embedder will be killed, and | 41 // If the embedder is not allowed access, the embedder will be killed, and |
| 41 // this method will return NULL. If no WebContents exists with the given | 42 // this method will return NULL. If no WebContents exists with the given |
| 42 // instance ID, then NULL will also be returned. | 43 // instance ID, then NULL will also be returned. |
| 43 content::WebContents* GetGuestByInstanceIDSafely( | 44 content::WebContents* GetGuestByInstanceIDSafely( |
| 44 int guest_instance_id, | 45 int guest_instance_id, |
| 45 int embedder_render_process_id); | 46 int embedder_render_process_id); |
| 46 | 47 |
| 47 int GetNextInstanceID(); | 48 int GetNextInstanceID(); |
| 48 | 49 |
| 49 typedef base::Callback<void(content::WebContents*)> | 50 typedef base::Callback<void(content::WebContents*)> |
| 50 WebContentsCreatedCallback; | 51 WebContentsCreatedCallback; |
| 51 void CreateGuest( | 52 void CreateGuest(const std::string& view_type, |
| 52 const std::string& view_type, | 53 const std::string& embedder_extension_id, |
| 53 const std::string& embedder_extension_id, | 54 content::WebContents* embedder_web_contents, |
| 54 int embedder_render_process_id, | 55 const base::DictionaryValue& create_params, |
| 55 const base::DictionaryValue& create_params, | 56 const WebContentsCreatedCallback& callback); |
| 56 const WebContentsCreatedCallback& callback); | |
| 57 | 57 |
| 58 content::WebContents* CreateGuestWithWebContentsParams( | 58 content::WebContents* CreateGuestWithWebContentsParams( |
| 59 const std::string& view_type, | 59 const std::string& view_type, |
| 60 const std::string& embedder_extension_id, | 60 const std::string& embedder_extension_id, |
| 61 int embedder_render_process_id, | 61 int embedder_render_process_id, |
| 62 const content::WebContents::CreateParams& create_params); | 62 const content::WebContents::CreateParams& create_params); |
| 63 | 63 |
| 64 content::SiteInstance* GetGuestSiteInstance( | 64 content::SiteInstance* GetGuestSiteInstance( |
| 65 const GURL& guest_site); | 65 const GURL& guest_site); |
| 66 | 66 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // The remaining instance IDs that are greater than | 114 // The remaining instance IDs that are greater than |
| 115 // |last_instance_id_removed_| are kept here. | 115 // |last_instance_id_removed_| are kept here. |
| 116 std::set<int> removed_instance_ids_; | 116 std::set<int> removed_instance_ids_; |
| 117 | 117 |
| 118 content::BrowserContext* context_; | 118 content::BrowserContext* context_; |
| 119 | 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); | 120 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 123 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| OLD | NEW |