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

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: 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 // Find browser or app window from a given |web_contents|.
247 gfx::NativeWindow FindParentWindowForWebContents(
248 content::WebContents* web_contents) {
249 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
250 if (browser && browser->window())
251 return browser->window()->GetNativeWindow();
252
253 const apps::AppWindowRegistry::AppWindowList& window_list =
254 apps::AppWindowRegistry::Get(
255 web_contents->GetBrowserContext())->app_windows();
256 for (apps::AppWindowRegistry::AppWindowList::const_iterator iter =
257 window_list.begin();
258 iter != window_list.end(); ++iter) {
259 if ((*iter)->web_contents() == web_contents)
260 return (*iter)->GetNativeWindow();
261 }
262
263 return NULL;
264 }
265
241 } // namespace 266 } // namespace
242 267
243 MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest( 268 MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest(
244 const content::MediaStreamRequest& request, 269 const content::MediaStreamRequest& request,
245 const content::MediaResponseCallback& callback) 270 const content::MediaResponseCallback& callback)
246 : request(request), 271 : request(request),
247 callback(callback) { 272 callback(callback) {
248 } 273 }
249 274
250 MediaCaptureDevicesDispatcher::PendingAccessRequest::~PendingAccessRequest() {} 275 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 472 // 1. Screen capturing is enabled via command line switch or white-listed for
448 // the given origin. 473 // the given origin.
449 // 2. Request comes from a page with a secure origin or from an extension. 474 // 2. Request comes from a page with a secure origin or from an extension.
450 if (screen_capture_enabled && origin_is_secure) { 475 if (screen_capture_enabled && origin_is_secure) {
451 // Get title of the calling application prior to showing the message box. 476 // Get title of the calling application prior to showing the message box.
452 // chrome::ShowMessageBox() starts a nested message loop which may allow 477 // chrome::ShowMessageBox() starts a nested message loop which may allow
453 // |web_contents| to be destroyed on the UI thread before the message box 478 // |web_contents| to be destroyed on the UI thread before the message box
454 // is closed. See http://crbug.com/326690. 479 // is closed. See http://crbug.com/326690.
455 base::string16 application_title = 480 base::string16 application_title =
456 GetApplicationTitle(web_contents, extension); 481 GetApplicationTitle(web_contents, extension);
482 gfx::NativeWindow parent_window =
483 FindParentWindowForWebContents(web_contents);
457 web_contents = NULL; 484 web_contents = NULL;
458 485
459 // For component extensions, bypass message box. 486 // For component extensions, bypass message box.
460 bool user_approved = false; 487 bool user_approved = false;
461 if (!component_extension) { 488 if (!component_extension) {
462 base::string16 application_name = base::UTF8ToUTF16( 489 base::string16 application_name = base::UTF8ToUTF16(
463 extension ? extension->name() : request.security_origin.spec()); 490 extension ? extension->name() : request.security_origin.spec());
464 base::string16 confirmation_text = l10n_util::GetStringFUTF16( 491 base::string16 confirmation_text = l10n_util::GetStringFUTF16(
465 request.audio_type == content::MEDIA_NO_SERVICE ? 492 request.audio_type == content::MEDIA_NO_SERVICE ?
466 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TEXT : 493 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TEXT :
467 IDS_MEDIA_SCREEN_AND_AUDIO_CAPTURE_CONFIRMATION_TEXT, 494 IDS_MEDIA_SCREEN_AND_AUDIO_CAPTURE_CONFIRMATION_TEXT,
468 application_name); 495 application_name);
469 chrome::MessageBoxResult result = chrome::ShowMessageBox( 496 chrome::MessageBoxResult result = chrome::ShowMessageBox(
470 NULL, 497 parent_window,
471 l10n_util::GetStringFUTF16( 498 l10n_util::GetStringFUTF16(
472 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TITLE, application_name), 499 IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TITLE, application_name),
473 confirmation_text, 500 confirmation_text,
474 chrome::MESSAGE_BOX_TYPE_QUESTION); 501 chrome::MESSAGE_BOX_TYPE_QUESTION);
475 user_approved = (result == chrome::MESSAGE_BOX_RESULT_YES); 502 user_approved = (result == chrome::MESSAGE_BOX_RESULT_YES);
476 } 503 }
477 504
478 if (user_approved || component_extension) { 505 if (user_approved || component_extension) {
479 content::DesktopMediaID screen_id; 506 content::DesktopMediaID screen_id;
480 #if defined(OS_CHROMEOS) 507 #if defined(OS_CHROMEOS)
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 971
945 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( 972 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices(
946 const MediaStreamDevices& devices) { 973 const MediaStreamDevices& devices) {
947 test_audio_devices_ = devices; 974 test_audio_devices_ = devices;
948 } 975 }
949 976
950 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( 977 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices(
951 const MediaStreamDevices& devices) { 978 const MediaStreamDevices& devices) {
952 test_video_devices_ = devices; 979 test_video_devices_ = devices;
953 } 980 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/simple_message_box_views.cc » ('j') | ui/wm/core/window_modality_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698