| 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 CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 | 12 |
| 13 class GURL; | 13 class GURL; |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class DictionaryValue; | 16 class DictionaryValue; |
| 17 } // namespace base | 17 } // namespace base |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class SiteInstance; | 21 class SiteInstance; |
| 22 class WebContents; | 22 class WebContents; |
| 23 | 23 |
| 24 // A BrowserPluginGuestManager offloads guest management and routing | 24 // A BrowserPluginGuestManager offloads guest management and routing |
| 25 // operations outside of the content layer. | 25 // operations outside of the content layer. |
| 26 class CONTENT_EXPORT BrowserPluginGuestManager { | 26 class CONTENT_EXPORT BrowserPluginGuestManager { |
| 27 public: | 27 public: |
| 28 virtual ~BrowserPluginGuestManager() {} | 28 virtual ~BrowserPluginGuestManager() {} |
| 29 | 29 |
| 30 // Requests the allocation of a new guest WebContents. | |
| 31 virtual content::WebContents* CreateGuest( | |
| 32 content::SiteInstance* embedder_site_instance, | |
| 33 int instance_id, | |
| 34 scoped_ptr<base::DictionaryValue> extra_params); | |
| 35 | |
| 36 // Return a new instance ID. | |
| 37 // TODO(fsamuel): Remove this. Once the instance ID concept is moved | |
| 38 // entirely out of content and into chrome, this API will be unnecessary. | |
| 39 virtual int GetNextInstanceID(); | |
| 40 | |
| 41 typedef base::Callback<void(WebContents*)> GuestByInstanceIDCallback; | 30 typedef base::Callback<void(WebContents*)> GuestByInstanceIDCallback; |
| 42 // Requests a guest WebContents associated with the provided | 31 // Requests a guest WebContents associated with the provided |
| 43 // |guest_instance_id|. If a guest associated with the provided ID | 32 // |guest_instance_id|. If a guest associated with the provided ID |
| 44 // does not exist, then the |callback| will be called with a NULL | 33 // does not exist, then the |callback| will be called with a NULL |
| 45 // WebContents. If the provided |embedder_render_process_id| does | 34 // WebContents. If the provided |embedder_render_process_id| does |
| 46 // not own the requested guest, then the embedder will be killed, | 35 // not own the requested guest, then the embedder will be killed, |
| 47 // and the |callback| will not be called. | 36 // and the |callback| will not be called. |
| 48 virtual void MaybeGetGuestByInstanceIDOrKill( | 37 virtual void MaybeGetGuestByInstanceIDOrKill( |
| 49 int guest_instance_id, | 38 int guest_instance_id, |
| 50 int embedder_render_process_id, | 39 int embedder_render_process_id, |
| 51 const GuestByInstanceIDCallback& callback) {} | 40 const GuestByInstanceIDCallback& callback) {} |
| 52 | 41 |
| 53 // Iterates over all WebContents belonging to a given |embedder_web_contents|, | 42 // Iterates over all WebContents belonging to a given |embedder_web_contents|, |
| 54 // calling |callback| for each. If one of the callbacks returns true, then | 43 // calling |callback| for each. If one of the callbacks returns true, then |
| 55 // the iteration exits early. | 44 // the iteration exits early. |
| 56 typedef base::Callback<bool(WebContents*)> GuestCallback; | 45 typedef base::Callback<bool(WebContents*)> GuestCallback; |
| 57 virtual bool ForEachGuest(WebContents* embedder_web_contents, | 46 virtual bool ForEachGuest(WebContents* embedder_web_contents, |
| 58 const GuestCallback& callback); | 47 const GuestCallback& callback); |
| 59 }; | 48 }; |
| 60 | 49 |
| 61 } // namespace content | 50 } // namespace content |
| 62 | 51 |
| 63 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_MANAGER_H_ | 52 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_MANAGER_H_ |
| OLD | NEW |