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

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

Issue 307453010: Fix a crash when chooseDesktopMedia is called with no target tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 | « chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc ('k') | no next file » | 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/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
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 WebContentsModalDialogManager* web_contents_modal_dialog_manager = NULL;
522 WebContentsModalDialogManager::FromWebContents(parent_web_contents); 522 if (parent_web_contents) {
Sergey Ulanov 2014/06/03 01:27:30 nit: add comment to explain what happens here, par
523 DCHECK(web_contents_modal_dialog_manager); 523 web_contents_modal_dialog_manager =
524 WebContentsModalDialogManagerDelegate* delegate = 524 WebContentsModalDialogManager::FromWebContents(parent_web_contents);
525 web_contents_modal_dialog_manager->delegate(); 525 DCHECK(web_contents_modal_dialog_manager);
526 DCHECK(delegate); 526 WebContentsModalDialogManagerDelegate* delegate =
527 views::Widget::CreateWindowAsFramelessChild( 527 web_contents_modal_dialog_manager->delegate();
528 this, 528 DCHECK(delegate);
529 delegate->GetWebContentsModalDialogHost()->GetHostView()); 529 views::Widget::CreateWindowAsFramelessChild(
530 this,
531 delegate->GetWebContentsModalDialogHost()->GetHostView());
532 } else {
533 DialogDelegate::CreateDialogWidget(this, context, parent_window);
534 }
530 535
531 // DesktopMediaList needs to know the ID of the picker window which 536 // 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 537 // matches the ID it gets from the OS. Depending on the OS and configuration
533 // we get this ID differently. 538 // we get this ID differently.
534 content::DesktopMediaID::Id dialog_window_id = 0; 539 content::DesktopMediaID::Id dialog_window_id = 0;
535 540
536 #if defined(USE_ASH) 541 #if defined(USE_ASH)
537 if (chrome::IsNativeWindowInAsh(GetWidget()->GetNativeWindow())) { 542 if (chrome::IsNativeWindowInAsh(GetWidget()->GetNativeWindow())) {
538 dialog_window_id = content::DesktopMediaID::RegisterAuraWindow( 543 dialog_window_id = content::DesktopMediaID::RegisterAuraWindow(
539 GetWidget()->GetNativeWindow()).id; 544 GetWidget()->GetNativeWindow()).id;
540 } else 545 } else
541 #endif 546 #endif
542 { 547 {
543 dialog_window_id = AcceleratedWidgetToDesktopMediaId( 548 dialog_window_id = AcceleratedWidgetToDesktopMediaId(
544 GetWidget()->GetNativeWindow()->GetHost()-> 549 GetWidget()->GetNativeWindow()->GetHost()->
545 GetAcceleratedWidget()); 550 GetAcceleratedWidget());
546 } 551 }
547 552
548 list_view_->StartUpdating(dialog_window_id); 553 list_view_->StartUpdating(dialog_window_id);
549 554
550 web_contents_modal_dialog_manager->ShowModalDialog( 555 if (parent_web_contents) {
551 GetWidget()->GetNativeView()); 556 web_contents_modal_dialog_manager->ShowModalDialog(
557 GetWidget()->GetNativeView());
558 } else {
559 GetWidget()->Show();
560 }
552 } 561 }
553 562
554 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} 563 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {}
555 564
556 void DesktopMediaPickerDialogView::DetachParent() { 565 void DesktopMediaPickerDialogView::DetachParent() {
557 parent_ = NULL; 566 parent_ = NULL;
558 } 567 }
559 568
560 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { 569 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const {
561 return gfx::Size(600, 500); 570 return gfx::Size(600, 500);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 base::Bind(callback_, source)); 673 base::Bind(callback_, source));
665 callback_.Reset(); 674 callback_.Reset();
666 } 675 }
667 676
668 } // namespace 677 } // namespace
669 678
670 // static 679 // static
671 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 680 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
672 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 681 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
673 } 682 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698