Chromium Code Reviews| Index: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm |
| index 5a660e5ae02eb48254335505ca4a96028680c17b..b2269a006d1153eefb7a2b191d87274304c53b19 100644 |
| --- a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm |
| +++ b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm |
| @@ -40,6 +40,8 @@ const CGFloat kThumbnailWidth = 150; |
| const CGFloat kThumbnailHeight = 150; |
| const CGFloat kSingleScreenWidth = 300; |
| const CGFloat kSingleScreenHeight = 300; |
| +const CGFloat kMultipleScreenWidth = 220; |
| +const CGFloat kMultipleScreenHeight = 220; |
| const CGFloat kFramePadding = 20; |
| const CGFloat kControlSpacing = 10; |
| const CGFloat kExcessButtonPadding = 6; |
| @@ -279,9 +281,12 @@ NSString* const kTitleId = @"title"; |
| - (void)createSourceViewsAtOrigin:(NSPoint)origin { |
| if (screenList_) { |
| - screenBrowser_.reset([[self |
| - createImageBrowserWithSize:NSMakeSize(kSingleScreenWidth, |
| - kSingleScreenHeight)] retain]); |
| + const bool is_single = screenList_->GetSourceCount() <= 1; |
| + const CGFloat width = is_single ? kSingleScreenWidth : kMultipleScreenWidth; |
| + const CGFloat height = |
| + is_single ? kSingleScreenHeight : kMultipleScreenHeight; |
| + screenBrowser_.reset( |
| + [[self createImageBrowserWithSize:NSMakeSize(width, height)] retain]); |
| } |
| if (windowList_) { |
| @@ -602,7 +607,6 @@ NSString* const kTitleId = @"title"; |
| // "Entire Screen", because it is redundant with tab label "Your Entire |
| // Screen". |
| [item setTitleHidden:browser == screenBrowser_ && [items count] == 1]; |
| - |
| return item; |
| } |
| @@ -693,10 +697,16 @@ NSString* const kTitleId = @"title"; |
| if (sourceType == DesktopMediaID::TYPE_WEB_CONTENTS) { |
| // Memorizing selection. |
| [self setTabBrowserIndex:selectedIndex]; |
| - } else if (sourceType == DesktopMediaID::TYPE_SCREEN && [items count] == 1) { |
| - // Preselect the first screen source. |
| - [browser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] |
| - byExtendingSelection:NO]; |
| + } else if (sourceType == DesktopMediaID::TYPE_SCREEN) { |
| + if ([items count] == 1) { |
| + // Preselect the first screen source. |
| + [browser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] |
| + byExtendingSelection:NO]; |
| + } else if ([items count] == 2) { |
| + // Switch to multiple sources mode |
|
tapted
2017/05/23 20:36:11
nit: full stop at end
qiangchen
2017/05/23 21:33:17
Done.
|
| + [browser |
| + setCellSize:NSMakeSize(kMultipleScreenWidth, kMultipleScreenHeight)]; |
| + } |
| } |
| NSString* autoselectSource = base::SysUTF8ToNSString( |
| @@ -732,6 +742,9 @@ NSString* const kTitleId = @"title"; |
| } |
| [items removeObjectAtIndex:index]; |
| [browser reloadData]; |
|
tapted
2017/05/23 20:36:11
move this after the setCellSize call?
qiangchen
2017/05/23 21:33:17
Done.
|
| + if (sourceType == DesktopMediaID::TYPE_SCREEN && [items count] == 1) { |
| + [browser setCellSize:NSMakeSize(kSingleScreenWidth, kSingleScreenHeight)]; |
| + } |
|
tapted
2017/05/23 20:36:11
nit: curlies not needed
qiangchen
2017/05/23 21:33:17
Done.
|
| } |
| - (void)sourceMovedForList:(DesktopMediaList*)list |