Home | History | Annotate | Download | only in android
      1 // Copyright (c) 2012 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 #include "chrome/browser/android/intent_helper.h"
      6 
      7 #include <jni.h>
      8 
      9 #include "base/android/jni_android.h"
     10 #include "base/android/jni_string.h"
     11 #include "base/android/scoped_java_ref.h"
     12 #include "jni/IntentHelper_jni.h"
     13 
     14 using base::android::AttachCurrentThread;
     15 using base::android::ConvertUTF16ToJavaString;
     16 
     17 namespace chrome {
     18 namespace android {
     19 
     20 void SendEmail(const base::string16& d_email,
     21                const base::string16& d_subject,
     22                const base::string16& d_body,
     23                const base::string16& d_chooser_title,
     24                const base::string16& d_file_to_attach) {
     25   JNIEnv* env = AttachCurrentThread();
     26   ScopedJavaLocalRef<jstring> j_email = ConvertUTF16ToJavaString(env, d_email);
     27   ScopedJavaLocalRef<jstring> j_subject =
     28       ConvertUTF16ToJavaString(env, d_subject);
     29   ScopedJavaLocalRef<jstring> j_body = ConvertUTF16ToJavaString(env, d_body);
     30   ScopedJavaLocalRef<jstring> j_chooser_title =
     31       ConvertUTF16ToJavaString(env, d_chooser_title);
     32   ScopedJavaLocalRef<jstring> j_file_to_attach =
     33       ConvertUTF16ToJavaString(env, d_file_to_attach);
     34   Java_IntentHelper_sendEmail(env,
     35                               base::android::GetApplicationContext(),
     36                               j_email.obj(),
     37                               j_subject.obj(),
     38                               j_body.obj(),
     39                               j_chooser_title.obj(),
     40                               j_file_to_attach.obj());
     41 }
     42 
     43 bool RegisterIntentHelper(JNIEnv* env) {
     44   return RegisterNativesImpl(env);
     45 }
     46 
     47 }  // namespace android
     48 }  // namespace chrome
     49