Index: components/html_viewer/html_frame_properties.cc |
diff --git a/components/html_viewer/html_frame_properties.cc b/components/html_viewer/html_frame_properties.cc |
index 9d6ac9246d36353b2c637cc7705479b981dece9d..88c50bae10bd497e7df3fc91ef2e2d68f2ac1a94 100644 |
--- a/components/html_viewer/html_frame_properties.cc |
+++ b/components/html_viewer/html_frame_properties.cc |
@@ -10,6 +10,7 @@ |
#include "third_party/WebKit/public/platform/WebString.h" |
#include "third_party/WebKit/public/web/WebDocument.h" |
#include "third_party/WebKit/public/web/WebFrame.h" |
+#include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
#include "third_party/WebKit/public/web/WebSandboxFlags.h" |
#include "url/origin.h" |
#include "url/url_util.h" |
@@ -20,6 +21,8 @@ const char kPropertyFrameTreeScope[] = "html-viewer-frame-tree-scope"; |
const char kPropertyFrameOrigin[] = "html-viewer-replicated-frame-origin"; |
const char kPropertyFrameName[] = "html-viewer-replicated-frame-name"; |
const char kPropertyFrameSandboxFlags[] = "html-viewer-sandbox-flags"; |
+const char kPropertyFrameOwnerProperties[] = |
+ "html-viewer-frame-owner-properties"; |
namespace { |
@@ -79,6 +82,18 @@ mojo::Array<uint8_t> FrameSandboxFlagsToClientProperty( |
return IntToClientPropertyArray(static_cast<int>(flags)).Pass(); |
} |
+mojo::Array<uint8_t> FrameOwnerPropertiesToClientProperty( |
+ const blink::WebFrameOwnerProperties& owner_properties) { |
+ base::Pickle pickle; |
+ pickle.WriteInt(static_cast<int>(owner_properties.scrollingMode)); |
+ pickle.WriteInt(owner_properties.marginWidth); |
+ pickle.WriteInt(owner_properties.marginHeight); |
+ |
+ mojo::Array<uint8_t> owner_properties_array(pickle.size()); |
+ memcpy(&(owner_properties_array.front()), pickle.data(), pickle.size()); |
+ return owner_properties_array.Pass(); |
+} |
+ |
bool FrameSandboxFlagsFromClientProperty(const mojo::Array<uint8_t>& new_data, |
blink::WebSandboxFlags* flags) { |
if (new_data.is_null()) |
@@ -143,6 +158,35 @@ url::Origin FrameOriginFromClientProperty(const mojo::Array<uint8_t>& data) { |
return result; |
} |
+bool FrameOwnerPropertiesFromClientProperty( |
alexmos
2015/10/02 21:24:19
Should we have unit tests for this and FrameOwnerP
lazyboy
2015/10/05 22:16:08
I've removed these on the latest patch.
|
+ const mojo::Array<uint8_t>& data, |
+ blink::WebFrameOwnerProperties* owner_properties) { |
+ if (data.is_null()) |
+ return false; |
+ |
+ CHECK(data.size()); |
+ CHECK(data.size() < static_cast<size_t>(std::numeric_limits<int>::max())); |
+ COMPILE_ASSERT(sizeof(uint8_t) == sizeof(unsigned char), |
+ uint8_t_same_size_as_unsigned_char); |
+ const base::Pickle pickle(reinterpret_cast<const char*>(&(data.front())), |
+ static_cast<int>(data.size())); |
+ CHECK(pickle.data()); |
+ base::PickleIterator iter(pickle); |
+ |
+ int scrolling_mode_as_int; |
+ CHECK(iter.ReadInt(&scrolling_mode_as_int)); |
+ CHECK(scrolling_mode_as_int >= 0 && |
+ scrolling_mode_as_int <= |
+ static_cast<int>( |
+ blink::WebFrameOwnerProperties::ScrollingMode::Last)); |
+ owner_properties->scrollingMode = |
+ static_cast<blink::WebFrameOwnerProperties::ScrollingMode>( |
+ scrolling_mode_as_int); |
+ CHECK(iter.ReadInt(&(owner_properties->marginWidth))); |
+ CHECK(iter.ReadInt(&(owner_properties->marginHeight))); |
+ return true; |
+} |
+ |
void AddToClientPropertiesIfValid( |
const std::string& name, |
mojo::Array<uint8_t> value, |