OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // A BrowserPluginGuestManager serves as a message router to BrowserPluginGuests | 5 // A BrowserPluginGuestManager serves as a message router to BrowserPluginGuests |
6 // for all guests within a given profile. | 6 // for all guests within a given profile. |
7 // Messages are routed to a particular guest instance based on an instance_id. | 7 // Messages are routed to a particular guest instance based on an instance_id. |
8 | 8 |
9 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ | 9 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
10 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ | 10 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // ID. | 61 // ID. |
62 int GetNextInstanceID(); | 62 int GetNextInstanceID(); |
63 | 63 |
64 // Creates a guest WebContents with the provided |instance_id| and |params|. | 64 // Creates a guest WebContents with the provided |instance_id| and |params|. |
65 // If params.src is present, the new guest will also be navigated to the | 65 // If params.src is present, the new guest will also be navigated to the |
66 // provided URL. Optionally, the new guest may be attached to a | 66 // provided URL. Optionally, the new guest may be attached to a |
67 // |guest_opener|, and may be attached to a pre-selected |routing_id|. | 67 // |guest_opener|, and may be attached to a pre-selected |routing_id|. |
68 BrowserPluginGuest* CreateGuest( | 68 BrowserPluginGuest* CreateGuest( |
69 SiteInstance* embedder_site_instance, | 69 SiteInstance* embedder_site_instance, |
70 int instance_id, | 70 int instance_id, |
71 const BrowserPluginHostMsg_Attach_Params& params, | 71 const StorageInfo& storage_info, |
72 scoped_ptr<base::DictionaryValue> extra_params); | 72 scoped_ptr<base::DictionaryValue> extra_params); |
73 | 73 |
74 // Adds a new |guest_web_contents| to the embedder (overridable in test). | 74 // Adds a new |guest_web_contents| to the embedder (overridable in test). |
75 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); | 75 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); |
76 | 76 |
77 // Removes the guest with the given |instance_id| from this | 77 // Removes the guest with the given |instance_id| from this |
78 // BrowserPluginGuestManager. | 78 // BrowserPluginGuestManager. |
79 void RemoveGuest(int instance_id); | 79 void RemoveGuest(int instance_id); |
80 | 80 |
81 typedef base::Callback<void(BrowserPluginGuest*)> GuestByInstanceIDCallback; | 81 typedef base::Callback<void(BrowserPluginGuest*)> GuestByInstanceIDCallback; |
82 void MaybeGetGuestByInstanceIDOrKill( | 82 void MaybeGetGuestByInstanceIDOrKill( |
83 int instance_id, | 83 int instance_id, |
84 int embedder_render_process_id, | 84 int embedder_render_process_id, |
85 const GuestByInstanceIDCallback& callback) const; | 85 const GuestByInstanceIDCallback& callback) const; |
86 | 86 |
87 typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback; | 87 typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback; |
88 bool ForEachGuest(WebContents* embedder_web_contents, | 88 bool ForEachGuest(WebContents* embedder_web_contents, |
89 const GuestCallback& callback); | 89 const GuestCallback& callback); |
90 | 90 |
91 void OnMessageReceived(const IPC::Message& message, int render_process_id); | 91 void OnMessageReceived(const IPC::Message& message, int render_process_id); |
92 | 92 |
93 private: | 93 private: |
94 friend class TestBrowserPluginGuestManager; | 94 friend class TestBrowserPluginGuestManager; |
95 | 95 |
96 explicit BrowserPluginGuestManager(BrowserContext* context); | 96 explicit BrowserPluginGuestManager(BrowserContext* context); |
97 | 97 |
98 // Returns an existing SiteInstance if the current profile has a guest of the | |
99 // given |guest_site|. | |
100 SiteInstance* GetGuestSiteInstance(const GURL& guest_site); | |
101 | |
102 // Static factory instance (always NULL outside of tests). | 98 // Static factory instance (always NULL outside of tests). |
103 static BrowserPluginHostFactory* factory_; | 99 static BrowserPluginHostFactory* factory_; |
104 | 100 |
105 // The BrowserContext in which this manager this stored. | 101 // The BrowserContext in which this manager this stored. |
106 BrowserContext* context_; | 102 BrowserContext* context_; |
107 | 103 |
108 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager); | 104 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager); |
109 }; | 105 }; |
110 | 106 |
111 } // namespace content | 107 } // namespace content |
112 | 108 |
113 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ | 109 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
OLD | NEW |