OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implementation of the geolocation content settings map. Styled on | 5 // Implementation of the geolocation content settings map. Styled on |
6 // HostContentSettingsMap however unlike that class, this one does not hold | 6 // HostContentSettingsMap however unlike that class, this one does not hold |
7 // an additional in-memory copy of the settings as it does not need to support | 7 // an additional in-memory copy of the settings as it does not need to support |
8 // thread safe synchronous access to the settings; all geolocation permissions | 8 // thread safe synchronous access to the settings; all geolocation permissions |
9 // are read and written in the UI thread. (If in future this is no longer the | 9 // are read and written in the UI thread. (If in future this is no longer the |
10 // case, refer to http://codereview.chromium.org/1525018 for a previous version | 10 // case, refer to http://codereview.chromium.org/1525018 for a previous version |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 Details<const ContentSettingsDetails>(&details)); | 204 Details<const ContentSettingsDetails>(&details)); |
205 } | 205 } |
206 | 206 |
207 void GeolocationContentSettingsMap::Observe( | 207 void GeolocationContentSettingsMap::Observe( |
208 NotificationType type, | 208 NotificationType type, |
209 const NotificationSource& source, | 209 const NotificationSource& source, |
210 const NotificationDetails& details) { | 210 const NotificationDetails& details) { |
211 if (type == NotificationType::PREF_CHANGED) { | 211 if (type == NotificationType::PREF_CHANGED) { |
212 const std::string& name = *Details<std::string>(details).ptr(); | 212 const std::string& name = *Details<std::string>(details).ptr(); |
213 if (name == prefs::kGeolocationDefaultContentSetting) { | 213 if (name == prefs::kGeolocationDefaultContentSetting) { |
214 NotifyObservers(ContentSettingsDetails( | 214 ContentSettingsDetails details(ContentSettingsPattern(), |
215 ContentSettingsPattern(), | 215 CONTENT_SETTINGS_TYPE_DEFAULT, |
216 CONTENT_SETTINGS_TYPE_DEFAULT, | 216 std::string()); |
217 "")); | 217 NotifyObservers(details); |
218 } | 218 } |
219 } else if (NotificationType::PROFILE_DESTROYED == type) { | 219 } else if (NotificationType::PROFILE_DESTROYED == type) { |
220 UnregisterObservers(); | 220 UnregisterObservers(); |
221 } else { | 221 } else { |
222 NOTREACHED(); | 222 NOTREACHED(); |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 void GeolocationContentSettingsMap::UnregisterObservers() { | 226 void GeolocationContentSettingsMap::UnregisterObservers() { |
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 20 matching lines...) Expand all Loading... |
248 bool found = dictionary->GetIntegerWithoutPathExpansion(target, &setting); | 248 bool found = dictionary->GetIntegerWithoutPathExpansion(target, &setting); |
249 DCHECK(found); | 249 DCHECK(found); |
250 GURL target_url(target); | 250 GURL target_url(target); |
251 // An empty URL has a special meaning (wildcard), so only accept invalid | 251 // An empty URL has a special meaning (wildcard), so only accept invalid |
252 // URLs if the original version was empty (avoids treating corrupted prefs | 252 // URLs if the original version was empty (avoids treating corrupted prefs |
253 // as the wildcard entry; see http://crbug.com/39685) | 253 // as the wildcard entry; see http://crbug.com/39685) |
254 if (target_url.is_valid() || target.empty()) | 254 if (target_url.is_valid() || target.empty()) |
255 (*one_origin_settings)[target_url] = IntToContentSetting(setting); | 255 (*one_origin_settings)[target_url] = IntToContentSetting(setting); |
256 } | 256 } |
257 } | 257 } |
OLD | NEW |