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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #import "ios/chrome/browser/ui/activity_services/reading_list_activity.h"
6
7 #include "base/logging.h"
8 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
9 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
10 #import "ios/chrome/browser/ui/commands/reading_list_add_command.h"
11 #include "ios/chrome/grit/ios_strings.h"
12 #include "ui/base/l10n/l10n_util_mac.h"
13 #include "url/gurl.h"
14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 namespace {
20
21 NSString* const kReadingListActivityType =
22 @"com.google.chrome.readingListActivity";
23
24 } // namespace
25
26 @interface ReadingListActivity () {
27 GURL _activityURL;
28 NSString* _title;
29 // The responder that receives ChromeCommands when the activity is performed.
30 __weak UIResponder* _responder;
31 }
32 @end
33
34 @implementation ReadingListActivity
35
36 + (NSString*)activityIdentifier {
37 return kReadingListActivityType;
38 }
39
40 - (instancetype)initWithURL:(const GURL&)activityURL
41 title:(NSString*)title
42 responder:(UIResponder*)responder {
43 if (self = [super init]) {
44 _responder = responder;
45 _activityURL = activityURL;
46 _title = [NSString stringWithString:title];
47 }
48 return self;
49 }
50
51 #pragma mark - UIActivity
52
53 - (NSString*)activityType {
54 return [[self class] activityIdentifier];
55 }
56
57 - (NSString*)activityTitle {
58 return l10n_util::GetNSString(IDS_IOS_SHARE_MENU_READING_LIST_ACTION);
59 }
60
61 - (UIImage*)activityImage {
62 return [UIImage imageNamed:@"activity_services_reading_list"];
63 }
64
65 - (BOOL)canPerformWithActivityItems:(NSArray*)activityItems {
66 return YES;
67 }
68
69 + (UIActivityCategory)activityCategory {
70 return UIActivityCategoryAction;
71 }
72
73 - (void)performActivity {
74 ReadingListAddCommand* command =
75 [[ReadingListAddCommand alloc] initWithURL:_activityURL title:_title];
76 [_responder chromeExecuteCommand:command];
77 [self activityDidFinish:YES];
78 }
79
80 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698