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