| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/power/renderer_freezer.h" | 5 #include "chrome/browser/chromeos/power/renderer_freezer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 void RendererFreezer::OnScreenLockStateChanged(chromeos::ScreenLocker* locker, | 142 void RendererFreezer::OnScreenLockStateChanged(chromeos::ScreenLocker* locker, |
| 143 bool is_locked) { | 143 bool is_locked) { |
| 144 // The ScreenLocker class sends NOTIFICATION_SCREEN_LOCK_STATE_CHANGED when | 144 // The ScreenLocker class sends NOTIFICATION_SCREEN_LOCK_STATE_CHANGED when |
| 145 // the lock screen becomes ready, resulting in this code running synchronously | 145 // the lock screen becomes ready, resulting in this code running synchronously |
| 146 // to mark the screen locker renderer to remain unfrozen during a suspend | 146 // to mark the screen locker renderer to remain unfrozen during a suspend |
| 147 // request. Since this happens before the PowerManagerClient calls | 147 // request. Since this happens before the PowerManagerClient calls |
| 148 // RendererFreezer::SuspendImminent(), it is guaranteed that the screen locker | 148 // RendererFreezer::SuspendImminent(), it is guaranteed that the screen locker |
| 149 // renderer will not be frozen at any point. | 149 // renderer will not be frozen at any point. |
| 150 if (is_locked) { | 150 if (is_locked) { |
| 151 delegate_->SetShouldFreezeRenderer(locker->delegate() | 151 // |web_contents| is null when using views-based login/lock screen. |
| 152 ->GetWebContents() | 152 // TODO(jdufault): Remove this code after webui login/lock is gone. See |
| 153 ->GetRenderProcessHost() | 153 // crbug.com/719015. |
| 154 ->GetHandle(), | 154 content::WebContents* web_contents = locker->delegate()->GetWebContents(); |
| 155 false); | 155 if (web_contents) { |
| 156 delegate_->SetShouldFreezeRenderer( |
| 157 web_contents->GetRenderProcessHost()->GetHandle(), false); |
| 158 } |
| 156 } | 159 } |
| 157 } | 160 } |
| 158 | 161 |
| 159 void RendererFreezer::OnRenderProcessCreated(content::RenderProcessHost* rph) { | 162 void RendererFreezer::OnRenderProcessCreated(content::RenderProcessHost* rph) { |
| 160 const int rph_id = rph->GetID(); | 163 const int rph_id = rph->GetID(); |
| 161 | 164 |
| 162 if (gcm_extension_processes_.find(rph_id) != gcm_extension_processes_.end()) { | 165 if (gcm_extension_processes_.find(rph_id) != gcm_extension_processes_.end()) { |
| 163 LOG(ERROR) << "Received duplicate notifications about the creation of a " | 166 LOG(ERROR) << "Received duplicate notifications about the creation of a " |
| 164 << "RenderProcessHost with id " << rph_id; | 167 << "RenderProcessHost with id " << rph_id; |
| 165 return; | 168 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 rph->AddObserver(this); | 202 rph->AddObserver(this); |
| 200 return; | 203 return; |
| 201 } | 204 } |
| 202 | 205 |
| 203 // We didn't find an extension in this RenderProcessHost that is using GCM so | 206 // We didn't find an extension in this RenderProcessHost that is using GCM so |
| 204 // we can go ahead and freeze it on suspend. | 207 // we can go ahead and freeze it on suspend. |
| 205 delegate_->SetShouldFreezeRenderer(rph->GetHandle(), true); | 208 delegate_->SetShouldFreezeRenderer(rph->GetHandle(), true); |
| 206 } | 209 } |
| 207 | 210 |
| 208 } // namespace chromeos | 211 } // namespace chromeos |
| OLD | NEW |