| 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 "android_webview/native/permission/permission_request_handler.h" | 5 #include "android_webview/native/permission/permission_request_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/native/permission/aw_permission_request.h" | 9 #include "android_webview/native/permission/aw_permission_request.h" |
| 10 #include "android_webview/native/permission/aw_permission_request_delegate.h" | 10 #include "android_webview/native/permission/aw_permission_request_delegate.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 : content::WebContentsObserver(web_contents), | 37 : content::WebContentsObserver(web_contents), |
| 38 client_(client), | 38 client_(client), |
| 39 contents_unique_id_(GetLastCommittedEntryID(web_contents)) { | 39 contents_unique_id_(GetLastCommittedEntryID(web_contents)) { |
| 40 } | 40 } |
| 41 | 41 |
| 42 PermissionRequestHandler::~PermissionRequestHandler() { | 42 PermissionRequestHandler::~PermissionRequestHandler() { |
| 43 CancelAllRequests(); | 43 CancelAllRequests(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PermissionRequestHandler::SendRequest( | 46 void PermissionRequestHandler::SendRequest( |
| 47 scoped_ptr<AwPermissionRequestDelegate> request) { | 47 std::unique_ptr<AwPermissionRequestDelegate> request) { |
| 48 if (Preauthorized(request->GetOrigin(), request->GetResources())) { | 48 if (Preauthorized(request->GetOrigin(), request->GetResources())) { |
| 49 request->NotifyRequestResult(true); | 49 request->NotifyRequestResult(true); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 base::WeakPtr<AwPermissionRequest> weak_request; | 53 base::WeakPtr<AwPermissionRequest> weak_request; |
| 54 base::android::ScopedJavaLocalRef<jobject> java_peer = | 54 base::android::ScopedJavaLocalRef<jobject> java_peer = |
| 55 AwPermissionRequest::Create(std::move(request), &weak_request); | 55 AwPermissionRequest::Create(std::move(request), &weak_request); |
| 56 requests_.push_back(weak_request); | 56 requests_.push_back(weak_request); |
| 57 client_->OnPermissionRequest(java_peer, weak_request.get()); | 57 client_->OnPermissionRequest(java_peer, weak_request.get()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 bool PermissionRequestHandler::Preauthorized(const GURL& origin, | 134 bool PermissionRequestHandler::Preauthorized(const GURL& origin, |
| 135 int64_t resources) { | 135 int64_t resources) { |
| 136 std::map<std::string, int64_t>::iterator i = | 136 std::map<std::string, int64_t>::iterator i = |
| 137 preauthorized_permission_.find(origin.GetOrigin().spec()); | 137 preauthorized_permission_.find(origin.GetOrigin().spec()); |
| 138 | 138 |
| 139 return i != preauthorized_permission_.end() && | 139 return i != preauthorized_permission_.end() && |
| 140 (resources & i->second) == resources; | 140 (resources & i->second) == resources; |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace android_webivew | 143 } // namespace android_webivew |
| OLD | NEW |