| Index: chrome/browser/ui/media_stream_infobar_delegate.cc
|
| ===================================================================
|
| --- chrome/browser/ui/media_stream_infobar_delegate.cc (revision 175396)
|
| +++ chrome/browser/ui/media_stream_infobar_delegate.cc (working copy)
|
| @@ -8,6 +8,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/api/infobars/infobar_service.h"
|
| #include "chrome/browser/google/google_util.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "googleurl/src/gurl.h"
|
| @@ -16,17 +17,40 @@
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
|
|
| -MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate(
|
| - InfoBarService* infobar_service,
|
| - MediaStreamDevicesController* controller)
|
| - : ConfirmInfoBarDelegate(infobar_service),
|
| - controller_(controller) {
|
| - DCHECK(controller_.get());
|
| - DCHECK(controller_->has_audio() || controller_->has_video());
|
| +MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {}
|
| +
|
| +// static
|
| +bool MediaStreamInfoBarDelegate::Create(
|
| + content::WebContents* web_contents,
|
| + const content::MediaStreamRequest& request,
|
| + const content::MediaResponseCallback& callback) {
|
| + Profile* profile =
|
| + Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
| +
|
| + scoped_ptr<MediaStreamDevicesController> controller(
|
| + new MediaStreamDevicesController(profile, request, callback));
|
| + if (!controller->DismissInfoBarAndTakeActionOnSettings()) {
|
| + InfoBarService* infobar_service =
|
| + InfoBarService::FromWebContents(web_contents);
|
| + InfoBarDelegate* old_infobar = NULL;
|
| + for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
|
| + old_infobar = infobar_service->GetInfoBarDelegateAt(i)->
|
| + AsMediaStreamInfoBarDelegate();
|
| + if (old_infobar)
|
| + break;
|
| + }
|
| +
|
| + scoped_ptr<InfoBarDelegate> infobar(
|
| + new MediaStreamInfoBarDelegate(infobar_service, controller.release()));
|
| + if (old_infobar)
|
| + infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass());
|
| + else
|
| + infobar_service->AddInfoBar(infobar.Pass());
|
| + return true;
|
| + }
|
| + return false;
|
| }
|
|
|
| -MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {}
|
| -
|
| void MediaStreamInfoBarDelegate::InfoBarDismissed() {
|
| // Deny the request if the infobar was closed with the 'x' button, since
|
| // we don't want WebRTC to be waiting for an answer that will never come.
|
| @@ -91,3 +115,12 @@
|
|
|
| return false; // Do not dismiss the info bar.
|
| }
|
| +
|
| +MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate(
|
| + InfoBarService* infobar_service,
|
| + MediaStreamDevicesController* controller)
|
| + : ConfirmInfoBarDelegate(infobar_service),
|
| + controller_(controller) {
|
| + DCHECK(controller_.get());
|
| + DCHECK(controller_->has_audio() || controller_->has_video());
|
| +}
|
|
|