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