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

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

Issue 264943006: BrowserPlugin: Simplify content/public API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_v1
Patch Set: 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 BrowserPluginHostMsg_Attach_Params& params,
72 scoped_ptr<base::DictionaryValue> extra_params); 72 scoped_ptr<base::DictionaryValue> extra_params);
73 73
74 // Returns a BrowserPluginGuest given an |instance_id|. Returns NULL if the
75 // guest wasn't found. If the embedder is not permitted to access the given
76 // |instance_id|, the embedder is killed, and NULL is returned.
77 BrowserPluginGuest* GetGuestByInstanceID(
78 int instance_id,
79 int embedder_render_process_id) const;
80
81 // 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).
82 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); 75 virtual void AddGuest(int instance_id, WebContents* guest_web_contents);
83 76
84 // Removes the guest with the given |instance_id| from this 77 // Removes the guest with the given |instance_id| from this
85 // BrowserPluginGuestManager. 78 // BrowserPluginGuestManager.
86 void RemoveGuest(int instance_id); 79 void RemoveGuest(int instance_id);
87 80
88 // Returns whether the specified embedder is permitted to access the given 81 typedef base::Callback<void(BrowserPluginGuest*)> GuestByInstanceIDCallback;
lazyboy 2014/05/01 23:27:58 optional: GuestByInstanceIDCallback can be improve
Fady Samuel 2014/05/06 16:51:36 This whole file is going away in a couple of CLs a
lazyboy 2014/05/06 18:03:54 SG.
89 // |instance_id|, and kills the embedder if not. 82 void MaybeGetGuestByInstanceIDOrKill(
90 bool CanEmbedderAccessInstanceIDMaybeKill(int embedder_render_process_id, 83 int instance_id,
91 int instance_id) const; 84 int embedder_render_process_id,
85 const GuestByInstanceIDCallback& callback) const;
92 86
93 typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback; 87 typedef base::Callback<bool(BrowserPluginGuest*)> GuestCallback;
94 bool ForEachGuest(WebContents* embedder_web_contents, 88 bool ForEachGuest(WebContents* embedder_web_contents,
95 const GuestCallback& callback); 89 const GuestCallback& callback);
96 90
97 void OnMessageReceived(const IPC::Message& message, int render_process_id); 91 void OnMessageReceived(const IPC::Message& message, int render_process_id);
98 92
99 private: 93 private:
100 friend class TestBrowserPluginGuestManager; 94 friend class TestBrowserPluginGuestManager;
101 95
102 explicit BrowserPluginGuestManager(BrowserContext* context); 96 explicit BrowserPluginGuestManager(BrowserContext* context);
103 97
104 // Returns an existing SiteInstance if the current profile has a guest of the 98 // Returns an existing SiteInstance if the current profile has a guest of the
105 // given |guest_site|. 99 // given |guest_site|.
106 SiteInstance* GetGuestSiteInstance(const GURL& guest_site); 100 SiteInstance* GetGuestSiteInstance(const GURL& guest_site);
107 101
108 // Static factory instance (always NULL outside of tests). 102 // Static factory instance (always NULL outside of tests).
109 static BrowserPluginHostFactory* factory_; 103 static BrowserPluginHostFactory* factory_;
110 104
111 // The BrowserContext in which this manager this stored. 105 // The BrowserContext in which this manager this stored.
112 BrowserContext* context_; 106 BrowserContext* context_;
113 107
114 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager); 108 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuestManager);
115 }; 109 };
116 110
117 } // namespace content 111 } // namespace content
118 112
119 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_ 113 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698