Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: chrome/browser/autofill/android/phone_number_util_android.h

Issue 2743763003: [Payments] Format and validate phone number by using libphonenumber (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/android/phone_number_util_android.h
diff --git a/chrome/browser/autofill/android/phone_number_util_android.h b/chrome/browser/autofill/android/phone_number_util_android.h
new file mode 100644
index 0000000000000000000000000000000000000000..889556ef1dbae55ee62fbabda9212827735467e6
--- /dev/null
+++ b/chrome/browser/autofill/android/phone_number_util_android.h
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_AUTOFILL_ANDROID_PHONE_NUMBER_UTIL_ANDROID_H_
+#define CHROME_BROWSER_AUTOFILL_ANDROID_PHONE_NUMBER_UTIL_ANDROID_H_
+
+#include "base/android/jni_weak_ref.h"
+#include "base/android/scoped_java_ref.h"
+#include "third_party/libphonenumber/phonenumber_api.h"
+
+using base::android::JavaParamRef;
+using base::android::ScopedJavaLocalRef;
+using i18n::phonenumbers::PhoneNumberUtil;
+
+namespace autofill {
+
+// Android wrapper of i18n::phonenumbers::PhoneNumberUtil.
+class PhoneNumberUtilAndroid {
+ public:
+ PhoneNumberUtilAndroid(JNIEnv* env, jobject obj);
+
+ // Formats the given number |jphone_number| by using
+ // i18n::phonenumbers::PhoneNumberUtil::Format.
+ ScopedJavaLocalRef<jstring> Format(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& unused_obj,
+ const JavaParamRef<jstring>& jphone_number);
+
+ // Checks whether the given number |jphone_number| is valid by using
+ // i18n::phonenumbers::PhoneNumberUtil::IsValidNumber.
+ jboolean IsValidNumber(JNIEnv* env,
+ const JavaParamRef<jobject>& unused_obj,
+ const JavaParamRef<jstring>& jphone_number);
+
+ // Registers the JNI bindings for this class.
+ static bool Register(JNIEnv* env);
+
+ private:
+ // Pointer to the java counterpart.
+ JavaObjectWeakGlobalRef weak_java_obj_;
+
+ // Instance of i18n::phonenumbers::PhoneNumberUtil.
+ PhoneNumberUtil* phone_number_util_;
+};
+
+} // namespace autofill
+
+#endif // CHROME_BROWSER_AUTOFILL_ANDROID_PHONE_NUMBER_UTIL_ANDROID_H_

Powered by Google App Engine
This is Rietveld 408576698