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

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

Issue 12843009: Replace screen capture confirmation infobar with a message box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/screen_capture_infobar_delegate.cc
diff --git a/chrome/browser/ui/screen_capture_infobar_delegate.cc b/chrome/browser/ui/screen_capture_infobar_delegate.cc
index 3ff83c3c1116670ed3fddd6472079adff1b175d1..c6b90f128ae0fc95c724fa72b56d35098d8d70e1 100644
--- a/chrome/browser/ui/screen_capture_infobar_delegate.cc
+++ b/chrome/browser/ui/screen_capture_infobar_delegate.cc
@@ -4,77 +4,30 @@
#include "chrome/browser/ui/screen_capture_infobar_delegate.h"
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
#include "chrome/browser/api/infobars/infobar_service.h"
-#include "chrome/common/chrome_switches.h"
+#include "chrome/browser/ui/screen_capture_confirmation_ui_infobar.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
-namespace {
-
-// This is a short-term solution to allow testing of the the Screen Capture API
-// with Google Hangouts in M27.
-// TODO(sergeyu): Remove this whitelist as soon as possible.
-bool IsWhitelistedOrigin(const GURL& origin) {
-#if defined(OFFICIAL_BUILD)
- return origin.spec() == "https://staging.talkgadget.google.com/" ||
- origin.spec() == "https://plus.google.com/";
-#else
- return false;
-#endif
-}
-
-} // namespace
-
-// static
-void ScreenCaptureInfoBarDelegate::Create(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) {
- bool screen_capture_enabled = CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableUserMediaScreenCapturing) ||
- IsWhitelistedOrigin(request.security_origin);
- // Deny request automatically in the following cases:
- // 1. Screen capturing is not enabled via command line switch.
- // 2. Audio capture was requested (it's not supported yet).
- // 3. Request from a page that was not loaded from a secure origin.
- if (!screen_capture_enabled ||
- request.audio_type != content::MEDIA_NO_SERVICE ||
- !request.security_origin.SchemeIsSecure()) {
- callback.Run(content::MediaStreamDevices());
- return;
- }
-
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents);
- infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
- new ScreenCaptureInfoBarDelegate(infobar_service, request, callback)));
-}
-
ScreenCaptureInfoBarDelegate::ScreenCaptureInfoBarDelegate(
InfoBarService* infobar_service,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback)
+ const string16& application_name,
+ ScreenCaptureConfirmationUIInfobar* result_handler)
: ConfirmInfoBarDelegate(infobar_service),
- request_(request),
- callback_(callback) {
- DCHECK_EQ(content::MEDIA_SCREEN_VIDEO_CAPTURE, request.video_type);
+ result_handler_(result_handler),
+ application_name_(application_name) {
}
ScreenCaptureInfoBarDelegate::~ScreenCaptureInfoBarDelegate() {
-}
-
-// Needed to avoid having more than one infobar with the same request.
-bool ScreenCaptureInfoBarDelegate::EqualsDelegate(
- InfoBarDelegate* delegate) const {
- ScreenCaptureInfoBarDelegate* other =
- delegate->AsScreenCaptureInfoBarDelegate();
- return other && other->request_.security_origin == request_.security_origin;
+ // Notify the handler if it hasn't been notified yet (e.g. if the tab is being
+ // closed).
+ if (result_handler_)
+ result_handler_->OnInfobarResult(false);
}
void ScreenCaptureInfoBarDelegate::InfoBarDismissed() {
- Deny();
+ result_handler_->OnInfobarResult(false);
+ result_handler_ = NULL;
}
InfoBarDelegate::Type ScreenCaptureInfoBarDelegate::GetInfoBarType() const {
@@ -88,8 +41,7 @@ ScreenCaptureInfoBarDelegate*
string16 ScreenCaptureInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringFUTF16(
- IDS_MEDIA_CAPTURE_SCREEN,
- UTF8ToUTF16(request_.security_origin.spec()));
+ IDS_MEDIA_CAPTURE_SCREEN, application_name_);
}
string16 ScreenCaptureInfoBarDelegate::GetButtonLabel(
@@ -99,21 +51,13 @@ string16 ScreenCaptureInfoBarDelegate::GetButtonLabel(
}
bool ScreenCaptureInfoBarDelegate::Accept() {
- content::MediaStreamDevices devices;
-
- // Add screen capturer source if it was requested.
- devices.push_back(content::MediaStreamDevice(
- content::MEDIA_SCREEN_VIDEO_CAPTURE, std::string(), "Screen"));
-
- callback_.Run(devices);
+ result_handler_->OnInfobarResult(true);
+ result_handler_ = NULL;
return true;
}
bool ScreenCaptureInfoBarDelegate::Cancel() {
- Deny();
+ result_handler_->OnInfobarResult(false);
+ result_handler_ = NULL;
return true;
}
-
-void ScreenCaptureInfoBarDelegate::Deny() {
- callback_.Run(content::MediaStreamDevices());
-}

Powered by Google App Engine
This is Rietveld 408576698