| OLD | NEW |
| 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_t* display_id) { |
| 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 22 DCHECK(rfh); | 22 DCHECK(rfh); |
| 23 DCHECK(display_id); | 23 DCHECK(display_id); |
| 24 | 24 |
| 25 gfx::NativeView native_view = rfh->GetNativeView(); | 25 gfx::NativeView native_view = rfh->GetNativeView(); |
| 26 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); | 26 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); |
| 27 if (!screen) | 27 if (!screen) |
| 28 return false; | 28 return false; |
| 29 gfx::Display display = screen->GetDisplayNearestWindow(native_view); | 29 gfx::Display display = screen->GetDisplayNearestWindow(native_view); |
| 30 *display_id = display.id(); | 30 *display_id = display.id(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 void OutputProtectionDelegate::OnWindowHierarchyChanged( | 158 void OutputProtectionDelegate::OnWindowHierarchyChanged( |
| 159 const aura::WindowObserver::HierarchyChangeParams& params) { | 159 const aura::WindowObserver::HierarchyChangeParams& params) { |
| 160 content::RenderFrameHost* rfh = | 160 content::RenderFrameHost* rfh = |
| 161 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 161 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 162 if (!rfh) { | 162 if (!rfh) { |
| 163 LOG(WARNING) << "RenderFrameHost is not alive."; | 163 LOG(WARNING) << "RenderFrameHost is not alive."; |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 | 166 |
| 167 int64 new_display_id = 0; | 167 int64_t new_display_id = 0; |
| 168 if (!GetCurrentDisplayId(rfh, &new_display_id)) | 168 if (!GetCurrentDisplayId(rfh, &new_display_id)) |
| 169 return; | 169 return; |
| 170 if (display_id_ == new_display_id) | 170 if (display_id_ == new_display_id) |
| 171 return; | 171 return; |
| 172 | 172 |
| 173 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { | 173 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { |
| 174 // Display changed and should enable output protections on new display. | 174 // Display changed and should enable output protections on new display. |
| 175 ui::DisplayConfigurator* configurator = | 175 ui::DisplayConfigurator* configurator = |
| 176 ash::Shell::GetInstance()->display_configurator(); | 176 ash::Shell::GetInstance()->display_configurator(); |
| 177 configurator->EnableContentProtection(GetClientId(), new_display_id, | 177 configurator->EnableContentProtection(GetClientId(), new_display_id, |
| 178 desired_method_mask_, | 178 desired_method_mask_, |
| 179 base::Bind(&DoNothing)); | 179 base::Bind(&DoNothing)); |
| 180 configurator->EnableContentProtection(GetClientId(), display_id_, | 180 configurator->EnableContentProtection(GetClientId(), display_id_, |
| 181 ui::CONTENT_PROTECTION_METHOD_NONE, | 181 ui::CONTENT_PROTECTION_METHOD_NONE, |
| 182 base::Bind(&DoNothing)); | 182 base::Bind(&DoNothing)); |
| 183 } | 183 } |
| 184 display_id_ = new_display_id; | 184 display_id_ = new_display_id; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { | 187 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { |
| 188 DCHECK_EQ(window, window_); | 188 DCHECK_EQ(window, window_); |
| 189 window_->RemoveObserver(this); | 189 window_->RemoveObserver(this); |
| 190 window_ = nullptr; | 190 window_ = nullptr; |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace chromeos | 193 } // namespace chromeos |
| OLD | NEW |