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

Side by Side Diff: chrome/browser/media/media_capture_devices_dispatcher.cc

Issue 252673002: Fixed screen capture confirmation dialog to be either system or browser window modal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android build fix Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
6 6
7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h"
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 12 #include "base/prefs/scoped_user_pref_update.h"
11 #include "base/sha1.h" 13 #include "base/sha1.h"
12 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" 17 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
16 #include "chrome/browser/media/desktop_streams_registry.h" 18 #include "chrome/browser/media/desktop_streams_registry.h"
17 #include "chrome/browser/media/media_stream_capture_indicator.h" 19 #include "chrome/browser/media/media_stream_capture_indicator.h"
18 #include "chrome/browser/media/media_stream_infobar_delegate.h" 20 #include "chrome/browser/media/media_stream_infobar_delegate.h"
19 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/screen_capture_notification_ui.h" 25 #include "chrome/browser/ui/screen_capture_notification_ui.h"
21 #include "chrome/browser/ui/simple_message_box.h" 26 #include "chrome/browser/ui/simple_message_box.h"
22 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 27 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
23 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/chrome_version_info.h" 29 #include "chrome/common/chrome_version_info.h"
25 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
26 #include "components/user_prefs/pref_registry_syncable.h" 31 #include "components/user_prefs/pref_registry_syncable.h"
27 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/desktop_media_id.h" 33 #include "content/public/browser/desktop_media_id.h"
29 #include "content/public/browser/media_capture_devices.h" 34 #include "content/public/browser/media_capture_devices.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 int render_frame_id, 236 int render_frame_id,
232 int stream_id) { 237 int stream_id) {
233 AudioStreamMonitor* const audio_stream_monitor = 238 AudioStreamMonitor* const audio_stream_monitor =
234 AudioStreamMonitorFromRenderFrame(render_process_id, render_frame_id); 239 AudioStreamMonitorFromRenderFrame(render_process_id, render_frame_id);
235 if (audio_stream_monitor) 240 if (audio_stream_monitor)
236 audio_stream_monitor->StopMonitoringStream(stream_id); 241 audio_stream_monitor->StopMonitoringStream(stream_id);
237 } 242 }
238 243
239 #endif // defined(AUDIO_STREAM_MONITORING) 244 #endif // defined(AUDIO_STREAM_MONITORING)
240 245
246 #if !defined(OS_ANDROID)
247 // Find browser or app window from a given |web_contents|.
248 gfx::NativeWindow FindParentWindowForWebContents(
249 content::WebContents* web_contents) {
250 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
251 if (browser && browser->window())
252 return browser->window()->GetNativeWindow();
253
254 const apps::AppWindowRegistry::AppWindowList& window_list =
255 apps::AppWindowRegistry::Get(
256 web_contents->GetBrowserContext())->app_windows();
257 for (apps::AppWindowRegistry::AppWindowList::const_iterator iter =
258 window_list.begin();
259 iter != window_list.end(); ++iter) {
260 if ((*iter)->web_contents() == web_contents)
261 return (*iter)->GetNativeWindow();
262 }
263
264 return NULL;
265 }
266 #endif
267
241 } // namespace 268 } // namespace
242 269
243 MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest( 270 MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest(
244 const content::MediaStreamRequest& request, 271 const content::MediaStreamRequest& request,
245 const content::MediaResponseCallback& callback) 272 const content::MediaResponseCallback& callback)
246 : request(request), 273 : request(request),
247 callback(callback) { 274 callback(callback) {
248 } 275 }
249 276
250 MediaCaptureDevicesDispatcher::PendingAccessRequest::~PendingAccessRequest() {} 277 MediaCaptureDevicesDispatcher::PendingAccessRequest::~PendingAccessRequest() {}
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // 1. Screen capturing is enabled via command line switch or white-listed for 474 // 1. Screen capturing is enabled via command line switch or white-listed for
448 // the given origin. 475 // the given origin.
449 // 2. Request comes from a page with a secure origin or from an extension. 476 // 2. Request comes from a page with a secure origin or from an extension.
450 if (screen_capture_enabled && origin_is_secure) { 477 if (screen_capture_enabled && origin_is_secure) {
451 // Get title of the calling application prior to showing the message box. 478 // Get title of the calling application prior to showing the message box.
452 // chrome::ShowMessageBox() starts a nested message loop which may allow 479 // chrome::ShowMessageBox() starts a nested message loop which may allow
453 // |web_contents| to be destroyed on the UI thread before the message box 480 // |web_contents| to be destroyed on the UI thread before the message box
454 // is closed. See http://crbug.com/326690. 481 // is closed. See http://crbug.com/326690.
455 base::string16 application_title = 482 base::string16 application_title =
456 GetApplicationTitle(web_contents, extension); 483 GetApplicationTitle(web_contents, extension);
484 #if !defined(OS_ANDROID)
485 gfx::NativeWindow parent_window =
486 FindParentWindowForWebContents(web_contents);
487 #else
488 gfx::NativeWindow parent_window = NULL;
489 #endif
457 web_contents = NULL; 490 web_contents = NULL;
458 491
459 // For component extensions, bypass message box. 492 // For component extensions, bypass message box.
460 bool user_approved = false; 493 bool user_approved = false;
461 if (!component_extension) { 494 if (!component_extension) {
462 base::string16 application_name = base::UTF8ToUTF16( 495 base::string16 application_name = base::UTF8ToUTF16(
463 extension ? extension->name() : request.security_origin.spec()); 496 extension ? extension->name() : request.security_origin.spec());
464 base::string16 confirmation_text = l10n_util::GetStringFUTF16( 497 base::string16 confirmation_text = l10n_util::GetStringFUTF16(
465 request.audio_type == content::MEDIA_NO_SERVICE ? 498 request.audio_type == content::MEDIA_NO_SERVICE ?
466 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TEXT : 499 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TEXT :
467 IDS_MEDIA_SCREEN_AND_AUDIO_CAPTURE_CONFIRMATION_TEXT, 500 IDS_MEDIA_SCREEN_AND_AUDIO_CAPTURE_CONFIRMATION_TEXT,
468 application_name); 501 application_name);
469 chrome::MessageBoxResult result = chrome::ShowMessageBox( 502 chrome::MessageBoxResult result = chrome::ShowMessageBox(
470 NULL, 503 parent_window,
471 l10n_util::GetStringFUTF16( 504 l10n_util::GetStringFUTF16(
472 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TITLE, application_name), 505 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TITLE, application_name),
473 confirmation_text, 506 confirmation_text,
474 chrome::MESSAGE_BOX_TYPE_QUESTION); 507 chrome::MESSAGE_BOX_TYPE_QUESTION);
475 user_approved = (result == chrome::MESSAGE_BOX_RESULT_YES); 508 user_approved = (result == chrome::MESSAGE_BOX_RESULT_YES);
476 } 509 }
477 510
478 if (user_approved || component_extension) { 511 if (user_approved || component_extension) {
479 content::DesktopMediaID screen_id; 512 content::DesktopMediaID screen_id;
480 #if defined(OS_CHROMEOS) 513 #if defined(OS_CHROMEOS)
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 977
945 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( 978 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices(
946 const MediaStreamDevices& devices) { 979 const MediaStreamDevices& devices) {
947 test_audio_devices_ = devices; 980 test_audio_devices_ = devices;
948 } 981 }
949 982
950 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( 983 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices(
951 const MediaStreamDevices& devices) { 984 const MediaStreamDevices& devices) {
952 test_video_devices_ = devices; 985 test_video_devices_ = devices;
953 } 986 }
OLDNEW
« no previous file with comments | « ash/wm/window_modality_controller_unittest.cc ('k') | chrome/browser/ui/views/simple_message_box_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698