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

Side by Side Diff: android_webview/native/permission/permission_request_handler.cc

Issue 1852513003: Convert //android_webview to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git is hard Created 4 years, 8 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 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698