Commit 246e2d1e authored by xhwang's avatar xhwang Committed by Commit bot

PepperOutputProtectionMessageFilter: set window_ only when client_id_ is valid.

TBR=kcwu@chromium.org
BUG=484857
TEST=No crash now.

Review URL: https://codereview.chromium.org/1122353002

Cr-Commit-Position: refs/heads/master@{#330494}
parent 18082458
...@@ -19,6 +19,9 @@ namespace { ...@@ -19,6 +19,9 @@ namespace {
bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(rfh);
DCHECK(display_id);
gfx::NativeView native_view = rfh->GetNativeView(); gfx::NativeView native_view = rfh->GetNativeView();
gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
if (!screen) if (!screen)
...@@ -61,19 +64,21 @@ OutputProtectionDelegate::GetClientId() { ...@@ -61,19 +64,21 @@ OutputProtectionDelegate::GetClientId() {
if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) {
content::RenderFrameHost* rfh = content::RenderFrameHost* rfh =
content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
if (!GetCurrentDisplayId(rfh, &display_id_)) if (!rfh || !GetCurrentDisplayId(rfh, &display_id_))
return ui::DisplayConfigurator::kInvalidClientId; return ui::DisplayConfigurator::kInvalidClientId;
window_ = rfh->GetNativeView(); aura::Window* window = rfh->GetNativeView();
if (!window_) if (!window)
return ui::DisplayConfigurator::kInvalidClientId; return ui::DisplayConfigurator::kInvalidClientId;
ui::DisplayConfigurator* configurator = ui::DisplayConfigurator* configurator =
ash::Shell::GetInstance()->display_configurator(); ash::Shell::GetInstance()->display_configurator();
client_id_ = configurator->RegisterContentProtectionClient(); client_id_ = configurator->RegisterContentProtectionClient();
if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) {
window_->AddObserver(this); window->AddObserver(this);
window_ = window;
}
} }
return client_id_; return client_id_;
} }
......
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