Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / html_viewer / replicated_frame_state.cc
blobc514ad2673a64178b93a698bab98b9fd46297c24
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 #include "components/html_viewer/replicated_frame_state.h"
7 #include "components/html_viewer/html_frame_properties.h"
9 namespace html_viewer {
11 ReplicatedFrameState::ReplicatedFrameState()
12 : sandbox_flags(blink::WebSandboxFlags::None),
13 tree_scope(blink::WebTreeScopeType::Document) {}
15 ReplicatedFrameState::~ReplicatedFrameState() {}
17 void SetReplicatedFrameStateFromClientProperties(
18 const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties,
19 ReplicatedFrameState* state) {
20 state->name = FrameNameFromClientProperty(
21 GetValueFromClientProperties(kPropertyFrameName, properties));
22 state->origin = FrameOriginFromClientProperty(
23 GetValueFromClientProperties(kPropertyFrameOrigin, properties));
24 if (!FrameSandboxFlagsFromClientProperty(
25 GetValueFromClientProperties(kPropertyFrameSandboxFlags, properties),
26 &(state->sandbox_flags))) {
27 state->sandbox_flags = blink::WebSandboxFlags::None;
29 if (!FrameTreeScopeFromClientProperty(
30 GetValueFromClientProperties(kPropertyFrameTreeScope, properties),
31 &(state->tree_scope))) {
32 state->tree_scope = blink::WebTreeScopeType::Document;
36 void ClientPropertiesFromReplicatedFrameState(
37 const ReplicatedFrameState& state,
38 mojo::Map<mojo::String, mojo::Array<uint8_t>>* properties) {
39 AddToClientPropertiesIfValid(kPropertyFrameName,
40 FrameNameToClientProperty(state.name).Pass(),
41 properties);
42 AddToClientPropertiesIfValid(
43 kPropertyFrameTreeScope,
44 FrameTreeScopeToClientProperty(state.tree_scope).Pass(), properties);
45 AddToClientPropertiesIfValid(
46 kPropertyFrameSandboxFlags,
47 FrameSandboxFlagsToClientProperty(state.sandbox_flags).Pass(),
48 properties);
51 } // namespace html_viewer