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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/activity_services/share_to_data.mm
diff --git a/ios/chrome/browser/ui/activity_services/share_to_data.mm b/ios/chrome/browser/ui/activity_services/share_to_data.mm
new file mode 100644
index 0000000000000000000000000000000000000000..40018418250c8ae64248d14381fe36cf3005777c
--- /dev/null
+++ b/ios/chrome/browser/ui/activity_services/share_to_data.mm
@@ -0,0 +1,94 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/ui/activity_services/share_to_data.h"
+
+#include "base/logging.h"
+#include "base/strings/sys_string_conversions.h"
+#include "ios/chrome/browser/tabs/tab.h"
+#import "net/base/mac/url_conversions.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@interface ShareToData () {
+ @private
+ // URL to be shared.
+ GURL url_;
+
+ // Title to be shared (not nil).
+ NSString* title_;
+
+ // Whether the title was provided by the page (i.e., was not generated from
+ // the url).
+ BOOL isOriginalTitle_;
+
+ // Whether the page is printable or not.
+ BOOL isPagePrintable_;
+}
+
+@property(nonatomic, readwrite, copy) NSString* title;
+@property(nonatomic, readwrite, assign) BOOL isOriginalTitle;
+@property(nonatomic, readwrite, assign) BOOL isPagePrintable;
+@end
+
+@implementation ShareToData
+
+@synthesize title = title_;
+@synthesize image = image_;
+@synthesize isOriginalTitle = isOriginalTitle_;
+@synthesize isPagePrintable = isPagePrintable_;
+
+- (id)init {
+ NOTREACHED();
+ return nil;
+}
+
+- (id)initWithURL:(const GURL&)url
+ title:(NSString*)title
+ isOriginalTitle:(BOOL)isOriginalTitle
+ isPagePrintable:(BOOL)isPagePrintable {
+ DCHECK(url.is_valid());
+ DCHECK(title);
+ self = [super init];
+ if (self) {
+ url_ = url;
+ self.title = title;
+ self.isOriginalTitle = isOriginalTitle;
+ self.isPagePrintable = isPagePrintable;
+ }
+ return self;
+}
+
+- (const GURL&)url {
+ return url_;
+}
+
+- (NSURL*)nsurl {
+ return net::NSURLWithGURL(url_);
+}
+
+- (BOOL)isEqual:(id)object {
+ if (![object isMemberOfClass:self.class])
+ return NO;
+ DCHECK(self.url.is_valid());
+ DCHECK(self.title);
+ ShareToData* other = (ShareToData*)object;
+ return self.url == other.url && [self.title isEqual:other.title] &&
+ self.image == other.image &&
+ self.isOriginalTitle == other.isOriginalTitle;
+}
+
+- (NSUInteger)hash {
+ DCHECK(self.url.is_valid());
+ DCHECK(self.title);
+ const NSUInteger kPrime = 31;
+ NSString* urlString = base::SysUTF8ToNSString(self.url.spec());
+ return kPrime * kPrime * kPrime * urlString.hash +
+ kPrime * kPrime * self.title.hash + kPrime * self.image.hash +
+ (self.isOriginalTitle ? 0 : 1);
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698