OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chrome_geolocation_permission_context.h" | 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" | 16 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" |
17 #include "chrome/browser/prefs/pref_service.h" | |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/tab_contents/tab_util.h" | 18 #include "chrome/browser/tab_contents/tab_util.h" |
20 #include "chrome/browser/view_type_utils.h" | 19 #include "chrome/browser/view_type_utils.h" |
21 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/pref_names.h" | |
23 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
26 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
28 | 26 |
29 using WebKit::WebSecurityOrigin; | 27 using WebKit::WebSecurityOrigin; |
30 using content::BrowserThread; | 28 using content::BrowserThread; |
31 using content::WebContents; | 29 using content::WebContents; |
32 | 30 |
33 // GeolocationPermissionContext ----------------------------------------------- | 31 // GeolocationPermissionContext ----------------------------------------------- |
34 | 32 |
33 #if !defined(OS_ANDROID) | |
bulach
2012/10/17 13:17:38
if you agree with the comment in the other patch,
Ramya
2012/10/17 21:43:31
Done.
| |
35 ChromeGeolocationPermissionContext* ChromeGeolocationPermissionContext::Create( | 34 ChromeGeolocationPermissionContext* ChromeGeolocationPermissionContext::Create( |
36 Profile *profile) { | 35 Profile *profile) { |
37 return new ChromeGeolocationPermissionContext(profile); | 36 return new ChromeGeolocationPermissionContext(profile); |
38 } | 37 } |
39 | 38 |
40 void ChromeGeolocationPermissionContext::RegisterUserPrefs( | 39 void ChromeGeolocationPermissionContext::RegisterUserPrefs( |
41 PrefService *user_prefs) { | 40 PrefService *user_prefs) { |
42 #if defined(OS_ANDROID) | 41 } |
43 user_prefs->RegisterBooleanPref(prefs::kGeolocationEnabled, true, | |
44 PrefService::UNSYNCABLE_PREF); | |
45 #endif | 42 #endif |
46 } | |
47 | 43 |
48 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( | 44 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( |
49 Profile* profile) | 45 Profile* profile) |
50 : profile_(profile) { | 46 : profile_(profile) { |
51 } | 47 } |
52 | 48 |
53 ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() { | 49 ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() { |
54 } | 50 } |
55 | 51 |
56 void ChromeGeolocationPermissionContext::RequestGeolocationPermission( | 52 void ChromeGeolocationPermissionContext::RequestGeolocationPermission( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 const GURL& requesting_frame) { | 99 const GURL& requesting_frame) { |
104 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | 100 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); |
105 } | 101 } |
106 | 102 |
107 void ChromeGeolocationPermissionContext::DecidePermission( | 103 void ChromeGeolocationPermissionContext::DecidePermission( |
108 int render_process_id, int render_view_id, int bridge_id, | 104 int render_process_id, int render_view_id, int bridge_id, |
109 const GURL& requesting_frame, const GURL& embedder, | 105 const GURL& requesting_frame, const GURL& embedder, |
110 base::Callback<void(bool)> callback) { | 106 base::Callback<void(bool)> callback) { |
111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
112 | 108 |
113 #if defined(OS_ANDROID) | |
114 // Check to see if the feature in its entirety has been disabled. | |
115 // This must happen before other services (e.g. tabs, extensions) | |
116 // get an opportunity to allow the geolocation request. | |
117 if (!profile()->GetPrefs()->GetBoolean(prefs::kGeolocationEnabled)) { | |
118 PermissionDecided(render_process_id, render_view_id, bridge_id, | |
119 requesting_frame, embedder, callback, false); | |
120 return; | |
121 } | |
122 #endif | |
123 | |
124 ExtensionService* extension_service = profile_->GetExtensionService(); | 109 ExtensionService* extension_service = profile_->GetExtensionService(); |
125 if (extension_service) { | 110 if (extension_service) { |
126 const extensions::Extension* extension = | 111 const extensions::Extension* extension = |
127 extension_service->extensions()->GetExtensionOrAppByURL( | 112 extension_service->extensions()->GetExtensionOrAppByURL( |
128 ExtensionURLInfo( | 113 ExtensionURLInfo( |
129 WebSecurityOrigin::createFromString( | 114 WebSecurityOrigin::createFromString( |
130 UTF8ToUTF16(requesting_frame.spec())), | 115 UTF8ToUTF16(requesting_frame.spec())), |
131 requesting_frame)); | 116 requesting_frame)); |
132 if (extension && | 117 if (extension && |
133 extension->HasAPIPermission(extensions::APIPermission::kGeolocation)) { | 118 extension->HasAPIPermission(extensions::APIPermission::kGeolocation)) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 210 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
226 this, render_process_id, render_view_id, bridge_id)); | 211 this, render_process_id, render_view_id, bridge_id)); |
227 return; | 212 return; |
228 } | 213 } |
229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
230 QueueController()->CancelInfoBarRequest( | 215 QueueController()->CancelInfoBarRequest( |
231 render_process_id, | 216 render_process_id, |
232 render_view_id, | 217 render_view_id, |
233 bridge_id); | 218 bridge_id); |
234 } | 219 } |
OLD | NEW |