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_item.h" | 5 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" |
6 | 6 |
7 #import <Quartz/Quartz.h> | 7 #import <Quartz/Quartz.h> |
8 | 8 |
9 #include "chrome/browser/media/desktop_media_list.h" | 9 #include "chrome/browser/media/desktop_media_list.h" |
10 | 10 |
11 @implementation DesktopMediaPickerItem | 11 @implementation DesktopMediaPickerItem |
12 | 12 |
13 - (id)initWithSourceId:(content::DesktopMediaID)sourceID | 13 - (id)initWithSourceId:(content::DesktopMediaID)sourceID |
14 imageUID:(int)imageUID | 14 imageUID:(int)imageUID |
15 imageTitle:(NSString*)imageTitle { | 15 imageTitle:(NSString*)imageTitle { |
16 if ((self = [super init])) { | 16 if ((self = [super init])) { |
17 sourceID_ = sourceID; | 17 sourceID_ = sourceID; |
18 imageUID_.reset([[NSString stringWithFormat:@"%d", imageUID] retain]); | 18 imageUID_.reset([[NSString stringWithFormat:@"%d", imageUID] retain]); |
19 imageTitle_.reset([imageTitle retain]); | 19 imageTitle_.reset([imageTitle retain]); |
20 } | 20 } |
21 hiddenTitle_ = false; | |
tapted
2016/07/22 03:43:37
ObjC objects are memset to 0s, so this isn't neede
qiangchen
2016/07/22 18:33:55
Done.
| |
21 return self; | 22 return self; |
22 } | 23 } |
23 | 24 |
24 - (content::DesktopMediaID)sourceID { | 25 - (content::DesktopMediaID)sourceID { |
25 return sourceID_; | 26 return sourceID_; |
26 } | 27 } |
27 | 28 |
28 - (void)setImageRepresentation:(NSImage*)image { | 29 - (void)setImageRepresentation:(NSImage*)image { |
29 image_.reset([image retain]); | 30 image_.reset([image retain]); |
30 ++imageVersion_; | 31 ++imageVersion_; |
31 } | 32 } |
32 | 33 |
33 - (void)setImageTitle:(NSString*)imageTitle { | 34 - (void)setImageTitle:(NSString*)imageTitle { |
34 imageTitle_.reset([imageTitle copy]); | 35 imageTitle_.reset([imageTitle copy]); |
35 } | 36 } |
36 | 37 |
38 - (void)setTitleHidden:(bool)hidden { | |
39 hiddenTitle_ = hidden; | |
40 } | |
41 | |
37 #pragma mark IKImageBrowserItem | 42 #pragma mark IKImageBrowserItem |
38 | 43 |
39 - (NSString*)imageUID { | 44 - (NSString*)imageUID { |
40 return imageUID_; | 45 return imageUID_; |
41 } | 46 } |
42 | 47 |
43 - (NSString*)imageRepresentationType { | 48 - (NSString*)imageRepresentationType { |
44 return IKImageBrowserNSImageRepresentationType; | 49 return IKImageBrowserNSImageRepresentationType; |
45 } | 50 } |
46 | 51 |
47 - (NSString*)imageTitle { | 52 - (NSString*)imageTitle { |
53 if (hiddenTitle_) | |
tapted
2016/07/22 03:43:37
nit: return titleHidden_ ? nil : imageTitle_;
(th
qiangchen
2016/07/22 18:33:55
Done.
| |
54 return nil; | |
48 return imageTitle_.get(); | 55 return imageTitle_.get(); |
49 } | 56 } |
50 | 57 |
51 - (NSUInteger)imageVersion { | 58 - (NSUInteger)imageVersion { |
52 return imageVersion_; | 59 return imageVersion_; |
53 } | 60 } |
54 | 61 |
55 - (id)imageRepresentation { | 62 - (id)imageRepresentation { |
56 return image_.get(); | 63 return image_.get(); |
57 } | 64 } |
58 | 65 |
59 @end // @interface DesktopMediaPickerItem | 66 @end // @interface DesktopMediaPickerItem |
OLD | NEW |