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

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

Issue 1932413002: Desktop Capture Picker New UI: Non Mac Structure Change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 7 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
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 "desktop_media_picker_views_deprecated.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/media/combined_desktop_media_list.h" 14 #include "chrome/browser/media/combined_desktop_media_list.h"
15 #include "chrome/browser/media/desktop_media_list.h" 15 #include "chrome/browser/media/desktop_media_list.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return static_cast<DesktopMediaID::Id>(accelerated_widget); 67 return static_cast<DesktopMediaID::Id>(accelerated_widget);
68 #endif 68 #endif
69 } 69 }
70 70
71 int GetMediaListViewHeightForRows(size_t rows) { 71 int GetMediaListViewHeightForRows(size_t rows) {
72 return kListItemHeight * rows; 72 return kListItemHeight * rows;
73 } 73 }
74 74
75 } // namespace 75 } // namespace
76 76
77 DesktopMediaSourceView::DesktopMediaSourceView( 77 namespace deprecated {
78 DesktopMediaListView* parent, 78
79 DesktopMediaID source_id) 79 DesktopMediaSourceView::DesktopMediaSourceView(DesktopMediaListView* parent,
80 DesktopMediaID source_id)
80 : parent_(parent), 81 : parent_(parent),
81 source_id_(source_id), 82 source_id_(source_id),
82 image_view_(new views::ImageView()), 83 image_view_(new views::ImageView()),
83 label_(new views::Label()), 84 label_(new views::Label()),
84 selected_(false) { 85 selected_(false) {
85 AddChildView(image_view_); 86 AddChildView(image_view_);
86 AddChildView(label_); 87 AddChildView(label_);
87 SetFocusable(true); 88 SetFocusable(true);
88 } 89 }
89 90
90 DesktopMediaSourceView::~DesktopMediaSourceView() {} 91 DesktopMediaSourceView::~DesktopMediaSourceView() {}
91 92
92 void DesktopMediaSourceView::SetName(const base::string16& name) { 93 void DesktopMediaSourceView::SetName(const base::string16& name) {
93 label_->SetText(name); 94 label_->SetText(name);
94 } 95 }
(...skipping 30 matching lines...) Expand all
125 } 126 }
126 127
127 SchedulePaint(); 128 SchedulePaint();
128 } 129 }
129 130
130 const char* DesktopMediaSourceView::GetClassName() const { 131 const char* DesktopMediaSourceView::GetClassName() const {
131 return kDesktopMediaSourceViewClassName; 132 return kDesktopMediaSourceViewClassName;
132 } 133 }
133 134
134 void DesktopMediaSourceView::Layout() { 135 void DesktopMediaSourceView::Layout() {
135 image_view_->SetBounds(kThumbnailMargin, kThumbnailMargin, 136 image_view_->SetBounds(kThumbnailMargin, kThumbnailMargin, kThumbnailWidth,
136 kThumbnailWidth, kThumbnailHeight); 137 kThumbnailHeight);
137 label_->SetBounds(kThumbnailMargin, kThumbnailHeight + kThumbnailMargin, 138 label_->SetBounds(kThumbnailMargin, kThumbnailHeight + kThumbnailMargin,
138 kThumbnailWidth, kLabelHeight); 139 kThumbnailWidth, kLabelHeight);
139 } 140 }
140 141
141 views::View* DesktopMediaSourceView::GetSelectedViewForGroup(int group) { 142 views::View* DesktopMediaSourceView::GetSelectedViewForGroup(int group) {
142 Views neighbours; 143 Views neighbours;
143 parent()->GetViewsInGroup(group, &neighbours); 144 parent()->GetViewsInGroup(group, &neighbours);
144 if (neighbours.empty()) 145 if (neighbours.empty())
145 return NULL; 146 return NULL;
146 147
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 456 }
456 457
457 // If |parent_web_contents| is set and it's not a background page then the 458 // If |parent_web_contents| is set and it's not a background page then the
458 // picker will be shown modal to the web contents. Otherwise the picker is 459 // picker will be shown modal to the web contents. Otherwise the picker is
459 // shown in a separate window. 460 // shown in a separate window.
460 views::Widget* widget = NULL; 461 views::Widget* widget = NULL;
461 bool modal_dialog = 462 bool modal_dialog =
462 parent_web_contents && 463 parent_web_contents &&
463 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents); 464 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents);
464 if (modal_dialog) { 465 if (modal_dialog) {
465 widget = constrained_window::ShowWebModalDialogViews(this, 466 widget =
466 parent_web_contents); 467 constrained_window::ShowWebModalDialogViews(this, parent_web_contents);
467 } else { 468 } else {
468 widget = DialogDelegate::CreateDialogWidget(this, context, NULL); 469 widget = DialogDelegate::CreateDialogWidget(this, context, NULL);
469 widget->Show(); 470 widget->Show();
470 } 471 }
471 472
472 // If the picker is not modal to the calling web contents then it is displayed 473 // If the picker is not modal to the calling web contents then it is displayed
473 // in its own top-level window, so in that case it needs to be filtered out of 474 // in its own top-level window, so in that case it needs to be filtered out of
474 // the list of top-level windows available for capture, and to achieve that 475 // the list of top-level windows available for capture, and to achieve that
475 // the Id is passed to DesktopMediaList. 476 // the Id is passed to DesktopMediaList.
476 DesktopMediaID dialog_window_id; 477 DesktopMediaID dialog_window_id;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 return sources_list_view_->GetSelection() != NULL; 519 return sources_list_view_->GetSelection() != NULL;
519 return true; 520 return true;
520 } 521 }
521 522
522 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() { 523 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() {
523 return sources_list_view_; 524 return sources_list_view_;
524 } 525 }
525 526
526 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( 527 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel(
527 ui::DialogButton button) const { 528 ui::DialogButton button) const {
528 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? 529 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK
529 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); 530 ? IDS_DESKTOP_MEDIA_PICKER_SHARE
531 : IDS_CANCEL);
530 } 532 }
531 533
532 bool DesktopMediaPickerDialogView::Accept() { 534 bool DesktopMediaPickerDialogView::Accept() {
533 DesktopMediaSourceView* selection = sources_list_view_->GetSelection(); 535 DesktopMediaSourceView* selection = sources_list_view_->GetSelection();
534 536
535 // Ok button should only be enabled when a source is selected. 537 // Ok button should only be enabled when a source is selected.
536 DCHECK(selection); 538 DCHECK(selection);
537 DesktopMediaID source = selection->source_id(); 539 DesktopMediaID source = selection->source_id();
538 source.audio_share = audio_share_checkbox_ && 540 source.audio_share = audio_share_checkbox_ &&
539 audio_share_checkbox_->enabled() && 541 audio_share_checkbox_->enabled() &&
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 618
617 DesktopMediaSourceView* 619 DesktopMediaSourceView*
618 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const { 620 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const {
619 if (sources_list_view_->child_count() <= index) 621 if (sources_list_view_->child_count() <= index)
620 return NULL; 622 return NULL;
621 623
622 return reinterpret_cast<DesktopMediaSourceView*>( 624 return reinterpret_cast<DesktopMediaSourceView*>(
623 sources_list_view_->child_at(index)); 625 sources_list_view_->child_at(index));
624 } 626 }
625 627
626 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) { 628 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) {}
627 }
628 629
629 DesktopMediaPickerViews::~DesktopMediaPickerViews() { 630 DesktopMediaPickerViews::~DesktopMediaPickerViews() {
630 if (dialog_) { 631 if (dialog_) {
631 dialog_->DetachParent(); 632 dialog_->DetachParent();
632 dialog_->GetWidget()->Close(); 633 dialog_->GetWidget()->Close();
633 } 634 }
634 } 635 }
635 636
636 void DesktopMediaPickerViews::Show( 637 void DesktopMediaPickerViews::Show(
637 content::WebContents* web_contents, 638 content::WebContents* web_contents,
(...skipping 15 matching lines...) Expand all
653 654
654 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { 655 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) {
655 // Once this method is called the |dialog_| will close and destroy itself. 656 // Once this method is called the |dialog_| will close and destroy itself.
656 dialog_->DetachParent(); 657 dialog_->DetachParent();
657 dialog_ = NULL; 658 dialog_ = NULL;
658 659
659 DCHECK(!callback_.is_null()); 660 DCHECK(!callback_.is_null());
660 661
661 // Notify the |callback_| asynchronously because it may need to destroy 662 // Notify the |callback_| asynchronously because it may need to destroy
662 // DesktopMediaPicker. 663 // DesktopMediaPicker.
663 content::BrowserThread::PostTask( 664 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
664 content::BrowserThread::UI, FROM_HERE, 665 base::Bind(callback_, source));
665 base::Bind(callback_, source));
666 callback_.Reset(); 666 callback_.Reset();
667 } 667 }
668 668
669 // static 669 } // namespace deprecated
670 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
671 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
672 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698