Trust the renderer's same-document navigation flag if it is a same-origin nav.
[chromium-blink-merge.git] / content / common / android / gin_java_bridge_value.h
blob8a7f3eb8f51d5cb7615f3ca25951e69171d4bc09
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.
17 namespace content {
19 class GinJavaBridgeValue {
20 public:
21 enum Type {
22 TYPE_FIRST_VALUE = 0,
23 // JavaScript 'undefined'
24 TYPE_UNDEFINED = 0,
25 // JavaScript NaN and Infinity
26 TYPE_NONFINITE,
27 // Bridge Object ID
28 TYPE_OBJECT_ID,
29 TYPE_LAST_VALUE
32 // Serialization
33 CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateUndefinedValue();
34 CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateNonFiniteValue(
35 float in_value);
36 CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateNonFiniteValue(
37 double in_value);
38 CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateObjectIDValue(
39 int32 in_value);
41 // De-serialization
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;
53 private:
54 explicit GinJavaBridgeValue(Type type);
55 explicit GinJavaBridgeValue(const base::BinaryValue* value);
56 base::BinaryValue* SerializeToBinaryValue();
58 Pickle pickle_;
60 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeValue);
63 } // namespace content
65 #endif // CONTENT_COMMON_ANDROID_GIN_JAVA_BRIDGE_VALUE_H_