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

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

Issue 1223643002: android_webview: Replace usage of GetActiveEntry by GetLastCommittedEntry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 "android_webview/native/permission/aw_permission_request.h" 7 #include "android_webview/native/permission/aw_permission_request.h"
8 #include "android_webview/native/permission/aw_permission_request_delegate.h" 8 #include "android_webview/native/permission/aw_permission_request_delegate.h"
9 #include "android_webview/native/permission/permission_request_handler_client.h" 9 #include "android_webview/native/permission/permission_request_handler_client.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 15
16 using base::android::ScopedJavaLocalRef; 16 using base::android::ScopedJavaLocalRef;
17 17
18 namespace android_webview { 18 namespace android_webview {
19 19
20 namespace { 20 namespace {
21 21
22 int GetActiveEntryID(content::WebContents* web_contents) { 22 int GetLastCommittedEntryID(content::WebContents* web_contents) {
23 if (!web_contents) return 0; 23 if (!web_contents) return 0;
24 24
25 content::NavigationEntry* active_entry = 25 content::NavigationEntry* entry =
26 web_contents->GetController().GetActiveEntry(); 26 web_contents->GetController().GetLastCommittedEntry();
27 return active_entry ? active_entry->GetUniqueID() : 0; 27 return entry ? entry->GetUniqueID() : 0;
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 PermissionRequestHandler::PermissionRequestHandler( 32 PermissionRequestHandler::PermissionRequestHandler(
33 PermissionRequestHandlerClient* client, content::WebContents* web_contents) 33 PermissionRequestHandlerClient* client,
34 content::WebContents* web_contents)
34 : content::WebContentsObserver(web_contents), 35 : content::WebContentsObserver(web_contents),
35 client_(client), 36 client_(client),
36 contents_unique_id_(GetActiveEntryID(web_contents)) { 37 contents_unique_id_(GetLastCommittedEntryID(web_contents)) {
37 } 38 }
38 39
39 PermissionRequestHandler::~PermissionRequestHandler() { 40 PermissionRequestHandler::~PermissionRequestHandler() {
40 CancelAllRequests(); 41 CancelAllRequests();
41 } 42 }
42 43
43 void PermissionRequestHandler::SendRequest( 44 void PermissionRequestHandler::SendRequest(
44 scoped_ptr<AwPermissionRequestDelegate> request) { 45 scoped_ptr<AwPermissionRequestDelegate> request) {
45 if (Preauthorized(request->GetOrigin(), request->GetResources())) { 46 if (Preauthorized(request->GetOrigin(), request->GetResources())) {
46 request->NotifyRequestResult(true); 47 request->NotifyRequestResult(true);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool PermissionRequestHandler::Preauthorized(const GURL& origin, 132 bool PermissionRequestHandler::Preauthorized(const GURL& origin,
132 int64 resources) { 133 int64 resources) {
133 std::map<std::string, int64>::iterator i = 134 std::map<std::string, int64>::iterator i =
134 preauthorized_permission_.find(origin.GetOrigin().spec()); 135 preauthorized_permission_.find(origin.GetOrigin().spec());
135 136
136 return i != preauthorized_permission_.end() && 137 return i != preauthorized_permission_.end() &&
137 (resources & i->second) == resources; 138 (resources & i->second) == resources;
138 } 139 }
139 140
140 } // namespace android_webivew 141 } // namespace android_webivew
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698