Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / chrome / browser / ui / show_mail_composer_util.mm
blob2d9624c56b1506cda08b68cc272a715c022e2aed
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
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/ui/show_mail_composer_util.h"
7 #include <UIKit/UIKit.h>
9 #include "base/logging.h"
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h"
12 #include "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
13 #include "ios/chrome/browser/ui/commands/show_mail_composer_command.h"
15 void ShowMailComposer(const base::string16& to_recipient,
16                       const base::string16& subject,
17                       const base::string16& body,
18                       const base::string16& title,
19                       const base::FilePath& text_file_to_attach,
20                       int email_not_configured_alert_title_id,
21                       int email_not_configured_alert_message_id) {
22   base::scoped_nsobject<ShowMailComposerCommand>
23   command([[ShowMailComposerCommand alloc]
24                    initWithToRecipient:base::SysUTF16ToNSString(to_recipient)
25                                subject:base::SysUTF16ToNSString(subject)
26                                   body:base::SysUTF16ToNSString(body)
27         emailNotConfiguredAlertTitleId:email_not_configured_alert_title_id
28       emailNotConfiguredAlertMessageId:email_not_configured_alert_message_id]);
29   [command setTextFileToAttach:text_file_to_attach];
30   UIWindow* main_window = [[UIApplication sharedApplication] keyWindow];
31   DCHECK(main_window);
32   [main_window.rootViewController chromeExecuteCommand:command];