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

Unified Diff: chrome/browser/ui/content_settings/content_setting_image_model.cc

Issue 588153003: Remove MediaSettingChangedInfobar and show latest state in bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits, add tests, refactor to use bitmask instead of enum. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/content_settings/content_setting_image_model.cc
diff --git a/chrome/browser/ui/content_settings/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc
index 9eff20e4c68c977b252caaaf78deff8e77c492e5..9162a8587cba8cfd9368d7bf65c59106c97e7ec2 100644
--- a/chrome/browser/ui/content_settings/content_setting_image_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc
@@ -245,38 +245,34 @@ void ContentSettingMediaImageModel::UpdateFromWebContents(
TabSpecificContentSettings::FromWebContents(web_contents);
if (!content_settings)
return;
- TabSpecificContentSettings::MicrophoneCameraState state =
- content_settings->GetMicrophoneCameraState();
+ unsigned state = content_settings->GetMicrophoneCameraState();
- switch (state) {
- case TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED:
- // If neither the microphone nor the camera stream was accessed then no
- // icon is displayed in the omnibox.
- return;
- case TabSpecificContentSettings::MICROPHONE_ACCESSED:
- set_icon(IDR_ASK_MEDIA);
- set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
- break;
- case TabSpecificContentSettings::CAMERA_ACCESSED:
- set_icon(IDR_ASK_MEDIA);
- set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED));
- break;
- case TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED:
- set_icon(IDR_ASK_MEDIA);
- set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
- break;
- case TabSpecificContentSettings::MICROPHONE_BLOCKED:
- set_icon(IDR_BLOCKED_MEDIA);
+ // If neither the microphone nor the camera stream was accessed then no icon
+ // is displayed in the omnibox.
+ if (state == TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED)
+ return;
+
+ const bool is_mic = state & TabSpecificContentSettings::MICROPHONE_ACCESSED;
+ const bool is_cam = state & TabSpecificContentSettings::CAMERA_ACCESSED;
+ DCHECK(is_mic || is_cam);
+
+ if (state & (TabSpecificContentSettings::MICROPHONE_BLOCKED |
+ TabSpecificContentSettings::CAMERA_BLOCKED)) {
+ set_icon(IDR_BLOCKED_MEDIA);
+ if (is_mic && is_cam)
+ set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_BLOCKED));
+ else if (is_mic)
set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_BLOCKED));
- break;
- case TabSpecificContentSettings::CAMERA_BLOCKED:
- set_icon(IDR_BLOCKED_MEDIA);
+ else if (is_cam)
Peter Kasting 2014/09/24 01:33:00 Nit: This conditional is always true. Here's a sh
robwu 2014/09/24 23:38:45 Nice. Done.
set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_BLOCKED));
- break;
- case TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED:
- set_icon(IDR_BLOCKED_MEDIA);
- set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_BLOCKED));
- break;
+ } else {
+ set_icon(IDR_ASK_MEDIA);
+ if (is_mic && is_cam)
+ set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
+ else if (is_mic)
+ set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
+ else if (is_cam)
+ set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED));
}
set_visible(true);
}

Powered by Google App Engine
This is Rietveld 408576698