unguessable_token_android.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. UnguessableTokenAndroid() = delete;
  29. UnguessableTokenAndroid(const UnguessableTokenAndroid&) = delete;
  30. UnguessableTokenAndroid& operator=(const UnguessableTokenAndroid&) = delete;
  31. };
  32. } // namespace android
  33. } // namespace base
  34. #endif // BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_