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 #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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | |
8 #import "base/mac/bundle_locations.h" | 9 #import "base/mac/bundle_locations.h" |
9 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
10 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" | 11 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" |
12 #include "chrome/common/chrome_switches.h" | |
11 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
12 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
13 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" | 15 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" |
14 #import "ui/base/cocoa/flipped_view.h" | 16 #import "ui/base/cocoa/flipped_view.h" |
15 #import "ui/base/cocoa/window_size_constants.h" | 17 #import "ui/base/cocoa/window_size_constants.h" |
16 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/gfx/image/image_skia_util_mac.h" | 19 #include "ui/gfx/image/image_skia_util_mac.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 278 |
277 - (void)sourceAddedAtIndex:(int)index { | 279 - (void)sourceAddedAtIndex:(int)index { |
278 const DesktopMediaList::Source& source = media_list_->GetSource(index); | 280 const DesktopMediaList::Source& source = media_list_->GetSource(index); |
279 NSString* imageTitle = base::SysUTF16ToNSString(source.name); | 281 NSString* imageTitle = base::SysUTF16ToNSString(source.name); |
280 base::scoped_nsobject<DesktopMediaPickerItem> item( | 282 base::scoped_nsobject<DesktopMediaPickerItem> item( |
281 [[DesktopMediaPickerItem alloc] initWithSourceId:source.id | 283 [[DesktopMediaPickerItem alloc] initWithSourceId:source.id |
282 imageUID:++lastImageUID_ | 284 imageUID:++lastImageUID_ |
283 imageTitle:imageTitle]); | 285 imageTitle:imageTitle]); |
284 [items_ insertObject:item atIndex:index]; | 286 [items_ insertObject:item atIndex:index]; |
285 [sourceBrowser_ reloadData]; | 287 [sourceBrowser_ reloadData]; |
288 | |
289 NSString* autoselectSource = base::SysUTF8ToNSString( | |
290 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
291 switches::kAutoSelectDesktopCaptureSource)); | |
292 | |
293 if ([autoselectSource isEqualToString:imageTitle]) { | |
294 [self reportResult:[item sourceID]]; | |
phoglund_chromium
2015/04/14 12:41:22
I assume here it's OK to do this on this thread an
groby-ooo-7-16
2015/04/14 15:01:21
It *should* be OK. sourceAddedAtIndex definitely h
dcaiafa
2015/04/22 20:32:42
It's been a while since I looked at this code, but
| |
295 [self close]; | |
296 } | |
286 } | 297 } |
287 | 298 |
288 - (void)sourceRemovedAtIndex:(int)index { | 299 - (void)sourceRemovedAtIndex:(int)index { |
289 if ([[sourceBrowser_ selectionIndexes] containsIndex:index]) { | 300 if ([[sourceBrowser_ selectionIndexes] containsIndex:index]) { |
290 // Selected item was removed. Clear selection. | 301 // Selected item was removed. Clear selection. |
291 [sourceBrowser_ setSelectionIndexes:[NSIndexSet indexSet] | 302 [sourceBrowser_ setSelectionIndexes:[NSIndexSet indexSet] |
292 byExtendingSelection:FALSE]; | 303 byExtendingSelection:FALSE]; |
293 } | 304 } |
294 [items_ removeObjectAtIndex:index]; | 305 [items_ removeObjectAtIndex:index]; |
295 [sourceBrowser_ reloadData]; | 306 [sourceBrowser_ reloadData]; |
(...skipping 17 matching lines...) Expand all Loading... | |
313 - (void)sourceThumbnailChangedAtIndex:(int)index { | 324 - (void)sourceThumbnailChangedAtIndex:(int)index { |
314 const DesktopMediaList::Source& source = media_list_->GetSource(index); | 325 const DesktopMediaList::Source& source = media_list_->GetSource(index); |
315 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); | 326 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); |
316 | 327 |
317 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; | 328 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; |
318 [item setImageRepresentation:image]; | 329 [item setImageRepresentation:image]; |
319 [sourceBrowser_ reloadData]; | 330 [sourceBrowser_ reloadData]; |
320 } | 331 } |
321 | 332 |
322 @end // @interface DesktopMediaPickerController | 333 @end // @interface DesktopMediaPickerController |
OLD | NEW |