| 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/ui/views/desktop_capture/desktop_media_picker_views.h" | 5 #include "chrome/browser/ui/views/desktop_capture/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 "chrome/browser/media/desktop_media_list.h" | 9 #include "chrome/browser/media/desktop_media_list.h" |
| 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" | 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" |
| 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" | 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" |
| 12 #include "chrome/browser/ui/views/desktop_media_picker_views_deprecated.h" | 12 #include "chrome/browser/ui/views/desktop_media_picker_views_deprecated.h" |
| 13 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "chrome/grit/google_chrome_strings.h" | 15 #include "chrome/grit/google_chrome_strings.h" |
| 16 #include "components/constrained_window/constrained_window_views.h" | 16 #include "components/constrained_window/constrained_window_views.h" |
| 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
| 21 #include "extensions/common/switches.h" | 21 #include "extensions/common/switches.h" |
| 22 #include "grit/components_strings.h" | 22 #include "grit/components_strings.h" |
| 23 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/events/keycodes/keyboard_codes.h" | 25 #include "ui/events/keycodes/keyboard_codes.h" |
| 26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/views/background.h" |
| 27 #include "ui/views/controls/button/checkbox.h" | 28 #include "ui/views/controls/button/checkbox.h" |
| 28 #include "ui/views/controls/scroll_view.h" | 29 #include "ui/views/controls/scroll_view.h" |
| 29 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | 30 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| 30 #include "ui/views/layout/box_layout.h" | 31 #include "ui/views/layout/box_layout.h" |
| 31 #include "ui/views/layout/layout_constants.h" | 32 #include "ui/views/layout/layout_constants.h" |
| 32 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 33 #include "ui/views/window/dialog_client_view.h" | 34 #include "ui/views/window/dialog_client_view.h" |
| 34 #include "ui/wm/core/shadow_types.h" | 35 #include "ui/wm/core/shadow_types.h" |
| 35 | 36 |
| 36 using content::DesktopMediaID; | 37 using content::DesktopMediaID; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 65 audio_share_checkbox_(nullptr), | 66 audio_share_checkbox_(nullptr), |
| 66 pane_(new views::TabbedPane()) { | 67 pane_(new views::TabbedPane()) { |
| 67 SetLayoutManager(new views::BoxLayout( | 68 SetLayoutManager(new views::BoxLayout( |
| 68 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, | 69 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, |
| 69 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); | 70 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); |
| 70 | 71 |
| 71 description_label_->SetMultiLine(true); | 72 description_label_->SetMultiLine(true); |
| 72 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 73 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 73 AddChildView(description_label_); | 74 AddChildView(description_label_); |
| 74 | 75 |
| 76 const SkColor bg_color = GetNativeTheme()->GetSystemColor( |
| 77 ui::NativeTheme::kColorId_MenuBackgroundColor); |
| 78 |
| 75 if (screen_list) { | 79 if (screen_list) { |
| 76 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); | 80 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); |
| 77 | 81 |
| 82 const DesktopMediaSourceViewStyle kSingleScreenStyle( |
| 83 1, // columns |
| 84 gfx::Size(360, 280), // item_size |
| 85 gfx::Rect(), // label_rect |
| 86 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment |
| 87 gfx::Rect(20, 20, 320, 240), // image_rect |
| 88 4, // selection_border_thickness |
| 89 5); // focus_rectangle_inset |
| 90 |
| 91 const DesktopMediaSourceViewStyle kGenericScreenStyle( |
| 92 2, // columns |
| 93 gfx::Size(270, 220), // item_size |
| 94 gfx::Rect(15, 165, 240, 40), // label_rect |
| 95 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment |
| 96 gfx::Rect(15, 15, 240, 150), // image_rect |
| 97 2, // selection_border_thickness |
| 98 5); // focus_rectangle_inset |
| 99 |
| 78 views::ScrollView* screen_scroll_view = | 100 views::ScrollView* screen_scroll_view = |
| 79 views::ScrollView::CreateScrollViewWithBorder(); | 101 views::ScrollView::CreateScrollViewWithBorder(); |
| 80 list_views_.push_back( | 102 list_views_.push_back(new DesktopMediaListView( |
| 81 new DesktopMediaListView(this, std::move(screen_list))); | 103 this, std::move(screen_list), kGenericScreenStyle, kSingleScreenStyle)); |
| 82 | 104 |
| 83 screen_scroll_view->SetContents(list_views_.back()); | 105 screen_scroll_view->SetContents(list_views_.back()); |
| 84 screen_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 106 screen_scroll_view->ClipHeightTo( |
| 107 kGenericScreenStyle.item_size.height(), |
| 108 kGenericScreenStyle.item_size.height() * 2); |
| 109 screen_scroll_view->set_hide_horizontal_scrollbar(true); |
| 110 screen_scroll_view->set_background( |
| 111 views::Background::CreateSolidBackground(bg_color)); |
| 112 |
| 85 pane_->AddTab( | 113 pane_->AddTab( |
| 86 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), | 114 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), |
| 87 screen_scroll_view); | 115 screen_scroll_view); |
| 88 pane_->set_listener(this); | 116 pane_->set_listener(this); |
| 89 } | 117 } |
| 90 | 118 |
| 91 if (window_list) { | 119 if (window_list) { |
| 92 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); | 120 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); |
| 121 |
| 122 const DesktopMediaSourceViewStyle kWindowStyle( |
| 123 3, // columns |
| 124 gfx::Size(180, 160), // item_size |
| 125 gfx::Rect(10, 110, 160, 40), // label_rect |
| 126 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment |
| 127 gfx::Rect(8, 8, 164, 104), // image_rect |
| 128 2, // selection_border_thickness |
| 129 5); // focus_rectangle_inset |
| 130 |
| 93 views::ScrollView* window_scroll_view = | 131 views::ScrollView* window_scroll_view = |
| 94 views::ScrollView::CreateScrollViewWithBorder(); | 132 views::ScrollView::CreateScrollViewWithBorder(); |
| 95 list_views_.push_back( | 133 list_views_.push_back(new DesktopMediaListView(this, std::move(window_list), |
| 96 new DesktopMediaListView(this, std::move(window_list))); | 134 kWindowStyle, kWindowStyle)); |
| 97 | |
| 98 window_scroll_view->SetContents(list_views_.back()); | 135 window_scroll_view->SetContents(list_views_.back()); |
| 99 window_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 136 window_scroll_view->ClipHeightTo(kWindowStyle.item_size.height(), |
| 137 kWindowStyle.item_size.height() * 2); |
| 138 window_scroll_view->set_hide_horizontal_scrollbar(true); |
| 139 window_scroll_view->set_background( |
| 140 views::Background::CreateSolidBackground(bg_color)); |
| 100 | 141 |
| 101 pane_->AddTab( | 142 pane_->AddTab( |
| 102 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), | 143 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), |
| 103 window_scroll_view); | 144 window_scroll_view); |
| 104 pane_->set_listener(this); | 145 pane_->set_listener(this); |
| 105 } | 146 } |
| 106 | 147 |
| 107 if (tab_list) { | 148 if (tab_list) { |
| 108 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); | 149 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); |
| 150 |
| 151 const DesktopMediaSourceViewStyle kTabStyle( |
| 152 1, // columns |
| 153 gfx::Size(600, 30), // item_size |
| 154 gfx::Rect(46, 0, 490, 30), // label_rect |
| 155 gfx::HorizontalAlignment::ALIGN_LEFT, // text_alignment |
| 156 gfx::Rect(10, 2, 26, 26), // image_rect |
| 157 1, // selection_border_thickness |
| 158 0); // focus_rectangle_inset |
| 159 |
| 109 views::ScrollView* tab_scroll_view = | 160 views::ScrollView* tab_scroll_view = |
| 110 views::ScrollView::CreateScrollViewWithBorder(); | 161 views::ScrollView::CreateScrollViewWithBorder(); |
| 111 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list))); | 162 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list), |
| 163 kTabStyle, kTabStyle)); |
| 112 | 164 |
| 113 tab_scroll_view->SetContents(list_views_.back()); | 165 tab_scroll_view->SetContents(list_views_.back()); |
| 114 tab_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 166 tab_scroll_view->ClipHeightTo(kTabStyle.item_size.height(), |
| 167 kTabStyle.item_size.height() * 2); |
| 168 tab_scroll_view->set_hide_horizontal_scrollbar(true); |
| 169 tab_scroll_view->set_background( |
| 170 views::Background::CreateSolidBackground(bg_color)); |
| 115 | 171 |
| 116 pane_->AddTab( | 172 pane_->AddTab( |
| 117 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), | 173 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), |
| 118 tab_scroll_view); | 174 tab_scroll_view); |
| 119 pane_->set_listener(this); | 175 pane_->set_listener(this); |
| 120 } | 176 } |
| 121 | 177 |
| 122 if (app_name == target_name) { | 178 if (app_name == target_name) { |
| 123 description_label_->SetText( | 179 description_label_->SetText( |
| 124 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); | 180 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 431 |
| 376 // static | 432 // static |
| 377 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 433 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 378 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 434 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 379 extensions::switches::kDisableDesktopCapturePickerOldUI)) { | 435 extensions::switches::kDisableDesktopCapturePickerOldUI)) { |
| 380 return std::unique_ptr<DesktopMediaPicker>( | 436 return std::unique_ptr<DesktopMediaPicker>( |
| 381 new deprecated::DesktopMediaPickerViews()); | 437 new deprecated::DesktopMediaPickerViews()); |
| 382 } | 438 } |
| 383 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 439 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 384 } | 440 } |
| OLD | NEW |