Chromium Code Reviews| Index: chrome/browser/media/media_stream_capture_indicator.cc |
| diff --git a/chrome/browser/media/media_stream_capture_indicator.cc b/chrome/browser/media/media_stream_capture_indicator.cc |
| index 7c47dcf672da2244b6e5cdfaf1fbaeab430fcc0d..3f73ff16a6f8a758acbe091763acc9b5cea0731c 100644 |
| --- a/chrome/browser/media/media_stream_capture_indicator.cc |
| +++ b/chrome/browser/media/media_stream_capture_indicator.cc |
| @@ -17,6 +17,7 @@ |
| #include "chrome/browser/status_icons/status_icon.h" |
| #include "chrome/browser/status_icons/status_tray.h" |
| #include "chrome/browser/tab_contents/tab_util.h" |
| +#include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/pref_names.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/content_browser_client.h" |
| @@ -57,6 +58,25 @@ const extensions::Extension* GetExtension(WebContents* web_contents) { |
| web_contents->GetURL()); |
| } |
| +#if !defined(OS_ANDROID) |
| + |
| +bool IsWhitelistedExtension(const extensions::Extension* extension) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + static const char* kExtensionWhitelist[] = { |
|
no longer working on chromium
2014/04/25 11:19:34
nit, static const char* const ?
tommi (sloooow) - chröme
2014/04/25 14:53:50
Done.
|
| + extension_misc::kHotwordExtensionId, |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(kExtensionWhitelist); ++i) { |
| + if (extension->id() == kExtensionWhitelist[i]) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| +#endif // !defined(OS_ANDROID) |
|
no longer working on chromium
2014/04/25 11:19:34
nit, one empty space between // and !defined(OS_AN
tommi (sloooow) - chröme
2014/04/25 14:53:50
Done.
|
| + |
| // Gets the security originator of the tab. It returns a string with no '/' |
| // at the end to display in the UI. |
| base::string16 GetSecurityOrigin(WebContents* web_contents) { |
| @@ -405,30 +425,33 @@ void MediaStreamCaptureIndicator::UpdateNotificationUserInterface() { |
| iter != usage_map_.end(); ++iter) { |
| // Check if any audio and video devices have been used. |
| const WebContentsDeviceUsage& usage = *iter->second; |
| + if (!usage.IsCapturingAudio() && !usage.IsCapturingVideo()) |
| + continue; |
| + |
| WebContents* const web_contents = iter->first; |
| // Audio/video icon is shown only for extensions or on Android. |
|
no longer working on chromium
2014/04/25 11:19:34
could you please update the comment to explain we
tommi (sloooow) - chröme
2014/04/25 14:53:50
Done.
|
| // For regular tabs on desktop, we show an indicator in the tab icon. |
| - if ((usage.IsCapturingAudio() || usage.IsCapturingVideo()) |
| #if !defined(OS_ANDROID) |
| - && GetExtension(web_contents) |
| + const extensions::Extension* extension = GetExtension(web_contents); |
| + if (!extension || IsWhitelistedExtension(extension)) |
| + continue; |
| #endif |
| - ) { |
| - audio = audio || usage.IsCapturingAudio(); |
| - video = video || usage.IsCapturingVideo(); |
| - command_targets_.push_back(web_contents); |
| - menu->AddItem(command_id, GetTitle(web_contents)); |
| + audio = audio || usage.IsCapturingAudio(); |
| + video = video || usage.IsCapturingVideo(); |
| - // If the menu item is not a label, enable it. |
| - menu->SetCommandIdEnabled(command_id, |
| - command_id != IDC_MinimumLabelValue); |
| + command_targets_.push_back(web_contents); |
| + menu->AddItem(command_id, GetTitle(web_contents)); |
| - // If reaching the maximum number, no more item will be added to the menu. |
| - if (command_id == IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_LAST) |
| - break; |
| - ++command_id; |
| - } |
| + // If the menu item is not a label, enable it. |
| + menu->SetCommandIdEnabled(command_id, |
| + command_id != IDC_MinimumLabelValue); |
| + |
| + // If reaching the maximum number, no more item will be added to the menu. |
| + if (command_id == IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_LAST) |
| + break; |
| + ++command_id; |
| } |
| if (command_targets_.empty()) { |