OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "ios/chrome/browser/ui/activity_services/share_to_data.h" | 5 #include "ios/chrome/browser/ui/activity_services/share_to_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "ios/chrome/browser/tabs/tab.h" | 9 #include "ios/chrome/browser/tabs/tab.h" |
10 #import "net/base/mac/url_conversions.h" | 10 #import "net/base/mac/url_conversions.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 @property(nonatomic, readwrite, copy) NSString* title; | 32 @property(nonatomic, readwrite, copy) NSString* title; |
33 @property(nonatomic, readwrite, assign) BOOL isOriginalTitle; | 33 @property(nonatomic, readwrite, assign) BOOL isOriginalTitle; |
34 @property(nonatomic, readwrite, assign) BOOL isPagePrintable; | 34 @property(nonatomic, readwrite, assign) BOOL isPagePrintable; |
35 @end | 35 @end |
36 | 36 |
37 @implementation ShareToData | 37 @implementation ShareToData |
38 | 38 |
39 @synthesize title = title_; | 39 @synthesize title = title_; |
40 @synthesize image = image_; | 40 @synthesize image = image_; |
| 41 @synthesize thumbnailGenerator = thumbnailGenerator_; |
41 @synthesize isOriginalTitle = isOriginalTitle_; | 42 @synthesize isOriginalTitle = isOriginalTitle_; |
42 @synthesize isPagePrintable = isPagePrintable_; | 43 @synthesize isPagePrintable = isPagePrintable_; |
43 | 44 |
44 - (id)init { | 45 - (id)init { |
45 NOTREACHED(); | 46 NOTREACHED(); |
46 return nil; | 47 return nil; |
47 } | 48 } |
48 | 49 |
49 - (id)initWithURL:(const GURL&)url | 50 - (id)initWithURL:(const GURL&)url |
50 title:(NSString*)title | 51 title:(NSString*)title |
51 isOriginalTitle:(BOOL)isOriginalTitle | 52 isOriginalTitle:(BOOL)isOriginalTitle |
52 isPagePrintable:(BOOL)isPagePrintable { | 53 isPagePrintable:(BOOL)isPagePrintable |
| 54 thumbnailGenerator:(ThumbnailGeneratorBlock)thumbnailGenerator { |
53 DCHECK(url.is_valid()); | 55 DCHECK(url.is_valid()); |
54 DCHECK(title); | 56 DCHECK(title); |
55 self = [super init]; | 57 self = [super init]; |
56 if (self) { | 58 if (self) { |
57 url_ = url; | 59 url_ = url; |
58 self.title = title; | 60 title_ = title; |
59 self.isOriginalTitle = isOriginalTitle; | 61 isOriginalTitle_ = isOriginalTitle; |
60 self.isPagePrintable = isPagePrintable; | 62 isPagePrintable_ = isPagePrintable; |
| 63 thumbnailGenerator_ = thumbnailGenerator; |
61 } | 64 } |
62 return self; | 65 return self; |
63 } | 66 } |
64 | 67 |
65 - (const GURL&)url { | 68 - (const GURL&)url { |
66 return url_; | 69 return url_; |
67 } | 70 } |
68 | 71 |
69 - (NSURL*)nsurl { | 72 - (NSURL*)nsurl { |
70 return net::NSURLWithGURL(url_); | 73 return net::NSURLWithGURL(url_); |
71 } | 74 } |
72 | 75 |
73 - (BOOL)isEqual:(id)object { | |
74 if (![object isMemberOfClass:self.class]) | |
75 return NO; | |
76 DCHECK(self.url.is_valid()); | |
77 DCHECK(self.title); | |
78 ShareToData* other = (ShareToData*)object; | |
79 return self.url == other.url && [self.title isEqual:other.title] && | |
80 self.image == other.image && | |
81 self.isOriginalTitle == other.isOriginalTitle; | |
82 } | |
83 | |
84 - (NSUInteger)hash { | |
85 DCHECK(self.url.is_valid()); | |
86 DCHECK(self.title); | |
87 const NSUInteger kPrime = 31; | |
88 NSString* urlString = base::SysUTF8ToNSString(self.url.spec()); | |
89 return kPrime * kPrime * kPrime * urlString.hash + | |
90 kPrime * kPrime * self.title.hash + kPrime * self.image.hash + | |
91 (self.isOriginalTitle ? 0 : 1); | |
92 } | |
93 | |
94 @end | 76 @end |
OLD | NEW |