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 "extensions/browser/guest_view/web_view/web_view_permission_helper.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 const PermissionResponseCallback& callback, | 316 const PermissionResponseCallback& callback, |
317 bool allowed_by_default) { | 317 bool allowed_by_default) { |
318 // If there are too many pending permission requests then reject this request. | 318 // If there are too many pending permission requests then reject this request. |
319 if (pending_permission_requests_.size() >= | 319 if (pending_permission_requests_.size() >= |
320 webview::kMaxOutstandingPermissionRequests) { | 320 webview::kMaxOutstandingPermissionRequests) { |
321 // Let the stack unwind before we deny the permission request so that | 321 // Let the stack unwind before we deny the permission request so that |
322 // objects held by the permission request are not destroyed immediately | 322 // objects held by the permission request are not destroyed immediately |
323 // after creation. This is to allow those same objects to be accessed again | 323 // after creation. This is to allow those same objects to be accessed again |
324 // in the same scope without fear of use after freeing. | 324 // in the same scope without fear of use after freeing. |
325 base::ThreadTaskRunnerHandle::Get()->PostTask( | 325 base::ThreadTaskRunnerHandle::Get()->PostTask( |
326 FROM_HERE, | 326 FROM_HERE, base::Bind(callback, allowed_by_default, std::string())); |
327 base::Bind(&PermissionResponseCallback::Run, | |
328 base::Owned(new PermissionResponseCallback(callback)), | |
329 allowed_by_default, std::string())); | |
330 return webview::kInvalidPermissionRequestID; | 327 return webview::kInvalidPermissionRequestID; |
331 } | 328 } |
332 | 329 |
333 int request_id = next_permission_request_id_++; | 330 int request_id = next_permission_request_id_++; |
334 pending_permission_requests_[request_id] = | 331 pending_permission_requests_[request_id] = |
335 PermissionResponseInfo(callback, permission_type, allowed_by_default); | 332 PermissionResponseInfo(callback, permission_type, allowed_by_default); |
336 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 333 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
337 args->Set(webview::kRequestInfo, request_info.DeepCopy()); | 334 args->Set(webview::kRequestInfo, request_info.DeepCopy()); |
338 args->SetInteger(webview::kRequestId, request_id); | 335 args->SetInteger(webview::kRequestId, request_id); |
339 switch (permission_type) { | 336 switch (permission_type) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 allowed_by_default(allowed_by_default) { | 405 allowed_by_default(allowed_by_default) { |
409 } | 406 } |
410 | 407 |
411 WebViewPermissionHelper::PermissionResponseInfo::PermissionResponseInfo( | 408 WebViewPermissionHelper::PermissionResponseInfo::PermissionResponseInfo( |
412 const PermissionResponseInfo& other) = default; | 409 const PermissionResponseInfo& other) = default; |
413 | 410 |
414 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { | 411 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { |
415 } | 412 } |
416 | 413 |
417 } // namespace extensions | 414 } // namespace extensions |
OLD | NEW |