OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/print_activity.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 9 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 11 #include "ios/chrome/grit/ios_strings.h" |
| 12 #include "ui/base/l10n/l10n_util_mac.h" |
| 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." |
| 16 #endif |
| 17 |
| 18 namespace { |
| 19 |
| 20 NSString* const kPrintActivityType = @"com.google.chrome.printActivity"; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 @interface PrintActivity () { |
| 25 UIResponder* responder_; |
| 26 } |
| 27 @end |
| 28 |
| 29 @implementation PrintActivity |
| 30 @dynamic responder; |
| 31 |
| 32 + (NSString*)activityIdentifier { |
| 33 return kPrintActivityType; |
| 34 } |
| 35 |
| 36 #pragma mark - UIActivity |
| 37 |
| 38 - (void)setResponder:(UIResponder*)responder { |
| 39 responder_ = responder; |
| 40 } |
| 41 |
| 42 - (NSString*)activityType { |
| 43 return [PrintActivity activityIdentifier]; |
| 44 } |
| 45 |
| 46 - (NSString*)activityTitle { |
| 47 return l10n_util::GetNSString(IDS_IOS_SHARE_MENU_PRINT_ACTION); |
| 48 } |
| 49 |
| 50 - (UIImage*)activityImage { |
| 51 return [UIImage imageNamed:@"activity_services_print"]; |
| 52 } |
| 53 |
| 54 - (BOOL)canPerformWithActivityItems:(NSArray*)activityItems { |
| 55 return YES; |
| 56 } |
| 57 |
| 58 - (void)prepareWithActivityItems:(NSArray*)activityItems { |
| 59 } |
| 60 |
| 61 + (UIActivityCategory)activityCategory { |
| 62 return UIActivityCategoryAction; |
| 63 } |
| 64 |
| 65 - (void)performActivity { |
| 66 GenericChromeCommand* command = |
| 67 [[GenericChromeCommand alloc] initWithTag:IDC_PRINT]; |
| 68 DCHECK(responder_); |
| 69 [responder_ chromeExecuteCommand:command]; |
| 70 [self activityDidFinish:YES]; |
| 71 } |
| 72 |
| 73 @end |
OLD | NEW |