Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / html_viewer / html_frame_properties.h
blob8944d463665466d7d1e7256673dea5dce1d7ebc3
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.
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_FRAME_PROPERTIES_H_
6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_PROPERTIES_H_
8 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
9 #include "third_party/mojo/src/mojo/public/cpp/bindings/map.h"
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/string.h"
12 namespace blink {
13 class WebFrame;
14 enum class WebSandboxFlags : int;
15 class WebString;
16 enum class WebTreeScopeType;
19 namespace url {
20 class Origin;
23 // Functions used to communicate html specific state for each frame.
24 namespace html_viewer {
26 // Keys used for client properties.
27 extern const char kPropertyFrameName[];
28 extern const char kPropertyFrameOrigin[];
29 extern const char kPropertyFrameSandboxFlags[];
30 extern const char kPropertyFrameTreeScope[];
32 mojo::Array<uint8_t> FrameNameToClientProperty(const blink::WebString& name);
33 blink::WebString FrameNameFromClientProperty(
34 const mojo::Array<uint8_t>& new_data);
36 mojo::Array<uint8_t> FrameTreeScopeToClientProperty(
37 blink::WebTreeScopeType scope_type);
38 bool FrameTreeScopeFromClientProperty(const mojo::Array<uint8_t>& new_data,
39 blink::WebTreeScopeType* scope);
41 mojo::Array<uint8_t> FrameSandboxFlagsToClientProperty(
42 blink::WebSandboxFlags flags);
43 bool FrameSandboxFlagsFromClientProperty(const mojo::Array<uint8_t>& new_data,
44 blink::WebSandboxFlags* flags);
46 url::Origin FrameOrigin(blink::WebFrame* frame);
47 mojo::Array<uint8_t> FrameOriginToClientProperty(blink::WebFrame* frame);
48 url::Origin FrameOriginFromClientProperty(const mojo::Array<uint8_t>& data);
50 // Convenience to add |value| to |client_properties| if non-null.
51 void AddToClientPropertiesIfValid(
52 const std::string& name,
53 mojo::Array<uint8_t> value,
54 mojo::Map<mojo::String, mojo::Array<uint8_t>>* client_properties);
56 // Returns |properties[name]| if exists, otherwise a null array.
57 mojo::Array<uint8_t> GetValueFromClientProperties(
58 const std::string& name,
59 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties);
61 } // namespace html_viewer
63 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_PROPERTIES_H_