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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 10537099: add "always allow" option to the mediastream infobar and allow user to allow/not allow acces to devi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use only content settings, added a device controller, addressed all the comments Created 8 years, 6 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/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 9cc0a79944806e2daa6dd7185fed86358a6b6f59..7c71c9ea041706e2adc70b6d305db6fd6ce36eaf 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -40,6 +40,7 @@
#include "chrome/browser/gpu_util.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/media/media_internals.h"
+#include "chrome/browser/media/media_stream_devices_controller.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
@@ -1118,20 +1119,28 @@ void ChromeContentBrowserClient::RequestMediaAccessPermission(
TabContentsWrapper::GetCurrentWrapperForContents(contents);
DCHECK(tab);
- InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper();
- InfoBarDelegate* old_infobar = NULL;
- for (size_t i = 0; i < infobar_helper->infobar_count() && !old_infobar; ++i) {
- old_infobar =
- infobar_helper->GetInfoBarDelegateAt(i)->AsMediaStreamInfoBarDelegate();
- }
+ scoped_ptr<MediaStreamDevicesController>
+ controller(new MediaStreamDevicesController(tab->profile(),
+ request,
+ callback));
+ if (!controller->DismissInfoBarAndTakeActionOnSettings()) {
+ InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper();
+ InfoBarDelegate* old_infobar = NULL;
+ size_t i = 0;
+ for (; i < infobar_helper->infobar_count() && !old_infobar; ++i) {
+ old_infobar = infobar_helper->GetInfoBarDelegateAt(i)->
+ AsMediaStreamInfoBarDelegate();
+ }
- InfoBarDelegate* infobar = new MediaStreamInfoBarDelegate(infobar_helper,
- request,
- callback);
- if (old_infobar)
- infobar_helper->ReplaceInfoBar(old_infobar, infobar);
- else
- infobar_helper->AddInfoBar(infobar);
+ // The MediaStreamInfoBarDelegate will take the ownership of the controller;
+ MediaStreamInfoBarDelegate* infobar =
+ new MediaStreamInfoBarDelegate(infobar_helper,
+ controller.release());
+ if (old_infobar)
+ infobar_helper->ReplaceInfoBar(old_infobar, infobar);
+ else
+ infobar_helper->AddInfoBar(infobar);
+ }
}
content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {

Powered by Google App Engine
This is Rietveld 408576698