| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/commands/show_mail_composer_command.h" | 5 #import "ios/chrome/browser/ui/commands/show_mail_composer_command.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 11 | 11 |
| 12 @implementation ShowMailComposerCommand { | 12 @implementation ShowMailComposerCommand { |
| 13 base::scoped_nsobject<NSArray> _toRecipients; | 13 base::scoped_nsobject<NSArray> _toRecipients; |
| 14 base::scoped_nsobject<NSString> _subject; | 14 base::scoped_nsobject<NSString> _subject; |
| 15 base::scoped_nsobject<NSString> _body; | 15 base::scoped_nsobject<NSString> _body; |
| 16 base::FilePath _textFileToAttach; | 16 base::FilePath _textFileToAttach; |
| 17 // Alert message ids for the case when no email account is configured. | |
| 18 int _emailNotConfiguredAlertTitleId; | |
| 19 int _emailNotConfiguredAlertMessageId; | |
| 20 } | 17 } |
| 21 | 18 |
| 22 @synthesize textFileToAttach; | 19 @synthesize emailNotConfiguredAlertTitleId = _emailNotConfiguredAlertTitleId; |
| 20 @synthesize emailNotConfiguredAlertMessageId = |
| 21 _emailNotConfiguredAlertMessageId; |
| 23 | 22 |
| 24 - (id)initWithToRecipient:(NSString*)toRecipient | 23 - (instancetype)initWithTag:(NSInteger)tag { |
| 24 NOTREACHED(); |
| 25 return nil; |
| 26 } |
| 27 |
| 28 - (instancetype)initWithToRecipient:(NSString*)toRecipient |
| 25 subject:(NSString*)subject | 29 subject:(NSString*)subject |
| 26 body:(NSString*)body | 30 body:(NSString*)body |
| 27 emailNotConfiguredAlertTitleId:(int)alertTitleId | 31 emailNotConfiguredAlertTitleId:(int)alertTitleId |
| 28 emailNotConfiguredAlertMessageId:(int)alertMessageId { | 32 emailNotConfiguredAlertMessageId:(int)alertMessageId { |
| 29 DCHECK(alertTitleId); | 33 DCHECK(alertTitleId); |
| 30 DCHECK(alertMessageId); | 34 DCHECK(alertMessageId); |
| 31 self = [super init]; | 35 self = [super initWithTag:IDC_SHOW_MAIL_COMPOSER]; |
| 32 if (self) { | 36 if (self) { |
| 33 self.tag = IDC_SHOW_MAIL_COMPOSER; | |
| 34 _toRecipients.reset([@[ toRecipient ] retain]); | 37 _toRecipients.reset([@[ toRecipient ] retain]); |
| 35 _subject.reset([subject retain]); | 38 _subject.reset([subject copy]); |
| 36 _body.reset([body retain]); | 39 _body.reset([body copy]); |
| 37 _emailNotConfiguredAlertTitleId = alertTitleId; | 40 _emailNotConfiguredAlertTitleId = alertTitleId; |
| 38 _emailNotConfiguredAlertMessageId = alertMessageId; | 41 _emailNotConfiguredAlertMessageId = alertMessageId; |
| 39 } | 42 } |
| 40 return self; | 43 return self; |
| 41 } | 44 } |
| 42 | 45 |
| 43 - (NSArray*)toRecipients { | 46 - (NSArray*)toRecipients { |
| 44 return _toRecipients.get(); | 47 return _toRecipients.get(); |
| 45 } | 48 } |
| 46 | 49 |
| 47 - (NSString*)subject { | 50 - (NSString*)subject { |
| 48 return _subject.get(); | 51 return _subject.get(); |
| 49 } | 52 } |
| 50 | 53 |
| 51 - (NSString*)body { | 54 - (NSString*)body { |
| 52 return _body.get(); | 55 return _body.get(); |
| 53 } | 56 } |
| 54 | 57 |
| 55 - (int)emailNotConfiguredAlertTitleId { | 58 - (const base::FilePath&)textFileToAttach { |
| 56 return _emailNotConfiguredAlertTitleId; | 59 return _textFileToAttach; |
| 57 } | 60 } |
| 58 | 61 |
| 59 - (int)emailNotConfiguredAlertMessageId { | 62 - (void)setTextFileToAttach:(const base::FilePath&)textFileToAttach { |
| 60 return _emailNotConfiguredAlertMessageId; | 63 _textFileToAttach = textFileToAttach; |
| 61 } | 64 } |
| 62 | 65 |
| 63 @end | 66 @end |
| OLD | NEW |