Chromium Code Reviews| 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 b16b6682d80e5e8a0ad110f8fda478973c7602ce..e942423aee341b1a3d4023091f4736cf11dfb23c 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
| @@ -578,12 +578,16 @@ class ContentSettingMediaStreamBubbleModel |
| ~ContentSettingMediaStreamBubbleModel() override; |
| + void OnManageLinkClicked() override; |
| + |
| private: |
| void SetTitle(); |
| // Sets the data for the radio buttons of the bubble. |
| void SetRadioGroup(); |
| // Sets the data for the media menus of the bubble. |
| void SetMediaMenus(); |
| + // Set the settings management link. |
| + void SetManageLink(); |
| void SetCustomLink(); |
| // Updates the camera and microphone setting with the passed |setting|. |
| void UpdateSettings(ContentSetting setting); |
| @@ -614,6 +618,16 @@ ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel( |
| delegate, web_contents, profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM), |
| selected_item_(0), |
| state_(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) { |
| + // TODO(msramek): Every bubble is tied to a particular content setting. |
| + // The media bubble has three states - mic only, camera only, and both. |
| + // However, it is always tied to the deprecated MEDIASTREAM setting. Refactor |
| + // this so that it refers to the MIC setting for microphone and CAMERA |
| + // setting for camera to reduce the duplication of code in practically every |
| + // method. Furthermore, it should be possible not to tie the bubble to any |
| + // particular content setting type, as we still need the bubble for both |
| + // camera and microphone, but should not use the deprecated MEDIASTREAM |
| + // setting. |
| + |
| DCHECK(profile); |
| // Initialize the content settings associated with the individual radio |
| // buttons. |
| @@ -629,6 +643,7 @@ ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel( |
| SetTitle(); |
| SetRadioGroup(); |
| SetMediaMenus(); |
| + SetManageLink(); |
| SetCustomLink(); |
| } |
| @@ -653,6 +668,21 @@ ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { |
| } |
| } |
| +void ContentSettingMediaStreamBubbleModel::OnManageLinkClicked() { |
| + if (!delegate()) |
| + return; |
| + |
| + if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) { |
| + delegate()->ShowContentSettingsPage( |
| + state_ & TabSpecificContentSettings::CAMERA_ACCESSED |
| + ? CONTENT_SETTINGS_TYPE_MEDIASTREAM |
| + : CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| + } else { |
| + delegate()->ShowContentSettingsPage( |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| + } |
| +} |
| + |
| void ContentSettingMediaStreamBubbleModel::SetTitle() { |
| DCHECK_NE(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED, state_); |
| int title_id = 0; |
| @@ -845,6 +875,21 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() { |
| } |
| } |
| +void ContentSettingMediaStreamBubbleModel::SetManageLink() { |
| + // By default, the manage link refers to both media types. We only need |
| + // to change the text if only one media type was accessed. |
|
msw
2015/07/30 17:15:27
nit: s/text/link/
msramek
2015/07/31 12:34:52
Actually, I wanted to emphasize that here we're ch
msw
2015/07/31 17:36:04
Acknowledged.
|
| + if ((state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) && |
| + (state_ & TabSpecificContentSettings::CAMERA_ACCESSED)) { |
| + return; |
| + } |
| + |
| + set_manage_link(state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED |
| + ? l10n_util::GetStringUTF8( |
|
msw
2015/07/30 17:15:27
nit: put the trinary within l10n_util::GetStringUT
msramek
2015/07/31 12:34:52
Done.
|
| + IDS_MEDIASTREAM_MICROPHONE_BUBBLE_MANAGE_LINK) |
| + : l10n_util::GetStringUTF8( |
| + IDS_MEDIASTREAM_CAMERA_BUBBLE_MANAGE_LINK)); |
| +} |
| + |
| void ContentSettingMediaStreamBubbleModel::SetCustomLink() { |
| TabSpecificContentSettings* content_settings = |
| TabSpecificContentSettings::FromWebContents(web_contents()); |