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

Unified Diff: chrome/browser/ui/media_stream_infobar_delegate.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/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());
+}
« no previous file with comments | « chrome/browser/ui/media_stream_infobar_delegate.h ('k') | chrome/browser/ui/startup/autolaunch_prompt_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698