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

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

Issue 2612993002: Make geolocation API and X-Geo header access consistent (Closed)
Patch Set: Fix wups Created 3 years, 11 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"
11 #include "chrome/browser/android/location_settings.h" 11 #include "chrome/browser/android/location_settings.h"
12 #include "chrome/browser/android/location_settings_impl.h" 12 #include "chrome/browser/android/location_settings_impl.h"
13 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h "
13 #include "chrome/browser/permissions/permission_request_id.h" 14 #include "chrome/browser/permissions/permission_request_id.h"
14 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 15 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
16 #include "chrome/browser/profiles/profile.h"
15 #include "components/infobars/core/infobar.h" 17 #include "components/infobars/core/infobar.h"
16 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
18 #include "url/gurl.h" 20 #include "url/gurl.h"
19 21
20 GeolocationPermissionContextAndroid:: 22 GeolocationPermissionContextAndroid::
21 GeolocationPermissionContextAndroid(Profile* profile) 23 GeolocationPermissionContextAndroid(Profile* profile)
22 : GeolocationPermissionContext(profile), 24 : GeolocationPermissionContext(profile),
23 location_settings_(new LocationSettingsImpl()), 25 location_settings_(new LocationSettingsImpl()),
24 permission_update_infobar_(nullptr), 26 permission_update_infobar_(nullptr),
25 weak_factory_(this) { 27 weak_factory_(this) {
26 } 28 }
27 29
28 GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() { 30 GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() {
29 } 31 }
30 32
33 ContentSetting GeolocationPermissionContextAndroid::GetPermissionStatusInternal(
34 const GURL& requesting_origin,
35 const GURL& embedding_origin) const {
36 ContentSetting value =
37 GeolocationPermissionContext::GetPermissionStatusInternal(
38 requesting_origin, embedding_origin);
39
40 if (value == CONTENT_SETTING_ASK) {
41 // Consult the DSE Geolocation setting. Note that this only needs to be
42 // consulted when the content setting is ASK. In the other cases (ALLOW or
43 // BLOCK) checking the setting is redundant, as the setting is kept
44 // consistent with the content setting.
45 SearchGeolocationService* search_helper =
46 SearchGeolocationService::Factory::GetForBrowserContext(profile());
47 if (search_helper &&
48 search_helper->UseDSEGeolocationSetting(
49 url::Origin(embedding_origin))) {
raymes 2017/01/10 03:19:32 I think we only want to do this if requesting_orig
benwells 2017/01/11 05:35:32 Done.
50 value = search_helper->GetDSEGeolocationSetting() ? CONTENT_SETTING_ALLOW
51 : CONTENT_SETTING_BLOCK;
52 }
53 }
54
55 return value;
56 }
57
31 void GeolocationPermissionContextAndroid::RequestPermission( 58 void GeolocationPermissionContextAndroid::RequestPermission(
32 content::WebContents* web_contents, 59 content::WebContents* web_contents,
33 const PermissionRequestID& id, 60 const PermissionRequestID& id,
34 const GURL& requesting_frame_origin, 61 const GURL& requesting_frame_origin,
35 bool user_gesture, 62 bool user_gesture,
36 const BrowserPermissionCallback& callback) { 63 const BrowserPermissionCallback& callback) {
37 if (!location_settings_->CanSitesRequestLocationPermission(web_contents)) { 64 if (!location_settings_->CanSitesRequestLocationPermission(web_contents)) {
38 PermissionDecided(id, requesting_frame_origin, 65 PermissionDecided(id, requesting_frame_origin,
39 web_contents->GetLastCommittedURL().GetOrigin(), 66 web_contents->GetLastCommittedURL().GetOrigin(),
40 user_gesture, callback, false /* persist */, 67 user_gesture, callback, false /* persist */,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 117 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
91 118
92 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, 119 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback,
93 false /* persist */, new_setting); 120 false /* persist */, new_setting);
94 } 121 }
95 122
96 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( 123 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting(
97 std::unique_ptr<LocationSettings> settings) { 124 std::unique_ptr<LocationSettings> settings) {
98 location_settings_ = std::move(settings); 125 location_settings_ = std::move(settings);
99 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698