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

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

Issue 1880693002: Desktop Capture Picker New UI: Preliminary Refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 <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/desktop_media_list.h" 15 #include "chrome/browser/media/desktop_media_list.h"
15 #include "chrome/browser/ui/ash/ash_util.h" 16 #include "chrome/browser/ui/ash/ash_util.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "components/constrained_window/constrained_window_views.h" 19 #include "components/constrained_window/constrained_window_views.h"
19 #include "components/web_modal/web_contents_modal_dialog_manager.h" 20 #include "components/web_modal/web_contents_modal_dialog_manager.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/render_frame_host.h" 22 #include "content/public/browser/render_frame_host.h"
22 #include "content/public/browser/web_contents_delegate.h" 23 #include "content/public/browser/web_contents_delegate.h"
23 #include "grit/components_strings.h" 24 #include "grit/components_strings.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 OnSelectionChanged(); 389 OnSelectionChanged();
389 OnDoubleClick(); 390 OnDoubleClick();
390 } 391 }
391 392
392 DesktopMediaPickerDialogView::DesktopMediaPickerDialogView( 393 DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
393 content::WebContents* parent_web_contents, 394 content::WebContents* parent_web_contents,
394 gfx::NativeWindow context, 395 gfx::NativeWindow context,
395 DesktopMediaPickerViews* parent, 396 DesktopMediaPickerViews* parent,
396 const base::string16& app_name, 397 const base::string16& app_name,
397 const base::string16& target_name, 398 const base::string16& target_name,
398 std::unique_ptr<DesktopMediaList> media_list, 399 std::unique_ptr<DesktopMediaList> screen_list,
400 std::unique_ptr<DesktopMediaList> window_list,
401 std::unique_ptr<DesktopMediaList> tab_list,
399 bool request_audio) 402 bool request_audio)
400 : parent_(parent), 403 : parent_(parent),
401 app_name_(app_name), 404 app_name_(app_name),
402 description_label_(new views::Label()), 405 description_label_(new views::Label()),
403 audio_share_checkbox_(nullptr), 406 audio_share_checkbox_(nullptr),
404 audio_share_checked_(true), 407 audio_share_checked_(true),
405 sources_scroll_view_(views::ScrollView::CreateScrollViewWithBorder()), 408 sources_scroll_view_(views::ScrollView::CreateScrollViewWithBorder()) {
406 sources_list_view_( 409 std::vector<std::unique_ptr<DesktopMediaList>> media_lists;
407 new DesktopMediaListView(this, std::move(media_list))) { 410 if (screen_list)
411 media_lists.push_back(std::move(screen_list));
412 if (window_list)
413 media_lists.push_back(std::move(window_list));
414 if (tab_list)
415 media_lists.push_back(std::move(tab_list));
416
417 std::unique_ptr<DesktopMediaList> media_list;
418 if (media_lists.size() > 1)
419 media_list.reset(new CombinedDesktopMediaList(media_lists));
420 else
421 media_list = std::move(media_lists[0]);
Sergey Ulanov 2016/04/14 22:39:52 DCHECK that media_lists is not empty.
qiangchen 2016/04/15 20:11:27 Done.
422
423 sources_list_view_ = new DesktopMediaListView(this, std::move(media_list));
424
408 // TODO(estade): we should be getting the inside-border spacing by default as 425 // TODO(estade): we should be getting the inside-border spacing by default as
409 // a DialogDelegateView subclass, via default BubbleFrameView content margins. 426 // a DialogDelegateView subclass, via default BubbleFrameView content margins.
410 SetLayoutManager(new views::BoxLayout( 427 SetLayoutManager(new views::BoxLayout(
411 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, 428 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew,
412 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); 429 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing));
413 430
414 if (app_name == target_name) { 431 if (app_name == target_name) {
415 description_label_->SetText( 432 description_label_->SetText(
416 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); 433 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name));
417 } else { 434 } else {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) { 625 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) {
609 } 626 }
610 627
611 DesktopMediaPickerViews::~DesktopMediaPickerViews() { 628 DesktopMediaPickerViews::~DesktopMediaPickerViews() {
612 if (dialog_) { 629 if (dialog_) {
613 dialog_->DetachParent(); 630 dialog_->DetachParent();
614 dialog_->GetWidget()->Close(); 631 dialog_->GetWidget()->Close();
615 } 632 }
616 } 633 }
617 634
618 void DesktopMediaPickerViews::Show(content::WebContents* web_contents, 635 void DesktopMediaPickerViews::Show(
619 gfx::NativeWindow context, 636 content::WebContents* web_contents,
620 gfx::NativeWindow parent, 637 gfx::NativeWindow context,
621 const base::string16& app_name, 638 gfx::NativeWindow parent,
622 const base::string16& target_name, 639 const base::string16& app_name,
623 std::unique_ptr<DesktopMediaList> media_list, 640 const base::string16& target_name,
624 bool request_audio, 641 std::unique_ptr<DesktopMediaList> screen_list,
625 const DoneCallback& done_callback) { 642 std::unique_ptr<DesktopMediaList> window_list,
643 std::unique_ptr<DesktopMediaList> tab_list,
644 bool request_audio,
645 const DoneCallback& done_callback) {
626 callback_ = done_callback; 646 callback_ = done_callback;
627 dialog_ = new DesktopMediaPickerDialogView( 647 dialog_ = new DesktopMediaPickerDialogView(
628 web_contents, context, this, app_name, target_name, std::move(media_list), 648 web_contents, context, this, app_name, target_name,
649 std::move(screen_list), std::move(window_list), std::move(tab_list),
629 request_audio); 650 request_audio);
630 } 651 }
631 652
632 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { 653 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) {
633 // Once this method is called the |dialog_| will close and destroy itself. 654 // Once this method is called the |dialog_| will close and destroy itself.
634 dialog_->DetachParent(); 655 dialog_->DetachParent();
635 dialog_ = NULL; 656 dialog_ = NULL;
636 657
637 DCHECK(!callback_.is_null()); 658 DCHECK(!callback_.is_null());
638 659
639 // Notify the |callback_| asynchronously because it may need to destroy 660 // Notify the |callback_| asynchronously because it may need to destroy
640 // DesktopMediaPicker. 661 // DesktopMediaPicker.
641 content::BrowserThread::PostTask( 662 content::BrowserThread::PostTask(
642 content::BrowserThread::UI, FROM_HERE, 663 content::BrowserThread::UI, FROM_HERE,
643 base::Bind(callback_, source)); 664 base::Bind(callback_, source));
644 callback_.Reset(); 665 callback_.Reset();
645 } 666 }
646 667
647 // static 668 // static
648 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 669 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
649 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 670 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
650 } 671 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698