Index: chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
index 102ddb65fae0c0592bc35fa2e2baf0f3f9d36ec9..4a5fc63ef154cee2c0cf43b1a48d88fbcea54945 100644 |
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
@@ -15,13 +15,13 @@ |
#include "chrome/browser/favicon/favicon_tab_helper.h" |
#include "chrome/browser/infobars/infobar_service.h" |
#include "chrome/browser/media/media_capture_devices_dispatcher.h" |
+#include "chrome/browser/media/media_stream_capture_indicator.h" |
#include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
#include "chrome/browser/ui/browser_navigator.h" |
#include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
#include "chrome/browser/ui/content_settings/content_setting_bubble_model_delegate.h" |
-#include "chrome/browser/ui/content_settings/media_setting_changed_infobar_delegate.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/common/render_messages.h" |
@@ -566,6 +566,7 @@ class ContentSettingMediaStreamBubbleModel |
void SetRadioGroup(); |
// Sets the data for the media menus of the bubble. |
void SetMediaMenus(); |
+ void SetCustomLink(); |
// Updates the camera and microphone setting with the passed |setting|. |
void UpdateSettings(ContentSetting setting); |
// Updates the camera and microphone default device with the passed |type| |
@@ -608,6 +609,7 @@ ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel( |
SetTitle(); |
SetRadioGroup(); |
SetMediaMenus(); |
+ SetCustomLink(); |
} |
ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { |
@@ -616,25 +618,16 @@ ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { |
if (!web_contents()) |
return; |
- bool media_setting_changed = false; |
for (MediaMenuMap::const_iterator it = bubble_content().media_menus.begin(); |
it != bubble_content().media_menus.end(); ++it) { |
if (it->second.selected_device.id != it->second.default_device.id) { |
UpdateDefaultDeviceForType(it->first, it->second.selected_device.id); |
- media_setting_changed = true; |
} |
} |
// Update the media settings if the radio button selection was changed. |
if (selected_item_ != bubble_content().radio_group.default_item) { |
UpdateSettings(radio_item_setting_[selected_item_]); |
- media_setting_changed = true; |
- } |
- |
- // Trigger the reload infobar if the media setting has been changed. |
- if (media_setting_changed) { |
- MediaSettingChangedInfoBarDelegate::Create( |
- InfoBarService::FromWebContents(web_contents())); |
} |
} |
@@ -685,6 +678,10 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
if (display_host.empty()) |
display_host = url.spec(); |
+ const bool is_mic_blocked = content_settings->IsContentBlocked( |
+ CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
+ const bool is_cam_blocked = content_settings->IsContentBlocked( |
+ CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
int radio_allow_label_id = 0; |
int radio_block_label_id = 0; |
switch (state_) { |
@@ -694,17 +691,17 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
case TabSpecificContentSettings::MICROPHONE_ACCESSED: |
radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION; |
radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK; |
- selected_item_ = 0; |
+ selected_item_ = is_mic_blocked ? 1 : 0; |
break; |
case TabSpecificContentSettings::CAMERA_ACCESSED: |
radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION; |
radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK; |
- selected_item_ = 0; |
+ selected_item_ = is_cam_blocked ? 1 : 0; |
break; |
case TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED: |
radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION; |
radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK; |
- selected_item_ = 0; |
+ selected_item_ = is_mic_blocked || is_cam_blocked ? 1 : 0; |
break; |
case TabSpecificContentSettings::MICROPHONE_BLOCKED: |
if (url.SchemeIsSecure()) { |
@@ -715,7 +712,7 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
} |
radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION; |
- selected_item_ = 1; |
+ selected_item_ = is_mic_blocked ? 1 : 0; |
break; |
case TabSpecificContentSettings::CAMERA_BLOCKED: |
if (url.SchemeIsSecure()) { |
@@ -726,7 +723,7 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
} |
radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION; |
- selected_item_ = 1; |
+ selected_item_ = is_cam_blocked ? 1 : 0; |
break; |
case TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED: |
if (url.SchemeIsSecure()) { |
@@ -737,7 +734,7 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
} |
radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION; |
- selected_item_ = 1; |
+ selected_item_ = is_mic_blocked || is_cam_blocked ? 1 : 0; |
break; |
} |
@@ -876,6 +873,25 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() { |
} |
} |
+void ContentSettingMediaStreamBubbleModel::SetCustomLink() { |
Peter Kasting
2014/09/22 23:11:23
Nit: Instead of having this function set the link
|
+ TabSpecificContentSettings* content_settings = |
+ TabSpecificContentSettings::FromWebContents(web_contents()); |
+ PrefService* prefs = profile()->GetPrefs(); |
+ |
+ if (content_settings->IsMicrophoneCameraStateChanged() || |
+ ((prefs->GetString(prefs::kDefaultAudioCaptureDevice) != |
+ content_settings->media_stream_selected_audio_device() || |
+ prefs->GetString(prefs::kDefaultVideoCaptureDevice) != |
+ content_settings->media_stream_selected_video_device()) && |
+ MediaCaptureDevicesDispatcher::GetInstance()-> |
+ GetMediaStreamCaptureIndicator()-> |
+ IsCapturingUserMedia(web_contents()))) { |
+ // TODO(robwu): Rename the next resource ID (remove "INFOBAR"). |
Peter Kasting
2014/09/22 23:11:23
Why not go ahead and do that in this change? It's
robwu
2014/09/24 00:03:04
Done.
|
+ set_custom_link(l10n_util::GetStringUTF8( |
+ IDS_MEDIASTREAM_SETTING_CHANGED_INFOBAR_MESSAGE)); |
Peter Kasting
2014/09/22 23:11:23
Nit: Bizarre indenting (should be 4)
robwu
2014/09/24 00:03:04
Done.
|
+ } |
+} |
+ |
void ContentSettingMediaStreamBubbleModel::OnRadioClicked(int radio_index) { |
selected_item_ = radio_index; |
} |