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

Side by Side Diff: chrome/browser/geolocation/geolocation_permission_context.cc

Issue 2110343002: Reintroduce plumbing for user gesture into permission system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "chrome/browser/geolocation/geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/geolocation_permission_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/permissions/permission_request_id.h" 9 #include "chrome/browser/permissions/permission_request_id.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 10 matching lines...) Expand all
21 extensions_context_(profile) {} 21 extensions_context_(profile) {}
22 22
23 GeolocationPermissionContext::~GeolocationPermissionContext() { 23 GeolocationPermissionContext::~GeolocationPermissionContext() {
24 } 24 }
25 25
26 void GeolocationPermissionContext::DecidePermission( 26 void GeolocationPermissionContext::DecidePermission(
27 content::WebContents* web_contents, 27 content::WebContents* web_contents,
28 const PermissionRequestID& id, 28 const PermissionRequestID& id,
29 const GURL& requesting_origin, 29 const GURL& requesting_origin,
30 const GURL& embedding_origin, 30 const GURL& embedding_origin,
31 bool user_gesture,
31 const BrowserPermissionCallback& callback) { 32 const BrowserPermissionCallback& callback) {
32 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 33 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
33 34
34 bool permission_set; 35 bool permission_set;
35 bool new_permission; 36 bool new_permission;
36 if (extensions_context_.DecidePermission( 37 if (extensions_context_.DecidePermission(
37 web_contents, id, id.request_id(), requesting_origin, callback, 38 web_contents, id, id.request_id(), requesting_origin, user_gesture,
38 &permission_set, &new_permission)) { 39 callback, &permission_set, &new_permission)) {
39 if (permission_set) { 40 if (permission_set) {
40 ContentSetting content_setting = 41 ContentSetting content_setting =
41 new_permission ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 42 new_permission ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
42 NotifyPermissionSet(id, 43 NotifyPermissionSet(id,
43 requesting_origin, 44 requesting_origin,
44 web_contents->GetLastCommittedURL().GetOrigin(), 45 web_contents->GetLastCommittedURL().GetOrigin(),
45 callback, 46 callback,
46 false /* persist */, 47 false /* persist */,
47 content_setting); 48 content_setting);
48 } 49 }
49 return; 50 return;
50 } 51 }
51 52
52 PermissionContextBase::DecidePermission(web_contents, 53 PermissionContextBase::DecidePermission(web_contents,
53 id, 54 id,
54 requesting_origin, 55 requesting_origin,
55 embedding_origin, 56 embedding_origin,
57 user_gesture,
56 callback); 58 callback);
57 } 59 }
58 60
59 void GeolocationPermissionContext::CancelPermissionRequest( 61 void GeolocationPermissionContext::CancelPermissionRequest(
60 content::WebContents* web_contents, 62 content::WebContents* web_contents,
61 const PermissionRequestID& id) { 63 const PermissionRequestID& id) {
62 64
63 if (extensions_context_.CancelPermissionRequest( 65 if (extensions_context_.CancelPermissionRequest(
64 web_contents, id.request_id())) 66 web_contents, id.request_id()))
65 return; 67 return;
(...skipping 16 matching lines...) Expand all
82 84
83 if (allowed) { 85 if (allowed) {
84 content::GeolocationProvider::GetInstance() 86 content::GeolocationProvider::GetInstance()
85 ->UserDidOptIntoLocationServices(); 87 ->UserDidOptIntoLocationServices();
86 } 88 }
87 } 89 }
88 90
89 bool GeolocationPermissionContext::IsRestrictedToSecureOrigins() const { 91 bool GeolocationPermissionContext::IsRestrictedToSecureOrigins() const {
90 return true; 92 return true;
91 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698