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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 1266583003: Fix the links in the media bubble pointing to the media UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The definitions too. Created 5 years, 4 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
« no previous file with comments | « chrome/browser/ui/chrome_pages.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // The model of the content settings bubble for media settings. 571 // The model of the content settings bubble for media settings.
572 class ContentSettingMediaStreamBubbleModel 572 class ContentSettingMediaStreamBubbleModel
573 : public ContentSettingTitleAndLinkModel { 573 : public ContentSettingTitleAndLinkModel {
574 public: 574 public:
575 ContentSettingMediaStreamBubbleModel(Delegate* delegate, 575 ContentSettingMediaStreamBubbleModel(Delegate* delegate,
576 WebContents* web_contents, 576 WebContents* web_contents,
577 Profile* profile); 577 Profile* profile);
578 578
579 ~ContentSettingMediaStreamBubbleModel() override; 579 ~ContentSettingMediaStreamBubbleModel() override;
580 580
581 void OnManageLinkClicked() override;
582
581 private: 583 private:
584 // Helper functions to check if this bubble was invoked for microphone,
585 // camera, or both devices.
586 bool MicrophoneAccessed() const;
587 bool CameraAccessed() const;
588
582 void SetTitle(); 589 void SetTitle();
583 // Sets the data for the radio buttons of the bubble. 590 // Sets the data for the radio buttons of the bubble.
584 void SetRadioGroup(); 591 void SetRadioGroup();
585 // Sets the data for the media menus of the bubble. 592 // Sets the data for the media menus of the bubble.
586 void SetMediaMenus(); 593 void SetMediaMenus();
594 // Set the settings management link.
595 void SetManageLink();
587 void SetCustomLink(); 596 void SetCustomLink();
588 // Updates the camera and microphone setting with the passed |setting|. 597 // Updates the camera and microphone setting with the passed |setting|.
589 void UpdateSettings(ContentSetting setting); 598 void UpdateSettings(ContentSetting setting);
590 // Updates the camera and microphone default device with the passed |type| 599 // Updates the camera and microphone default device with the passed |type|
591 // and device. 600 // and device.
592 void UpdateDefaultDeviceForType(content::MediaStreamType type, 601 void UpdateDefaultDeviceForType(content::MediaStreamType type,
593 const std::string& device); 602 const std::string& device);
594 603
595 // ContentSettingBubbleModel implementation. 604 // ContentSettingBubbleModel implementation.
596 void OnRadioClicked(int radio_index) override; 605 void OnRadioClicked(int radio_index) override;
(...skipping 10 matching lines...) Expand all
607 }; 616 };
608 617
609 ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel( 618 ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel(
610 Delegate* delegate, 619 Delegate* delegate,
611 WebContents* web_contents, 620 WebContents* web_contents,
612 Profile* profile) 621 Profile* profile)
613 : ContentSettingTitleAndLinkModel( 622 : ContentSettingTitleAndLinkModel(
614 delegate, web_contents, profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM), 623 delegate, web_contents, profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM),
615 selected_item_(0), 624 selected_item_(0),
616 state_(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) { 625 state_(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) {
626 // TODO(msramek): Every bubble is tied to a particular content setting.
627 // The media bubble has three states - mic only, camera only, and both.
628 // However, it is always tied to the deprecated MEDIASTREAM setting. Refactor
629 // this so that it refers to the MIC setting for microphone and CAMERA
630 // setting for camera to reduce the duplication of code in practically every
631 // method. Furthermore, it should be possible not to tie the bubble to any
632 // particular content setting type, as we still need the bubble for both
633 // camera and microphone, but should not use the deprecated MEDIASTREAM
634 // setting.
635
617 DCHECK(profile); 636 DCHECK(profile);
618 // Initialize the content settings associated with the individual radio 637 // Initialize the content settings associated with the individual radio
619 // buttons. 638 // buttons.
620 radio_item_setting_[0] = CONTENT_SETTING_ASK; 639 radio_item_setting_[0] = CONTENT_SETTING_ASK;
621 radio_item_setting_[1] = CONTENT_SETTING_BLOCK; 640 radio_item_setting_[1] = CONTENT_SETTING_BLOCK;
622 641
623 TabSpecificContentSettings* content_settings = 642 TabSpecificContentSettings* content_settings =
624 TabSpecificContentSettings::FromWebContents(web_contents); 643 TabSpecificContentSettings::FromWebContents(web_contents);
625 state_ = content_settings->GetMicrophoneCameraState(); 644 state_ = content_settings->GetMicrophoneCameraState();
626 DCHECK(state_ & (TabSpecificContentSettings::MICROPHONE_ACCESSED | 645 DCHECK(CameraAccessed() || MicrophoneAccessed());
627 TabSpecificContentSettings::CAMERA_ACCESSED));
628 646
629 SetTitle(); 647 SetTitle();
630 SetRadioGroup(); 648 SetRadioGroup();
631 SetMediaMenus(); 649 SetMediaMenus();
650 SetManageLink();
632 SetCustomLink(); 651 SetCustomLink();
633 } 652 }
634 653
635 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { 654 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() {
636 // On some platforms (e.g. MacOS X) it is possible to close a tab while the 655 // On some platforms (e.g. MacOS X) it is possible to close a tab while the
637 // media stream bubble is open. This resets the web contents to NULL. 656 // media stream bubble is open. This resets the web contents to NULL.
638 if (!web_contents()) 657 if (!web_contents())
639 return; 658 return;
640 659
641 for (const std::pair<content::MediaStreamType, MediaMenu>& media_menu : 660 for (const std::pair<content::MediaStreamType, MediaMenu>& media_menu :
642 bubble_content().media_menus) { 661 bubble_content().media_menus) {
643 if (media_menu.second.selected_device.id != 662 if (media_menu.second.selected_device.id !=
644 media_menu.second.default_device.id) { 663 media_menu.second.default_device.id) {
645 UpdateDefaultDeviceForType(media_menu.first, 664 UpdateDefaultDeviceForType(media_menu.first,
646 media_menu.second.selected_device.id); 665 media_menu.second.selected_device.id);
647 } 666 }
648 } 667 }
649 668
650 // Update the media settings if the radio button selection was changed. 669 // Update the media settings if the radio button selection was changed.
651 if (selected_item_ != bubble_content().radio_group.default_item) { 670 if (selected_item_ != bubble_content().radio_group.default_item) {
652 UpdateSettings(radio_item_setting_[selected_item_]); 671 UpdateSettings(radio_item_setting_[selected_item_]);
653 } 672 }
654 } 673 }
655 674
675 bool ContentSettingMediaStreamBubbleModel::MicrophoneAccessed() const {
676 return (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0;
677 }
678
679 bool ContentSettingMediaStreamBubbleModel::CameraAccessed() const {
680 return (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0;
681 }
682
683 void ContentSettingMediaStreamBubbleModel::OnManageLinkClicked() {
684 if (!delegate())
685 return;
686
687 if (MicrophoneAccessed()) {
688 delegate()->ShowContentSettingsPage(CameraAccessed()
689 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM
690 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
691 } else {
692 delegate()->ShowContentSettingsPage(
693 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
694 }
695 }
696
656 void ContentSettingMediaStreamBubbleModel::SetTitle() { 697 void ContentSettingMediaStreamBubbleModel::SetTitle() {
657 DCHECK_NE(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED, state_); 698 DCHECK(CameraAccessed() || MicrophoneAccessed());
658 int title_id = 0; 699 int title_id = 0;
659 if (state_ & TabSpecificContentSettings::MICROPHONE_BLOCKED) { 700 if (state_ & TabSpecificContentSettings::MICROPHONE_BLOCKED) {
660 title_id = (state_ & TabSpecificContentSettings::CAMERA_BLOCKED) ? 701 title_id = (state_ & TabSpecificContentSettings::CAMERA_BLOCKED) ?
661 IDS_MICROPHONE_CAMERA_BLOCKED : IDS_MICROPHONE_BLOCKED; 702 IDS_MICROPHONE_CAMERA_BLOCKED : IDS_MICROPHONE_BLOCKED;
662 } else if (state_ & TabSpecificContentSettings::CAMERA_BLOCKED) { 703 } else if (state_ & TabSpecificContentSettings::CAMERA_BLOCKED) {
663 title_id = IDS_CAMERA_BLOCKED; 704 title_id = IDS_CAMERA_BLOCKED;
664 } else if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) { 705 } else if (MicrophoneAccessed()) {
665 title_id = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) ? 706 title_id = CameraAccessed() ? IDS_MICROPHONE_CAMERA_ALLOWED
666 IDS_MICROPHONE_CAMERA_ALLOWED : IDS_MICROPHONE_ACCESSED; 707 : IDS_MICROPHONE_ACCESSED;
667 } else if (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) { 708 } else if (CameraAccessed()) {
668 title_id = IDS_CAMERA_ACCESSED; 709 title_id = IDS_CAMERA_ACCESSED;
669 } 710 }
670 set_title(l10n_util::GetStringUTF8(title_id)); 711 set_title(l10n_util::GetStringUTF8(title_id));
671 } 712 }
672 713
673 void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { 714 void ContentSettingMediaStreamBubbleModel::SetRadioGroup() {
674 TabSpecificContentSettings* content_settings = 715 TabSpecificContentSettings* content_settings =
675 TabSpecificContentSettings::FromWebContents(web_contents()); 716 TabSpecificContentSettings::FromWebContents(web_contents());
676 GURL url = content_settings->media_stream_access_origin(); 717 GURL url = content_settings->media_stream_access_origin();
677 RadioGroup radio_group; 718 RadioGroup radio_group;
678 radio_group.url = url; 719 radio_group.url = url;
679 720
680 base::string16 display_host_utf16 = 721 base::string16 display_host_utf16 =
681 secure_display::FormatUrlForSecurityDisplay( 722 secure_display::FormatUrlForSecurityDisplay(
682 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); 723 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages));
683 std::string display_host(base::UTF16ToUTF8(display_host_utf16)); 724 std::string display_host(base::UTF16ToUTF8(display_host_utf16));
684 if (display_host.empty()) 725 if (display_host.empty())
685 display_host = url.spec(); 726 display_host = url.spec();
686 727
687 bool is_mic = (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; 728 DCHECK(CameraAccessed() || MicrophoneAccessed());
688 bool is_cam = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0;
689 DCHECK(is_mic || is_cam);
690 int radio_allow_label_id = 0; 729 int radio_allow_label_id = 0;
691 int radio_block_label_id = 0; 730 int radio_block_label_id = 0;
692 if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED | 731 if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED |
693 TabSpecificContentSettings::CAMERA_BLOCKED)) { 732 TabSpecificContentSettings::CAMERA_BLOCKED)) {
694 if (content::IsOriginSecure(url)) { 733 if (content::IsOriginSecure(url)) {
695 radio_item_setting_[0] = CONTENT_SETTING_ALLOW; 734 radio_item_setting_[0] = CONTENT_SETTING_ALLOW;
696 radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ALLOW; 735 radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ALLOW;
697 if (is_mic) 736 if (MicrophoneAccessed())
698 radio_allow_label_id = is_cam ? 737 radio_allow_label_id = CameraAccessed() ?
699 IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ALLOW : 738 IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ALLOW :
700 IDS_BLOCKED_MEDIASTREAM_MIC_ALLOW; 739 IDS_BLOCKED_MEDIASTREAM_MIC_ALLOW;
701 } else { 740 } else {
702 radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK; 741 radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK;
703 if (is_mic) 742 if (MicrophoneAccessed())
704 radio_allow_label_id = is_cam ? 743 radio_allow_label_id = CameraAccessed() ?
705 IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ASK : 744 IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ASK :
706 IDS_BLOCKED_MEDIASTREAM_MIC_ASK; 745 IDS_BLOCKED_MEDIASTREAM_MIC_ASK;
707 } 746 }
708 radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION; 747 radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION;
709 if (is_mic) 748 if (MicrophoneAccessed())
710 radio_block_label_id = is_cam ? 749 radio_block_label_id = CameraAccessed() ?
711 IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION : 750 IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION :
712 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION; 751 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION;
713 } else { 752 } else {
714 if (is_mic && is_cam) { 753 if (MicrophoneAccessed() && CameraAccessed()) {
715 radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION; 754 radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION;
716 radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK; 755 radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK;
717 } else if (is_mic) { 756 } else if (MicrophoneAccessed()) {
718 radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION; 757 radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION;
719 radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK; 758 radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK;
720 } else { 759 } else {
721 radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION; 760 radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION;
722 radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK; 761 radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK;
723 } 762 }
724 } 763 }
725 selected_item_ = 764 selected_item_ =
726 (is_mic && content_settings->IsContentBlocked( 765 (MicrophoneAccessed() && content_settings->IsContentBlocked(
727 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)) || 766 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)) ||
728 (is_cam && content_settings->IsContentBlocked( 767 (CameraAccessed() && content_settings->IsContentBlocked(
729 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) ? 1 : 0; 768 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) ? 1 : 0;
730 769
731 std::string radio_allow_label = l10n_util::GetStringFUTF8( 770 std::string radio_allow_label = l10n_util::GetStringFUTF8(
732 radio_allow_label_id, base::UTF8ToUTF16(display_host)); 771 radio_allow_label_id, base::UTF8ToUTF16(display_host));
733 std::string radio_block_label = 772 std::string radio_block_label =
734 l10n_util::GetStringUTF8(radio_block_label_id); 773 l10n_util::GetStringUTF8(radio_block_label_id);
735 774
736 radio_group.default_item = selected_item_; 775 radio_group.default_item = selected_item_;
737 radio_group.radio_items.push_back(radio_allow_label); 776 radio_group.radio_items.push_back(radio_allow_label);
738 radio_group.radio_items.push_back(radio_block_label); 777 radio_group.radio_items.push_back(radio_block_label);
(...skipping 11 matching lines...) Expand all
750 TabSpecificContentSettings::FromWebContents(web_contents()); 789 TabSpecificContentSettings::FromWebContents(web_contents());
751 // The same patterns must be used as in other places (e.g. the infobar) in 790 // The same patterns must be used as in other places (e.g. the infobar) in
752 // order to override the existing rule. Otherwise a new rule is created. 791 // order to override the existing rule. Otherwise a new rule is created.
753 // TODO(markusheintz): Extract to a helper so that there is only a single 792 // TODO(markusheintz): Extract to a helper so that there is only a single
754 // place to touch. 793 // place to touch.
755 ContentSettingsPattern primary_pattern = 794 ContentSettingsPattern primary_pattern =
756 ContentSettingsPattern::FromURLNoWildcard( 795 ContentSettingsPattern::FromURLNoWildcard(
757 tab_content_settings->media_stream_access_origin()); 796 tab_content_settings->media_stream_access_origin());
758 ContentSettingsPattern secondary_pattern = 797 ContentSettingsPattern secondary_pattern =
759 ContentSettingsPattern::Wildcard(); 798 ContentSettingsPattern::Wildcard();
760 if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) { 799 if (MicrophoneAccessed()) {
761 content_settings->SetContentSetting( 800 content_settings->SetContentSetting(
762 primary_pattern, secondary_pattern, 801 primary_pattern, secondary_pattern,
763 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting); 802 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting);
764 } 803 }
765 if (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) { 804 if (CameraAccessed()) {
766 content_settings->SetContentSetting( 805 content_settings->SetContentSetting(
767 primary_pattern, secondary_pattern, 806 primary_pattern, secondary_pattern,
768 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting); 807 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting);
769 } 808 }
770 } 809 }
771 } 810 }
772 811
773 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType( 812 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType(
774 content::MediaStreamType type, 813 content::MediaStreamType type,
775 const std::string& device) { 814 const std::string& device) {
(...skipping 14 matching lines...) Expand all
790 const std::string& requested_camera = 829 const std::string& requested_camera =
791 content_settings->media_stream_requested_video_device(); 830 content_settings->media_stream_requested_video_device();
792 831
793 // Add microphone menu. 832 // Add microphone menu.
794 PrefService* prefs = profile()->GetPrefs(); 833 PrefService* prefs = profile()->GetPrefs();
795 MediaCaptureDevicesDispatcher* dispatcher = 834 MediaCaptureDevicesDispatcher* dispatcher =
796 MediaCaptureDevicesDispatcher::GetInstance(); 835 MediaCaptureDevicesDispatcher::GetInstance();
797 const content::MediaStreamDevices& microphones = 836 const content::MediaStreamDevices& microphones =
798 dispatcher->GetAudioCaptureDevices(); 837 dispatcher->GetAudioCaptureDevices();
799 838
800 if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) { 839 if (MicrophoneAccessed()) {
801 MediaMenu mic_menu; 840 MediaMenu mic_menu;
802 mic_menu.label = l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_MIC_LABEL); 841 mic_menu.label = l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_MIC_LABEL);
803 if (!microphones.empty()) { 842 if (!microphones.empty()) {
804 std::string preferred_mic; 843 std::string preferred_mic;
805 if (requested_microphone.empty()) { 844 if (requested_microphone.empty()) {
806 preferred_mic = prefs->GetString(prefs::kDefaultAudioCaptureDevice); 845 preferred_mic = prefs->GetString(prefs::kDefaultAudioCaptureDevice);
807 mic_menu.disabled = false; 846 mic_menu.disabled = false;
808 } else { 847 } else {
809 // Set the |disabled| to true in order to disable the device selection 848 // Set the |disabled| to true in order to disable the device selection
810 // menu on the media settings bubble. This must be done if the website 849 // menu on the media settings bubble. This must be done if the website
811 // manages the microphone devices itself. 850 // manages the microphone devices itself.
812 preferred_mic = requested_microphone; 851 preferred_mic = requested_microphone;
813 mic_menu.disabled = true; 852 mic_menu.disabled = true;
814 } 853 }
815 854
816 mic_menu.default_device = GetMediaDeviceById(preferred_mic, microphones); 855 mic_menu.default_device = GetMediaDeviceById(preferred_mic, microphones);
817 mic_menu.selected_device = mic_menu.default_device; 856 mic_menu.selected_device = mic_menu.default_device;
818 } 857 }
819 add_media_menu(content::MEDIA_DEVICE_AUDIO_CAPTURE, mic_menu); 858 add_media_menu(content::MEDIA_DEVICE_AUDIO_CAPTURE, mic_menu);
820 } 859 }
821 860
822 if (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) { 861 if (CameraAccessed()) {
823 const content::MediaStreamDevices& cameras = 862 const content::MediaStreamDevices& cameras =
824 dispatcher->GetVideoCaptureDevices(); 863 dispatcher->GetVideoCaptureDevices();
825 MediaMenu camera_menu; 864 MediaMenu camera_menu;
826 camera_menu.label = 865 camera_menu.label =
827 l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_CAMERA_LABEL); 866 l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_CAMERA_LABEL);
828 if (!cameras.empty()) { 867 if (!cameras.empty()) {
829 std::string preferred_camera; 868 std::string preferred_camera;
830 if (requested_camera.empty()) { 869 if (requested_camera.empty()) {
831 preferred_camera = prefs->GetString(prefs::kDefaultVideoCaptureDevice); 870 preferred_camera = prefs->GetString(prefs::kDefaultVideoCaptureDevice);
832 camera_menu.disabled = false; 871 camera_menu.disabled = false;
833 } else { 872 } else {
834 // Disable the menu since the website is managing the camera devices 873 // Disable the menu since the website is managing the camera devices
835 // itself. 874 // itself.
836 preferred_camera = requested_camera; 875 preferred_camera = requested_camera;
837 camera_menu.disabled = true; 876 camera_menu.disabled = true;
838 } 877 }
839 878
840 camera_menu.default_device = 879 camera_menu.default_device =
841 GetMediaDeviceById(preferred_camera, cameras); 880 GetMediaDeviceById(preferred_camera, cameras);
842 camera_menu.selected_device = camera_menu.default_device; 881 camera_menu.selected_device = camera_menu.default_device;
843 } 882 }
844 add_media_menu(content::MEDIA_DEVICE_VIDEO_CAPTURE, camera_menu); 883 add_media_menu(content::MEDIA_DEVICE_VIDEO_CAPTURE, camera_menu);
845 } 884 }
846 } 885 }
847 886
887 void ContentSettingMediaStreamBubbleModel::SetManageLink() {
888 // By default, the manage link refers to both media types. We only need
889 // to change the link text if only one media type was accessed.
890 if (CameraAccessed() && MicrophoneAccessed())
891 return;
892
893 set_manage_link(l10n_util::GetStringUTF8(MicrophoneAccessed()
894 ? IDS_MEDIASTREAM_MICROPHONE_BUBBLE_MANAGE_LINK
895 : IDS_MEDIASTREAM_CAMERA_BUBBLE_MANAGE_LINK));
896 }
897
848 void ContentSettingMediaStreamBubbleModel::SetCustomLink() { 898 void ContentSettingMediaStreamBubbleModel::SetCustomLink() {
849 TabSpecificContentSettings* content_settings = 899 TabSpecificContentSettings* content_settings =
850 TabSpecificContentSettings::FromWebContents(web_contents()); 900 TabSpecificContentSettings::FromWebContents(web_contents());
851 if (content_settings->IsMicrophoneCameraStateChanged()) { 901 if (content_settings->IsMicrophoneCameraStateChanged()) {
852 set_custom_link(l10n_util::GetStringUTF8( 902 set_custom_link(l10n_util::GetStringUTF8(
853 IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE)); 903 IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE));
854 } 904 }
855 } 905 }
856 906
857 void ContentSettingMediaStreamBubbleModel::OnRadioClicked(int radio_index) { 907 void ContentSettingMediaStreamBubbleModel::OnRadioClicked(int radio_index) {
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1349 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1300 DCHECK_EQ(web_contents_, 1350 DCHECK_EQ(web_contents_,
1301 content::Source<WebContents>(source).ptr()); 1351 content::Source<WebContents>(source).ptr());
1302 web_contents_ = NULL; 1352 web_contents_ = NULL;
1303 } else { 1353 } else {
1304 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1354 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1305 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1355 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1306 profile_ = NULL; 1356 profile_ = NULL;
1307 } 1357 }
1308 } 1358 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/chrome_pages.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698