Commit 2b6c7d1d authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Removing callers of the WebContents::GetRenderProcessHost() method.

WebContents::GetRenderProcessHost is an API that doesn't behave as
expected with out-of-process iframes, as multiple processes can be
associated with a single WebContents.  This CL replaces callers of this
API, so that they go through an equivalent API that explicitly selects
which frame's process is needed.

This CL was started by using an ad-hoc clang-plugin that replaced
existing callsites of WebContents::GetRenderProcessHost() with a call to
something like wc->GetMainFrame()->GetProcess().  This was followed-up
by manually adding an include of render_frame_host.h and git cl format
and git cl lint and then a self-review with small tweaks (e.g. sometimes
using a wc->GetRenderViewHost()->GetProcess() is more appropriate).

This CL was uploaded by git cl split.

R=tbarzic@chromium.org

Bug: 666525
Change-Id: I9411427ca99d25dd1081871d3db6400e8d16a418
Reviewed-on: https://chromium-review.googlesource.com/689131Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505077}
parent e883cfb3
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include <stdint.h> #include <stdint.h>
#include <algorithm> #include <algorithm>
#include <memory>
#include <set>
#include <utility>
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
...@@ -20,6 +23,7 @@ ...@@ -20,6 +23,7 @@
#include "chrome/common/extensions/api/processes.h" #include "chrome/common/extensions/api/processes.h"
#include "content/public/browser/browser_child_process_host.h" #include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/child_process_data.h" #include "content/public/browser/child_process_data.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h" #include "content/public/common/child_process_host.h"
...@@ -459,7 +463,9 @@ ExtensionFunction::ResponseAction ProcessesGetProcessIdForTabFunction::Run() { ...@@ -459,7 +463,9 @@ ExtensionFunction::ResponseAction ProcessesGetProcessIdForTabFunction::Run() {
base::IntToString(tab_id))); base::IntToString(tab_id)));
} }
const int process_id = contents->GetRenderProcessHost()->GetID(); // TODO(https://crbug.com/767563): chrome.processes.getProcessIdForTab API
// incorrectly assumes a *single* renderer process per tab.
const int process_id = contents->GetMainFrame()->GetProcess()->GetID();
return RespondNow(ArgumentList( return RespondNow(ArgumentList(
api::processes::GetProcessIdForTab::Results::Create(process_id))); api::processes::GetProcessIdForTab::Results::Create(process_id)));
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "content/public/browser/media_device_id.h" #include "content/public/browser/media_device_id.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
...@@ -170,7 +171,7 @@ WebrtcAudioPrivateFunction::GetRenderProcessHostFromRequest( ...@@ -170,7 +171,7 @@ WebrtcAudioPrivateFunction::GetRenderProcessHostFromRequest(
expected_origin.spec().c_str(), security_origin.c_str()); expected_origin.spec().c_str(), security_origin.c_str());
return nullptr; return nullptr;
} }
return contents->GetRenderProcessHost(); return contents->GetMainFrame()->GetProcess();
} }
bool WebrtcAudioPrivateGetSinksFunction::RunAsync() { bool WebrtcAudioPrivateGetSinksFunction::RunAsync() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment