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 "content/browser/permissions/permission_service_impl.h" | 5 #include "content/browser/permissions/permission_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "content/public/browser/permission_manager.h" | 12 #include "content/public/browser/permission_manager.h" |
13 #include "content/public/browser/permission_type.h" | 13 #include "content/public/browser/permission_type.h" |
14 | 14 |
15 using blink::mojom::PermissionName; | |
16 using blink::mojom::PermissionStatus; | |
17 | |
15 namespace content { | 18 namespace content { |
16 | 19 |
17 namespace { | 20 namespace { |
18 | 21 |
19 PermissionType PermissionNameToPermissionType(mojom::PermissionName name) { | 22 PermissionType PermissionNameToPermissionType(PermissionName name) { |
20 switch(name) { | 23 switch(name) { |
21 case mojom::PermissionName::GEOLOCATION: | 24 case PermissionName::GEOLOCATION: |
jam
2016/03/31 19:45:52
(not for this cl)
this duplicate enum seems unnec
| |
22 return PermissionType::GEOLOCATION; | 25 return PermissionType::GEOLOCATION; |
23 case mojom::PermissionName::NOTIFICATIONS: | 26 case PermissionName::NOTIFICATIONS: |
24 return PermissionType::NOTIFICATIONS; | 27 return PermissionType::NOTIFICATIONS; |
25 case mojom::PermissionName::PUSH_NOTIFICATIONS: | 28 case PermissionName::PUSH_NOTIFICATIONS: |
26 return PermissionType::PUSH_MESSAGING; | 29 return PermissionType::PUSH_MESSAGING; |
27 case mojom::PermissionName::MIDI: | 30 case PermissionName::MIDI: |
28 return PermissionType::MIDI; | 31 return PermissionType::MIDI; |
29 case mojom::PermissionName::MIDI_SYSEX: | 32 case PermissionName::MIDI_SYSEX: |
30 return PermissionType::MIDI_SYSEX; | 33 return PermissionType::MIDI_SYSEX; |
31 case mojom::PermissionName::PROTECTED_MEDIA_IDENTIFIER: | 34 case PermissionName::PROTECTED_MEDIA_IDENTIFIER: |
32 return PermissionType::PROTECTED_MEDIA_IDENTIFIER; | 35 return PermissionType::PROTECTED_MEDIA_IDENTIFIER; |
33 case mojom::PermissionName::DURABLE_STORAGE: | 36 case PermissionName::DURABLE_STORAGE: |
34 return PermissionType::DURABLE_STORAGE; | 37 return PermissionType::DURABLE_STORAGE; |
35 case mojom::PermissionName::AUDIO_CAPTURE: | 38 case PermissionName::AUDIO_CAPTURE: |
36 return PermissionType::AUDIO_CAPTURE; | 39 return PermissionType::AUDIO_CAPTURE; |
37 case mojom::PermissionName::VIDEO_CAPTURE: | 40 case PermissionName::VIDEO_CAPTURE: |
38 return PermissionType::VIDEO_CAPTURE; | 41 return PermissionType::VIDEO_CAPTURE; |
39 } | 42 } |
40 | 43 |
41 NOTREACHED(); | 44 NOTREACHED(); |
42 return PermissionType::NUM; | 45 return PermissionType::NUM; |
43 } | 46 } |
44 | 47 |
45 // This function allows the usage of the the multiple request map | 48 // This function allows the usage of the the multiple request map |
46 // with single requests. | 49 // with single requests. |
47 void PermissionRequestResponseCallbackWrapper( | 50 void PermissionRequestResponseCallbackWrapper( |
48 const mojo::Callback<void(mojom::PermissionStatus)>& callback, | 51 const mojo::Callback<void(PermissionStatus)>& callback, |
49 const mojo::Array<mojom::PermissionStatus>& vector) { | 52 const mojo::Array<PermissionStatus>& vector) { |
50 DCHECK_EQ(vector.size(), 1ul); | 53 DCHECK_EQ(vector.size(), 1ul); |
51 callback.Run(vector[0]); | 54 callback.Run(vector[0]); |
52 } | 55 } |
53 | 56 |
54 } // anonymous namespace | 57 } // anonymous namespace |
55 | 58 |
56 PermissionServiceImpl::PendingRequest::PendingRequest( | 59 PermissionServiceImpl::PendingRequest::PendingRequest( |
57 const PermissionsStatusCallback& callback, | 60 const PermissionsStatusCallback& callback, |
58 int request_count) | 61 int request_count) |
59 : callback(callback), | 62 : callback(callback), |
60 request_count(request_count) { | 63 request_count(request_count) { |
61 } | 64 } |
62 | 65 |
63 PermissionServiceImpl::PendingRequest::~PendingRequest() { | 66 PermissionServiceImpl::PendingRequest::~PendingRequest() { |
64 if (callback.is_null()) | 67 if (callback.is_null()) |
65 return; | 68 return; |
66 | 69 |
67 mojo::Array<mojom::PermissionStatus> result = | 70 mojo::Array<PermissionStatus> result = |
68 mojo::Array<mojom::PermissionStatus>::New(request_count); | 71 mojo::Array<PermissionStatus>::New(request_count); |
69 for (int i = 0; i < request_count; ++i) | 72 for (int i = 0; i < request_count; ++i) |
70 result[i] = mojom::PermissionStatus::DENIED; | 73 result[i] = PermissionStatus::DENIED; |
71 callback.Run(std::move(result)); | 74 callback.Run(std::move(result)); |
72 } | 75 } |
73 | 76 |
74 PermissionServiceImpl::PendingSubscription::PendingSubscription( | 77 PermissionServiceImpl::PendingSubscription::PendingSubscription( |
75 PermissionType permission, | 78 PermissionType permission, |
76 const GURL& origin, | 79 const GURL& origin, |
77 const PermissionStatusCallback& callback) | 80 const PermissionStatusCallback& callback) |
78 : id(-1), | 81 : id(-1), |
79 permission(permission), | 82 permission(permission), |
80 origin(origin), | 83 origin(origin), |
81 callback(callback) { | 84 callback(callback) { |
82 } | 85 } |
83 | 86 |
84 PermissionServiceImpl::PendingSubscription::~PendingSubscription() { | 87 PermissionServiceImpl::PendingSubscription::~PendingSubscription() { |
85 if (!callback.is_null()) | 88 if (!callback.is_null()) |
86 callback.Run(mojom::PermissionStatus::ASK); | 89 callback.Run(PermissionStatus::ASK); |
87 } | 90 } |
88 | 91 |
89 PermissionServiceImpl::PermissionServiceImpl( | 92 PermissionServiceImpl::PermissionServiceImpl( |
90 PermissionServiceContext* context, | 93 PermissionServiceContext* context, |
91 mojo::InterfaceRequest<mojom::PermissionService> request) | 94 mojo::InterfaceRequest<blink::mojom::PermissionService> request) |
92 : context_(context), | 95 : context_(context), |
93 binding_(this, std::move(request)), | 96 binding_(this, std::move(request)), |
94 weak_factory_(this) { | 97 weak_factory_(this) { |
95 binding_.set_connection_error_handler( | 98 binding_.set_connection_error_handler( |
96 base::Bind(&PermissionServiceImpl::OnConnectionError, | 99 base::Bind(&PermissionServiceImpl::OnConnectionError, |
97 base::Unretained(this))); | 100 base::Unretained(this))); |
98 } | 101 } |
99 | 102 |
100 PermissionServiceImpl::~PermissionServiceImpl() { | 103 PermissionServiceImpl::~PermissionServiceImpl() { |
101 DCHECK(pending_requests_.IsEmpty()); | 104 DCHECK(pending_requests_.IsEmpty()); |
102 } | 105 } |
103 | 106 |
104 void PermissionServiceImpl::OnConnectionError() { | 107 void PermissionServiceImpl::OnConnectionError() { |
105 context_->ServiceHadConnectionError(this); | 108 context_->ServiceHadConnectionError(this); |
106 // After that call, |this| will be deleted. | 109 // After that call, |this| will be deleted. |
107 } | 110 } |
108 | 111 |
109 void PermissionServiceImpl::RequestPermission( | 112 void PermissionServiceImpl::RequestPermission( |
110 mojom::PermissionName permission, | 113 PermissionName permission, |
111 const mojo::String& origin, | 114 const mojo::String& origin, |
112 const PermissionStatusCallback& callback) { | 115 const PermissionStatusCallback& callback) { |
113 // This condition is valid if the call is coming from a ChildThread instead of | 116 // This condition is valid if the call is coming from a ChildThread instead of |
114 // a RenderFrame. Some consumers of the service run in Workers and some in | 117 // a RenderFrame. Some consumers of the service run in Workers and some in |
115 // Frames. In the context of a Worker, it is not possible to show a | 118 // Frames. In the context of a Worker, it is not possible to show a |
116 // permission prompt because there is no tab. In the context of a Frame, we | 119 // permission prompt because there is no tab. In the context of a Frame, we |
117 // can. Even if the call comes from a context where it is not possible to show | 120 // can. Even if the call comes from a context where it is not possible to show |
118 // any UI, we want to still return something relevant so the current | 121 // any UI, we want to still return something relevant so the current |
119 // permission status is returned. | 122 // permission status is returned. |
120 BrowserContext* browser_context = context_->GetBrowserContext(); | 123 BrowserContext* browser_context = context_->GetBrowserContext(); |
(...skipping 18 matching lines...) Expand all Loading... | |
139 // callback if it was run synchronously. | 142 // callback if it was run synchronously. |
140 PendingRequest* pending_request = pending_requests_.Lookup( | 143 PendingRequest* pending_request = pending_requests_.Lookup( |
141 pending_request_id); | 144 pending_request_id); |
142 if (!pending_request) | 145 if (!pending_request) |
143 return; | 146 return; |
144 pending_request->id = id; | 147 pending_request->id = id; |
145 } | 148 } |
146 | 149 |
147 void PermissionServiceImpl::OnRequestPermissionResponse( | 150 void PermissionServiceImpl::OnRequestPermissionResponse( |
148 int pending_request_id, | 151 int pending_request_id, |
149 mojom::PermissionStatus status) { | 152 PermissionStatus status) { |
150 OnRequestPermissionsResponse(pending_request_id, | 153 OnRequestPermissionsResponse(pending_request_id, |
151 std::vector<mojom::PermissionStatus>(1, status)); | 154 std::vector<PermissionStatus>(1, status)); |
152 } | 155 } |
153 | 156 |
154 void PermissionServiceImpl::RequestPermissions( | 157 void PermissionServiceImpl::RequestPermissions( |
155 mojo::Array<mojom::PermissionName> permissions, | 158 mojo::Array<PermissionName> permissions, |
156 const mojo::String& origin, | 159 const mojo::String& origin, |
157 const PermissionsStatusCallback& callback) { | 160 const PermissionsStatusCallback& callback) { |
158 if (permissions.is_null()) { | 161 if (permissions.is_null()) { |
159 callback.Run(mojo::Array<mojom::PermissionStatus>()); | 162 callback.Run(mojo::Array<PermissionStatus>()); |
160 return; | 163 return; |
161 } | 164 } |
162 | 165 |
163 // This condition is valid if the call is coming from a ChildThread instead of | 166 // This condition is valid if the call is coming from a ChildThread instead of |
164 // a RenderFrame. Some consumers of the service run in Workers and some in | 167 // a RenderFrame. Some consumers of the service run in Workers and some in |
165 // Frames. In the context of a Worker, it is not possible to show a | 168 // Frames. In the context of a Worker, it is not possible to show a |
166 // permission prompt because there is no tab. In the context of a Frame, we | 169 // permission prompt because there is no tab. In the context of a Frame, we |
167 // can. Even if the call comes from a context where it is not possible to show | 170 // can. Even if the call comes from a context where it is not possible to show |
168 // any UI, we want to still return something relevant so the current | 171 // any UI, we want to still return something relevant so the current |
169 // permission status is returned for each permission. | 172 // permission status is returned for each permission. |
170 BrowserContext* browser_context = context_->GetBrowserContext(); | 173 BrowserContext* browser_context = context_->GetBrowserContext(); |
171 DCHECK(browser_context); | 174 DCHECK(browser_context); |
172 if (!context_->render_frame_host() || | 175 if (!context_->render_frame_host() || |
173 !browser_context->GetPermissionManager()) { | 176 !browser_context->GetPermissionManager()) { |
174 mojo::Array<mojom::PermissionStatus> result(permissions.size()); | 177 mojo::Array<PermissionStatus> result(permissions.size()); |
175 for (size_t i = 0; i < permissions.size(); ++i) { | 178 for (size_t i = 0; i < permissions.size(); ++i) { |
176 result[i] = | 179 result[i] = |
177 GetPermissionStatusFromName(permissions[i], GURL(origin.get())); | 180 GetPermissionStatusFromName(permissions[i], GURL(origin.get())); |
178 } | 181 } |
179 callback.Run(std::move(result)); | 182 callback.Run(std::move(result)); |
180 return; | 183 return; |
181 } | 184 } |
182 | 185 |
183 std::vector<PermissionType> types(permissions.size()); | 186 std::vector<PermissionType> types(permissions.size()); |
184 for (size_t i = 0; i < types.size(); ++i) | 187 for (size_t i = 0; i < types.size(); ++i) |
(...skipping 13 matching lines...) Expand all Loading... | |
198 // the response callback. | 201 // the response callback. |
199 PendingRequest* pending_request = pending_requests_.Lookup( | 202 PendingRequest* pending_request = pending_requests_.Lookup( |
200 pending_request_id); | 203 pending_request_id); |
201 if (!pending_request) | 204 if (!pending_request) |
202 return; | 205 return; |
203 pending_request->id = id; | 206 pending_request->id = id; |
204 } | 207 } |
205 | 208 |
206 void PermissionServiceImpl::OnRequestPermissionsResponse( | 209 void PermissionServiceImpl::OnRequestPermissionsResponse( |
207 int pending_request_id, | 210 int pending_request_id, |
208 const std::vector<mojom::PermissionStatus>& result) { | 211 const std::vector<PermissionStatus>& result) { |
209 PendingRequest* request = pending_requests_.Lookup(pending_request_id); | 212 PendingRequest* request = pending_requests_.Lookup(pending_request_id); |
210 PermissionsStatusCallback callback(request->callback); | 213 PermissionsStatusCallback callback(request->callback); |
211 request->callback.reset(); | 214 request->callback.reset(); |
212 pending_requests_.Remove(pending_request_id); | 215 pending_requests_.Remove(pending_request_id); |
213 callback.Run(mojo::Array<mojom::PermissionStatus>::From(result)); | 216 callback.Run(mojo::Array<PermissionStatus>::From(result)); |
214 } | 217 } |
215 | 218 |
216 void PermissionServiceImpl::CancelPendingOperations() { | 219 void PermissionServiceImpl::CancelPendingOperations() { |
217 DCHECK(context_->GetBrowserContext()); | 220 DCHECK(context_->GetBrowserContext()); |
218 | 221 |
219 PermissionManager* permission_manager = | 222 PermissionManager* permission_manager = |
220 context_->GetBrowserContext()->GetPermissionManager(); | 223 context_->GetBrowserContext()->GetPermissionManager(); |
221 if (!permission_manager) | 224 if (!permission_manager) |
222 return; | 225 return; |
223 | 226 |
(...skipping 11 matching lines...) Expand all Loading... | |
235 it.GetCurrentValue()->callback.Run(GetPermissionStatusFromType( | 238 it.GetCurrentValue()->callback.Run(GetPermissionStatusFromType( |
236 it.GetCurrentValue()->permission, it.GetCurrentValue()->origin)); | 239 it.GetCurrentValue()->permission, it.GetCurrentValue()->origin)); |
237 it.GetCurrentValue()->callback.reset(); | 240 it.GetCurrentValue()->callback.reset(); |
238 permission_manager->UnsubscribePermissionStatusChange( | 241 permission_manager->UnsubscribePermissionStatusChange( |
239 it.GetCurrentValue()->id); | 242 it.GetCurrentValue()->id); |
240 } | 243 } |
241 pending_subscriptions_.Clear(); | 244 pending_subscriptions_.Clear(); |
242 } | 245 } |
243 | 246 |
244 void PermissionServiceImpl::HasPermission( | 247 void PermissionServiceImpl::HasPermission( |
245 mojom::PermissionName permission, | 248 PermissionName permission, |
246 const mojo::String& origin, | 249 const mojo::String& origin, |
247 const PermissionStatusCallback& callback) { | 250 const PermissionStatusCallback& callback) { |
248 callback.Run(GetPermissionStatusFromName(permission, GURL(origin.get()))); | 251 callback.Run(GetPermissionStatusFromName(permission, GURL(origin.get()))); |
249 } | 252 } |
250 | 253 |
251 void PermissionServiceImpl::RevokePermission( | 254 void PermissionServiceImpl::RevokePermission( |
252 mojom::PermissionName permission, | 255 PermissionName permission, |
253 const mojo::String& origin, | 256 const mojo::String& origin, |
254 const PermissionStatusCallback& callback) { | 257 const PermissionStatusCallback& callback) { |
255 GURL origin_url(origin.get()); | 258 GURL origin_url(origin.get()); |
256 PermissionType permission_type = PermissionNameToPermissionType(permission); | 259 PermissionType permission_type = PermissionNameToPermissionType(permission); |
257 mojom::PermissionStatus status = | 260 PermissionStatus status = |
258 GetPermissionStatusFromType(permission_type, origin_url); | 261 GetPermissionStatusFromType(permission_type, origin_url); |
259 | 262 |
260 // Resetting the permission should only be possible if the permission is | 263 // Resetting the permission should only be possible if the permission is |
261 // already granted. | 264 // already granted. |
262 if (status != mojom::PermissionStatus::GRANTED) { | 265 if (status != PermissionStatus::GRANTED) { |
263 callback.Run(status); | 266 callback.Run(status); |
264 return; | 267 return; |
265 } | 268 } |
266 | 269 |
267 ResetPermissionStatus(permission_type, origin_url); | 270 ResetPermissionStatus(permission_type, origin_url); |
268 | 271 |
269 callback.Run(GetPermissionStatusFromType(permission_type, origin_url)); | 272 callback.Run(GetPermissionStatusFromType(permission_type, origin_url)); |
270 } | 273 } |
271 | 274 |
272 void PermissionServiceImpl::GetNextPermissionChange( | 275 void PermissionServiceImpl::GetNextPermissionChange( |
273 mojom::PermissionName permission, | 276 PermissionName permission, |
274 const mojo::String& mojo_origin, | 277 const mojo::String& mojo_origin, |
275 mojom::PermissionStatus last_known_status, | 278 PermissionStatus last_known_status, |
276 const PermissionStatusCallback& callback) { | 279 const PermissionStatusCallback& callback) { |
277 GURL origin(mojo_origin.get()); | 280 GURL origin(mojo_origin.get()); |
278 mojom::PermissionStatus current_status = | 281 PermissionStatus current_status = |
279 GetPermissionStatusFromName(permission, origin); | 282 GetPermissionStatusFromName(permission, origin); |
280 if (current_status != last_known_status) { | 283 if (current_status != last_known_status) { |
281 callback.Run(current_status); | 284 callback.Run(current_status); |
282 return; | 285 return; |
283 } | 286 } |
284 | 287 |
285 BrowserContext* browser_context = context_->GetBrowserContext(); | 288 BrowserContext* browser_context = context_->GetBrowserContext(); |
286 DCHECK(browser_context); | 289 DCHECK(browser_context); |
287 if (!browser_context->GetPermissionManager()) { | 290 if (!browser_context->GetPermissionManager()) { |
288 callback.Run(current_status); | 291 callback.Run(current_status); |
(...skipping 14 matching lines...) Expand all Loading... | |
303 browser_context->GetPermissionManager()->SubscribePermissionStatusChange( | 306 browser_context->GetPermissionManager()->SubscribePermissionStatusChange( |
304 permission_type, | 307 permission_type, |
305 origin, | 308 origin, |
306 // If the embedding_origin is empty, we,ll use the |origin| instead. | 309 // If the embedding_origin is empty, we,ll use the |origin| instead. |
307 embedding_origin.is_empty() ? origin : embedding_origin, | 310 embedding_origin.is_empty() ? origin : embedding_origin, |
308 base::Bind(&PermissionServiceImpl::OnPermissionStatusChanged, | 311 base::Bind(&PermissionServiceImpl::OnPermissionStatusChanged, |
309 weak_factory_.GetWeakPtr(), | 312 weak_factory_.GetWeakPtr(), |
310 pending_subscription_id)); | 313 pending_subscription_id)); |
311 } | 314 } |
312 | 315 |
313 mojom::PermissionStatus PermissionServiceImpl::GetPermissionStatusFromName( | 316 PermissionStatus PermissionServiceImpl::GetPermissionStatusFromName( |
314 mojom::PermissionName permission, | 317 PermissionName permission, |
315 const GURL& origin) { | 318 const GURL& origin) { |
316 return GetPermissionStatusFromType(PermissionNameToPermissionType(permission), | 319 return GetPermissionStatusFromType(PermissionNameToPermissionType(permission), |
317 origin); | 320 origin); |
318 } | 321 } |
319 | 322 |
320 mojom::PermissionStatus PermissionServiceImpl::GetPermissionStatusFromType( | 323 PermissionStatus PermissionServiceImpl::GetPermissionStatusFromType( |
321 PermissionType type, | 324 PermissionType type, |
322 const GURL& origin) { | 325 const GURL& origin) { |
323 BrowserContext* browser_context = context_->GetBrowserContext(); | 326 BrowserContext* browser_context = context_->GetBrowserContext(); |
324 DCHECK(browser_context); | 327 DCHECK(browser_context); |
325 if (!browser_context->GetPermissionManager()) | 328 if (!browser_context->GetPermissionManager()) |
326 return mojom::PermissionStatus::DENIED; | 329 return PermissionStatus::DENIED; |
327 | 330 |
328 // If the embedding_origin is empty we'll use |origin| instead. | 331 // If the embedding_origin is empty we'll use |origin| instead. |
329 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 332 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
330 return browser_context->GetPermissionManager()->GetPermissionStatus( | 333 return browser_context->GetPermissionManager()->GetPermissionStatus( |
331 type, origin, embedding_origin.is_empty() ? origin : embedding_origin); | 334 type, origin, embedding_origin.is_empty() ? origin : embedding_origin); |
332 } | 335 } |
333 | 336 |
334 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, | 337 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, |
335 const GURL& origin) { | 338 const GURL& origin) { |
336 BrowserContext* browser_context = context_->GetBrowserContext(); | 339 BrowserContext* browser_context = context_->GetBrowserContext(); |
337 DCHECK(browser_context); | 340 DCHECK(browser_context); |
338 if (!browser_context->GetPermissionManager()) | 341 if (!browser_context->GetPermissionManager()) |
339 return; | 342 return; |
340 | 343 |
341 // If the embedding_origin is empty we'll use |origin| instead. | 344 // If the embedding_origin is empty we'll use |origin| instead. |
342 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 345 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
343 browser_context->GetPermissionManager()->ResetPermission( | 346 browser_context->GetPermissionManager()->ResetPermission( |
344 type, origin, embedding_origin.is_empty() ? origin : embedding_origin); | 347 type, origin, embedding_origin.is_empty() ? origin : embedding_origin); |
345 } | 348 } |
346 | 349 |
347 void PermissionServiceImpl::OnPermissionStatusChanged( | 350 void PermissionServiceImpl::OnPermissionStatusChanged( |
348 int pending_subscription_id, | 351 int pending_subscription_id, |
349 mojom::PermissionStatus status) { | 352 PermissionStatus status) { |
350 PendingSubscription* subscription = | 353 PendingSubscription* subscription = |
351 pending_subscriptions_.Lookup(pending_subscription_id); | 354 pending_subscriptions_.Lookup(pending_subscription_id); |
352 | 355 |
353 BrowserContext* browser_context = context_->GetBrowserContext(); | 356 BrowserContext* browser_context = context_->GetBrowserContext(); |
354 DCHECK(browser_context); | 357 DCHECK(browser_context); |
355 if (browser_context->GetPermissionManager()) { | 358 if (browser_context->GetPermissionManager()) { |
356 browser_context->GetPermissionManager()->UnsubscribePermissionStatusChange( | 359 browser_context->GetPermissionManager()->UnsubscribePermissionStatusChange( |
357 subscription->id); | 360 subscription->id); |
358 } | 361 } |
359 | 362 |
360 PermissionStatusCallback callback = subscription->callback; | 363 PermissionStatusCallback callback = subscription->callback; |
361 | 364 |
362 subscription->callback.reset(); | 365 subscription->callback.reset(); |
363 pending_subscriptions_.Remove(pending_subscription_id); | 366 pending_subscriptions_.Remove(pending_subscription_id); |
364 | 367 |
365 callback.Run(status); | 368 callback.Run(status); |
366 } | 369 } |
367 | 370 |
368 } // namespace content | 371 } // namespace content |
OLD | NEW |