Implement PlatformUtil::OpenExternal() so that mailto: can work
Clicking a mailto link inside an iframe doesn't work on android.
This is because PlatformUtil::OpenExternal() is not implemented.
This CL adds the implementation for this feature.
BUG=523491
Review URL: https://codereview.chromium.org/1310873003
Cr-Commit-Position: refs/heads/master@{#347774}
diff --git a/chrome/browser/platform_util_android.cc b/chrome/browser/platform_util_android.cc
index 8a14b58..04a0f0d 100644
--- a/chrome/browser/platform_util_android.cc
+++ b/chrome/browser/platform_util_android.cc
@@ -2,9 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <jni.h>
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
#include "base/logging.h"
#include "chrome/browser/platform_util.h"
+#include "jni/PlatformUtil_jni.h"
#include "ui/android/view_android.h"
+#include "url/gurl.h"
namespace platform_util {
@@ -22,7 +28,10 @@
}
void OpenExternal(Profile* profile, const GURL& url) {
- NOTIMPLEMENTED();
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> j_url =
+ base::android::ConvertUTF8ToJavaString(env, url.spec());
+ Java_PlatformUtil_launchExternalProtocol(env, j_url.obj());
}
gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
@@ -49,4 +58,8 @@
return true;
}
+bool RegisterPlatformUtil(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
} // namespace platform_util