unguessable_token_android.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2016 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. #ifndef BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_
  5. #define BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_
  6. #include <jni.h>
  7. #include "base/android/scoped_java_ref.h"
  8. #include "base/base_export.h"
  9. #include "base/unguessable_token.h"
  10. namespace base {
  11. namespace android {
  12. class BASE_EXPORT UnguessableTokenAndroid {
  13. public:
  14. // Create a Java UnguessableToken with the same value as |token|.
  15. static ScopedJavaLocalRef<jobject> Create(
  16. JNIEnv* env,
  17. const base::UnguessableToken& token);
  18. // Create a native UnguessableToken from Java UnguessableToken |token|.
  19. static base::UnguessableToken FromJavaUnguessableToken(
  20. JNIEnv* env,
  21. const JavaRef<jobject>& token);
  22. // Parcel UnguessableToken |token| and unparcel it, and return the result.
  23. // While this method is intended for facilitating unit tests, it results only
  24. // in a clone of |token|.
  25. static ScopedJavaLocalRef<jobject> ParcelAndUnparcelForTesting(
  26. JNIEnv* env,
  27. const JavaRef<jobject>& token);
  28. private:
  29. DISALLOW_COPY_AND_ASSIGN(UnguessableTokenAndroid);
  30. };
  31. } // namespace android
  32. } // namespace base
  33. #endif // BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_