1 // Copyright 2014 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.
5 #ifndef CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
6 #define CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/pickle.h"
10 #include "base/values.h"
11 #include "content/common/content_export.h"
13 // In Java Bridge, we need to pass some kinds of values that can't
14 // be put into base::Value. And since base::Value is not extensible,
15 // we transfer these special values via base::BinaryValue.
19 class GinJavaBridgeValue
{
23 // JavaScript 'undefined'
25 // JavaScript NaN and Infinity
33 CONTENT_EXPORT
static scoped_ptr
<base::BinaryValue
> CreateUndefinedValue();
34 CONTENT_EXPORT
static scoped_ptr
<base::BinaryValue
> CreateNonFiniteValue(
36 CONTENT_EXPORT
static scoped_ptr
<base::BinaryValue
> CreateNonFiniteValue(
38 CONTENT_EXPORT
static scoped_ptr
<base::BinaryValue
> CreateObjectIDValue(
42 CONTENT_EXPORT
static bool ContainsGinJavaBridgeValue(
43 const base::Value
* value
);
44 CONTENT_EXPORT
static scoped_ptr
<const GinJavaBridgeValue
> FromValue(
45 const base::Value
* value
);
47 CONTENT_EXPORT Type
GetType() const;
48 CONTENT_EXPORT
bool IsType(Type type
) const;
50 CONTENT_EXPORT
bool GetAsNonFinite(float* out_value
) const;
51 CONTENT_EXPORT
bool GetAsObjectID(int32
* out_object_id
) const;
54 explicit GinJavaBridgeValue(Type type
);
55 explicit GinJavaBridgeValue(const base::BinaryValue
* value
);
56 base::BinaryValue
* SerializeToBinaryValue();
60 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeValue
);
63 } // namespace content
65 #endif // CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_