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

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

Issue 2723983004: Add PermissionManager::GetPermissionStatusForFrame function (Closed)
Patch Set: Add PermissionManager::GetPermissionStatusForFrame function Created 3 years, 9 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_android.h" 5 #include "chrome/browser/geolocation/geolocation_permission_context_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 20 matching lines...) Expand all
31 : GeolocationPermissionContext(profile), 31 : GeolocationPermissionContext(profile),
32 location_settings_(new LocationSettingsImpl()), 32 location_settings_(new LocationSettingsImpl()),
33 permission_update_infobar_(nullptr), 33 permission_update_infobar_(nullptr),
34 weak_factory_(this) { 34 weak_factory_(this) {
35 } 35 }
36 36
37 GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() { 37 GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() {
38 } 38 }
39 39
40 ContentSetting GeolocationPermissionContextAndroid::GetPermissionStatusInternal( 40 ContentSetting GeolocationPermissionContextAndroid::GetPermissionStatusInternal(
41 content::RenderFrameHost* render_frame_host,
41 const GURL& requesting_origin, 42 const GURL& requesting_origin,
42 const GURL& embedding_origin) const { 43 const GURL& embedding_origin) const {
43 ContentSetting value = 44 ContentSetting value =
44 GeolocationPermissionContext::GetPermissionStatusInternal( 45 GeolocationPermissionContext::GetPermissionStatusInternal(
45 requesting_origin, embedding_origin); 46 render_frame_host, requesting_origin, embedding_origin);
46 47
47 if (value == CONTENT_SETTING_ASK && requesting_origin == embedding_origin) { 48 if (value == CONTENT_SETTING_ASK && requesting_origin == embedding_origin) {
48 // Consult the DSE Geolocation setting. Note that this only needs to be 49 // Consult the DSE Geolocation setting. Note that this only needs to be
49 // consulted when the content setting is ASK. In the other cases (ALLOW or 50 // consulted when the content setting is ASK. In the other cases (ALLOW or
50 // BLOCK) checking the setting is redundant, as the setting is kept 51 // BLOCK) checking the setting is redundant, as the setting is kept
51 // consistent with the content setting. 52 // consistent with the content setting.
52 SearchGeolocationService* search_helper = 53 SearchGeolocationService* search_helper =
53 SearchGeolocationService::Factory::GetForBrowserContext(profile()); 54 SearchGeolocationService::Factory::GetForBrowserContext(profile());
54 55
55 // If the user is incognito, use the DSE Geolocation setting from the 56 // If the user is incognito, use the DSE Geolocation setting from the
(...skipping 30 matching lines...) Expand all
86 user_gesture)) { 87 user_gesture)) {
87 PermissionDecided(id, requesting_frame_origin, 88 PermissionDecided(id, requesting_frame_origin,
88 web_contents->GetLastCommittedURL().GetOrigin(), 89 web_contents->GetLastCommittedURL().GetOrigin(),
89 user_gesture, callback, false /* persist */, 90 user_gesture, callback, false /* persist */,
90 CONTENT_SETTING_BLOCK); 91 CONTENT_SETTING_BLOCK);
91 return; 92 return;
92 } 93 }
93 94
94 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); 95 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin();
95 ContentSetting content_setting = 96 ContentSetting content_setting =
96 GeolocationPermissionContext::GetPermissionStatus(requesting_frame_origin, 97 GeolocationPermissionContext::GetPermissionStatus(
97 embedding_origin) 98 nullptr /* render_frame_host */, requesting_frame_origin,
99 embedding_origin)
98 .content_setting; 100 .content_setting;
99 std::vector<ContentSettingsType> content_settings_types; 101 std::vector<ContentSettingsType> content_settings_types;
100 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION); 102 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION);
101 if (content_setting == CONTENT_SETTING_ALLOW && 103 if (content_setting == CONTENT_SETTING_ALLOW &&
102 PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar( 104 PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar(
103 web_contents, content_settings_types)) { 105 web_contents, content_settings_types)) {
104 permission_update_infobar_ = PermissionUpdateInfoBarDelegate::Create( 106 permission_update_infobar_ = PermissionUpdateInfoBarDelegate::Create(
105 web_contents, content_settings_types, 107 web_contents, content_settings_types,
106 base::Bind( 108 base::Bind(
107 &GeolocationPermissionContextAndroid 109 &GeolocationPermissionContextAndroid
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // The tab helper can be null in tests. 263 // The tab helper can be null in tests.
262 if (disclosure_helper) 264 if (disclosure_helper)
263 disclosure_helper->MaybeShowDisclosure(requesting_origin); 265 disclosure_helper->MaybeShowDisclosure(requesting_origin);
264 } 266 }
265 } 267 }
266 268
267 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( 269 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting(
268 std::unique_ptr<LocationSettings> settings) { 270 std::unique_ptr<LocationSettings> settings) {
269 location_settings_ = std::move(settings); 271 location_settings_ = std::move(settings);
270 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698