Commit 254b5995 authored by Tommy C. Li's avatar Tommy C. Li

Plugin Power Saver: Add missing RenderFrame null-checks in placeholders

PluginPlaceholders are RenderFrameObservers, and render_frames can
go away before the object is actually destructed (during shutdown).

This CL adds the missing null checks needed to prevent trying to use
null pointers.

BUG=693120
R=raymes@chromium.org

Review-Url: https://codereview.chromium.org/2845413002 .
Cr-Commit-Position: refs/heads/master@{#468451}
parent 770e6852
......@@ -233,6 +233,9 @@ void ChromePluginPlaceholder::PluginListChanged() {
if (!GetFrame() || !plugin())
return;
// Checking with GetFrame() is equivalent to checking render_frame().
DCHECK(render_frame());
ChromeViewHostMsg_GetPluginInfo_Output output;
std::string mime_type(GetPluginParams().mime_type.Utf8());
render_frame()->Send(new ChromeViewHostMsg_GetPluginInfo(
......@@ -289,6 +292,8 @@ void ChromePluginPlaceholder::ShowContextMenu(
const blink::WebMouseEvent& event) {
if (context_menu_request_id_)
return; // Don't allow nested context menu requests.
if (!render_frame())
return;
content::ContextMenuParams params;
......@@ -361,6 +366,7 @@ blink::WebPlugin* ChromePluginPlaceholder::CreatePlugin() {
}
void ChromePluginPlaceholder::OnBlockedTinyContent() {
DCHECK(render_frame());
if (did_send_blocked_content_notification_)
return;
......
......@@ -41,6 +41,7 @@ void LoadablePluginPlaceholder::BlockForPowerSaverPoster() {
DCHECK(!is_blocked_for_power_saver_poster_);
is_blocked_for_power_saver_poster_ = true;
DCHECK(render_frame());
render_frame()->RegisterPeripheralPlugin(
url::Origin(GURL(GetPluginParams().url)),
base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential,
......@@ -181,6 +182,8 @@ v8::Local<v8::Object> LoadablePluginPlaceholder::GetV8ScriptableObject(
void LoadablePluginPlaceholder::OnUnobscuredRectUpdate(
const gfx::Rect& unobscured_rect) {
DCHECK(content::RenderThread::Get());
if (!render_frame())
return;
if (!plugin() || !finished_loading_)
return;
......
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