OLD | NEW |
---|---|
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" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/permission_type.h" | 12 #include "content/public/browser/permission_type.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 #include "device/geolocation/geolocation_provider.h" | 15 #include "device/geolocation/geolocation_provider.h" |
16 #include "url/origin.h" | |
16 | 17 |
17 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
18 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_infobar_delegate.h" | 19 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h " |
19 #endif | 20 #endif |
20 | 21 |
21 GeolocationPermissionContext::GeolocationPermissionContext(Profile* profile) | 22 GeolocationPermissionContext::GeolocationPermissionContext(Profile* profile) |
22 : PermissionContextBase(profile, | 23 : PermissionContextBase(profile, |
23 content::PermissionType::GEOLOCATION, | 24 content::PermissionType::GEOLOCATION, |
24 CONTENT_SETTINGS_TYPE_GEOLOCATION), | 25 CONTENT_SETTINGS_TYPE_GEOLOCATION), |
25 extensions_context_(profile) {} | 26 extensions_context_(profile) {} |
26 | 27 |
27 GeolocationPermissionContext::~GeolocationPermissionContext() { | 28 GeolocationPermissionContext::~GeolocationPermissionContext() { |
28 } | 29 } |
(...skipping 19 matching lines...) Expand all Loading... | |
48 requesting_origin, | 49 requesting_origin, |
49 web_contents->GetLastCommittedURL().GetOrigin(), | 50 web_contents->GetLastCommittedURL().GetOrigin(), |
50 callback, | 51 callback, |
51 false /* persist */, | 52 false /* persist */, |
52 content_setting); | 53 content_setting); |
53 } | 54 } |
54 return; | 55 return; |
55 } | 56 } |
56 | 57 |
57 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
58 // If the search geolocation disclosure is open, don't pop up a permission | 59 // Consult the DSE Geolocation setting. Note that for API permission requests, |
59 // request. Treat this as a dismissal instead. | 60 // this only needs to be consulted here, as it is only needed when the content |
60 if (SearchGeolocationDisclosureInfoBarDelegate:: | 61 // setting is ASK. In the other cases (ALLOW or BLOCK) checking the setting is |
61 IsSearchGeolocationDisclosureOpen(web_contents)) { | 62 // reduntant, as the setting is kept consistent with the content setting. |
63 SearchGeolocationService* search_helper = | |
64 SearchGeolocationService::Factory::GetForBrowserContext( | |
65 web_contents->GetBrowserContext()); | |
66 if (search_helper && | |
67 search_helper->UseDSEGeolocationSetting(url::Origin(embedding_origin))) { | |
68 ContentSetting setting = search_helper->GetDSEGeolocationSetting() | |
69 ? CONTENT_SETTING_ALLOW | |
70 : CONTENT_SETTING_BLOCK; | |
raymes
2017/01/09 05:47:27
As discussed I think we want to move this to GetPe
benwells
2017/01/09 21:02:22
Done. That's much much nicer!
| |
62 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 71 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
63 false /* persist */, CONTENT_SETTING_DEFAULT); | 72 false /* persist */, setting); |
64 return; | 73 return; |
65 } | 74 } |
66 #endif | 75 #endif |
67 | 76 |
68 PermissionContextBase::DecidePermission(web_contents, | 77 PermissionContextBase::DecidePermission(web_contents, |
69 id, | 78 id, |
70 requesting_origin, | 79 requesting_origin, |
71 embedding_origin, | 80 embedding_origin, |
72 user_gesture, | 81 user_gesture, |
73 callback); | 82 callback); |
(...skipping 25 matching lines...) Expand all Loading... | |
99 | 108 |
100 if (allowed) { | 109 if (allowed) { |
101 device::GeolocationProvider::GetInstance() | 110 device::GeolocationProvider::GetInstance() |
102 ->UserDidOptIntoLocationServices(); | 111 ->UserDidOptIntoLocationServices(); |
103 } | 112 } |
104 } | 113 } |
105 | 114 |
106 bool GeolocationPermissionContext::IsRestrictedToSecureOrigins() const { | 115 bool GeolocationPermissionContext::IsRestrictedToSecureOrigins() const { |
107 return true; | 116 return true; |
108 } | 117 } |
OLD | NEW |