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

Side by Side Diff: chrome/browser/ui/views/desktop_media_picker_views.cc

Issue 501713002: Fix DesktopMediaPickerViews to handle background parent_web_contents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/api/desktopCapture/app.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/views/desktop_media_picker_views.h" 5 #include "chrome/browser/ui/views/desktop_media_picker_views.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/media/desktop_media_list.h" 10 #include "chrome/browser/media/desktop_media_list.h"
11 #include "chrome/browser/ui/ash/ash_util.h" 11 #include "chrome/browser/ui/ash/ash_util.h"
12 #include "chrome/browser/ui/views/constrained_window_views.h" 12 #include "chrome/browser/ui/views/constrained_window_views.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/web_modal/popup_manager.h" 15 #include "components/web_modal/popup_manager.h"
16 #include "components/web_modal/web_contents_modal_dialog_manager.h" 16 #include "components/web_modal/web_contents_modal_dialog_manager.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/web_contents_delegate.h"
18 #include "ui/aura/window_tree_host.h" 19 #include "ui/aura/window_tree_host.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/events/event_constants.h" 21 #include "ui/events/event_constants.h"
21 #include "ui/events/keycodes/keyboard_codes.h" 22 #include "ui/events/keycodes/keyboard_codes.h"
22 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
23 #include "ui/native_theme/native_theme.h" 24 #include "ui/native_theme/native_theme.h"
24 #include "ui/views/background.h" 25 #include "ui/views/background.h"
25 #include "ui/views/bubble/bubble_frame_view.h" 26 #include "ui/views/bubble/bubble_frame_view.h"
26 #include "ui/views/controls/image_view.h" 27 #include "ui/views/controls/image_view.h"
27 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 401 }
401 label_->SetMultiLine(true); 402 label_->SetMultiLine(true);
402 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 403 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
403 AddChildView(label_); 404 AddChildView(label_);
404 405
405 scroll_view_->SetContents(list_view_); 406 scroll_view_->SetContents(list_view_);
406 scroll_view_->ClipHeightTo( 407 scroll_view_->ClipHeightTo(
407 GetMediaListViewHeightForRows(1), GetMediaListViewHeightForRows(2)); 408 GetMediaListViewHeightForRows(1), GetMediaListViewHeightForRows(2));
408 AddChildView(scroll_view_); 409 AddChildView(scroll_view_);
409 410
410 // If |parent_web_contents| is set, the picker will be shown modal to the 411 // If |parent_web_contents| is set and it's not a background page then the
411 // web contents. Otherwise, a new dialog widget inside |parent_window| will be 412 // picker will be shown modal to the web contents. Otherwise the picker is
412 // created for the picker. Note that |parent_window| may also be NULL if 413 // shown in a separate window.
413 // parent web contents is not set. In this case the picker will be parented
414 // by a root window.
415 views::Widget* widget = NULL; 414 views::Widget* widget = NULL;
416 if (parent_web_contents) 415 bool modal_dialog =
Wez 2014/08/23 21:51:21 nit: Suggest has_visible_parent
Sergey Ulanov 2014/08/25 17:07:45 IMO |modal_dialog| makes code below more readable.
416 parent_web_contents &&
417 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents);
418 if (modal_dialog) {
417 widget = CreateWebModalDialogViews(this, parent_web_contents); 419 widget = CreateWebModalDialogViews(this, parent_web_contents);
418 else 420 } else {
419 widget = DialogDelegate::CreateDialogWidget(this, context, parent_window); 421 widget = DialogDelegate::CreateDialogWidget(this, context, NULL);
Wez 2014/08/23 21:51:20 Why do we also want to change the no-parent_web_co
Sergey Ulanov 2014/08/25 17:07:46 Currently this code is always called with parent_w
422 }
420 423
421 // DesktopMediaList needs to know the ID of the picker window which 424 // DesktopMediaList needs to know the ID of the picker window which
422 // matches the ID it gets from the OS. Depending on the OS and configuration 425 // matches the ID it gets from the OS. Depending on the OS and configuration
423 // we get this ID differently. 426 // we get this ID differently.
424 DesktopMediaID::Id dialog_window_id = 0; 427 DesktopMediaID::Id dialog_window_id = 0;
425 428
426 // If there is |parent_window| or |parent_web_contents|, the picker window 429 // If the picker is not modal then the picker window needs to be filtered.
Wez 2014/08/23 21:51:21 nit: Clarify what it means to be filtered/why? Wha
Sergey Ulanov 2014/08/25 17:07:45 Removed this comment and updated the comment above
427 // is embedded in the parent and does not have its own native window id, so we 430 if (!modal_dialog) {
428 // do not filter in that case.
429 if (!parent_window && !parent_web_contents) {
430 #if defined(USE_ASH) 431 #if defined(USE_ASH)
431 if (chrome::IsNativeWindowInAsh(widget->GetNativeWindow())) { 432 if (chrome::IsNativeWindowInAsh(widget->GetNativeWindow())) {
432 dialog_window_id = 433 dialog_window_id =
433 DesktopMediaID::RegisterAuraWindow(widget->GetNativeWindow()).id; 434 DesktopMediaID::RegisterAuraWindow(widget->GetNativeWindow()).id;
434 DCHECK_NE(dialog_window_id, 0); 435 DCHECK_NE(dialog_window_id, 0);
435 } 436 }
436 #endif 437 #endif
437 438
438 if (dialog_window_id == 0) { 439 if (dialog_window_id == 0) {
439 dialog_window_id = AcceleratedWidgetToDesktopMediaId( 440 dialog_window_id = AcceleratedWidgetToDesktopMediaId(
440 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()); 441 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
441 } 442 }
442 } 443 }
443 444
444 list_view_->StartUpdating(dialog_window_id); 445 list_view_->StartUpdating(dialog_window_id);
445 446
446 if (parent_web_contents) { 447 if (modal_dialog) {
447 web_modal::PopupManager* popup_manager = 448 web_modal::PopupManager* popup_manager =
448 web_modal::PopupManager::FromWebContents(parent_web_contents); 449 web_modal::PopupManager::FromWebContents(parent_web_contents);
449 popup_manager->ShowModalDialog(GetWidget()->GetNativeView(), 450 popup_manager->ShowModalDialog(GetWidget()->GetNativeView(),
450 parent_web_contents); 451 parent_web_contents);
451 } else { 452 } else {
452 widget->Show(); 453 widget->Show();
453 } 454 }
454 } 455 }
455 456
456 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} 457 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {}
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 content::BrowserThread::PostTask( 595 content::BrowserThread::PostTask(
595 content::BrowserThread::UI, FROM_HERE, 596 content::BrowserThread::UI, FROM_HERE,
596 base::Bind(callback_, source)); 597 base::Bind(callback_, source));
597 callback_.Reset(); 598 callback_.Reset();
598 } 599 }
599 600
600 // static 601 // static
601 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 602 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
602 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 603 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
603 } 604 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/examples/api/desktopCapture/app.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698