| Index: content/browser/wake_lock/wake_lock_service_context.cc | 
| diff --git a/content/browser/wake_lock/wake_lock_service_context.cc b/content/browser/wake_lock/wake_lock_service_context.cc | 
| index 7a706e8582da83c58305cda7e8ceb5517e97495a..1f0f0c56f80643d247c2a518d0982b14afe71474 100644 | 
| --- a/content/browser/wake_lock/wake_lock_service_context.cc | 
| +++ b/content/browser/wake_lock/wake_lock_service_context.cc | 
| @@ -13,6 +13,7 @@ | 
| #include "content/public/browser/power_save_blocker_factory.h" | 
| #include "content/public/browser/render_frame_host.h" | 
| #include "content/public/browser/render_process_host.h" | 
| +#include "content/public/browser/web_contents.h" | 
| #include "content/public/common/service_registry.h" | 
|  | 
| namespace content { | 
| @@ -36,6 +37,12 @@ void WakeLockServiceContext::RenderFrameDeleted( | 
| render_frame_host->GetRoutingID()); | 
| } | 
|  | 
| +void WakeLockServiceContext::WebContentsDestroyed() { | 
| +#if defined(OS_ANDROID) | 
| +  view_weak_factory_.reset(); | 
| +#endif | 
| +} | 
| + | 
| void WakeLockServiceContext::RequestWakeLock(int render_process_id, | 
| int render_frame_id) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| @@ -69,8 +76,12 @@ void WakeLockServiceContext::CreateWakeLock() { | 
| // On Android, additionaly associate the blocker with this WebContents. | 
| DCHECK(web_contents()); | 
|  | 
| -  static_cast<PowerSaveBlockerImpl*>(wake_lock_.get()) | 
| -      ->InitDisplaySleepBlocker(web_contents()); | 
| +  if (web_contents()->GetNativeView()) { | 
| +    view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>( | 
| +        web_contents()->GetNativeView())); | 
| +    static_cast<PowerSaveBlockerImpl*>(wake_lock_.get()) | 
| +        ->InitDisplaySleepBlocker(view_weak_factory_->GetWeakPtr()); | 
| +  } | 
| #endif | 
| } | 
|  | 
|  |