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/content_settings/tab_specific_content_settings.h" | 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 } | 257 } |
258 | 258 |
259 void TabSpecificContentSettings::OnContentBlocked( | 259 void TabSpecificContentSettings::OnContentBlocked( |
260 ContentSettingsType type, | 260 ContentSettingsType type, |
261 const std::string& resource_identifier) { | 261 const std::string& resource_identifier) { |
262 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 262 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
263 << "Geolocation settings handled by OnGeolocationPermissionSet"; | 263 << "Geolocation settings handled by OnGeolocationPermissionSet"; |
264 if (type < 0 || type >= CONTENT_SETTINGS_NUM_TYPES) | 264 if (type < 0 || type >= CONTENT_SETTINGS_NUM_TYPES) |
265 return; | 265 return; |
266 | 266 |
267 content_allowed_[type] = false; | 267 // Media is different from other content setting types since it allows new |
268 // setting to kick in without reloading the page, and the UI for media is | |
269 // always reflecting the newest permission setting. | |
270 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) | |
271 content_allowed_[type] = false; | |
272 else | |
273 content_allowed_[type] = true; | |
268 | 274 |
269 // Unless UI for resource content settings is enabled, ignore the resource | 275 // Unless UI for resource content settings is enabled, ignore the resource |
270 // identifier. | 276 // identifier. |
271 // TODO(bauerb): The UI to unblock content should be disabled if the content | 277 // TODO(bauerb): The UI to unblock content should be disabled if the content |
272 // setting was not set by the user. | 278 // setting was not set by the user. |
273 std::string identifier; | 279 std::string identifier; |
274 if (CommandLine::ForCurrentProcess()->HasSwitch( | 280 if (CommandLine::ForCurrentProcess()->HasSwitch( |
275 switches::kEnableResourceContentSettings)) { | 281 switches::kEnableResourceContentSettings)) { |
276 identifier = resource_identifier; | 282 identifier = resource_identifier; |
277 } | 283 } |
(...skipping 18 matching lines...) Expand all Loading... | |
296 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 302 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
297 content::Source<WebContents>(web_contents()), | 303 content::Source<WebContents>(web_contents()), |
298 content::NotificationService::NoDetails()); | 304 content::NotificationService::NoDetails()); |
299 } | 305 } |
300 } | 306 } |
301 | 307 |
302 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { | 308 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { |
303 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 309 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
304 << "Geolocation settings handled by OnGeolocationPermissionSet"; | 310 << "Geolocation settings handled by OnGeolocationPermissionSet"; |
305 bool access_changed = false; | 311 bool access_changed = false; |
306 if (content_blocked_[type]) { | 312 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
307 content_blocked_[type] = false; | 313 // The setting for media is overwritten here because media does not need to |
308 access_changed = true; | 314 // reload the page to have the new setting kick in. See issue/175993. |
309 } | 315 if (content_blocked_[type]) { |
316 content_blocked_[type] = false; | |
317 access_changed = true; | |
318 } | |
jochen (gone - plz use gerrit)
2013/04/02 13:08:53
nit, you can just close the if block here, no need
no longer working on chromium
2013/04/02 14:12:06
Done.
| |
310 | 319 |
311 if (!content_allowed_[type]) { | 320 if (!content_allowed_[type]) { |
312 content_allowed_[type] = true; | 321 content_allowed_[type] = true; |
313 access_changed = true; | 322 access_changed = true; |
323 } | |
324 } else { | |
325 if (!content_allowed_[type]) { | |
326 content_allowed_[type] = true; | |
327 access_changed = true; | |
328 } | |
314 } | 329 } |
315 | 330 |
316 if (access_changed) { | 331 if (access_changed) { |
317 content::NotificationService::current()->Notify( | 332 content::NotificationService::current()->Notify( |
318 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 333 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
319 content::Source<WebContents>(web_contents()), | 334 content::Source<WebContents>(web_contents()), |
320 content::NotificationService::NoDetails()); | 335 content::NotificationService::NoDetails()); |
321 } | 336 } |
322 } | 337 } |
323 | 338 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 } | 601 } |
587 | 602 |
588 void TabSpecificContentSettings::RemoveSiteDataObserver( | 603 void TabSpecificContentSettings::RemoveSiteDataObserver( |
589 SiteDataObserver* observer) { | 604 SiteDataObserver* observer) { |
590 observer_list_.RemoveObserver(observer); | 605 observer_list_.RemoveObserver(observer); |
591 } | 606 } |
592 | 607 |
593 void TabSpecificContentSettings::NotifySiteDataObservers() { | 608 void TabSpecificContentSettings::NotifySiteDataObservers() { |
594 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 609 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
595 } | 610 } |
OLD | NEW |