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

Side by Side Diff: ios/chrome/browser/ui/activity_services/share_to_data.mm

Issue 2586993002: Upstream Chrome on iOS source code [3/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ui/activity_services/share_to_data.h"
6
7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h"
9 #include "ios/chrome/browser/tabs/tab.h"
10 #import "net/base/mac/url_conversions.h"
11
12 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support."
14 #endif
15
16 @interface ShareToData () {
17 @private
18 // URL to be shared.
19 GURL url_;
20
21 // Title to be shared (not nil).
22 NSString* title_;
23
24 // Whether the title was provided by the page (i.e., was not generated from
25 // the url).
26 BOOL isOriginalTitle_;
27
28 // Whether the page is printable or not.
29 BOOL isPagePrintable_;
30 }
31
32 @property(nonatomic, readwrite, copy) NSString* title;
33 @property(nonatomic, readwrite, assign) BOOL isOriginalTitle;
34 @property(nonatomic, readwrite, assign) BOOL isPagePrintable;
35 @end
36
37 @implementation ShareToData
38
39 @synthesize title = title_;
40 @synthesize image = image_;
41 @synthesize isOriginalTitle = isOriginalTitle_;
42 @synthesize isPagePrintable = isPagePrintable_;
43
44 - (id)init {
45 NOTREACHED();
46 return nil;
47 }
48
49 - (id)initWithURL:(const GURL&)url
50 title:(NSString*)title
51 isOriginalTitle:(BOOL)isOriginalTitle
52 isPagePrintable:(BOOL)isPagePrintable {
53 DCHECK(url.is_valid());
54 DCHECK(title);
55 self = [super init];
56 if (self) {
57 url_ = url;
58 self.title = title;
59 self.isOriginalTitle = isOriginalTitle;
60 self.isPagePrintable = isPagePrintable;
61 }
62 return self;
63 }
64
65 - (const GURL&)url {
66 return url_;
67 }
68
69 - (NSURL*)nsurl {
70 return net::NSURLWithGURL(url_);
71 }
72
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698