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

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

Issue 2613493002: Fix namespace for src/ui/display/. (Closed)
Patch Set: Rebase. Created 3 years, 11 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
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 "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
(...skipping 22 matching lines...) Expand all
33 void DoNothing(bool status) { 33 void DoNothing(bool status) {
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 OutputProtectionDelegate::OutputProtectionDelegate(int render_process_id, 38 OutputProtectionDelegate::OutputProtectionDelegate(int render_process_id,
39 int render_frame_id) 39 int render_frame_id)
40 : render_process_id_(render_process_id), 40 : render_process_id_(render_process_id),
41 render_frame_id_(render_frame_id), 41 render_frame_id_(render_frame_id),
42 window_(nullptr), 42 window_(nullptr),
43 client_id_(ui::DisplayConfigurator::kInvalidClientId), 43 client_id_(display::DisplayConfigurator::kInvalidClientId),
44 display_id_(0), 44 display_id_(0),
45 weak_ptr_factory_(this) { 45 weak_ptr_factory_(this) {
46 // This can be constructed on IO or UI thread. 46 // This can be constructed on IO or UI thread.
47 } 47 }
48 48
49 OutputProtectionDelegate::~OutputProtectionDelegate() { 49 OutputProtectionDelegate::~OutputProtectionDelegate() {
50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
51 51
52 ui::DisplayConfigurator* configurator = 52 display::DisplayConfigurator* configurator =
53 ash::Shell::GetInstance()->display_configurator(); 53 ash::Shell::GetInstance()->display_configurator();
54 configurator->UnregisterContentProtectionClient(client_id_); 54 configurator->UnregisterContentProtectionClient(client_id_);
55 55
56 if (window_) 56 if (window_)
57 window_->RemoveObserver(this); 57 window_->RemoveObserver(this);
58 } 58 }
59 59
60 ui::DisplayConfigurator::ContentProtectionClientId 60 display::DisplayConfigurator::ContentProtectionClientId
61 OutputProtectionDelegate::GetClientId() { 61 OutputProtectionDelegate::GetClientId() {
62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
63 if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { 63 if (client_id_ == display::DisplayConfigurator::kInvalidClientId) {
64 content::RenderFrameHost* rfh = 64 content::RenderFrameHost* rfh =
65 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 65 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
66 if (!rfh || !GetCurrentDisplayId(rfh, &display_id_)) 66 if (!rfh || !GetCurrentDisplayId(rfh, &display_id_))
67 return ui::DisplayConfigurator::kInvalidClientId; 67 return display::DisplayConfigurator::kInvalidClientId;
68 68
69 aura::Window* window = rfh->GetNativeView(); 69 aura::Window* window = rfh->GetNativeView();
70 if (!window) 70 if (!window)
71 return ui::DisplayConfigurator::kInvalidClientId; 71 return display::DisplayConfigurator::kInvalidClientId;
72 72
73 ui::DisplayConfigurator* configurator = 73 display::DisplayConfigurator* configurator =
74 ash::Shell::GetInstance()->display_configurator(); 74 ash::Shell::GetInstance()->display_configurator();
75 client_id_ = configurator->RegisterContentProtectionClient(); 75 client_id_ = configurator->RegisterContentProtectionClient();
76 76
77 if (client_id_ != ui::DisplayConfigurator::kInvalidClientId) { 77 if (client_id_ != display::DisplayConfigurator::kInvalidClientId) {
78 window->AddObserver(this); 78 window->AddObserver(this);
79 window_ = window; 79 window_ = window;
80 } 80 }
81 } 81 }
82 return client_id_; 82 return client_id_;
83 } 83 }
84 84
85 void OutputProtectionDelegate::QueryStatus( 85 void OutputProtectionDelegate::QueryStatus(
86 const QueryStatusCallback& callback) { 86 const QueryStatusCallback& callback) {
87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
88 88
89 content::RenderFrameHost* rfh = 89 content::RenderFrameHost* rfh =
90 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 90 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
91 if (!rfh) { 91 if (!rfh) {
92 LOG(WARNING) << "RenderFrameHost is not alive."; 92 LOG(WARNING) << "RenderFrameHost is not alive.";
93 callback.Run(false, 0, 0); 93 callback.Run(false, 0, 0);
94 return; 94 return;
95 } 95 }
96 96
97 ui::DisplayConfigurator* configurator = 97 display::DisplayConfigurator* configurator =
98 ash::Shell::GetInstance()->display_configurator(); 98 ash::Shell::GetInstance()->display_configurator();
99 configurator->QueryContentProtectionStatus( 99 configurator->QueryContentProtectionStatus(
100 GetClientId(), display_id_, 100 GetClientId(), display_id_,
101 base::Bind(&OutputProtectionDelegate::QueryStatusComplete, 101 base::Bind(&OutputProtectionDelegate::QueryStatusComplete,
102 weak_ptr_factory_.GetWeakPtr(), callback)); 102 weak_ptr_factory_.GetWeakPtr(), callback));
103 } 103 }
104 104
105 void OutputProtectionDelegate::EnableProtection( 105 void OutputProtectionDelegate::EnableProtection(
106 uint32_t desired_method_mask, 106 uint32_t desired_method_mask,
107 const EnableProtectionCallback& callback) { 107 const EnableProtectionCallback& callback) {
108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
109 109
110 ui::DisplayConfigurator* configurator = 110 display::DisplayConfigurator* configurator =
111 ash::Shell::GetInstance()->display_configurator(); 111 ash::Shell::GetInstance()->display_configurator();
112 configurator->EnableContentProtection( 112 configurator->EnableContentProtection(
113 GetClientId(), display_id_, desired_method_mask, 113 GetClientId(), display_id_, desired_method_mask,
114 base::Bind(&OutputProtectionDelegate::EnableProtectionComplete, 114 base::Bind(&OutputProtectionDelegate::EnableProtectionComplete,
115 weak_ptr_factory_.GetWeakPtr(), callback)); 115 weak_ptr_factory_.GetWeakPtr(), callback));
116 desired_method_mask_ = desired_method_mask; 116 desired_method_mask_ = desired_method_mask;
117 } 117 }
118 118
119 void OutputProtectionDelegate::QueryStatusComplete( 119 void OutputProtectionDelegate::QueryStatusComplete(
120 const QueryStatusCallback& callback, 120 const QueryStatusCallback& callback,
121 const ui::DisplayConfigurator::QueryProtectionResponse& response) { 121 const display::DisplayConfigurator::QueryProtectionResponse& response) {
122 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 122 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
123 123
124 content::RenderFrameHost* rfh = 124 content::RenderFrameHost* rfh =
125 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); 125 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
126 // TODO(xjz): Investigate whether this check (and the other one above) should 126 // TODO(xjz): Investigate whether this check (and the other one above) should
127 // be removed. 127 // be removed.
128 if (!rfh) { 128 if (!rfh) {
129 LOG(WARNING) << "RenderFrameHost is not alive."; 129 LOG(WARNING) << "RenderFrameHost is not alive.";
130 callback.Run(false, 0, 0); 130 callback.Run(false, 0, 0);
131 return; 131 return;
(...skipping 18 matching lines...) Expand all
150 LOG(WARNING) << "RenderFrameHost is not alive."; 150 LOG(WARNING) << "RenderFrameHost is not alive.";
151 return; 151 return;
152 } 152 }
153 153
154 int64_t new_display_id = 0; 154 int64_t new_display_id = 0;
155 if (!GetCurrentDisplayId(rfh, &new_display_id)) 155 if (!GetCurrentDisplayId(rfh, &new_display_id))
156 return; 156 return;
157 if (display_id_ == new_display_id) 157 if (display_id_ == new_display_id)
158 return; 158 return;
159 159
160 if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { 160 if (desired_method_mask_ != display::CONTENT_PROTECTION_METHOD_NONE) {
161 // Display changed and should enable output protections on new display. 161 // Display changed and should enable output protections on new display.
162 ui::DisplayConfigurator* configurator = 162 display::DisplayConfigurator* configurator =
163 ash::Shell::GetInstance()->display_configurator(); 163 ash::Shell::GetInstance()->display_configurator();
164 configurator->EnableContentProtection(GetClientId(), new_display_id, 164 configurator->EnableContentProtection(GetClientId(), new_display_id,
165 desired_method_mask_, 165 desired_method_mask_,
166 base::Bind(&DoNothing)); 166 base::Bind(&DoNothing));
167 configurator->EnableContentProtection(GetClientId(), display_id_, 167 configurator->EnableContentProtection(
168 ui::CONTENT_PROTECTION_METHOD_NONE, 168 GetClientId(), display_id_, display::CONTENT_PROTECTION_METHOD_NONE,
169 base::Bind(&DoNothing)); 169 base::Bind(&DoNothing));
170 } 170 }
171 display_id_ = new_display_id; 171 display_id_ = new_display_id;
172 } 172 }
173 173
174 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { 174 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) {
175 DCHECK_EQ(window, window_); 175 DCHECK_EQ(window, window_);
176 window_->RemoveObserver(this); 176 window_->RemoveObserver(this);
177 window_ = nullptr; 177 window_ = nullptr;
178 } 178 }
179 179
180 } // namespace chromeos 180 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698