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

Unified Diff: ios/chrome/browser/ui/activity_services/reading_list_activity.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/reading_list_activity.mm
diff --git a/ios/chrome/browser/ui/activity_services/reading_list_activity.mm b/ios/chrome/browser/ui/activity_services/reading_list_activity.mm
new file mode 100644
index 0000000000000000000000000000000000000000..f341689172983b665ebdb7623633494055606bf6
--- /dev/null
+++ b/ios/chrome/browser/ui/activity_services/reading_list_activity.mm
@@ -0,0 +1,80 @@
+// Copyright 2016 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.
+
+#import "ios/chrome/browser/ui/activity_services/reading_list_activity.h"
+
+#include "base/logging.h"
+#import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
+#include "ios/chrome/browser/ui/commands/ios_command_ids.h"
+#import "ios/chrome/browser/ui/commands/reading_list_add_command.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ui/base/l10n/l10n_util_mac.h"
+#include "url/gurl.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace {
+
+NSString* const kReadingListActivityType =
+ @"com.google.chrome.readingListActivity";
+
+} // namespace
+
+@interface ReadingListActivity () {
+ GURL _activityURL;
+ NSString* _title;
+ // The responder that receives ChromeCommands when the activity is performed.
+ __weak UIResponder* _responder;
+}
+@end
+
+@implementation ReadingListActivity
+
++ (NSString*)activityIdentifier {
+ return kReadingListActivityType;
+}
+
+- (instancetype)initWithURL:(const GURL&)activityURL
+ title:(NSString*)title
+ responder:(UIResponder*)responder {
+ if (self = [super init]) {
+ _responder = responder;
+ _activityURL = activityURL;
+ _title = [NSString stringWithString:title];
+ }
+ return self;
+}
+
+#pragma mark - UIActivity
+
+- (NSString*)activityType {
+ return [[self class] activityIdentifier];
+}
+
+- (NSString*)activityTitle {
+ return l10n_util::GetNSString(IDS_IOS_SHARE_MENU_READING_LIST_ACTION);
+}
+
+- (UIImage*)activityImage {
+ return [UIImage imageNamed:@"activity_services_reading_list"];
+}
+
+- (BOOL)canPerformWithActivityItems:(NSArray*)activityItems {
+ return YES;
+}
+
++ (UIActivityCategory)activityCategory {
+ return UIActivityCategoryAction;
+}
+
+- (void)performActivity {
+ ReadingListAddCommand* command =
+ [[ReadingListAddCommand alloc] initWithURL:_activityURL title:_title];
+ [_responder chromeExecuteCommand:command];
+ [self activityDidFinish:YES];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698