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

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

Issue 1166603002: Move PermissionRequestID to chrome/browser/permissions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_rfh
Patch Set: fix build Created 5 years, 6 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/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "components/content_settings/core/common/permission_request_id.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/geolocation_provider.h" 12 #include "content/public/browser/geolocation_provider.h"
13 #include "content/public/browser/render_frame_host.h" 13 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 15
16 16
17 GeolocationPermissionContext::GeolocationPermissionContext( 17 GeolocationPermissionContext::GeolocationPermissionContext(
18 Profile* profile) 18 Profile* profile)
19 : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_GEOLOCATION), 19 : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_GEOLOCATION),
20 extensions_context_(profile) { 20 extensions_context_(profile) {
21 } 21 }
22 22
23 GeolocationPermissionContext::~GeolocationPermissionContext() { 23 GeolocationPermissionContext::~GeolocationPermissionContext() {
24 } 24 }
25 25
26 void GeolocationPermissionContext::RequestPermission( 26 void GeolocationPermissionContext::RequestPermission(
27 content::WebContents* web_contents, 27 content::WebContents* web_contents,
28 const PermissionRequestID& id, 28 const PermissionRequestID& id,
29 const GURL& requesting_frame_origin, 29 const GURL& requesting_frame_origin,
30 bool user_gesture, 30 bool user_gesture,
31 const BrowserPermissionCallback& callback) { 31 const BrowserPermissionCallback& callback) {
32 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 32 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
33 33
34 bool permission_set; 34 bool permission_set;
35 bool new_permission; 35 bool new_permission;
36 if (extensions_context_.RequestPermission( 36 if (extensions_context_.RequestPermission(
37 web_contents, id, id.bridge_id(), requesting_frame_origin, user_gesture, 37 web_contents, id, id.request_id(), requesting_frame_origin, user_gesture,
38 callback, &permission_set, &new_permission)) { 38 callback, &permission_set, &new_permission)) {
39 if (permission_set) { 39 if (permission_set) {
40 ContentSetting content_setting = 40 ContentSetting content_setting =
41 new_permission ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 41 new_permission ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
42 NotifyPermissionSet(id, 42 NotifyPermissionSet(id,
43 requesting_frame_origin, 43 requesting_frame_origin,
44 web_contents->GetLastCommittedURL().GetOrigin(), 44 web_contents->GetLastCommittedURL().GetOrigin(),
45 callback, 45 callback,
46 false /* persist */, 46 false /* persist */,
47 content_setting); 47 content_setting);
48 } 48 }
49 return; 49 return;
50 } 50 }
51 51
52 PermissionContextBase::RequestPermission(web_contents, id, 52 PermissionContextBase::RequestPermission(web_contents, id,
53 requesting_frame_origin, 53 requesting_frame_origin,
54 user_gesture, 54 user_gesture,
55 callback); 55 callback);
56 } 56 }
57 57
58 void GeolocationPermissionContext::CancelPermissionRequest( 58 void GeolocationPermissionContext::CancelPermissionRequest(
59 content::WebContents* web_contents, 59 content::WebContents* web_contents,
60 const PermissionRequestID& id) { 60 const PermissionRequestID& id) {
61 61
62 if (extensions_context_.CancelPermissionRequest( 62 if (extensions_context_.CancelPermissionRequest(
63 web_contents, id.bridge_id())) 63 web_contents, id.request_id()))
64 return; 64 return;
65 PermissionContextBase::CancelPermissionRequest(web_contents, id); 65 PermissionContextBase::CancelPermissionRequest(web_contents, id);
66 } 66 }
67 67
68 void GeolocationPermissionContext::UpdateTabContext( 68 void GeolocationPermissionContext::UpdateTabContext(
69 const PermissionRequestID& id, 69 const PermissionRequestID& id,
70 const GURL& requesting_frame, 70 const GURL& requesting_frame,
71 bool allowed) { 71 bool allowed) {
72 TabSpecificContentSettings* content_settings = 72 TabSpecificContentSettings* content_settings =
73 TabSpecificContentSettings::GetForFrame(id.render_process_id(), 73 TabSpecificContentSettings::GetForFrame(id.render_process_id(),
74 id.render_frame_id()); 74 id.render_frame_id());
75 75
76 // WebContents might not exist (extensions) or no longer exist. In which case, 76 // WebContents might not exist (extensions) or no longer exist. In which case,
77 // TabSpecificContentSettings will be null. 77 // TabSpecificContentSettings will be null.
78 if (content_settings) 78 if (content_settings)
79 content_settings->OnGeolocationPermissionSet( 79 content_settings->OnGeolocationPermissionSet(
80 requesting_frame.GetOrigin(), allowed); 80 requesting_frame.GetOrigin(), allowed);
81 81
82 if (allowed) { 82 if (allowed) {
83 content::GeolocationProvider::GetInstance() 83 content::GeolocationProvider::GetInstance()
84 ->UserDidOptIntoLocationServices(); 84 ->UserDidOptIntoLocationServices();
85 } 85 }
86 } 86 }
87 87
88 bool GeolocationPermissionContext::IsRestrictedToSecureOrigins() const { 88 bool GeolocationPermissionContext::IsRestrictedToSecureOrigins() const {
89 return false; 89 return false;
90 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698