| 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/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" |
| 11 #include "chrome/browser/content_settings/content_settings_utils.h" | 11 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 12 #include "chrome/browser/content_settings/cookie_settings.h" | 12 #include "chrome/browser/content_settings/cookie_settings.h" |
| 13 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 13 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 14 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 14 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
| 17 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 17 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 18 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 18 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 21 #include "chrome/browser/ui/browser_navigator.h" | 21 #include "chrome/browser/ui/browser_navigator.h" |
| 22 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 22 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
| 23 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" | 23 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" |
| 24 #include "chrome/browser/ui/content_settings/media_setting_changed_infobar_deleg
ate.h" | 24 #include "chrome/browser/ui/content_settings/media_setting_changed_infobar_deleg
ate.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/content_settings.h" | 26 #include "chrome/common/content_settings.h" |
| 27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
| 29 #include "content/public/browser/media_capture_devices.h" |
| 29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 33 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/browser/web_contents_delegate.h" | 35 #include "content/public/browser/web_contents_delegate.h" |
| 35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 36 #include "grit/theme_resources.h" | 37 #include "grit/theme_resources.h" |
| 37 #include "grit/ui_resources.h" | 38 #include "grit/ui_resources.h" |
| 38 #include "net/base/net_util.h" | 39 #include "net/base/net_util.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
| 41 | 42 |
| 42 using base::UserMetricsAction; | 43 using base::UserMetricsAction; |
| 44 using content::MediaCaptureDevices; |
| 43 using content::WebContents; | 45 using content::WebContents; |
| 44 using content_settings::SettingInfo; | 46 using content_settings::SettingInfo; |
| 45 using content_settings::SettingSource; | 47 using content_settings::SettingSource; |
| 46 using content_settings::SETTING_SOURCE_USER; | 48 using content_settings::SETTING_SOURCE_USER; |
| 47 using content_settings::SETTING_SOURCE_NONE; | 49 using content_settings::SETTING_SOURCE_NONE; |
| 48 | 50 |
| 49 namespace { | 51 namespace { |
| 50 | 52 |
| 51 const int kAllowButtonIndex = 0; | 53 const int kAllowButtonIndex = 0; |
| 52 | 54 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 void ContentSettingMediaStreamBubbleModel::SetMediaMenus() { | 788 void ContentSettingMediaStreamBubbleModel::SetMediaMenus() { |
| 787 TabSpecificContentSettings* content_settings = | 789 TabSpecificContentSettings* content_settings = |
| 788 TabSpecificContentSettings::FromWebContents(web_contents()); | 790 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 789 const std::string& requested_microphone = | 791 const std::string& requested_microphone = |
| 790 content_settings->media_stream_requested_audio_device(); | 792 content_settings->media_stream_requested_audio_device(); |
| 791 const std::string& requested_camera = | 793 const std::string& requested_camera = |
| 792 content_settings->media_stream_requested_video_device(); | 794 content_settings->media_stream_requested_video_device(); |
| 793 | 795 |
| 794 // Add microphone menu. | 796 // Add microphone menu. |
| 795 PrefService* prefs = profile()->GetPrefs(); | 797 PrefService* prefs = profile()->GetPrefs(); |
| 796 MediaCaptureDevicesDispatcher* dispatcher = | 798 MediaCaptureDevices* media_capture_devices = |
| 797 MediaCaptureDevicesDispatcher::GetInstance(); | 799 MediaCaptureDevices::GetInstance(); |
| 798 const content::MediaStreamDevices& microphones = | 800 const content::MediaStreamDevices& microphones = |
| 799 dispatcher->GetAudioCaptureDevices(); | 801 media_capture_devices->GetAudioCaptureDevices(); |
| 800 | 802 |
| 801 bool show_mic_menu = | 803 bool show_mic_menu = |
| 802 (state_ == TabSpecificContentSettings::MICROPHONE_ACCESSED || | 804 (state_ == TabSpecificContentSettings::MICROPHONE_ACCESSED || |
| 803 state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED || | 805 state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED || |
| 804 state_ == TabSpecificContentSettings::MICROPHONE_BLOCKED || | 806 state_ == TabSpecificContentSettings::MICROPHONE_BLOCKED || |
| 805 state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED); | 807 state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED); |
| 806 bool show_camera_menu = | 808 bool show_camera_menu = |
| 807 (state_ == TabSpecificContentSettings::CAMERA_ACCESSED || | 809 (state_ == TabSpecificContentSettings::CAMERA_ACCESSED || |
| 808 state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED || | 810 state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED || |
| 809 state_ == TabSpecificContentSettings::CAMERA_BLOCKED || | 811 state_ == TabSpecificContentSettings::CAMERA_BLOCKED || |
| (...skipping 17 matching lines...) Expand all Loading... |
| 827 } | 829 } |
| 828 | 830 |
| 829 mic_menu.default_device = GetMediaDeviceById(preferred_mic, microphones); | 831 mic_menu.default_device = GetMediaDeviceById(preferred_mic, microphones); |
| 830 mic_menu.selected_device = mic_menu.default_device; | 832 mic_menu.selected_device = mic_menu.default_device; |
| 831 } | 833 } |
| 832 add_media_menu(content::MEDIA_DEVICE_AUDIO_CAPTURE, mic_menu); | 834 add_media_menu(content::MEDIA_DEVICE_AUDIO_CAPTURE, mic_menu); |
| 833 } | 835 } |
| 834 | 836 |
| 835 if (show_camera_menu) { | 837 if (show_camera_menu) { |
| 836 const content::MediaStreamDevices& cameras = | 838 const content::MediaStreamDevices& cameras = |
| 837 dispatcher->GetVideoCaptureDevices(); | 839 media_capture_devices->GetVideoCaptureDevices(); |
| 838 MediaMenu camera_menu; | 840 MediaMenu camera_menu; |
| 839 camera_menu.label = | 841 camera_menu.label = |
| 840 l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_CAMERA_LABEL); | 842 l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_CAMERA_LABEL); |
| 841 if (!cameras.empty()) { | 843 if (!cameras.empty()) { |
| 842 std::string preferred_camera; | 844 std::string preferred_camera; |
| 843 if (requested_camera.empty()) { | 845 if (requested_camera.empty()) { |
| 844 preferred_camera = prefs->GetString(prefs::kDefaultVideoCaptureDevice); | 846 preferred_camera = prefs->GetString(prefs::kDefaultVideoCaptureDevice); |
| 845 camera_menu.disabled = false; | 847 camera_menu.disabled = false; |
| 846 } else { | 848 } else { |
| 847 // Disable the menu since the website is managing the camera devices | 849 // Disable the menu since the website is managing the camera devices |
| (...skipping 13 matching lines...) Expand all Loading... |
| 861 void ContentSettingMediaStreamBubbleModel::OnRadioClicked(int radio_index) { | 863 void ContentSettingMediaStreamBubbleModel::OnRadioClicked(int radio_index) { |
| 862 selected_item_ = radio_index; | 864 selected_item_ = radio_index; |
| 863 } | 865 } |
| 864 | 866 |
| 865 void ContentSettingMediaStreamBubbleModel::OnMediaMenuClicked( | 867 void ContentSettingMediaStreamBubbleModel::OnMediaMenuClicked( |
| 866 content::MediaStreamType type, | 868 content::MediaStreamType type, |
| 867 const std::string& selected_device_id) { | 869 const std::string& selected_device_id) { |
| 868 DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE || | 870 DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE || |
| 869 type == content::MEDIA_DEVICE_VIDEO_CAPTURE); | 871 type == content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 870 DCHECK_EQ(1U, bubble_content().media_menus.count(type)); | 872 DCHECK_EQ(1U, bubble_content().media_menus.count(type)); |
| 871 MediaCaptureDevicesDispatcher* dispatcher = | 873 MediaCaptureDevices* media_capture_devices = |
| 872 MediaCaptureDevicesDispatcher::GetInstance(); | 874 MediaCaptureDevices::GetInstance(); |
| 873 const content::MediaStreamDevices& devices = | 875 const content::MediaStreamDevices& devices = |
| 874 (type == content::MEDIA_DEVICE_AUDIO_CAPTURE) ? | 876 (type == content::MEDIA_DEVICE_AUDIO_CAPTURE) ? |
| 875 dispatcher->GetAudioCaptureDevices() : | 877 media_capture_devices->GetAudioCaptureDevices() : |
| 876 dispatcher->GetVideoCaptureDevices(); | 878 media_capture_devices->GetVideoCaptureDevices(); |
| 877 set_selected_device(GetMediaDeviceById(selected_device_id, devices)); | 879 set_selected_device(GetMediaDeviceById(selected_device_id, devices)); |
| 878 } | 880 } |
| 879 | 881 |
| 880 class ContentSettingDomainListBubbleModel | 882 class ContentSettingDomainListBubbleModel |
| 881 : public ContentSettingTitleAndLinkModel { | 883 : public ContentSettingTitleAndLinkModel { |
| 882 public: | 884 public: |
| 883 ContentSettingDomainListBubbleModel(Delegate* delegate, | 885 ContentSettingDomainListBubbleModel(Delegate* delegate, |
| 884 WebContents* web_contents, | 886 WebContents* web_contents, |
| 885 Profile* profile, | 887 Profile* profile, |
| 886 ContentSettingsType content_type); | 888 ContentSettingsType content_type); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1307 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1306 DCHECK_EQ(web_contents_, | 1308 DCHECK_EQ(web_contents_, |
| 1307 content::Source<WebContents>(source).ptr()); | 1309 content::Source<WebContents>(source).ptr()); |
| 1308 web_contents_ = NULL; | 1310 web_contents_ = NULL; |
| 1309 } else { | 1311 } else { |
| 1310 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1312 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1311 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1313 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1312 profile_ = NULL; | 1314 profile_ = NULL; |
| 1313 } | 1315 } |
| 1314 } | 1316 } |
| OLD | NEW |