Commit d014a672 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Notify web_contents() when a media capture device stops being used.

This CL sends the chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED
when a device is removed.
This fixes a bug that occurs when a navigation occurs on a tab that
is capturing audio or video.
In this case, it is possible that the navigation will complete
before the device has been completely stopped, and the new page will
show an icon with the device capture permission corresponding to the
previous page on the omnibar.
To remove that icon, it is necessary to let the tab know that content
settings might have changed.
If the navigation completes after the device stops, the bug does not
reproduce because completing the navigation sends the notification
about the change in content settings.

This bug becomes much more frequent when Site Isolation is enabled.

Bug: 896211
Change-Id: I6e9d7197d549b00b458ffc84d155487cb3db2fe6
Reviewed-on: https://chromium-review.googlesource.com/c/1319595Reviewed-by: default avatarTommi <tommi@chromium.org>
Commit-Queue: Tommi <tommi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605695}
parent 01943b46
...@@ -15,12 +15,14 @@ ...@@ -15,12 +15,14 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/status_icons/status_icon.h" #include "chrome/browser/status_icons/status_icon.h"
#include "chrome/browser/status_icons/status_tray.h" #include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/tab_contents/tab_util.h"
#include "components/url_formatter/elide_url.h" #include "components/url_formatter/elide_url.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
...@@ -209,8 +211,13 @@ void MediaStreamCaptureIndicator::WebContentsDeviceUsage::RemoveDevices( ...@@ -209,8 +211,13 @@ void MediaStreamCaptureIndicator::WebContentsDeviceUsage::RemoveDevices(
DCHECK_GE(stream_count, 0); DCHECK_GE(stream_count, 0);
} }
if (web_contents()) if (web_contents()) {
web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
content::Source<WebContents>(web_contents()),
content::NotificationService::NoDetails());
}
indicator_->UpdateNotificationUserInterface(); indicator_->UpdateNotificationUserInterface();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment