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

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

Issue 1990053002: Desktop Capture Picker New UI: Non Mac Appearance Change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Resolved Created 4 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
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_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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
75 if (screen_list) { 76 if (screen_list) {
76 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); 77 source_types_.push_back(DesktopMediaID::TYPE_SCREEN);
77 78
79 const DesktopMediaSourceViewStyle kSingleScreenStyle(
80 1, // columns
81 gfx::Size(360, 280), // item_size
82 gfx::Rect(0, 0, 0, 0), // label_rect
msw 2016/05/25 17:22:13 nit: use default rect ctor
qiangchen 2016/05/25 20:27:29 Done.
83 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment
84 gfx::Rect(20, 20, 320, 240), // image_rect
85 4, // selection_border_thickness
86 5); // focus_rectangle_inset
87
88 const DesktopMediaSourceViewStyle kGenericScreenStyle(
89 2, // columns
90 gfx::Size(270, 220), // item_size
91 gfx::Rect(15, 165, 240, 40), // label_rect
92 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment
93 gfx::Rect(15, 15, 240, 150), // image_rect
94 2, // selection_border_thickness
95 5); // focus_rectangle_inset
96
78 views::ScrollView* screen_scroll_view = 97 views::ScrollView* screen_scroll_view =
79 views::ScrollView::CreateScrollViewWithBorder(); 98 views::ScrollView::CreateScrollViewWithBorder();
80 list_views_.push_back( 99 list_views_.push_back(new DesktopMediaListView(
81 new DesktopMediaListView(this, std::move(screen_list))); 100 this, std::move(screen_list), kGenericScreenStyle, kSingleScreenStyle));
82 101
83 screen_scroll_view->SetContents(list_views_.back()); 102 screen_scroll_view->SetContents(list_views_.back());
84 screen_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); 103 screen_scroll_view->ClipHeightTo(
104 kGenericScreenStyle.item_size.height(),
105 kGenericScreenStyle.item_size.height() * 2);
106 screen_scroll_view->set_hide_horizontal_scrollbar(true);
107
msw 2016/05/25 17:22:13 nit: remove blank line
qiangchen 2016/05/25 20:27:29 Done.
108 const SkColor bg_color = GetNativeTheme()->GetSystemColor(
msw 2016/05/25 17:22:13 nit define a single shared |bg_color| above these
qiangchen 2016/05/25 20:27:29 Done.
109 ui::NativeTheme::kColorId_MenuBackgroundColor);
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(
96 new DesktopMediaListView(this, std::move(window_list))); 134 new DesktopMediaListView(this, std::move(window_list), kWindowStyle));
135 window_scroll_view->SetContents(list_views_.back());
136 window_scroll_view->ClipHeightTo(kWindowStyle.item_size.height(),
137 kWindowStyle.item_size.height() * 2);
138 window_scroll_view->set_hide_horizontal_scrollbar(true);
97 139
msw 2016/05/25 17:22:13 nit: remove blank line
qiangchen 2016/05/25 20:27:29 Done.
98 window_scroll_view->SetContents(list_views_.back()); 140 const SkColor bg_color = GetNativeTheme()->GetSystemColor(
99 window_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); 141 ui::NativeTheme::kColorId_MenuBackgroundColor);
142 window_scroll_view->set_background(
143 views::Background::CreateSolidBackground(bg_color));
100 144
101 pane_->AddTab( 145 pane_->AddTab(
102 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), 146 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW),
103 window_scroll_view); 147 window_scroll_view);
104 pane_->set_listener(this); 148 pane_->set_listener(this);
105 } 149 }
106 150
107 if (tab_list) { 151 if (tab_list) {
108 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); 152 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS);
153
154 const DesktopMediaSourceViewStyle kTabStyle(
155 1, // columns
156 gfx::Size(600, 30), // item_size
157 gfx::Rect(46, 0, 490, 30), // label_rect
158 gfx::HorizontalAlignment::ALIGN_LEFT, // text_alignment
159 gfx::Rect(10, 2, 26, 26), // image_rect
160 1, // selection_border_thickness
161 0); // focus_rectangle_inset
162
109 views::ScrollView* tab_scroll_view = 163 views::ScrollView* tab_scroll_view =
110 views::ScrollView::CreateScrollViewWithBorder(); 164 views::ScrollView::CreateScrollViewWithBorder();
111 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list))); 165 list_views_.push_back(
166 new DesktopMediaListView(this, std::move(tab_list), kTabStyle));
112 167
113 tab_scroll_view->SetContents(list_views_.back()); 168 tab_scroll_view->SetContents(list_views_.back());
114 tab_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); 169 tab_scroll_view->ClipHeightTo(kTabStyle.item_size.height(),
170 kTabStyle.item_size.height() * 2);
171 tab_scroll_view->set_hide_horizontal_scrollbar(true);
172
msw 2016/05/25 17:22:13 nit: remove blank line
qiangchen 2016/05/25 20:27:29 Done.
173 const SkColor bg_color = GetNativeTheme()->GetSystemColor(
174 ui::NativeTheme::kColorId_MenuBackgroundColor);
175 tab_scroll_view->set_background(
176 views::Background::CreateSolidBackground(bg_color));
115 177
116 pane_->AddTab( 178 pane_->AddTab(
117 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), 179 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB),
118 tab_scroll_view); 180 tab_scroll_view);
119 pane_->set_listener(this); 181 pane_->set_listener(this);
120 } 182 }
121 183
122 if (app_name == target_name) { 184 if (app_name == target_name) {
123 description_label_->SetText( 185 description_label_->SetText(
124 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); 186 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 437
376 // static 438 // static
377 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 439 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
378 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 440 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
379 extensions::switches::kDisableDesktopCapturePickerOldUI)) { 441 extensions::switches::kDisableDesktopCapturePickerOldUI)) {
380 return std::unique_ptr<DesktopMediaPicker>( 442 return std::unique_ptr<DesktopMediaPicker>(
381 new deprecated::DesktopMediaPickerViews()); 443 new deprecated::DesktopMediaPickerViews());
382 } 444 }
383 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 445 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
384 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698