Chromium Code Reviews| 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" |
| 11 #include "base/prefs/pref_service.h" | |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 18 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 19 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/content_settings/content_settings_details.h" | 21 #include "chrome/browser/content_settings/content_settings_details.h" |
| 21 #include "chrome/browser/content_settings/content_settings_utils.h" | 22 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 22 #include "chrome/browser/content_settings/host_content_settings_map.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 24 #include "chrome/browser/media/media_stream_capture_indicator.h" | |
| 23 #include "chrome/browser/prerender/prerender_manager.h" | 25 #include "chrome/browser/prerender/prerender_manager.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | |
| 26 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
| 27 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/navigation_controller.h" | 31 #include "content/public/browser/navigation_controller.h" |
| 29 #include "content/public/browser/navigation_details.h" | 32 #include "content/public/browser/navigation_details.h" |
| 30 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
| 31 #include "content/public/browser/notification_registrar.h" | 34 #include "content/public/browser/notification_registrar.h" |
| 32 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/browser/render_frame_host.h" | 36 #include "content/public/browser/render_frame_host.h" |
| 34 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
| 35 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 64 : content::WebContentsObserver(tab), | 67 : content::WebContentsObserver(tab), |
| 65 profile_(Profile::FromBrowserContext(tab->GetBrowserContext())), | 68 profile_(Profile::FromBrowserContext(tab->GetBrowserContext())), |
| 66 allowed_local_shared_objects_(profile_), | 69 allowed_local_shared_objects_(profile_), |
| 67 blocked_local_shared_objects_(profile_), | 70 blocked_local_shared_objects_(profile_), |
| 68 geolocation_usages_state_(profile_, CONTENT_SETTINGS_TYPE_GEOLOCATION), | 71 geolocation_usages_state_(profile_, CONTENT_SETTINGS_TYPE_GEOLOCATION), |
| 69 midi_usages_state_(profile_, CONTENT_SETTINGS_TYPE_MIDI_SYSEX), | 72 midi_usages_state_(profile_, CONTENT_SETTINGS_TYPE_MIDI_SYSEX), |
| 70 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 73 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 71 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 74 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 72 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), | 75 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), |
| 73 load_plugins_link_enabled_(true), | 76 load_plugins_link_enabled_(true), |
| 77 microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), | |
| 74 observer_(this) { | 78 observer_(this) { |
| 75 ClearBlockedContentSettingsExceptForCookies(); | 79 ClearBlockedContentSettingsExceptForCookies(); |
| 76 ClearCookieSpecificContentSettings(); | 80 ClearCookieSpecificContentSettings(); |
| 77 | 81 |
| 78 observer_.Add(profile_->GetHostContentSettingsMap()); | 82 observer_.Add(profile_->GetHostContentSettingsMap()); |
| 79 } | 83 } |
| 80 | 84 |
| 81 TabSpecificContentSettings::~TabSpecificContentSettings() { | 85 TabSpecificContentSettings::~TabSpecificContentSettings() { |
| 82 FOR_EACH_OBSERVER( | 86 FOR_EACH_OBSERVER( |
| 83 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); | 87 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 269 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 266 return false; | 270 return false; |
| 267 } | 271 } |
| 268 | 272 |
| 269 return content_allowed_[content_type]; | 273 return content_allowed_[content_type]; |
| 270 } | 274 } |
| 271 | 275 |
| 272 void TabSpecificContentSettings::OnContentBlocked(ContentSettingsType type) { | 276 void TabSpecificContentSettings::OnContentBlocked(ContentSettingsType type) { |
| 273 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 277 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
| 274 << "Geolocation settings handled by OnGeolocationPermissionSet"; | 278 << "Geolocation settings handled by OnGeolocationPermissionSet"; |
| 279 DCHECK(type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | |
| 280 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) | |
| 281 << "Media stream settings handled by OnMediaStreamPermissionSet"; | |
| 275 if (type < 0 || type >= CONTENT_SETTINGS_NUM_TYPES) | 282 if (type < 0 || type >= CONTENT_SETTINGS_NUM_TYPES) |
| 276 return; | 283 return; |
| 277 | 284 |
| 278 // Media is different from other content setting types since it allows new | |
| 279 // setting to kick in without reloading the page, and the UI for media is | |
| 280 // always reflecting the newest permission setting. | |
| 281 switch (type) { | 285 switch (type) { |
| 282 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | |
| 283 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | |
| 284 #if defined(OS_ANDROID) | 286 #if defined(OS_ANDROID) |
| 285 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | 287 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 286 #endif | |
| 287 content_allowed_[type] = false; | 288 content_allowed_[type] = false; |
| 288 break; | 289 break; |
| 290 #endif | |
| 289 default: | 291 default: |
| 290 content_allowed_[type] = true; | 292 content_allowed_[type] = true; |
| 291 break; | 293 break; |
| 292 } | 294 } |
| 293 | 295 |
| 294 #if defined(OS_ANDROID) | 296 #if defined(OS_ANDROID) |
| 295 if (type == CONTENT_SETTINGS_TYPE_POPUPS) { | 297 if (type == CONTENT_SETTINGS_TYPE_POPUPS) { |
| 296 // For Android we do not have a persistent button that will always be | 298 // For Android we do not have a persistent button that will always be |
| 297 // visible for blocked popups. Instead we have info bars which could be | 299 // visible for blocked popups. Instead we have info bars which could be |
| 298 // dismissed. Have to clear the blocked state so we properly notify the | 300 // dismissed. Have to clear the blocked state so we properly notify the |
| 299 // relevant pieces again. | 301 // relevant pieces again. |
| 300 content_blocked_[type] = false; | 302 content_blocked_[type] = false; |
| 301 content_blockage_indicated_to_user_[type] = false; | 303 content_blockage_indicated_to_user_[type] = false; |
| 302 } | 304 } |
| 303 #endif | 305 #endif |
| 304 | 306 |
| 305 if (!content_blocked_[type]) { | 307 if (!content_blocked_[type]) { |
| 306 content_blocked_[type] = true; | 308 content_blocked_[type] = true; |
| 307 // TODO: it would be nice to have a way of mocking this in tests. | 309 // TODO: it would be nice to have a way of mocking this in tests. |
| 308 content::NotificationService::current()->Notify( | 310 content::NotificationService::current()->Notify( |
| 309 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 311 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 310 content::Source<WebContents>(web_contents()), | 312 content::Source<WebContents>(web_contents()), |
| 311 content::NotificationService::NoDetails()); | 313 content::NotificationService::NoDetails()); |
| 312 } | 314 } |
| 313 } | 315 } |
| 314 | 316 |
| 315 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { | 317 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { |
| 316 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 318 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
| 317 << "Geolocation settings handled by OnGeolocationPermissionSet"; | 319 << "Geolocation settings handled by OnGeolocationPermissionSet"; |
| 320 DCHECK(type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | |
| 321 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) | |
| 322 << "Media stream settings handled by OnMediaStreamPermissionSet"; | |
| 318 bool access_changed = false; | 323 bool access_changed = false; |
| 319 switch (type) { | 324 switch (type) { |
| 320 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | |
| 321 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | |
| 322 #if defined(OS_ANDROID) | 325 #if defined(OS_ANDROID) |
| 323 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | 326 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 324 #endif | |
| 325 // The setting for media is overwritten here because media does not need | |
| 326 // to reload the page to have the new setting kick in. See issue/175993. | |
| 327 if (content_blocked_[type]) { | 327 if (content_blocked_[type]) { |
| 328 content_blocked_[type] = false; | 328 content_blocked_[type] = false; |
| 329 access_changed = true; | 329 access_changed = true; |
| 330 } | 330 } |
| 331 break; | 331 break; |
| 332 #endif | |
| 332 default: | 333 default: |
| 333 break; | 334 break; |
| 334 } | 335 } |
| 335 | 336 |
| 336 if (!content_allowed_[type]) { | 337 if (!content_allowed_[type]) { |
| 337 content_allowed_[type] = true; | 338 content_allowed_[type] = true; |
| 338 access_changed = true; | 339 access_changed = true; |
| 339 } | 340 } |
| 340 | 341 |
| 341 if (access_changed) { | 342 if (access_changed) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 const GURL& requesting_origin, | 470 const GURL& requesting_origin, |
| 470 bool allowed) { | 471 bool allowed) { |
| 471 if (allowed) { | 472 if (allowed) { |
| 472 OnContentAllowed(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); | 473 OnContentAllowed(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); |
| 473 } else { | 474 } else { |
| 474 OnContentBlocked(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); | 475 OnContentBlocked(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); |
| 475 } | 476 } |
| 476 } | 477 } |
| 477 #endif | 478 #endif |
| 478 | 479 |
| 479 TabSpecificContentSettings::MicrophoneCameraState | 480 unsigned TabSpecificContentSettings::GetMicrophoneCameraState() const { |
| 480 TabSpecificContentSettings::GetMicrophoneCameraState() const { | 481 return microphone_camera_state_; |
| 481 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && | 482 } |
| 482 IsContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) { | |
| 483 return MICROPHONE_CAMERA_ACCESSED; | |
| 484 } else if (IsContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)) { | |
| 485 return MICROPHONE_ACCESSED; | |
| 486 } else if (IsContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) { | |
| 487 return CAMERA_ACCESSED; | |
| 488 } | |
| 489 | 483 |
| 490 if (IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && | 484 bool TabSpecificContentSettings::IsMicrophoneCameraStateChanged() const { |
| 491 IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) { | 485 if (microphone_camera_state_ == MICROPHONE_CAMERA_NOT_ACCESSED) |
|
Peter Kasting
2014/09/24 01:33:00
Nit: This conditional isn't really needed.
robwu
2014/09/24 23:38:44
It is a small optimization to fail fast. The user
Peter Kasting
2014/09/25 00:53:25
We should only worry about optimizing that if the
robwu
2014/09/25 08:57:57
All right, removed.
| |
| 492 return MICROPHONE_CAMERA_BLOCKED; | 486 return false; |
| 493 } else if (IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)) { | |
| 494 return MICROPHONE_BLOCKED; | |
| 495 } else if (IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) { | |
| 496 return CAMERA_BLOCKED; | |
| 497 } | |
| 498 | 487 |
| 499 return MICROPHONE_CAMERA_NOT_ACCESSED; | 488 if ((microphone_camera_state_ & MICROPHONE_ACCESSED) && |
| 489 ((microphone_camera_state_ & MICROPHONE_BLOCKED) ? | |
| 490 !IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) : | |
| 491 !IsContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC))) | |
| 492 return true; | |
| 493 | |
| 494 if ((microphone_camera_state_ & CAMERA_ACCESSED) && | |
| 495 ((microphone_camera_state_ & CAMERA_BLOCKED) ? | |
| 496 !IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) : | |
| 497 !IsContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA))) | |
| 498 return true; | |
| 499 | |
| 500 PrefService* prefs = | |
| 501 Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> | |
| 502 GetPrefs(); | |
| 503 scoped_refptr<MediaStreamCaptureIndicator> media_indicator = | |
| 504 MediaCaptureDevicesDispatcher::GetInstance()-> | |
| 505 GetMediaStreamCaptureIndicator(); | |
| 506 | |
| 507 if ((microphone_camera_state_ & MICROPHONE_ACCESSED) && | |
| 508 prefs->GetString(prefs::kDefaultAudioCaptureDevice) != | |
| 509 media_stream_selected_audio_device() && | |
| 510 media_indicator->IsCapturingAudio(web_contents())) | |
| 511 return true; | |
| 512 | |
| 513 if ((microphone_camera_state_ & CAMERA_ACCESSED) && | |
| 514 prefs->GetString(prefs::kDefaultVideoCaptureDevice) != | |
| 515 media_stream_selected_video_device() && | |
| 516 media_indicator->IsCapturingVideo(web_contents())) | |
| 517 return true; | |
| 518 | |
| 519 return false; | |
| 500 } | 520 } |
| 501 | 521 |
| 502 void TabSpecificContentSettings::OnMediaStreamPermissionSet( | 522 void TabSpecificContentSettings::OnMediaStreamPermissionSet( |
| 503 const GURL& request_origin, | 523 const GURL& request_origin, |
| 504 const MediaStreamDevicesController::MediaStreamTypeSettingsMap& | 524 const MediaStreamDevicesController::MediaStreamTypeSettingsMap& |
| 505 request_permissions) { | 525 request_permissions) { |
| 506 media_stream_access_origin_ = request_origin; | 526 media_stream_access_origin_ = request_origin; |
| 527 unsigned prev_microphone_camera_state = microphone_camera_state_; | |
| 528 microphone_camera_state_ = MICROPHONE_CAMERA_NOT_ACCESSED; | |
| 507 | 529 |
| 530 PrefService* prefs = | |
| 531 Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> | |
| 532 GetPrefs(); | |
| 508 MediaStreamDevicesController::MediaStreamTypeSettingsMap::const_iterator it = | 533 MediaStreamDevicesController::MediaStreamTypeSettingsMap::const_iterator it = |
| 509 request_permissions.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); | 534 request_permissions.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| 510 if (it != request_permissions.end()) { | 535 if (it != request_permissions.end()) { |
| 511 media_stream_requested_audio_device_ = it->second.requested_device_id; | 536 media_stream_requested_audio_device_ = it->second.requested_device_id; |
| 512 switch (it->second.permission) { | 537 media_stream_selected_audio_device_ = |
| 513 case MediaStreamDevicesController::MEDIA_NONE: | 538 media_stream_requested_audio_device_.empty() ? |
| 514 NOTREACHED(); | 539 prefs->GetString(prefs::kDefaultAudioCaptureDevice) : |
| 515 break; | 540 media_stream_requested_audio_device_; |
| 516 case MediaStreamDevicesController::MEDIA_ALLOWED: | 541 DCHECK_NE(MediaStreamDevicesController::MEDIA_NONE, it->second.permission); |
| 517 OnContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 542 const bool mic_allowed = |
| 518 break; | 543 it->second.permission == MediaStreamDevicesController::MEDIA_ALLOWED; |
| 519 // TODO(grunell): UI should show for what reason access has been blocked. | 544 content_allowed_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = mic_allowed; |
| 520 case MediaStreamDevicesController::MEDIA_BLOCKED_BY_POLICY: | 545 content_blocked_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = !mic_allowed; |
| 521 case MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER_SETTING: | 546 microphone_camera_state_ |= MICROPHONE_ACCESSED; |
|
Peter Kasting
2014/09/24 01:33:00
Nit: Shorter:
microphone_camera_state_ |=
robwu
2014/09/24 23:38:44
Done.
| |
| 522 case MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER: | 547 if (!mic_allowed) |
| 523 OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 548 microphone_camera_state_ |= MICROPHONE_BLOCKED; |
| 524 break; | |
| 525 } | |
| 526 } | 549 } |
| 527 | 550 |
| 528 it = request_permissions.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 551 it = request_permissions.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 529 if (it != request_permissions.end()) { | 552 if (it != request_permissions.end()) { |
| 530 media_stream_requested_video_device_ = it->second.requested_device_id; | 553 media_stream_requested_video_device_ = it->second.requested_device_id; |
| 531 switch (it->second.permission) { | 554 media_stream_selected_video_device_ = |
| 532 case MediaStreamDevicesController::MEDIA_NONE: | 555 media_stream_requested_video_device_.empty() ? |
| 533 NOTREACHED(); | 556 prefs->GetString(prefs::kDefaultVideoCaptureDevice) : |
| 534 break; | 557 media_stream_requested_video_device_; |
| 535 case MediaStreamDevicesController::MEDIA_ALLOWED: | 558 DCHECK_NE(MediaStreamDevicesController::MEDIA_NONE, it->second.permission); |
| 536 OnContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 559 const bool cam_allowed = |
| 537 break; | 560 it->second.permission == MediaStreamDevicesController::MEDIA_ALLOWED; |
| 538 // TODO(grunell): UI should show for what reason access has been blocked. | 561 content_allowed_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = cam_allowed; |
| 539 case MediaStreamDevicesController::MEDIA_BLOCKED_BY_POLICY: | 562 content_blocked_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = !cam_allowed; |
| 540 case MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER_SETTING: | 563 microphone_camera_state_ |= CAMERA_ACCESSED; |
| 541 case MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER: | 564 if (!cam_allowed) |
| 542 OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 565 microphone_camera_state_ |= CAMERA_BLOCKED; |
| 543 break; | 566 } |
| 544 } | 567 |
| 568 if (microphone_camera_state_ != prev_microphone_camera_state) { | |
| 569 content::NotificationService::current()->Notify( | |
| 570 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | |
| 571 content::Source<WebContents>(web_contents()), | |
| 572 content::NotificationService::NoDetails()); | |
| 545 } | 573 } |
| 546 } | 574 } |
| 547 | 575 |
| 548 void TabSpecificContentSettings::OnMidiSysExAccessed( | 576 void TabSpecificContentSettings::OnMidiSysExAccessed( |
| 549 const GURL& requesting_origin) { | 577 const GURL& requesting_origin) { |
| 550 midi_usages_state_.OnPermissionSet(requesting_origin, true); | 578 midi_usages_state_.OnPermissionSet(requesting_origin, true); |
| 551 OnContentAllowed(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 579 OnContentAllowed(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 552 } | 580 } |
| 553 | 581 |
| 554 void TabSpecificContentSettings::OnMidiSysExAccessBlocked( | 582 void TabSpecificContentSettings::OnMidiSysExAccessBlocked( |
| 555 const GURL& requesting_origin) { | 583 const GURL& requesting_origin) { |
| 556 midi_usages_state_.OnPermissionSet(requesting_origin, false); | 584 midi_usages_state_.OnPermissionSet(requesting_origin, false); |
| 557 OnContentBlocked(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 585 OnContentBlocked(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 558 } | 586 } |
| 559 | 587 |
| 560 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { | 588 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { |
| 561 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { | 589 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { |
| 562 if (i == CONTENT_SETTINGS_TYPE_COOKIES) | 590 if (i == CONTENT_SETTINGS_TYPE_COOKIES) |
| 563 continue; | 591 continue; |
| 564 content_blocked_[i] = false; | 592 content_blocked_[i] = false; |
| 565 content_allowed_[i] = false; | 593 content_allowed_[i] = false; |
| 566 content_blockage_indicated_to_user_[i] = false; | 594 content_blockage_indicated_to_user_[i] = false; |
| 567 } | 595 } |
| 596 microphone_camera_state_ = MICROPHONE_CAMERA_NOT_ACCESSED; | |
| 568 load_plugins_link_enabled_ = true; | 597 load_plugins_link_enabled_ = true; |
| 569 content::NotificationService::current()->Notify( | 598 content::NotificationService::current()->Notify( |
| 570 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 599 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 571 content::Source<WebContents>(web_contents()), | 600 content::Source<WebContents>(web_contents()), |
| 572 content::NotificationService::NoDetails()); | 601 content::NotificationService::NoDetails()); |
| 573 } | 602 } |
| 574 | 603 |
| 575 void TabSpecificContentSettings::ClearCookieSpecificContentSettings() { | 604 void TabSpecificContentSettings::ClearCookieSpecificContentSettings() { |
| 576 blocked_local_shared_objects_.Reset(); | 605 blocked_local_shared_objects_.Reset(); |
| 577 allowed_local_shared_objects_.Reset(); | 606 allowed_local_shared_objects_.Reset(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 NavigationEntry* entry = controller.GetVisibleEntry(); | 729 NavigationEntry* entry = controller.GetVisibleEntry(); |
| 701 GURL entry_url; | 730 GURL entry_url; |
| 702 if (entry) | 731 if (entry) |
| 703 entry_url = entry->GetURL(); | 732 entry_url = entry->GetURL(); |
| 704 if (details.update_all() || | 733 if (details.update_all() || |
| 705 // The visible NavigationEntry is the URL in the URL field of a tab. | 734 // The visible NavigationEntry is the URL in the URL field of a tab. |
| 706 // Currently this should be matched by the |primary_pattern|. | 735 // Currently this should be matched by the |primary_pattern|. |
| 707 details.primary_pattern().Matches(entry_url)) { | 736 details.primary_pattern().Matches(entry_url)) { |
| 708 Profile* profile = | 737 Profile* profile = |
| 709 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 738 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 739 const HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | |
| 740 | |
| 741 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | |
| 742 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | |
| 743 const GURL media_origin = media_stream_access_origin(); | |
| 744 ContentSetting setting = map->GetContentSetting(media_origin, | |
| 745 media_origin, | |
| 746 content_type, | |
| 747 std::string()); | |
| 748 content_allowed_[content_type] = setting == CONTENT_SETTING_ALLOW; | |
| 749 content_blocked_[content_type] = setting == CONTENT_SETTING_BLOCK; | |
| 750 } | |
| 710 RendererContentSettingRules rules; | 751 RendererContentSettingRules rules; |
| 711 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), | 752 GetRendererContentSettingRules(map, &rules); |
| 712 &rules); | |
| 713 Send(new ChromeViewMsg_SetContentSettingRules(rules)); | 753 Send(new ChromeViewMsg_SetContentSettingRules(rules)); |
| 714 } | 754 } |
| 715 } | 755 } |
| 716 | 756 |
| 717 void TabSpecificContentSettings::AddSiteDataObserver( | 757 void TabSpecificContentSettings::AddSiteDataObserver( |
| 718 SiteDataObserver* observer) { | 758 SiteDataObserver* observer) { |
| 719 observer_list_.AddObserver(observer); | 759 observer_list_.AddObserver(observer); |
| 720 } | 760 } |
| 721 | 761 |
| 722 void TabSpecificContentSettings::RemoveSiteDataObserver( | 762 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 723 SiteDataObserver* observer) { | 763 SiteDataObserver* observer) { |
| 724 observer_list_.RemoveObserver(observer); | 764 observer_list_.RemoveObserver(observer); |
| 725 } | 765 } |
| 726 | 766 |
| 727 void TabSpecificContentSettings::NotifySiteDataObservers() { | 767 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 728 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 768 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 729 } | 769 } |
| OLD | NEW |