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

Side by Side 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, 2 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
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_image_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
6 6
7 #include "chrome/browser/content_settings/host_content_settings_map.h" 7 #include "chrome/browser/content_settings/host_content_settings_map.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/prerender/prerender_manager.h" 9 #include "chrome/browser/prerender/prerender_manager.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. 238 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA.
239 DCHECK_EQ(get_content_settings_type(), CONTENT_SETTINGS_TYPE_MEDIASTREAM); 239 DCHECK_EQ(get_content_settings_type(), CONTENT_SETTINGS_TYPE_MEDIASTREAM);
240 240
241 if (!web_contents) 241 if (!web_contents)
242 return; 242 return;
243 243
244 TabSpecificContentSettings* content_settings = 244 TabSpecificContentSettings* content_settings =
245 TabSpecificContentSettings::FromWebContents(web_contents); 245 TabSpecificContentSettings::FromWebContents(web_contents);
246 if (!content_settings) 246 if (!content_settings)
247 return; 247 return;
248 TabSpecificContentSettings::MicrophoneCameraState state = 248 unsigned state = content_settings->GetMicrophoneCameraState();
249 content_settings->GetMicrophoneCameraState();
250 249
251 switch (state) { 250 // If neither the microphone nor the camera stream was accessed then no icon
252 case TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED: 251 // is displayed in the omnibox.
253 // If neither the microphone nor the camera stream was accessed then no 252 if (state == TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED)
254 // icon is displayed in the omnibox. 253 return;
255 return; 254
256 case TabSpecificContentSettings::MICROPHONE_ACCESSED: 255 const bool is_mic = state & TabSpecificContentSettings::MICROPHONE_ACCESSED;
257 set_icon(IDR_ASK_MEDIA); 256 const bool is_cam = state & TabSpecificContentSettings::CAMERA_ACCESSED;
257 DCHECK(is_mic || is_cam);
258
259 if (state & (TabSpecificContentSettings::MICROPHONE_BLOCKED |
260 TabSpecificContentSettings::CAMERA_BLOCKED)) {
261 set_icon(IDR_BLOCKED_MEDIA);
262 if (is_mic && is_cam)
263 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_BLOCKED));
264 else if (is_mic)
265 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_BLOCKED));
266 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.
267 set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_BLOCKED));
268 } else {
269 set_icon(IDR_ASK_MEDIA);
270 if (is_mic && is_cam)
271 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
272 else if (is_mic)
258 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED)); 273 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
259 break; 274 else if (is_cam)
260 case TabSpecificContentSettings::CAMERA_ACCESSED:
261 set_icon(IDR_ASK_MEDIA);
262 set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED)); 275 set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED));
263 break;
264 case TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED:
265 set_icon(IDR_ASK_MEDIA);
266 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
267 break;
268 case TabSpecificContentSettings::MICROPHONE_BLOCKED:
269 set_icon(IDR_BLOCKED_MEDIA);
270 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_BLOCKED));
271 break;
272 case TabSpecificContentSettings::CAMERA_BLOCKED:
273 set_icon(IDR_BLOCKED_MEDIA);
274 set_tooltip(l10n_util::GetStringUTF8(IDS_CAMERA_BLOCKED));
275 break;
276 case TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED:
277 set_icon(IDR_BLOCKED_MEDIA);
278 set_tooltip(l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_BLOCKED));
279 break;
280 } 276 }
281 set_visible(true); 277 set_visible(true);
282 } 278 }
283 279
284 ContentSettingRPHImageModel::ContentSettingRPHImageModel() 280 ContentSettingRPHImageModel::ContentSettingRPHImageModel()
285 : ContentSettingImageModel( 281 : ContentSettingImageModel(
286 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { 282 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
287 set_icon(IDR_REGISTER_PROTOCOL_HANDLER); 283 set_icon(IDR_REGISTER_PROTOCOL_HANDLER);
288 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); 284 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP));
289 } 285 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: 362 case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
367 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: 363 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
368 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: 364 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
369 return new ContentSettingMediaImageModel(content_settings_type); 365 return new ContentSettingMediaImageModel(content_settings_type);
370 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 366 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
371 return new ContentSettingMIDISysExImageModel(); 367 return new ContentSettingMIDISysExImageModel();
372 default: 368 default:
373 return new ContentSettingBlockedImageModel(content_settings_type); 369 return new ContentSettingBlockedImageModel(content_settings_type);
374 } 370 }
375 } 371 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698