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

Unified Diff: content/browser/browser_plugin/browser_plugin_guest_manager.cc

Issue 264943006: BrowserPlugin: Simplify content/public API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_v1
Patch Set: Fixed nit 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_guest_manager.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
index 4bc4235a6ca4dfeb8a603821263b737aefda5d0b..8e44c7f0e1a12c4d7f9f573c503a9e4f96d9bdb0 100644
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
@@ -121,18 +121,31 @@ BrowserPluginGuest* BrowserPluginGuestManager::CreateGuest(
extra_params.Pass());
}
-BrowserPluginGuest* BrowserPluginGuestManager::GetGuestByInstanceID(
- int instance_id,
- int embedder_render_process_id) const {
- if (!GetDelegate())
- return NULL;
+static void BrowserPluginGuestByInstanceIDCallback(
+ const BrowserPluginGuestManager::GuestByInstanceIDCallback& callback,
+ WebContents* guest_web_contents) {
+ if (!guest_web_contents) {
+ callback.Run(NULL);
+ return;
+ }
+ callback.Run(static_cast<WebContentsImpl*>(guest_web_contents)->
+ GetBrowserPluginGuest());
+}
- WebContentsImpl* guest_web_contents = static_cast<WebContentsImpl*>(
- GetDelegate()->GetGuestByInstanceID(instance_id,
- embedder_render_process_id));
+void BrowserPluginGuestManager::MaybeGetGuestByInstanceIDOrKill(
+ int instance_id,
+ int embedder_render_process_id,
+ const GuestByInstanceIDCallback& callback) const {
+ if (!GetDelegate()) {
+ callback.Run(NULL);
+ return;
+ }
- return guest_web_contents ?
- guest_web_contents->GetBrowserPluginGuest() : NULL;
+ GetDelegate()->MaybeGetGuestByInstanceIDOrKill(
+ instance_id,
+ embedder_render_process_id,
+ base::Bind(&BrowserPluginGuestByInstanceIDCallback,
+ callback));
}
void BrowserPluginGuestManager::AddGuest(int instance_id,
@@ -148,14 +161,11 @@ void BrowserPluginGuestManager::RemoveGuest(int instance_id) {
GetDelegate()->RemoveGuest(instance_id);
}
-bool BrowserPluginGuestManager::CanEmbedderAccessInstanceIDMaybeKill(
- int embedder_render_process_id,
- int instance_id) const {
- if (!GetDelegate())
- return false;
-
- return GetDelegate()->CanEmbedderAccessInstanceIDMaybeKill(
- embedder_render_process_id, instance_id);
+static void BrowserPluginGuestMessageCallback(const IPC::Message& message,
+ BrowserPluginGuest* guest) {
+ if (!guest)
+ return;
+ guest->OnMessageReceivedFromEmbedder(message);
}
void BrowserPluginGuestManager::OnMessageReceived(const IPC::Message& message,
@@ -166,11 +176,10 @@ void BrowserPluginGuestManager::OnMessageReceived(const IPC::Message& message,
PickleIterator iter(message);
bool success = iter.ReadInt(&instance_id);
DCHECK(success);
- BrowserPluginGuest* guest =
- GetGuestByInstanceID(instance_id, render_process_id);
- if (!guest)
- return;
- guest->OnMessageReceivedFromEmbedder(message);
+ MaybeGetGuestByInstanceIDOrKill(instance_id,
+ render_process_id,
+ base::Bind(&BrowserPluginGuestMessageCallback,
+ message));
}
SiteInstance* BrowserPluginGuestManager::GetGuestSiteInstance(

Powered by Google App Engine
This is Rietveld 408576698