1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_
6 #define BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_
10 #include "base/android/scoped_java_ref.h"
11 #include "base/base_export.h"
12 #include "base/unguessable_token.h"
17 class BASE_EXPORT UnguessableTokenAndroid {
19 // Create a Java UnguessableToken with the same value as |token|.
20 static ScopedJavaLocalRef<jobject> Create(
22 const base::UnguessableToken& token);
24 // Create a native UnguessableToken from Java UnguessableToken |token|.
25 static absl::optional<base::UnguessableToken> FromJavaUnguessableToken(
27 const JavaRef<jobject>& token);
29 // Parcel UnguessableToken |token| and unparcel it, and return the result.
30 // While this method is intended for facilitating unit tests, it results only
31 // in a clone of |token|.
32 static ScopedJavaLocalRef<jobject> ParcelAndUnparcelForTesting(
34 const JavaRef<jobject>& token);
36 UnguessableTokenAndroid() = delete;
37 UnguessableTokenAndroid(const UnguessableTokenAndroid&) = delete;
38 UnguessableTokenAndroid& operator=(const UnguessableTokenAndroid&) = delete;
41 } // namespace android
44 #endif // BASE_ANDROID_UNGUESSABLE_TOKEN_ANDROID_H_