Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest_manager.h

Issue 261013005: BrowserPlugin: Move CreateGuest to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_simplify_api
Patch Set: Fixed content_browsertests after a change Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 // Gets the next available instance id. 0 is considered an invalid instance 60 // Gets the next available instance id. 0 is considered an invalid instance
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 virtual 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 std::string& storage_partition_id,
72 bool persist_storage,
72 scoped_ptr<base::DictionaryValue> extra_params); 73 scoped_ptr<base::DictionaryValue> extra_params);
73 74
74 // Adds a new |guest_web_contents| to the embedder (overridable in test).
75 virtual void AddGuest(int instance_id, WebContents* guest_web_contents);
76
77 // Removes the guest with the given |instance_id| from this
78 // BrowserPluginGuestManager.
79 void RemoveGuest(int instance_id);
80
81 typedef base::Callback<void(BrowserPluginGuest*)> GuestByInstanceIDCallback; 75 typedef base::Callback<void(BrowserPluginGuest*)> GuestByInstanceIDCallback;
82 void MaybeGetGuestByInstanceIDOrKill( 76 void MaybeGetGuestByInstanceIDOrKill(
83 int instance_id, 77 int instance_id,
84 int embedder_render_process_id, 78 int embedder_render_process_id,
85 const GuestByInstanceIDCallback& callback) const; 79 const GuestByInstanceIDCallback& callback) const;
86 80
87 typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback; 81 typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback;
88 bool ForEachGuest(WebContents* embedder_web_contents, 82 bool ForEachGuest(WebContents* embedder_web_contents,
89 const GuestCallback& callback); 83 const GuestCallback& callback);
90 84
91 void OnMessageReceived(const IPC::Message& message, int render_process_id); 85 void OnMessageReceived(const IPC::Message& message, int render_process_id);
92 86
93 private: 87 private:
94 friend class TestBrowserPluginGuestManager; 88 friend class TestBrowserPluginGuestManager;
95 89
96 explicit BrowserPluginGuestManager(BrowserContext* context); 90 explicit BrowserPluginGuestManager(BrowserContext* context);
97 91
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). 92 // Static factory instance (always NULL outside of tests).
103 static BrowserPluginHostFactory* factory_; 93 static BrowserPluginHostFactory* factory_;
104 94
105 // The BrowserContext in which this manager this stored. 95 // The BrowserContext in which this manager this stored.
106 BrowserContext* context_; 96 BrowserContext* context_;
107 97
108 // Contains guests' WebContents, mapping from their instance ids. 98 // Contains guests' WebContents, mapping from their instance ids.
109 typedef std::map<int, WebContents*> GuestInstanceMap; 99 typedef std::map<int, WebContents*> GuestInstanceMap;
110 GuestInstanceMap guest_web_contents_by_instance_id_; 100 GuestInstanceMap guest_web_contents_by_instance_id_;
111 int next_instance_id_; 101 int next_instance_id_;
112 102
113 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager); 103 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager);
114 }; 104 };
115 105
116 } // namespace content 106 } // namespace content
117 107
118 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ 108 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.cc ('k') | content/browser/browser_plugin/browser_plugin_guest_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698