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

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
« no previous file with comments | « chrome/browser/ui/screen_capture_infobar_delegate.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index 3b06fbfff16c562e14fac959f974140180fb550e..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/screen_capture_infobar_delegate.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/screen_capture_infobar_delegate.h"
-
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/common/chrome_switches.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)
- : ConfirmInfoBarDelegate(infobar_service),
- request_(request),
- callback_(callback) {
- DCHECK_EQ(content::MEDIA_SCREEN_VIDEO_CAPTURE, request.video_type);
-}
-
-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;
-}
-
-void ScreenCaptureInfoBarDelegate::InfoBarDismissed() {
- Deny();
-}
-
-InfoBarDelegate::Type ScreenCaptureInfoBarDelegate::GetInfoBarType() const {
- return PAGE_ACTION_TYPE;
-}
-
-ScreenCaptureInfoBarDelegate*
- ScreenCaptureInfoBarDelegate::AsScreenCaptureInfoBarDelegate() {
- return this;
-}
-
-string16 ScreenCaptureInfoBarDelegate::GetMessageText() const {
- return l10n_util::GetStringFUTF16(
- IDS_MEDIA_CAPTURE_SCREEN,
- UTF8ToUTF16(request_.security_origin.spec()));
-}
-
-string16 ScreenCaptureInfoBarDelegate::GetButtonLabel(
- InfoBarButton button) const {
- return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
- IDS_MEDIA_CAPTURE_ALLOW : IDS_MEDIA_CAPTURE_DENY);
-}
-
-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);
- return true;
-}
-
-bool ScreenCaptureInfoBarDelegate::Cancel() {
- Deny();
- return true;
-}
-
-void ScreenCaptureInfoBarDelegate::Deny() {
- callback_.Run(content::MediaStreamDevices());
-}
« no previous file with comments | « chrome/browser/ui/screen_capture_infobar_delegate.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698