| OLD | NEW |
| 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/media/desktop_media_picker.h" | 5 #include "chrome/browser/media/desktop_media_picker.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "chrome/browser/media/desktop_media_list.h" | 8 #include "chrome/browser/media/desktop_media_list.h" |
| 9 #include "chrome/browser/media/desktop_media_list_observer.h" | 9 #include "chrome/browser/media/desktop_media_list_observer.h" |
| 10 #include "chrome/browser/ui/ash/ash_util.h" | 10 #include "chrome/browser/ui/ash/ash_util.h" |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 label_->SetText(l10n_util::GetStringFUTF16( | 511 label_->SetText(l10n_util::GetStringFUTF16( |
| 512 IDS_DESKTOP_MEDIA_PICKER_TEXT_DELEGATED, app_name, target_name)); | 512 IDS_DESKTOP_MEDIA_PICKER_TEXT_DELEGATED, app_name, target_name)); |
| 513 } | 513 } |
| 514 label_->SetMultiLine(true); | 514 label_->SetMultiLine(true); |
| 515 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 515 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 516 AddChildView(label_); | 516 AddChildView(label_); |
| 517 | 517 |
| 518 scroll_view_->SetContents(list_view_); | 518 scroll_view_->SetContents(list_view_); |
| 519 AddChildView(scroll_view_); | 519 AddChildView(scroll_view_); |
| 520 | 520 |
| 521 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 521 // If |parent_web_contents| is set, the picker will be shown modal to the |
| 522 WebContentsModalDialogManager::FromWebContents(parent_web_contents); | 522 // web contents. Otherwise, a new dialog widget inside |parent_window| will be |
| 523 DCHECK(web_contents_modal_dialog_manager); | 523 // created for the picker. Note that |parent_window| may also be NULL if |
| 524 WebContentsModalDialogManagerDelegate* delegate = | 524 // parent web contents is not set. In this case the picker will be parented |
| 525 web_contents_modal_dialog_manager->delegate(); | 525 // by a root window. |
| 526 DCHECK(delegate); | 526 WebContentsModalDialogManager* web_contents_modal_dialog_manager = NULL; |
| 527 views::Widget::CreateWindowAsFramelessChild( | 527 if (parent_web_contents) { |
| 528 this, | 528 web_contents_modal_dialog_manager = |
| 529 delegate->GetWebContentsModalDialogHost()->GetHostView()); | 529 WebContentsModalDialogManager::FromWebContents(parent_web_contents); |
| 530 DCHECK(web_contents_modal_dialog_manager); |
| 531 WebContentsModalDialogManagerDelegate* delegate = |
| 532 web_contents_modal_dialog_manager->delegate(); |
| 533 DCHECK(delegate); |
| 534 views::Widget::CreateWindowAsFramelessChild( |
| 535 this, |
| 536 delegate->GetWebContentsModalDialogHost()->GetHostView()); |
| 537 } else { |
| 538 DialogDelegate::CreateDialogWidget(this, context, parent_window); |
| 539 } |
| 530 | 540 |
| 531 // DesktopMediaList needs to know the ID of the picker window which | 541 // DesktopMediaList needs to know the ID of the picker window which |
| 532 // matches the ID it gets from the OS. Depending on the OS and configuration | 542 // matches the ID it gets from the OS. Depending on the OS and configuration |
| 533 // we get this ID differently. | 543 // we get this ID differently. |
| 534 content::DesktopMediaID::Id dialog_window_id = 0; | 544 content::DesktopMediaID::Id dialog_window_id = 0; |
| 535 | 545 |
| 536 #if defined(USE_ASH) | 546 #if defined(USE_ASH) |
| 537 if (chrome::IsNativeWindowInAsh(GetWidget()->GetNativeWindow())) { | 547 if (chrome::IsNativeWindowInAsh(GetWidget()->GetNativeWindow())) { |
| 538 dialog_window_id = content::DesktopMediaID::RegisterAuraWindow( | 548 dialog_window_id = content::DesktopMediaID::RegisterAuraWindow( |
| 539 GetWidget()->GetNativeWindow()).id; | 549 GetWidget()->GetNativeWindow()).id; |
| 540 } else | 550 } else |
| 541 #endif | 551 #endif |
| 542 { | 552 { |
| 543 dialog_window_id = AcceleratedWidgetToDesktopMediaId( | 553 dialog_window_id = AcceleratedWidgetToDesktopMediaId( |
| 544 GetWidget()->GetNativeWindow()->GetHost()-> | 554 GetWidget()->GetNativeWindow()->GetHost()-> |
| 545 GetAcceleratedWidget()); | 555 GetAcceleratedWidget()); |
| 546 } | 556 } |
| 547 | 557 |
| 548 list_view_->StartUpdating(dialog_window_id); | 558 list_view_->StartUpdating(dialog_window_id); |
| 549 | 559 |
| 550 web_contents_modal_dialog_manager->ShowModalDialog( | 560 if (parent_web_contents) { |
| 551 GetWidget()->GetNativeView()); | 561 web_contents_modal_dialog_manager->ShowModalDialog( |
| 562 GetWidget()->GetNativeView()); |
| 563 } else { |
| 564 GetWidget()->Show(); |
| 565 } |
| 552 } | 566 } |
| 553 | 567 |
| 554 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} | 568 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} |
| 555 | 569 |
| 556 void DesktopMediaPickerDialogView::DetachParent() { | 570 void DesktopMediaPickerDialogView::DetachParent() { |
| 557 parent_ = NULL; | 571 parent_ = NULL; |
| 558 } | 572 } |
| 559 | 573 |
| 560 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { | 574 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { |
| 561 return gfx::Size(600, 500); | 575 return gfx::Size(600, 500); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 base::Bind(callback_, source)); | 678 base::Bind(callback_, source)); |
| 665 callback_.Reset(); | 679 callback_.Reset(); |
| 666 } | 680 } |
| 667 | 681 |
| 668 } // namespace | 682 } // namespace |
| 669 | 683 |
| 670 // static | 684 // static |
| 671 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 685 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 672 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 686 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 673 } | 687 } |
| OLD | NEW |