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