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

Side by Side Diff: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm

Issue 1880693002: Desktop Capture Picker New UI: Preliminary Refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit 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 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h" 5 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #import "base/mac/bundle_locations.h" 11 #import "base/mac/bundle_locations.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/browser/media/combined_desktop_media_list.h"
13 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" 14 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h"
14 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" 15 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
16 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
21 #include "grit/components_strings.h" 22 #include "grit/components_strings.h"
22 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 23 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 - (void)reportResult:(content::DesktopMediaID)sourceID; 57 - (void)reportResult:(content::DesktopMediaID)sourceID;
57 58
58 // Action handlers. 59 // Action handlers.
59 - (void)sharePressed:(id)sender; 60 - (void)sharePressed:(id)sender;
60 - (void)cancelPressed:(id)sender; 61 - (void)cancelPressed:(id)sender;
61 62
62 @end 63 @end
63 64
64 @implementation DesktopMediaPickerController 65 @implementation DesktopMediaPickerController
65 66
66 - (id)initWithMediaList:(std::unique_ptr<DesktopMediaList>)media_list 67 - (id)initWithScreenList:(std::unique_ptr<DesktopMediaList>)screen_list
67 parent:(NSWindow*)parent 68 windowList:(std::unique_ptr<DesktopMediaList>)window_list
68 callback:(const DesktopMediaPicker::DoneCallback&)callback 69 tabList:(std::unique_ptr<DesktopMediaList>)tab_list
69 appName:(const base::string16&)appName 70 parent:(NSWindow*)parent
70 targetName:(const base::string16&)targetName 71 callback:(const DesktopMediaPicker::DoneCallback&)callback
71 requestAudio:(bool)requestAudio { 72 appName:(const base::string16&)appName
73 targetName:(const base::string16&)targetName
74 requestAudio:(bool)requestAudio {
72 const NSUInteger kStyleMask = 75 const NSUInteger kStyleMask =
73 NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask; 76 NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
74 base::scoped_nsobject<NSWindow> window( 77 base::scoped_nsobject<NSWindow> window(
75 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater 78 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
76 styleMask:kStyleMask 79 styleMask:kStyleMask
77 backing:NSBackingStoreBuffered 80 backing:NSBackingStoreBuffered
78 defer:NO]); 81 defer:NO]);
79 82
80 if ((self = [super initWithWindow:window])) { 83 if ((self = [super initWithWindow:window])) {
81 [parent addChildWindow:window ordered:NSWindowAbove]; 84 [parent addChildWindow:window ordered:NSWindowAbove];
82 [window setDelegate:self]; 85 [window setDelegate:self];
83 [self initializeContentsWithAppName:appName 86 [self initializeContentsWithAppName:appName
84 targetName:targetName 87 targetName:targetName
85 requestAudio:requestAudio]; 88 requestAudio:requestAudio];
86 media_list_ = std::move(media_list); 89 std::vector<std::unique_ptr<DesktopMediaList>> media_lists;
90 if (screen_list)
91 media_lists.push_back(std::move(screen_list));
92
93 if (window_list)
94 media_lists.push_back(std::move(window_list));
95
96 if (tab_list)
97 media_lists.push_back(std::move(tab_list));
98
99 if (media_lists.size() > 1)
100 media_list_.reset(new CombinedDesktopMediaList(media_lists));
101 else
102 media_list_ = std::move(media_lists[0]);
87 media_list_->SetViewDialogWindowId(content::DesktopMediaID( 103 media_list_->SetViewDialogWindowId(content::DesktopMediaID(
88 content::DesktopMediaID::TYPE_WINDOW, [window windowNumber])); 104 content::DesktopMediaID::TYPE_WINDOW, [window windowNumber]));
89 doneCallback_ = callback; 105 doneCallback_ = callback;
90 items_.reset([[NSMutableArray alloc] init]); 106 items_.reset([[NSMutableArray alloc] init]);
91 bridge_.reset(new DesktopMediaPickerBridge(self)); 107 bridge_.reset(new DesktopMediaPickerBridge(self));
92 } 108 }
93 return self; 109 return self;
94 } 110 }
95 111
96 - (void)dealloc { 112 - (void)dealloc {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 - (void)sourceThumbnailChangedAtIndex:(int)index { 433 - (void)sourceThumbnailChangedAtIndex:(int)index {
418 const DesktopMediaList::Source& source = media_list_->GetSource(index); 434 const DesktopMediaList::Source& source = media_list_->GetSource(index);
419 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); 435 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail);
420 436
421 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; 437 DesktopMediaPickerItem* item = [items_ objectAtIndex:index];
422 [item setImageRepresentation:image]; 438 [item setImageRepresentation:image];
423 [sourceBrowser_ reloadData]; 439 [sourceBrowser_ reloadData];
424 } 440 }
425 441
426 @end // @interface DesktopMediaPickerController 442 @end // @interface DesktopMediaPickerController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698