OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ios/chrome/browser/ui/show_mail_composer_util.h" | 5 #include "ios/chrome/browser/ui/show_mail_composer_util.h" |
6 | 6 |
7 #include <UIKit/UIKit.h> | 7 #include <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_nsobject.h" | |
11 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
12 #include "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 11 #include "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
13 #include "ios/chrome/browser/ui/commands/show_mail_composer_command.h" | 12 #include "ios/chrome/browser/ui/commands/show_mail_composer_command.h" |
14 | 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." |
| 16 #endif |
| 17 |
15 void ShowMailComposer(const base::string16& to_recipient, | 18 void ShowMailComposer(const base::string16& to_recipient, |
16 const base::string16& subject, | 19 const base::string16& subject, |
17 const base::string16& body, | 20 const base::string16& body, |
18 const base::string16& title, | 21 const base::string16& title, |
19 const base::FilePath& text_file_to_attach, | 22 const base::FilePath& text_file_to_attach, |
20 int email_not_configured_alert_title_id, | 23 int email_not_configured_alert_title_id, |
21 int email_not_configured_alert_message_id) { | 24 int email_not_configured_alert_message_id) { |
22 base::scoped_nsobject<ShowMailComposerCommand> | 25 ShowMailComposerCommand* command = [[ShowMailComposerCommand alloc] |
23 command([[ShowMailComposerCommand alloc] | |
24 initWithToRecipient:base::SysUTF16ToNSString(to_recipient) | 26 initWithToRecipient:base::SysUTF16ToNSString(to_recipient) |
25 subject:base::SysUTF16ToNSString(subject) | 27 subject:base::SysUTF16ToNSString(subject) |
26 body:base::SysUTF16ToNSString(body) | 28 body:base::SysUTF16ToNSString(body) |
27 emailNotConfiguredAlertTitleId:email_not_configured_alert_title_id | 29 emailNotConfiguredAlertTitleId:email_not_configured_alert_title_id |
28 emailNotConfiguredAlertMessageId:email_not_configured_alert_message_id]); | 30 emailNotConfiguredAlertMessageId:email_not_configured_alert_message_id]; |
29 [command setTextFileToAttach:text_file_to_attach]; | 31 [command setTextFileToAttach:text_file_to_attach]; |
30 UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; | 32 UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; |
31 DCHECK(main_window); | 33 DCHECK(main_window); |
32 [main_window.rootViewController chromeExecuteCommand:command]; | 34 [main_window.rootViewController chromeExecuteCommand:command]; |
33 } | 35 } |
OLD | NEW |