Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/chromeos/display/output_protection_delegate.cc

Issue 1122353002: PepperOutputProtectionMessageFilter: set window_ only when client_id_ is valid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/display/output_protection_delegate.h" 5 #include "chrome/browser/chromeos/display/output_protection_delegate.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/render_frame_host.h" 12 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 namespace { 18 namespace {
19 19
20 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { 20 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) {
21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
22 DCHECK(rfh);
23 DCHECK(display_id);
24
22 gfx::NativeView native_view = rfh->GetNativeView(); 25 gfx::NativeView native_view = rfh->GetNativeView();
23 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); 26 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
24 if (!screen) 27 if (!screen)
25 return false; 28 return false;
26 gfx::Display display = screen->GetDisplayNearestWindow(native_view); 29 gfx::Display display = screen->GetDisplayNearestWindow(native_view);
27 *display_id = display.id(); 30 *display_id = display.id();
28 return true; 31 return true;
29 } 32 }
30 33
31 void DoNothing(bool status) { 34 void DoNothing(bool status) {
(...skipping 22 matching lines...) Expand all
54 if (window_) 57 if (window_)
55 window_->RemoveObserver(this); 58 window_->RemoveObserver(this);
56 } 59 }
57 60
58 ui::DisplayConfigurator::ContentProtectionClientId 61 ui::DisplayConfigurator::ContentProtectionClientId
59 OutputProtectionDelegate::GetClientId() { 62 OutputProtectionDelegate::GetClientId() {
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
61 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { 64 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) {
62 content::RenderFrameHost* rfh = 65 content::RenderFrameHost* rfh =
63 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 66 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
64 if (!GetCurrentDisplayId(rfh, &display_id_)) 67 if (!rfh || !GetCurrentDisplayId(rfh, &display_id_))
65 return ui::DisplayConfigurator::kInvalidClientId; 68 return ui::DisplayConfigurator::kInvalidClientId;
66 69
67 window_ = rfh->GetNativeView(); 70 aura::Window* window = rfh->GetNativeView();
68 if (!window_) 71 if (!window)
69 return ui::DisplayConfigurator::kInvalidClientId; 72 return ui::DisplayConfigurator::kInvalidClientId;
70 73
71 ui::DisplayConfigurator* configurator = 74 ui::DisplayConfigurator* configurator =
72 ash::Shell::GetInstance()->display_configurator(); 75 ash::Shell::GetInstance()->display_configurator();
73 client_id_ = configurator->RegisterContentProtectionClient(); 76 client_id_ = configurator->RegisterContentProtectionClient();
74 77
75 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) 78 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) {
76 window_->AddObserver(this); 79 window->AddObserver(this);
80 window_ = window;
81 }
77 } 82 }
78 return client_id_; 83 return client_id_;
79 } 84 }
80 85
81 void OutputProtectionDelegate::QueryStatus( 86 void OutputProtectionDelegate::QueryStatus(
82 const QueryStatusCallback& callback) { 87 const QueryStatusCallback& callback) {
83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 88 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
84 89
85 content::RenderFrameHost* rfh = 90 content::RenderFrameHost* rfh =
86 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 91 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 display_id_ = new_display_id; 184 display_id_ = new_display_id;
180 } 185 }
181 186
182 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { 187 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) {
183 DCHECK_EQ(window, window_); 188 DCHECK_EQ(window, window_);
184 window_->RemoveObserver(this); 189 window_->RemoveObserver(this);
185 window_ = nullptr; 190 window_ = nullptr;
186 } 191 }
187 192
188 } // namespace chromeos 193 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698