OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 | |
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_FRAME_PROPERTIES_H_ | |
6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_PROPERTIES_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "mojo/public/cpp/bindings/array.h" | |
11 #include "mojo/public/cpp/bindings/map.h" | |
12 #include "mojo/public/cpp/bindings/string.h" | |
13 | |
14 namespace blink { | |
15 class WebFrame; | |
16 enum class WebSandboxFlags : int; | |
17 class WebString; | |
18 enum class WebTreeScopeType; | |
19 } | |
20 | |
21 namespace url { | |
22 class Origin; | |
23 } | |
24 | |
25 // Functions used to communicate html specific state for each frame. | |
26 namespace html_viewer { | |
27 | |
28 // Keys used for client properties. | |
29 extern const char kPropertyFrameName[]; | |
30 extern const char kPropertyFrameOrigin[]; | |
31 extern const char kPropertyFrameSandboxFlags[]; | |
32 extern const char kPropertyFrameTreeScope[]; | |
33 | |
34 mojo::Array<uint8_t> FrameNameToClientProperty(const blink::WebString& name); | |
35 blink::WebString FrameNameFromClientProperty( | |
36 const mojo::Array<uint8_t>& new_data); | |
37 | |
38 mojo::Array<uint8_t> FrameTreeScopeToClientProperty( | |
39 blink::WebTreeScopeType scope_type); | |
40 bool FrameTreeScopeFromClientProperty(const mojo::Array<uint8_t>& new_data, | |
41 blink::WebTreeScopeType* scope); | |
42 | |
43 mojo::Array<uint8_t> FrameSandboxFlagsToClientProperty( | |
44 blink::WebSandboxFlags flags); | |
45 bool FrameSandboxFlagsFromClientProperty(const mojo::Array<uint8_t>& new_data, | |
46 blink::WebSandboxFlags* flags); | |
47 | |
48 url::Origin FrameOrigin(blink::WebFrame* frame); | |
49 mojo::Array<uint8_t> FrameOriginToClientProperty(blink::WebFrame* frame); | |
50 url::Origin FrameOriginFromClientProperty(const mojo::Array<uint8_t>& data); | |
51 | |
52 // Convenience to add |value| to |client_properties| if non-null. | |
53 void AddToClientPropertiesIfValid( | |
54 const std::string& name, | |
55 mojo::Array<uint8_t> value, | |
56 mojo::Map<mojo::String, mojo::Array<uint8_t>>* client_properties); | |
57 | |
58 // Returns |properties[name]| if exists, otherwise a null array. | |
59 mojo::Array<uint8_t> GetValueFromClientProperties( | |
60 const std::string& name, | |
61 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties); | |
62 | |
63 } // namespace html_viewer | |
64 | |
65 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_PROPERTIES_H_ | |
OLD | NEW |