Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 1210173012: Split the Media settings UI into separate microphone and camera sections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the policy indicator test. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ui/webui/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose 82 // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose
83 // extensions which should have their extent displayed. 83 // extensions which should have their extent displayed.
84 typedef bool (*AppFilter)(const extensions::Extension& app, 84 typedef bool (*AppFilter)(const extensions::Extension& app,
85 content::BrowserContext* profile); 85 content::BrowserContext* profile);
86 86
87 const char kExceptionsLearnMoreUrl[] = 87 const char kExceptionsLearnMoreUrl[] =
88 "https://support.google.com/chrome/?p=settings_manage_exceptions"; 88 "https://support.google.com/chrome/?p=settings_manage_exceptions";
89 89
90 const char kSetting[] = "setting"; 90 const char kSetting[] = "setting";
91 const char kOrigin[] = "origin"; 91 const char kOrigin[] = "origin";
92 const char kPolicyProviderId[] = "policy";
92 const char kSource[] = "source"; 93 const char kSource[] = "source";
93 const char kAppName[] = "appName"; 94 const char kAppName[] = "appName";
94 const char kAppId[] = "appId"; 95 const char kAppId[] = "appId";
95 const char kEmbeddingOrigin[] = "embeddingOrigin"; 96 const char kEmbeddingOrigin[] = "embeddingOrigin";
96 const char kPreferencesSource[] = "preference"; 97 const char kPreferencesSource[] = "preference";
97 const char kVideoSetting[] = "video"; 98 const char kVideoSetting[] = "video";
98 const char kZoom[] = "zoom"; 99 const char kZoom[] = "zoom";
99 100
100 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { 101 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
101 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"}, 102 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"},
102 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, 103 {CONTENT_SETTINGS_TYPE_IMAGES, "images"},
103 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, 104 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"},
104 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, 105 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"},
105 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, 106 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"},
106 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, 107 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"},
107 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, 108 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
108 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, 109 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
109 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, 110 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
110 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, 111 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
111 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"}, 112 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"},
112 // The MEDIASTREAM content setting is deprecated, but the settings for 113 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"},
113 // microphone and camera still live in the part of UI labeled "media-stream". 114 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"},
114 // TODO(msramek): Clean this up once we have a new UI for media.
115 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "media-stream"},
116 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream"},
117 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream"},
118 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"}, 115 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"},
119 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"}, 116 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"},
120 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, 117 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"},
121 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"}, 118 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"},
122 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"}, 119 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"},
123 #if defined(OS_CHROMEOS) 120 #if defined(OS_CHROMEOS)
124 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, 121 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"},
125 #endif 122 #endif
126 }; 123 };
127 124
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 {"mouselockAllow", IDS_MOUSE_LOCK_ALLOW_RADIO}, 349 {"mouselockAllow", IDS_MOUSE_LOCK_ALLOW_RADIO},
353 {"mouselockAsk", IDS_MOUSE_LOCK_ASK_RADIO}, 350 {"mouselockAsk", IDS_MOUSE_LOCK_ASK_RADIO},
354 {"mouselockBlock", IDS_MOUSE_LOCK_BLOCK_RADIO}, 351 {"mouselockBlock", IDS_MOUSE_LOCK_BLOCK_RADIO},
355 #if defined(OS_CHROMEOS) || defined(OS_WIN) 352 #if defined(OS_CHROMEOS) || defined(OS_WIN)
356 // Protected Content filter 353 // Protected Content filter
357 {"protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL}, 354 {"protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL},
358 {"protectedContentInfo", IDS_PROTECTED_CONTENT_INFO}, 355 {"protectedContentInfo", IDS_PROTECTED_CONTENT_INFO},
359 {"protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, 356 {"protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE},
360 {"protectedContentHeader", IDS_PROTECTED_CONTENT_HEADER}, 357 {"protectedContentHeader", IDS_PROTECTED_CONTENT_HEADER},
361 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) 358 #endif // defined(OS_CHROMEOS) || defined(OS_WIN)
362 // Media stream capture device filter. 359 // Microphone filter.
363 {"mediaStreamTabLabel", IDS_MEDIA_STREAM_TAB_LABEL}, 360 {"mediaStreamMicTabLabel", IDS_MEDIA_STREAM_MIC_TAB_LABEL},
364 {"mediaStreamHeader", IDS_MEDIA_STREAM_HEADER}, 361 {"mediaStreamMicHeader", IDS_MEDIA_STREAM_MIC_HEADER},
365 {"mediaStreamAsk", IDS_MEDIA_STREAM_ASK_RADIO}, 362 {"mediaStreamMicAsk", IDS_MEDIA_STREAM_ASK_AUDIO_ONLY_RADIO},
366 {"mediaStreamBlock", IDS_MEDIA_STREAM_BLOCK_RADIO}, 363 {"mediaStreamMicBlock", IDS_MEDIA_STREAM_BLOCK_AUDIO_ONLY_RADIO},
367 {"mediaStreamAudioAsk", IDS_MEDIA_STREAM_ASK_AUDIO_ONLY_RADIO}, 364 // Camera filter.
368 {"mediaStreamAudioBlock", IDS_MEDIA_STREAM_BLOCK_AUDIO_ONLY_RADIO}, 365 {"mediaStreamCameraTabLabel", IDS_MEDIA_STREAM_CAMERA_TAB_LABEL},
369 {"mediaStreamVideoAsk", IDS_MEDIA_STREAM_ASK_VIDEO_ONLY_RADIO}, 366 {"mediaStreamCameraHeader", IDS_MEDIA_STREAM_CAMERA_HEADER},
370 {"mediaStreamVideoBlock", IDS_MEDIA_STREAM_BLOCK_VIDEO_ONLY_RADIO}, 367 {"mediaStreamCameraAsk", IDS_MEDIA_STREAM_ASK_VIDEO_ONLY_RADIO},
371 {"mediaStreamBubbleAudio", IDS_MEDIA_STREAM_AUDIO_MANAGED}, 368 {"mediaStreamCameraBlock", IDS_MEDIA_STREAM_BLOCK_VIDEO_ONLY_RADIO},
372 {"mediaStreamBubbleVideo", IDS_MEDIA_STREAM_VIDEO_MANAGED}, 369 // Flash media settings.
373 {"mediaAudioExceptionHeader", IDS_MEDIA_AUDIO_EXCEPTION_HEADER},
374 {"mediaVideoExceptionHeader", IDS_MEDIA_VIDEO_EXCEPTION_HEADER},
375 {"mediaPepperFlashDefaultDivergedLabel", 370 {"mediaPepperFlashDefaultDivergedLabel",
376 IDS_MEDIA_PEPPER_FLASH_DEFAULT_DIVERGED_LABEL}, 371 IDS_MEDIA_PEPPER_FLASH_DEFAULT_DIVERGED_LABEL},
377 {"mediaPepperFlashExceptionsDivergedLabel", 372 {"mediaPepperFlashExceptionsDivergedLabel",
378 IDS_MEDIA_PEPPER_FLASH_EXCEPTIONS_DIVERGED_LABEL}, 373 IDS_MEDIA_PEPPER_FLASH_EXCEPTIONS_DIVERGED_LABEL},
379 {"mediaPepperFlashChangeLink", IDS_MEDIA_PEPPER_FLASH_CHANGE_LINK}, 374 {"mediaPepperFlashChangeLink", IDS_MEDIA_PEPPER_FLASH_CHANGE_LINK},
380 {"mediaPepperFlashGlobalPrivacyURL", IDS_FLASH_GLOBAL_PRIVACY_URL}, 375 {"mediaPepperFlashGlobalPrivacyURL", IDS_FLASH_GLOBAL_PRIVACY_URL},
381 {"mediaPepperFlashWebsitePrivacyURL", IDS_FLASH_WEBSITE_PRIVACY_URL}, 376 {"mediaPepperFlashWebsitePrivacyURL", IDS_FLASH_WEBSITE_PRIVACY_URL},
382 // PPAPI broker filter. 377 // PPAPI broker filter.
383 {"ppapiBrokerHeader", IDS_PPAPI_BROKER_HEADER}, 378 {"ppapiBrokerHeader", IDS_PPAPI_BROKER_HEADER},
384 {"ppapiBrokerTabLabel", IDS_PPAPI_BROKER_TAB_LABEL}, 379 {"ppapiBrokerTabLabel", IDS_PPAPI_BROKER_TAB_LABEL},
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 RegisterTitle(localized_strings, "notifications", 436 RegisterTitle(localized_strings, "notifications",
442 IDS_NOTIFICATIONS_TAB_LABEL); 437 IDS_NOTIFICATIONS_TAB_LABEL);
443 RegisterTitle(localized_strings, "fullscreen", 438 RegisterTitle(localized_strings, "fullscreen",
444 IDS_FULLSCREEN_TAB_LABEL); 439 IDS_FULLSCREEN_TAB_LABEL);
445 RegisterTitle(localized_strings, "mouselock", 440 RegisterTitle(localized_strings, "mouselock",
446 IDS_MOUSE_LOCK_TAB_LABEL); 441 IDS_MOUSE_LOCK_TAB_LABEL);
447 #if defined(OS_CHROMEOS) 442 #if defined(OS_CHROMEOS)
448 RegisterTitle(localized_strings, "protectedContent", 443 RegisterTitle(localized_strings, "protectedContent",
449 IDS_PROTECTED_CONTENT_TAB_LABEL); 444 IDS_PROTECTED_CONTENT_TAB_LABEL);
450 #endif 445 #endif
451 RegisterTitle(localized_strings, "media-stream", 446 RegisterTitle(localized_strings, "media-stream-mic",
452 IDS_MEDIA_STREAM_TAB_LABEL); 447 IDS_MEDIA_STREAM_MIC_TAB_LABEL);
448 RegisterTitle(localized_strings, "media-stream-camera",
449 IDS_MEDIA_STREAM_CAMERA_TAB_LABEL);
453 RegisterTitle(localized_strings, "ppapi-broker", 450 RegisterTitle(localized_strings, "ppapi-broker",
454 IDS_PPAPI_BROKER_TAB_LABEL); 451 IDS_PPAPI_BROKER_TAB_LABEL);
455 RegisterTitle(localized_strings, "multiple-automatic-downloads", 452 RegisterTitle(localized_strings, "multiple-automatic-downloads",
456 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL); 453 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL);
457 RegisterTitle(localized_strings, "midi-sysex", 454 RegisterTitle(localized_strings, "midi-sysex",
458 IDS_MIDI_SYSEX_TAB_LABEL); 455 IDS_MIDI_SYSEX_TAB_LABEL);
459 RegisterTitle(localized_strings, "zoomlevels", 456 RegisterTitle(localized_strings, "zoomlevels",
460 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL); 457 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL);
461 458
462 localized_strings->SetString("exceptionsLearnMoreUrl", 459 localized_strings->SetString("exceptionsLearnMoreUrl",
(...skipping 17 matching lines...) Expand all
480 content::Source<content::BrowserContext>(context)); 477 content::Source<content::BrowserContext>(context));
481 478
482 PrefService* prefs = user_prefs::UserPrefs::Get(context); 479 PrefService* prefs = user_prefs::UserPrefs::Get(context);
483 pref_change_registrar_.Init(prefs); 480 pref_change_registrar_.Init(prefs);
484 pref_change_registrar_.Add( 481 pref_change_registrar_.Add(
485 prefs::kPepperFlashSettingsEnabled, 482 prefs::kPepperFlashSettingsEnabled,
486 base::Bind(&ContentSettingsHandler::OnPepperFlashPrefChanged, 483 base::Bind(&ContentSettingsHandler::OnPepperFlashPrefChanged,
487 base::Unretained(this))); 484 base::Unretained(this)));
488 pref_change_registrar_.Add( 485 pref_change_registrar_.Add(
489 prefs::kAudioCaptureAllowed, 486 prefs::kAudioCaptureAllowed,
490 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, 487 base::Bind(&ContentSettingsHandler::UpdateSettingDefaultFromModel,
491 base::Unretained(this))); 488 base::Unretained(this),
489 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC));
492 pref_change_registrar_.Add( 490 pref_change_registrar_.Add(
493 prefs::kVideoCaptureAllowed, 491 prefs::kVideoCaptureAllowed,
494 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, 492 base::Bind(&ContentSettingsHandler::UpdateSettingDefaultFromModel,
495 base::Unretained(this))); 493 base::Unretained(this),
494 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA));
496 pref_change_registrar_.Add( 495 pref_change_registrar_.Add(
497 prefs::kEnableDRM, 496 prefs::kEnableDRM,
498 base::Bind( 497 base::Bind(
499 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, 498 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton,
500 base::Unretained(this))); 499 base::Unretained(this)));
501 500
502 // Here we only subscribe to the HostZoomMap for the default storage partition 501 // Here we only subscribe to the HostZoomMap for the default storage partition
503 // since we don't allow the user to manage the zoom levels for apps. 502 // since we don't allow the user to manage the zoom levels for apps.
504 // We're only interested in zoom-levels that are persisted, since the user 503 // We're only interested in zoom-levels that are persisted, since the user
505 // is given the opportunity to view/delete these in the content-settings page. 504 // is given the opportunity to view/delete these in the content-settings page.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 std::string provider_id; 618 std::string provider_id;
620 ContentSetting default_setting = 619 ContentSetting default_setting =
621 GetContentSettingsMap()->GetDefaultContentSetting(type, &provider_id); 620 GetContentSettingsMap()->GetDefaultContentSetting(type, &provider_id);
622 621
623 #if defined(ENABLE_PLUGINS) 622 #if defined(ENABLE_PLUGINS)
624 default_setting = 623 default_setting =
625 content_settings::PluginsFieldTrial::EffectiveContentSetting( 624 content_settings::PluginsFieldTrial::EffectiveContentSetting(
626 type, default_setting); 625 type, default_setting);
627 #endif 626 #endif
628 627
628 CompareMediaSettingsWithFlash();
629
630 // Camera and microphone default content settings cannot be set by the policy.
631 // However, the policy can disable them. Treat this case visually in the same
632 // way as if the policy set the default setting to BLOCK.
633 if ((type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC &&
634 media_settings_.policy_disable_audio) ||
635 (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA &&
636 media_settings_.policy_disable_video)) {
637 default_setting = CONTENT_SETTING_BLOCK;
638 provider_id = kPolicyProviderId;
639 }
640
629 base::DictionaryValue filter_settings; 641 base::DictionaryValue filter_settings;
630 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", 642 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
631 ContentSettingToString(default_setting)); 643 ContentSettingToString(default_setting));
632 filter_settings.SetString( 644 filter_settings.SetString(
633 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); 645 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id);
634 646
635 web_ui()->CallJavascriptFunction( 647 web_ui()->CallJavascriptFunction(
636 "ContentSettings.setContentFilterSettingsValue", filter_settings); 648 "ContentSettings.setContentFilterSettingsValue", filter_settings);
637 } 649 }
638 650
639 void ContentSettingsHandler::UpdateMediaSettingsView() { 651 void ContentSettingsHandler::CompareMediaSettingsWithFlash() {
652 // TODO(msramek): Currently, we show the flash link if the combined
653 // camera and microphone content settings differ from the combined microphone
654 // and camera flash settings. Split this logic to only show the link for
655 // camera if camera settings differ, and analogically for microphone.
Bernhard Bauer 2015/07/17 08:37:11 Nit: "analogously"
msramek 2015/07/17 11:59:50 I wrote "analogously", then I checked a dictionary
640 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 656 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
641 bool audio_disabled = !prefs->GetBoolean(prefs::kAudioCaptureAllowed) && 657 bool audio_disabled = !prefs->GetBoolean(prefs::kAudioCaptureAllowed) &&
642 prefs->IsManagedPreference(prefs::kAudioCaptureAllowed); 658 prefs->IsManagedPreference(prefs::kAudioCaptureAllowed);
643 bool video_disabled = !prefs->GetBoolean(prefs::kVideoCaptureAllowed) && 659 bool video_disabled = !prefs->GetBoolean(prefs::kVideoCaptureAllowed) &&
644 prefs->IsManagedPreference(prefs::kVideoCaptureAllowed); 660 prefs->IsManagedPreference(prefs::kVideoCaptureAllowed);
645 661
646 media_settings_.policy_disable_audio = audio_disabled; 662 media_settings_.policy_disable_audio = audio_disabled;
647 media_settings_.policy_disable_video = video_disabled; 663 media_settings_.policy_disable_video = video_disabled;
648 media_settings_.default_audio_setting = 664 media_settings_.default_audio_setting =
649 GetContentSettingsMap()->GetDefaultContentSetting( 665 GetContentSettingsMap()->GetDefaultContentSetting(
650 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, NULL); 666 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, NULL);
651 media_settings_.default_video_setting = 667 media_settings_.default_video_setting =
652 GetContentSettingsMap()->GetDefaultContentSetting( 668 GetContentSettingsMap()->GetDefaultContentSetting(
653 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, NULL); 669 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, NULL);
654 media_settings_.default_settings_initialized = true; 670 media_settings_.default_settings_initialized = true;
671
655 UpdateFlashMediaLinksVisibility(); 672 UpdateFlashMediaLinksVisibility();
656
657 base::DictionaryValue media_ui_settings;
658 media_ui_settings.SetBoolean("cameraDisabled", video_disabled);
659 media_ui_settings.SetBoolean("micDisabled", audio_disabled);
660
661 // In case only video is enabled change the text appropriately.
662 if (audio_disabled && !video_disabled) {
663 media_ui_settings.SetString("askText", "mediaStreamVideoAsk");
664 media_ui_settings.SetString("blockText", "mediaStreamVideoBlock");
665 media_ui_settings.SetBoolean("showBubble", true);
666 media_ui_settings.SetString("bubbleText", "mediaStreamBubbleAudio");
667
668 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI",
669 media_ui_settings);
670 return;
671 }
672
673 // In case only audio is enabled change the text appropriately.
674 if (video_disabled && !audio_disabled) {
675 base::DictionaryValue media_ui_settings;
676 media_ui_settings.SetString("askText", "mediaStreamAudioAsk");
677 media_ui_settings.SetString("blockText", "mediaStreamAudioBlock");
678 media_ui_settings.SetBoolean("showBubble", true);
679 media_ui_settings.SetString("bubbleText", "mediaStreamBubbleVideo");
680
681 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI",
682 media_ui_settings);
683 return;
684 }
685
686 if (audio_disabled && video_disabled) {
687 // Fake policy controlled default because the user can not change anything
688 // until both audio and video are blocked.
689 base::DictionaryValue filter_settings;
690 std::string group_name =
691 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_MEDIASTREAM);
692 filter_settings.SetString(group_name + ".value",
693 ContentSettingToString(CONTENT_SETTING_BLOCK));
694 filter_settings.SetString(group_name + ".managedBy", "policy");
695 web_ui()->CallJavascriptFunction(
696 "ContentSettings.setContentFilterSettingsValue", filter_settings);
697 }
698
699 media_ui_settings.SetString("askText", "mediaStreamAsk");
700 media_ui_settings.SetString("blockText", "mediaStreamBlock");
701 media_ui_settings.SetBoolean("showBubble", false);
702 media_ui_settings.SetString("bubbleText", std::string());
703
704 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI",
705 media_ui_settings);
706 } 673 }
707 674
708 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { 675 void ContentSettingsHandler::UpdateHandlersEnabledRadios() {
709 base::FundamentalValue handlers_enabled( 676 base::FundamentalValue handlers_enabled(
710 GetProtocolHandlerRegistry()->enabled()); 677 GetProtocolHandlerRegistry()->enabled());
711 678
712 web_ui()->CallJavascriptFunction( 679 web_ui()->CallJavascriptFunction(
713 "ContentSettings.updateHandlersEnabledRadios", 680 "ContentSettings.updateHandlersEnabledRadios",
714 handlers_enabled); 681 handlers_enabled);
715 } 682 }
(...skipping 23 matching lines...) Expand all
739 break; 706 break;
740 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 707 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
741 UpdateNotificationExceptionsView(); 708 UpdateNotificationExceptionsView();
742 break; 709 break;
743 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: 710 case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
744 // The content settings type CONTENT_SETTINGS_TYPE_MEDIASSTREAM 711 // The content settings type CONTENT_SETTINGS_TYPE_MEDIASSTREAM
745 // is deprecated. 712 // is deprecated.
746 break; 713 break;
747 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: 714 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
748 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: 715 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
749 UpdateMediaSettingsView(); 716 CompareMediaExceptionsWithFlash();
750 UpdateMediaExceptionsView(); 717 UpdateExceptionsViewFromHostContentSettingsMap(type);
751 break; 718 break;
752 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT: 719 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
753 // We don't yet support exceptions for mixed scripting. 720 // We don't yet support exceptions for mixed scripting.
754 break; 721 break;
755 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: 722 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
756 // The content settings type CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE 723 // The content settings type CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE
757 // is supposed to be set by policy only. Hence there is no user facing UI 724 // is supposed to be set by policy only. Hence there is no user facing UI
758 // for this content type and we skip it here. 725 // for this content type and we skip it here.
759 break; 726 break;
760 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: 727 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 base::StringValue type_string( 886 base::StringValue type_string(
920 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 887 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
921 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", 888 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions",
922 type_string, exceptions); 889 type_string, exceptions);
923 890
924 // This is mainly here to keep this function ideologically parallel to 891 // This is mainly here to keep this function ideologically parallel to
925 // UpdateExceptionsViewFromHostContentSettingsMap(). 892 // UpdateExceptionsViewFromHostContentSettingsMap().
926 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 893 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
927 } 894 }
928 895
929 void ContentSettingsHandler::UpdateMediaExceptionsView() { 896 void ContentSettingsHandler::CompareMediaExceptionsWithFlash() {
897 // TODO(msramek): Split the combined microphone-camera exceptions
898 // in PepperFlashContentSettingsUtils. The complicated comparison in this
899 // method will then not be necessary.
900
930 base::ListValue media_exceptions; 901 base::ListValue media_exceptions;
931 GetExceptionsFromHostContentSettingsMap( 902 GetExceptionsFromHostContentSettingsMap(
932 GetContentSettingsMap(), 903 GetContentSettingsMap(),
933 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 904 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
934 &media_exceptions); 905 &media_exceptions);
935 906
936 base::ListValue video_exceptions; 907 base::ListValue video_exceptions;
937 GetExceptionsFromHostContentSettingsMap( 908 GetExceptionsFromHostContentSettingsMap(
938 GetContentSettingsMap(), 909 GetContentSettingsMap(),
939 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 910 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 media_dict->GetString(kVideoSetting, &video_setting); 971 media_dict->GetString(kVideoSetting, &video_setting);
1001 media_settings_.exceptions.push_back(MediaException( 972 media_settings_.exceptions.push_back(MediaException(
1002 ContentSettingsPattern::FromString(origin), 973 ContentSettingsPattern::FromString(origin),
1003 ContentSettingFromString(audio_setting), 974 ContentSettingFromString(audio_setting),
1004 ContentSettingFromString(video_setting))); 975 ContentSettingFromString(video_setting)));
1005 } 976 }
1006 PepperFlashContentSettingsUtils::SortMediaExceptions( 977 PepperFlashContentSettingsUtils::SortMediaExceptions(
1007 &media_settings_.exceptions); 978 &media_settings_.exceptions);
1008 media_settings_.exceptions_initialized = true; 979 media_settings_.exceptions_initialized = true;
1009 UpdateFlashMediaLinksVisibility(); 980 UpdateFlashMediaLinksVisibility();
1010
1011 base::StringValue type_string(
1012 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_MEDIASTREAM));
1013 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions",
1014 type_string, media_exceptions);
1015
1016 // TODO(msramek): We currently don't have a UI to show separate default
1017 // settings for microphone and camera. However, SetContentFilter always sets
1018 // both defaults to the same value, so it doesn't matter which one we pick
1019 // to show in the UI. Makes sure to update both when we have the new media UI.
1020 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
1021 } 981 }
1022 982
1023 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { 983 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() {
1024 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 984 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
1025 UpdateExceptionsViewFromHostContentSettingsMap( 985 UpdateExceptionsViewFromHostContentSettingsMap(
1026 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); 986 CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
1027 } 987 }
1028 988
1029 void ContentSettingsHandler::AdjustZoomLevelsListForSigninPageIfNecessary( 989 void ContentSettingsHandler::AdjustZoomLevelsListForSigninPageIfNecessary(
1030 content::HostZoomMap::ZoomLevelVector* zoom_levels) { 990 content::HostZoomMap::ZoomLevelVector* zoom_levels) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 } 1207 }
1248 } 1208 }
1249 1209
1250 for (size_t i = 0; i < all_provider_exceptions.size(); ++i) { 1210 for (size_t i = 0; i < all_provider_exceptions.size(); ++i) {
1251 for (size_t j = 0; j < all_provider_exceptions[i].size(); ++j) { 1211 for (size_t j = 0; j < all_provider_exceptions[i].size(); ++j) {
1252 exceptions->Append(all_provider_exceptions[i][j]); 1212 exceptions->Append(all_provider_exceptions[i][j]);
1253 } 1213 }
1254 } 1214 }
1255 } 1215 }
1256 1216
1257 void ContentSettingsHandler::RemoveMediaException(const base::ListValue* args) {
1258 std::string mode;
1259 bool rv = args->GetString(1, &mode);
1260 DCHECK(rv);
1261
1262 std::string pattern;
1263 rv = args->GetString(2, &pattern);
1264 DCHECK(rv);
1265
1266 HostContentSettingsMap* settings_map =
1267 mode == "normal" ? GetContentSettingsMap() :
1268 GetOTRContentSettingsMap();
1269 if (settings_map) {
1270 settings_map->SetWebsiteSetting(ContentSettingsPattern::FromString(pattern),
1271 ContentSettingsPattern::Wildcard(),
1272 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
1273 std::string(),
1274 NULL);
1275 settings_map->SetWebsiteSetting(ContentSettingsPattern::FromString(pattern),
1276 ContentSettingsPattern::Wildcard(),
1277 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
1278 std::string(),
1279 NULL);
1280 }
1281 }
1282
1283 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( 1217 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap(
1284 const base::ListValue* args, 1218 const base::ListValue* args,
1285 ContentSettingsType type) { 1219 ContentSettingsType type) {
1286 std::string mode; 1220 std::string mode;
1287 bool rv = args->GetString(1, &mode); 1221 bool rv = args->GetString(1, &mode);
1288 DCHECK(rv); 1222 DCHECK(rv);
1289 1223
1290 std::string pattern; 1224 std::string pattern;
1291 rv = args->GetString(2, &pattern); 1225 rv = args->GetString(2, &pattern);
1292 DCHECK(rv); 1226 DCHECK(rv);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 1388
1455 // Zoom levels are no actual content type so we need to handle them 1389 // Zoom levels are no actual content type so we need to handle them
1456 // separately. They would not be recognized by 1390 // separately. They would not be recognized by
1457 // ContentSettingsTypeFromGroupName. 1391 // ContentSettingsTypeFromGroupName.
1458 if (type_string == kZoomContentType) { 1392 if (type_string == kZoomContentType) {
1459 RemoveZoomLevelException(args); 1393 RemoveZoomLevelException(args);
1460 return; 1394 return;
1461 } 1395 }
1462 1396
1463 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); 1397 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
1464 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) 1398 RemoveExceptionFromHostContentSettingsMap(args, type);
1465 RemoveMediaException(args);
1466 else
1467 RemoveExceptionFromHostContentSettingsMap(args, type);
1468 1399
1469 WebSiteSettingsUmaUtil::LogPermissionChange( 1400 WebSiteSettingsUmaUtil::LogPermissionChange(
1470 type, ContentSetting::CONTENT_SETTING_DEFAULT); 1401 type, ContentSetting::CONTENT_SETTING_DEFAULT);
1471 } 1402 }
1472 1403
1473 void ContentSettingsHandler::SetException(const base::ListValue* args) { 1404 void ContentSettingsHandler::SetException(const base::ListValue* args) {
1474 std::string type_string; 1405 std::string type_string;
1475 CHECK(args->GetString(0, &type_string)); 1406 CHECK(args->GetString(0, &type_string));
1476 std::string mode; 1407 std::string mode;
1477 CHECK(args->GetString(1, &mode)); 1408 CHECK(args->GetString(1, &mode));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 1580
1650 // Exceptions apply only when the feature is enabled. 1581 // Exceptions apply only when the feature is enabled.
1651 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1582 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1652 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1583 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1653 web_ui()->CallJavascriptFunction( 1584 web_ui()->CallJavascriptFunction(
1654 "ContentSettings.enableProtectedContentExceptions", 1585 "ContentSettings.enableProtectedContentExceptions",
1655 base::FundamentalValue(enable_exceptions)); 1586 base::FundamentalValue(enable_exceptions));
1656 } 1587 }
1657 1588
1658 } // namespace options 1589 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698