Index: content/browser/browser_plugin/browser_plugin_guest_manager.h |
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.h b/content/browser/browser_plugin/browser_plugin_guest_manager.h |
index 10c6b24ca6fe2c76e49fde33ec1972fac8bce4fd..e080e0f0c6d2dd0ca82905b054465550c3bf48d0 100644 |
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.h |
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.h |
@@ -13,6 +13,7 @@ |
#include "base/supports_user_data.h" |
#include "base/values.h" |
#include "content/common/content_export.h" |
+#include "content/public/browser/browser_plugin_guest_manager_delegate.h" |
#include "ipc/ipc_message.h" |
struct BrowserPluginHostMsg_Attach_Params; |
@@ -29,12 +30,12 @@ class Message; |
namespace content { |
+class BrowserContext; |
class BrowserPluginGuest; |
class BrowserPluginHostFactory; |
class RenderWidgetHostImpl; |
class SiteInstance; |
class WebContents; |
-class WebContentsImpl; |
// WARNING: All APIs should be guarded with a process ID check like |
// CanEmbedderAccessInstanceIDMaybeKill, to prevent abuse by normal renderer |
@@ -44,7 +45,11 @@ class CONTENT_EXPORT BrowserPluginGuestManager : |
public: |
virtual ~BrowserPluginGuestManager(); |
- static BrowserPluginGuestManager* Create(); |
+ static BrowserPluginGuestManager* FromBrowserContext(BrowserContext* context); |
+ |
+ BrowserPluginGuestManagerDelegate* GetDelegate() const; |
+ |
+ static BrowserPluginGuestManager* Create(BrowserContext* context); |
// Overrides factory for testing. Default (NULL) value indicates regular |
// (non-test) environment. |
@@ -53,7 +58,7 @@ class CONTENT_EXPORT BrowserPluginGuestManager : |
} |
// Gets the next available instance id. |
lazyboy
2014/05/01 20:06:59
Can you also add a comment saying 0 is an invalid
Fady Samuel
2014/05/01 21:05:28
Done.
|
- int get_next_instance_id() { return ++next_instance_id_; } |
+ int GetNextInstanceID(); |
// Creates a guest WebContents with the provided |instance_id| and |params|. |
// If params.src is present, the new guest will also be navigated to the |
@@ -73,7 +78,7 @@ class CONTENT_EXPORT BrowserPluginGuestManager : |
int embedder_render_process_id) const; |
// Adds a new |guest_web_contents| to the embedder (overridable in test). |
- virtual void AddGuest(int instance_id, WebContentsImpl* guest_web_contents); |
+ virtual void AddGuest(int instance_id, WebContents* guest_web_contents); |
// Removes the guest with the given |instance_id| from this |
// BrowserPluginGuestManager. |
@@ -85,29 +90,20 @@ class CONTENT_EXPORT BrowserPluginGuestManager : |
int instance_id) const; |
typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback; |
- bool ForEachGuest(WebContentsImpl* embedder_web_contents, |
+ bool ForEachGuest(WebContents* embedder_web_contents, |
const GuestCallback& callback); |
+ typedef BrowserPluginGuestManagerDelegate::InstanceIDResponseCallback |
+ InstanceIDResponseCallback; |
+ void RequestInstanceID(const std::string& src, |
+ const InstanceIDResponseCallback& callback); |
+ |
void OnMessageReceived(const IPC::Message& message, int render_process_id); |
private: |
friend class TestBrowserPluginGuestManager; |
- BrowserPluginGuestManager(); |
- |
- // Returns whether the given embedder process is allowed to access the |
- // provided |guest|. |
- static bool CanEmbedderAccessGuest(int embedder_render_process_id, |
- BrowserPluginGuest* guest); |
- |
- // Returns whether the given embedder process is allowed to use the provided |
- // |instance_id| or access the guest associated with the |instance_id|. If the |
- // embedder can, the method returns true. If the guest does not exist but the |
- // embedder can use that |instance_id|, then it returns true. If the embedder |
- // is not permitted to use that instance ID or access the associated guest, |
- // then it returns false. |
- bool CanEmbedderAccessInstanceID(int embedder_render_process_id, |
- int instance_id) const; |
+ explicit BrowserPluginGuestManager(BrowserContext* context); |
// Returns an existing SiteInstance if the current profile has a guest of the |
// given |guest_site|. |
@@ -116,10 +112,8 @@ class CONTENT_EXPORT BrowserPluginGuestManager : |
// Static factory instance (always NULL outside of tests). |
static BrowserPluginHostFactory* factory_; |
- // Contains guests' WebContents, mapping from their instance ids. |
- typedef std::map<int, WebContentsImpl*> GuestInstanceMap; |
- GuestInstanceMap guest_web_contents_by_instance_id_; |
- int next_instance_id_; |
+ // The BrowserContext in which this manager this stored. |
+ BrowserContext* context_; |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager); |
}; |
@@ -127,4 +121,3 @@ class CONTENT_EXPORT BrowserPluginGuestManager : |
} // namespace content |
#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
- |