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/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc
index d4b2bdf..83848da 100644
--- a/chrome/browser/android/chrome_jni_registrar.cc
+++ b/chrome/browser/android/chrome_jni_registrar.cc
@@ -93,6 +93,7 @@
#include "chrome/browser/notifications/notification_ui_manager_android.h"
#include "chrome/browser/password_manager/credential_android.h"
#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
+#include "chrome/browser/platform_util.h"
#include "chrome/browser/prerender/external_prerender_handler_android.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/search_engines/template_url_service_android.h"
@@ -280,6 +281,7 @@
{"OmniboxUrlEmphasizer",
OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer},
{"OmniboxViewUtil", OmniboxViewUtil::RegisterOmniboxViewUtil},
+ {"PlatformUtil", platform_util::RegisterPlatformUtil},
{"PartnerBookmarksReader",
PartnerBookmarksReader::RegisterPartnerBookmarksReader},
{"PasswordGenerationPopup",
diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h
index 822e89d..6c46b4db 100644
--- a/chrome/browser/platform_util.h
+++ b/chrome/browser/platform_util.h
@@ -98,6 +98,9 @@
bool IsSwipeTrackingFromScrollEventsEnabled();
#endif
+#if defined(OS_ANDROID)
+bool RegisterPlatformUtil(JNIEnv* env);
+#endif
} // namespace platform_util
#endif // CHROME_BROWSER_PLATFORM_UTIL_H_
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