• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
31 #define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
32 #pragma once
33 
34 #include "include/internal/cef_string.h"
35 #include "include/internal/cef_string_list.h"
36 #include "include/internal/cef_types.h"
37 
38 ///
39 // Template class that provides common functionality for CEF structure wrapping.
40 ///
41 template <class traits>
42 class CefStructBase : public traits::struct_type {
43  public:
44   typedef typename traits::struct_type struct_type;
45 
CefStructBase()46   CefStructBase() : attached_to_(NULL) { Init(); }
~CefStructBase()47   virtual ~CefStructBase() {
48     // Only clear this object's data if it isn't currently attached to a
49     // structure.
50     if (!attached_to_)
51       Clear(this);
52   }
53 
CefStructBase(const CefStructBase & r)54   CefStructBase(const CefStructBase& r) {
55     Init();
56     *this = r;
57   }
CefStructBase(const struct_type & r)58   CefStructBase(const struct_type& r) {
59     Init();
60     *this = r;
61   }
62 
63   ///
64   // Clear this object's values.
65   ///
Reset()66   void Reset() {
67     Clear(this);
68     Init();
69   }
70 
71   ///
72   // Attach to the source structure's existing values. DetachTo() can be called
73   // to insert the values back into the existing structure.
74   ///
AttachTo(struct_type & source)75   void AttachTo(struct_type& source) {
76     // Only clear this object's data if it isn't currently attached to a
77     // structure.
78     if (!attached_to_)
79       Clear(this);
80 
81     // This object is now attached to the new structure.
82     attached_to_ = &source;
83 
84     // Transfer ownership of the values from the source structure.
85     memcpy(static_cast<struct_type*>(this), &source, sizeof(struct_type));
86   }
87 
88   ///
89   // Relinquish ownership of values to the target structure.
90   ///
DetachTo(struct_type & target)91   void DetachTo(struct_type& target) {
92     if (attached_to_ != &target) {
93       // Clear the target structure's values only if we are not currently
94       // attached to that structure.
95       Clear(&target);
96     }
97 
98     // Transfer ownership of the values to the target structure.
99     memcpy(&target, static_cast<struct_type*>(this), sizeof(struct_type));
100 
101     // Remove the references from this object.
102     Init();
103   }
104 
105   ///
106   // Set this object's values. If |copy| is true the source structure's values
107   // will be copied instead of referenced.
108   ///
Set(const struct_type & source,bool copy)109   void Set(const struct_type& source, bool copy) {
110     traits::set(&source, this, copy);
111   }
112 
113   CefStructBase& operator=(const CefStructBase& s) {
114     return operator=(static_cast<const struct_type&>(s));
115   }
116 
117   CefStructBase& operator=(const struct_type& s) {
118     Set(s, true);
119     return *this;
120   }
121 
122  protected:
Init()123   void Init() {
124     memset(static_cast<struct_type*>(this), 0, sizeof(struct_type));
125     attached_to_ = NULL;
126     traits::init(this);
127   }
128 
Clear(struct_type * s)129   static void Clear(struct_type* s) { traits::clear(s); }
130 
131   struct_type* attached_to_;
132 };
133 
134 struct CefPointTraits {
135   typedef cef_point_t struct_type;
136 
initCefPointTraits137   static inline void init(struct_type* s) {}
clearCefPointTraits138   static inline void clear(struct_type* s) {}
139 
setCefPointTraits140   static inline void set(const struct_type* src,
141                          struct_type* target,
142                          bool copy) {
143     *target = *src;
144   }
145 };
146 
147 ///
148 // Class representing a point.
149 ///
150 class CefPoint : public CefStructBase<CefPointTraits> {
151  public:
152   typedef CefStructBase<CefPointTraits> parent;
153 
CefPoint()154   CefPoint() {}
CefPoint(const cef_point_t & r)155   CefPoint(const cef_point_t& r) : parent(r) {}
CefPoint(int x,int y)156   CefPoint(int x, int y) { Set(x, y); }
157 
IsEmpty()158   bool IsEmpty() const { return x <= 0 && y <= 0; }
Set(int x_val,int y_val)159   void Set(int x_val, int y_val) { x = x_val, y = y_val; }
160 };
161 
162 inline bool operator==(const CefPoint& a, const CefPoint& b) {
163   return a.x == b.x && a.y == b.y;
164 }
165 
166 inline bool operator!=(const CefPoint& a, const CefPoint& b) {
167   return !(a == b);
168 }
169 
170 struct CefRectTraits {
171   typedef cef_rect_t struct_type;
172 
initCefRectTraits173   static inline void init(struct_type* s) {}
clearCefRectTraits174   static inline void clear(struct_type* s) {}
175 
setCefRectTraits176   static inline void set(const struct_type* src,
177                          struct_type* target,
178                          bool copy) {
179     *target = *src;
180   }
181 };
182 
183 ///
184 // Class representing a rectangle.
185 ///
186 class CefRect : public CefStructBase<CefRectTraits> {
187  public:
188   typedef CefStructBase<CefRectTraits> parent;
189 
CefRect()190   CefRect() {}
CefRect(const cef_rect_t & r)191   CefRect(const cef_rect_t& r) : parent(r) {}
CefRect(int x,int y,int width,int height)192   CefRect(int x, int y, int width, int height) { Set(x, y, width, height); }
193 
IsEmpty()194   bool IsEmpty() const { return width <= 0 || height <= 0; }
Set(int x_val,int y_val,int width_val,int height_val)195   void Set(int x_val, int y_val, int width_val, int height_val) {
196     x = x_val, y = y_val, width = width_val, height = height_val;
197   }
198 
199   // Returns true if the point identified by point_x and point_y falls inside
200   // this rectangle.  The point (x, y) is inside the rectangle, but the
201   // point (x + width, y + height) is not.
Contains(int point_x,int point_y)202   bool Contains(int point_x, int point_y) const {
203     return (point_x >= x) && (point_x < x + width) && (point_y >= y) &&
204            (point_y < y + height);
205   }
Contains(const CefPoint & point)206   bool Contains(const CefPoint& point) const {
207     return Contains(point.x, point.y);
208   }
209 };
210 
211 inline bool operator==(const CefRect& a, const CefRect& b) {
212   return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
213 }
214 
215 inline bool operator!=(const CefRect& a, const CefRect& b) {
216   return !(a == b);
217 }
218 
219 struct CefSizeTraits {
220   typedef cef_size_t struct_type;
221 
initCefSizeTraits222   static inline void init(struct_type* s) {}
clearCefSizeTraits223   static inline void clear(struct_type* s) {}
224 
setCefSizeTraits225   static inline void set(const struct_type* src,
226                          struct_type* target,
227                          bool copy) {
228     *target = *src;
229   }
230 };
231 
232 ///
233 // Class representing a size.
234 ///
235 class CefSize : public CefStructBase<CefSizeTraits> {
236  public:
237   typedef CefStructBase<CefSizeTraits> parent;
238 
CefSize()239   CefSize() {}
CefSize(const cef_size_t & r)240   CefSize(const cef_size_t& r) : parent(r) {}
CefSize(int width,int height)241   CefSize(int width, int height) { Set(width, height); }
242 
IsEmpty()243   bool IsEmpty() const { return width <= 0 || height <= 0; }
Set(int width_val,int height_val)244   void Set(int width_val, int height_val) {
245     width = width_val, height = height_val;
246   }
247 };
248 
249 inline bool operator==(const CefSize& a, const CefSize& b) {
250   return a.width == b.width && a.height == b.height;
251 }
252 
253 inline bool operator!=(const CefSize& a, const CefSize& b) {
254   return !(a == b);
255 }
256 
257 struct CefRangeTraits {
258   typedef cef_range_t struct_type;
259 
initCefRangeTraits260   static inline void init(struct_type* s) {}
clearCefRangeTraits261   static inline void clear(struct_type* s) {}
262 
setCefRangeTraits263   static inline void set(const struct_type* src,
264                          struct_type* target,
265                          bool copy) {
266     *target = *src;
267   }
268 };
269 
270 ///
271 // Class representing a range.
272 ///
273 class CefRange : public CefStructBase<CefRangeTraits> {
274  public:
275   typedef CefStructBase<CefRangeTraits> parent;
276 
CefRange()277   CefRange() {}
CefRange(const cef_range_t & r)278   CefRange(const cef_range_t& r) : parent(r) {}
CefRange(int from,int to)279   CefRange(int from, int to) { Set(from, to); }
280 
Set(int from_val,int to_val)281   void Set(int from_val, int to_val) { from = from_val, to = to_val; }
282 };
283 
284 inline bool operator==(const CefRange& a, const CefRange& b) {
285   return a.from == b.from && a.to == b.to;
286 }
287 
288 inline bool operator!=(const CefRange& a, const CefRange& b) {
289   return !(a == b);
290 }
291 
292 struct CefInsetsTraits {
293   typedef cef_insets_t struct_type;
294 
initCefInsetsTraits295   static inline void init(struct_type* s) {}
clearCefInsetsTraits296   static inline void clear(struct_type* s) {}
297 
setCefInsetsTraits298   static inline void set(const struct_type* src,
299                          struct_type* target,
300                          bool copy) {
301     *target = *src;
302   }
303 };
304 
305 ///
306 // Class representing insets.
307 ///
308 class CefInsets : public CefStructBase<CefInsetsTraits> {
309  public:
310   typedef CefStructBase<CefInsetsTraits> parent;
311 
CefInsets()312   CefInsets() {}
CefInsets(const cef_insets_t & r)313   CefInsets(const cef_insets_t& r) : parent(r) {}
CefInsets(int top,int left,int bottom,int right)314   CefInsets(int top, int left, int bottom, int right) {
315     Set(top, left, bottom, right);
316   }
317 
Set(int top_val,int left_val,int bottom_val,int right_val)318   void Set(int top_val, int left_val, int bottom_val, int right_val) {
319     top = top_val, left = left_val, bottom = bottom_val, right = right_val;
320   }
321 };
322 
323 inline bool operator==(const CefInsets& a, const CefInsets& b) {
324   return a.top == b.top && a.left == b.left && a.bottom == b.bottom &&
325          a.right == b.right;
326 }
327 
328 inline bool operator!=(const CefInsets& a, const CefInsets& b) {
329   return !(a == b);
330 }
331 
332 struct CefDraggableRegionTraits {
333   typedef cef_draggable_region_t struct_type;
334 
initCefDraggableRegionTraits335   static inline void init(struct_type* s) {}
clearCefDraggableRegionTraits336   static inline void clear(struct_type* s) {}
337 
setCefDraggableRegionTraits338   static inline void set(const struct_type* src,
339                          struct_type* target,
340                          bool copy) {
341     *target = *src;
342   }
343 };
344 
345 ///
346 // Class representing a draggable region.
347 ///
348 class CefDraggableRegion : public CefStructBase<CefDraggableRegionTraits> {
349  public:
350   typedef CefStructBase<CefDraggableRegionTraits> parent;
351 
CefDraggableRegion()352   CefDraggableRegion() {}
CefDraggableRegion(const cef_draggable_region_t & r)353   CefDraggableRegion(const cef_draggable_region_t& r) : parent(r) {}
CefDraggableRegion(const CefRect & bounds,bool draggable)354   CefDraggableRegion(const CefRect& bounds, bool draggable) {
355     Set(bounds, draggable);
356   }
357 
Set(const CefRect & bounds_val,bool draggable_val)358   void Set(const CefRect& bounds_val, bool draggable_val) {
359     bounds = bounds_val, draggable = draggable_val;
360   }
361 };
362 
363 inline bool operator==(const CefDraggableRegion& a,
364                        const CefDraggableRegion& b) {
365   return a.bounds == b.bounds && a.draggable == b.draggable;
366 }
367 
368 inline bool operator!=(const CefDraggableRegion& a,
369                        const CefDraggableRegion& b) {
370   return !(a == b);
371 }
372 
373 struct CefScreenInfoTraits {
374   typedef cef_screen_info_t struct_type;
375 
initCefScreenInfoTraits376   static inline void init(struct_type* s) {}
377 
clearCefScreenInfoTraits378   static inline void clear(struct_type* s) {}
379 
setCefScreenInfoTraits380   static inline void set(const struct_type* src,
381                          struct_type* target,
382                          bool copy) {
383     target->device_scale_factor = src->device_scale_factor;
384     target->depth = src->depth;
385     target->depth_per_component = src->depth_per_component;
386     target->is_monochrome = src->is_monochrome;
387     target->rect = src->rect;
388     target->available_rect = src->available_rect;
389   }
390 };
391 
392 ///
393 // Class representing the virtual screen information for use when window
394 // rendering is disabled.
395 ///
396 class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
397  public:
398   typedef CefStructBase<CefScreenInfoTraits> parent;
399 
CefScreenInfo()400   CefScreenInfo() {}
CefScreenInfo(const cef_screen_info_t & r)401   CefScreenInfo(const cef_screen_info_t& r) : parent(r) {}
CefScreenInfo(float device_scale_factor,int depth,int depth_per_component,bool is_monochrome,const CefRect & rect,const CefRect & available_rect)402   CefScreenInfo(float device_scale_factor,
403                 int depth,
404                 int depth_per_component,
405                 bool is_monochrome,
406                 const CefRect& rect,
407                 const CefRect& available_rect) {
408     Set(device_scale_factor, depth, depth_per_component, is_monochrome, rect,
409         available_rect);
410   }
411 
Set(float device_scale_factor_val,int depth_val,int depth_per_component_val,bool is_monochrome_val,const CefRect & rect_val,const CefRect & available_rect_val)412   void Set(float device_scale_factor_val,
413            int depth_val,
414            int depth_per_component_val,
415            bool is_monochrome_val,
416            const CefRect& rect_val,
417            const CefRect& available_rect_val) {
418     device_scale_factor = device_scale_factor_val;
419     depth = depth_val;
420     depth_per_component = depth_per_component_val;
421     is_monochrome = is_monochrome_val;
422     rect = rect_val;
423     available_rect = available_rect_val;
424   }
425 };
426 
427 struct CefKeyEventTraits {
428   typedef cef_key_event_t struct_type;
429 
initCefKeyEventTraits430   static inline void init(struct_type* s) {}
431 
clearCefKeyEventTraits432   static inline void clear(struct_type* s) {}
433 
setCefKeyEventTraits434   static inline void set(const struct_type* src,
435                          struct_type* target,
436                          bool copy) {
437     target->type = src->type;
438     target->modifiers = src->modifiers;
439     target->windows_key_code = src->windows_key_code;
440     target->native_key_code = src->native_key_code;
441     target->is_system_key = src->is_system_key;
442     target->character = src->character;
443     target->unmodified_character = src->unmodified_character;
444     target->focus_on_editable_field = src->focus_on_editable_field;
445   }
446 };
447 
448 ///
449 // Class representing a a keyboard event.
450 ///
451 typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
452 
453 struct CefMouseEventTraits {
454   typedef cef_mouse_event_t struct_type;
455 
initCefMouseEventTraits456   static inline void init(struct_type* s) {}
457 
clearCefMouseEventTraits458   static inline void clear(struct_type* s) {}
459 
setCefMouseEventTraits460   static inline void set(const struct_type* src,
461                          struct_type* target,
462                          bool copy) {
463     target->x = src->x;
464     target->y = src->y;
465     target->modifiers = src->modifiers;
466   }
467 };
468 
469 ///
470 // Class representing a mouse event.
471 ///
472 typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
473 
474 struct CefTouchEventTraits {
475   typedef cef_touch_event_t struct_type;
476 
initCefTouchEventTraits477   static inline void init(struct_type* s) {}
478 
clearCefTouchEventTraits479   static inline void clear(struct_type* s) {}
480 
setCefTouchEventTraits481   static inline void set(const struct_type* src,
482                          struct_type* target,
483                          bool copy) {
484     *target = *src;
485   }
486 };
487 
488 ///
489 // Class representing a touch event.
490 ///
491 typedef CefStructBase<CefTouchEventTraits> CefTouchEvent;
492 
493 struct CefPopupFeaturesTraits {
494   typedef cef_popup_features_t struct_type;
495 
initCefPopupFeaturesTraits496   static inline void init(struct_type* s) {
497     s->menuBarVisible = true;
498     s->statusBarVisible = true;
499     s->toolBarVisible = true;
500     s->scrollbarsVisible = true;
501   }
502 
clearCefPopupFeaturesTraits503   static inline void clear(struct_type* s) {}
504 
setCefPopupFeaturesTraits505   static inline void set(const struct_type* src,
506                          struct_type* target,
507                          bool copy) {
508     target->x = src->x;
509     target->xSet = src->xSet;
510     target->y = src->y;
511     target->ySet = src->ySet;
512     target->width = src->width;
513     target->widthSet = src->widthSet;
514     target->height = src->height;
515     target->heightSet = src->heightSet;
516     target->menuBarVisible = src->menuBarVisible;
517     target->statusBarVisible = src->statusBarVisible;
518     target->toolBarVisible = src->toolBarVisible;
519     target->scrollbarsVisible = src->scrollbarsVisible;
520   }
521 };
522 
523 ///
524 // Class representing popup window features.
525 ///
526 typedef CefStructBase<CefPopupFeaturesTraits> CefPopupFeatures;
527 
528 struct CefSettingsTraits {
529   typedef cef_settings_t struct_type;
530 
initCefSettingsTraits531   static inline void init(struct_type* s) { s->size = sizeof(struct_type); }
532 
clearCefSettingsTraits533   static inline void clear(struct_type* s) {
534     cef_string_clear(&s->browser_subprocess_path);
535     cef_string_clear(&s->framework_dir_path);
536     cef_string_clear(&s->main_bundle_path);
537     cef_string_clear(&s->cache_path);
538     cef_string_clear(&s->root_cache_path);
539     cef_string_clear(&s->user_data_path);
540     cef_string_clear(&s->user_agent);
541     cef_string_clear(&s->user_agent_product);
542     cef_string_clear(&s->locale);
543     cef_string_clear(&s->log_file);
544     cef_string_clear(&s->javascript_flags);
545     cef_string_clear(&s->resources_dir_path);
546     cef_string_clear(&s->locales_dir_path);
547     cef_string_clear(&s->accept_language_list);
548     cef_string_clear(&s->cookieable_schemes_list);
549     cef_string_clear(&s->application_client_id_for_file_scanning);
550   }
551 
setCefSettingsTraits552   static inline void set(const struct_type* src,
553                          struct_type* target,
554                          bool copy) {
555     target->no_sandbox = src->no_sandbox;
556     cef_string_set(src->browser_subprocess_path.str,
557                    src->browser_subprocess_path.length,
558                    &target->browser_subprocess_path, copy);
559     cef_string_set(src->framework_dir_path.str, src->framework_dir_path.length,
560                    &target->framework_dir_path, copy);
561     cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
562                    &target->main_bundle_path, copy);
563     target->chrome_runtime = src->chrome_runtime;
564     target->multi_threaded_message_loop = src->multi_threaded_message_loop;
565     target->external_message_pump = src->external_message_pump;
566     target->windowless_rendering_enabled = src->windowless_rendering_enabled;
567     target->command_line_args_disabled = src->command_line_args_disabled;
568 
569     cef_string_set(src->cache_path.str, src->cache_path.length,
570                    &target->cache_path, copy);
571     cef_string_set(src->root_cache_path.str, src->root_cache_path.length,
572                    &target->root_cache_path, copy);
573     cef_string_set(src->user_data_path.str, src->user_data_path.length,
574                    &target->user_data_path, copy);
575     target->persist_session_cookies = src->persist_session_cookies;
576     target->persist_user_preferences = src->persist_user_preferences;
577 
578     cef_string_set(src->user_agent.str, src->user_agent.length,
579                    &target->user_agent, copy);
580     cef_string_set(src->user_agent_product.str, src->user_agent_product.length,
581                    &target->user_agent_product, copy);
582     cef_string_set(src->locale.str, src->locale.length, &target->locale, copy);
583 
584     cef_string_set(src->log_file.str, src->log_file.length, &target->log_file,
585                    copy);
586     target->log_severity = src->log_severity;
587     cef_string_set(src->javascript_flags.str, src->javascript_flags.length,
588                    &target->javascript_flags, copy);
589 
590     cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length,
591                    &target->resources_dir_path, copy);
592     cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
593                    &target->locales_dir_path, copy);
594     target->pack_loading_disabled = src->pack_loading_disabled;
595     target->remote_debugging_port = src->remote_debugging_port;
596     target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
597     target->ignore_certificate_errors = src->ignore_certificate_errors;
598     target->background_color = src->background_color;
599 
600     cef_string_set(src->accept_language_list.str,
601                    src->accept_language_list.length,
602                    &target->accept_language_list, copy);
603 
604     cef_string_set(src->cookieable_schemes_list.str,
605                    src->cookieable_schemes_list.length,
606                    &target->cookieable_schemes_list, copy);
607     target->cookieable_schemes_exclude_defaults =
608         src->cookieable_schemes_exclude_defaults;
609 
610     cef_string_set(src->application_client_id_for_file_scanning.str,
611                    src->application_client_id_for_file_scanning.length,
612                    &target->application_client_id_for_file_scanning, copy);
613   }
614 };
615 
616 ///
617 // Class representing initialization settings.
618 ///
619 typedef CefStructBase<CefSettingsTraits> CefSettings;
620 
621 struct CefRequestContextSettingsTraits {
622   typedef cef_request_context_settings_t struct_type;
623 
initCefRequestContextSettingsTraits624   static inline void init(struct_type* s) { s->size = sizeof(struct_type); }
625 
clearCefRequestContextSettingsTraits626   static inline void clear(struct_type* s) {
627     cef_string_clear(&s->cache_path);
628     cef_string_clear(&s->accept_language_list);
629     cef_string_clear(&s->cookieable_schemes_list);
630   }
631 
setCefRequestContextSettingsTraits632   static inline void set(const struct_type* src,
633                          struct_type* target,
634                          bool copy) {
635     cef_string_set(src->cache_path.str, src->cache_path.length,
636                    &target->cache_path, copy);
637     target->persist_session_cookies = src->persist_session_cookies;
638     target->persist_user_preferences = src->persist_user_preferences;
639     target->ignore_certificate_errors = src->ignore_certificate_errors;
640     cef_string_set(src->accept_language_list.str,
641                    src->accept_language_list.length,
642                    &target->accept_language_list, copy);
643 
644     cef_string_set(src->cookieable_schemes_list.str,
645                    src->cookieable_schemes_list.length,
646                    &target->cookieable_schemes_list, copy);
647     target->cookieable_schemes_exclude_defaults =
648         src->cookieable_schemes_exclude_defaults;
649   }
650 };
651 
652 ///
653 // Class representing request context initialization settings.
654 ///
655 typedef CefStructBase<CefRequestContextSettingsTraits>
656     CefRequestContextSettings;
657 
658 struct CefBrowserSettingsTraits {
659   typedef cef_browser_settings_t struct_type;
660 
initCefBrowserSettingsTraits661   static inline void init(struct_type* s) { s->size = sizeof(struct_type); }
662 
clearCefBrowserSettingsTraits663   static inline void clear(struct_type* s) {
664     cef_string_clear(&s->standard_font_family);
665     cef_string_clear(&s->fixed_font_family);
666     cef_string_clear(&s->serif_font_family);
667     cef_string_clear(&s->sans_serif_font_family);
668     cef_string_clear(&s->cursive_font_family);
669     cef_string_clear(&s->fantasy_font_family);
670     cef_string_clear(&s->default_encoding);
671     cef_string_clear(&s->accept_language_list);
672   }
673 
setCefBrowserSettingsTraits674   static inline void set(const struct_type* src,
675                          struct_type* target,
676                          bool copy) {
677     target->windowless_frame_rate = src->windowless_frame_rate;
678 
679     cef_string_set(src->standard_font_family.str,
680                    src->standard_font_family.length,
681                    &target->standard_font_family, copy);
682     cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length,
683                    &target->fixed_font_family, copy);
684     cef_string_set(src->serif_font_family.str, src->serif_font_family.length,
685                    &target->serif_font_family, copy);
686     cef_string_set(src->sans_serif_font_family.str,
687                    src->sans_serif_font_family.length,
688                    &target->sans_serif_font_family, copy);
689     cef_string_set(src->cursive_font_family.str,
690                    src->cursive_font_family.length,
691                    &target->cursive_font_family, copy);
692     cef_string_set(src->fantasy_font_family.str,
693                    src->fantasy_font_family.length,
694                    &target->fantasy_font_family, copy);
695 
696     target->default_font_size = src->default_font_size;
697     target->default_fixed_font_size = src->default_fixed_font_size;
698     target->minimum_font_size = src->minimum_font_size;
699     target->minimum_logical_font_size = src->minimum_logical_font_size;
700 
701     cef_string_set(src->default_encoding.str, src->default_encoding.length,
702                    &target->default_encoding, copy);
703 
704     target->remote_fonts = src->remote_fonts;
705     target->javascript = src->javascript;
706     target->javascript_close_windows = src->javascript_close_windows;
707     target->javascript_access_clipboard = src->javascript_access_clipboard;
708     target->javascript_dom_paste = src->javascript_dom_paste;
709     target->plugins = src->plugins;
710     target->universal_access_from_file_urls =
711         src->universal_access_from_file_urls;
712     target->file_access_from_file_urls = src->file_access_from_file_urls;
713     target->image_loading = src->image_loading;
714     target->image_shrink_standalone_to_fit =
715         src->image_shrink_standalone_to_fit;
716     target->text_area_resize = src->text_area_resize;
717     target->tab_to_links = src->tab_to_links;
718     target->local_storage = src->local_storage;
719     target->databases = src->databases;
720     target->application_cache = src->application_cache;
721     target->webgl = src->webgl;
722 
723     target->background_color = src->background_color;
724 
725     cef_string_set(src->accept_language_list.str,
726                    src->accept_language_list.length,
727                    &target->accept_language_list, copy);
728   }
729 };
730 
731 ///
732 // Class representing browser initialization settings.
733 ///
734 typedef CefStructBase<CefBrowserSettingsTraits> CefBrowserSettings;
735 
736 struct CefURLPartsTraits {
737   typedef cef_urlparts_t struct_type;
738 
initCefURLPartsTraits739   static inline void init(struct_type* s) {}
740 
clearCefURLPartsTraits741   static inline void clear(struct_type* s) {
742     cef_string_clear(&s->spec);
743     cef_string_clear(&s->scheme);
744     cef_string_clear(&s->username);
745     cef_string_clear(&s->password);
746     cef_string_clear(&s->host);
747     cef_string_clear(&s->port);
748     cef_string_clear(&s->origin);
749     cef_string_clear(&s->path);
750     cef_string_clear(&s->query);
751     cef_string_clear(&s->fragment);
752   }
753 
setCefURLPartsTraits754   static inline void set(const struct_type* src,
755                          struct_type* target,
756                          bool copy) {
757     cef_string_set(src->spec.str, src->spec.length, &target->spec, copy);
758     cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy);
759     cef_string_set(src->username.str, src->username.length, &target->username,
760                    copy);
761     cef_string_set(src->password.str, src->password.length, &target->password,
762                    copy);
763     cef_string_set(src->host.str, src->host.length, &target->host, copy);
764     cef_string_set(src->port.str, src->port.length, &target->port, copy);
765     cef_string_set(src->origin.str, src->origin.length, &target->origin, copy);
766     cef_string_set(src->path.str, src->path.length, &target->path, copy);
767     cef_string_set(src->query.str, src->query.length, &target->query, copy);
768     cef_string_set(src->fragment.str, src->fragment.length, &target->fragment,
769                    copy);
770   }
771 };
772 
773 ///
774 // Class representing a URL's component parts.
775 ///
776 typedef CefStructBase<CefURLPartsTraits> CefURLParts;
777 
778 struct CefTimeTraits {
779   typedef cef_time_t struct_type;
780 
initCefTimeTraits781   static inline void init(struct_type* s) {}
782 
clearCefTimeTraits783   static inline void clear(struct_type* s) {}
784 
setCefTimeTraits785   static inline void set(const struct_type* src,
786                          struct_type* target,
787                          bool copy) {
788     *target = *src;
789   }
790 };
791 
792 ///
793 // Class representing a time.
794 ///
795 class CefTime : public CefStructBase<CefTimeTraits> {
796  public:
797   typedef CefStructBase<CefTimeTraits> parent;
798 
CefTime()799   CefTime() {}
CefTime(const cef_time_t & r)800   CefTime(const cef_time_t& r) : parent(r) {}
CefTime(time_t r)801   explicit CefTime(time_t r) { SetTimeT(r); }
CefTime(double r)802   explicit CefTime(double r) { SetDoubleT(r); }
803 
804   // Converts to/from time_t.
SetTimeT(time_t r)805   void SetTimeT(time_t r) { cef_time_from_timet(r, this); }
GetTimeT()806   time_t GetTimeT() const {
807     time_t time = 0;
808     cef_time_to_timet(this, &time);
809     return time;
810   }
811 
812   // Converts to/from a double which is the number of seconds since epoch
813   // (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
814   // means "not initialized".
SetDoubleT(double r)815   void SetDoubleT(double r) { cef_time_from_doublet(r, this); }
GetDoubleT()816   double GetDoubleT() const {
817     double time = 0;
818     cef_time_to_doublet(this, &time);
819     return time;
820   }
821 
822   // Set this object to now.
Now()823   void Now() { cef_time_now(this); }
824 
825   // Return the delta between this object and |other| in milliseconds.
Delta(const CefTime & other)826   long long Delta(const CefTime& other) {
827     long long delta = 0;
828     cef_time_delta(this, &other, &delta);
829     return delta;
830   }
831 };
832 
833 struct CefCookieTraits {
834   typedef cef_cookie_t struct_type;
835 
initCefCookieTraits836   static inline void init(struct_type* s) {}
837 
clearCefCookieTraits838   static inline void clear(struct_type* s) {
839     cef_string_clear(&s->name);
840     cef_string_clear(&s->value);
841     cef_string_clear(&s->domain);
842     cef_string_clear(&s->path);
843   }
844 
setCefCookieTraits845   static inline void set(const struct_type* src,
846                          struct_type* target,
847                          bool copy) {
848     cef_string_set(src->name.str, src->name.length, &target->name, copy);
849     cef_string_set(src->value.str, src->value.length, &target->value, copy);
850     cef_string_set(src->domain.str, src->domain.length, &target->domain, copy);
851     cef_string_set(src->path.str, src->path.length, &target->path, copy);
852     target->secure = src->secure;
853     target->httponly = src->httponly;
854     target->creation = src->creation;
855     target->last_access = src->last_access;
856     target->has_expires = src->has_expires;
857     target->expires = src->expires;
858     target->same_site = src->same_site;
859     target->priority = src->priority;
860   }
861 };
862 
863 ///
864 // Class representing a cookie.
865 ///
866 typedef CefStructBase<CefCookieTraits> CefCookie;
867 
868 struct CefCursorInfoTraits {
869   typedef cef_cursor_info_t struct_type;
870 
initCefCursorInfoTraits871   static inline void init(struct_type* s) {}
872 
clearCefCursorInfoTraits873   static inline void clear(struct_type* s) {}
874 
setCefCursorInfoTraits875   static inline void set(const struct_type* src,
876                          struct_type* target,
877                          bool copy) {
878     *target = *src;
879   }
880 };
881 
882 ///
883 // Class representing cursor information.
884 ///
885 typedef CefStructBase<CefCursorInfoTraits> CefCursorInfo;
886 
887 struct CefPdfPrintSettingsTraits {
888   typedef cef_pdf_print_settings_t struct_type;
889 
initCefPdfPrintSettingsTraits890   static inline void init(struct_type* s) {}
891 
clearCefPdfPrintSettingsTraits892   static inline void clear(struct_type* s) {
893     cef_string_clear(&s->header_footer_title);
894     cef_string_clear(&s->header_footer_url);
895   }
896 
setCefPdfPrintSettingsTraits897   static inline void set(const struct_type* src,
898                          struct_type* target,
899                          bool copy) {
900     cef_string_set(src->header_footer_title.str,
901                    src->header_footer_title.length,
902                    &target->header_footer_title, copy);
903     cef_string_set(src->header_footer_url.str, src->header_footer_url.length,
904                    &target->header_footer_url, copy);
905 
906     target->page_width = src->page_width;
907     target->page_height = src->page_height;
908 
909     target->scale_factor = src->scale_factor;
910 
911     target->margin_top = src->margin_top;
912     target->margin_right = src->margin_right;
913     target->margin_bottom = src->margin_bottom;
914     target->margin_left = src->margin_left;
915     target->margin_type = src->margin_type;
916 
917     target->header_footer_enabled = src->header_footer_enabled;
918     target->selection_only = src->selection_only;
919     target->landscape = src->landscape;
920     target->backgrounds_enabled = src->backgrounds_enabled;
921   }
922 };
923 
924 ///
925 // Class representing PDF print settings
926 ///
927 typedef CefStructBase<CefPdfPrintSettingsTraits> CefPdfPrintSettings;
928 
929 struct CefBoxLayoutSettingsTraits {
930   typedef cef_box_layout_settings_t struct_type;
931 
initCefBoxLayoutSettingsTraits932   static inline void init(struct_type* s) {}
933 
clearCefBoxLayoutSettingsTraits934   static inline void clear(struct_type* s) {}
935 
setCefBoxLayoutSettingsTraits936   static inline void set(const struct_type* src,
937                          struct_type* target,
938                          bool copy) {
939     *target = *src;
940   }
941 };
942 
943 ///
944 // Class representing CefBoxLayout settings.
945 ///
946 typedef CefStructBase<CefBoxLayoutSettingsTraits> CefBoxLayoutSettings;
947 
948 struct CefCompositionUnderlineTraits {
949   typedef cef_composition_underline_t struct_type;
950 
initCefCompositionUnderlineTraits951   static inline void init(struct_type* s) {}
952 
clearCefCompositionUnderlineTraits953   static inline void clear(struct_type* s) {}
954 
setCefCompositionUnderlineTraits955   static inline void set(const struct_type* src,
956                          struct_type* target,
957                          bool copy) {
958     *target = *src;
959   }
960 };
961 
962 ///
963 // Class representing IME composition underline.
964 ///
965 typedef CefStructBase<CefCompositionUnderlineTraits> CefCompositionUnderline;
966 
967 struct CefAudioParametersTraits {
968   typedef cef_audio_parameters_t struct_type;
969 
initCefAudioParametersTraits970   static inline void init(struct_type* s) {}
971 
clearCefAudioParametersTraits972   static inline void clear(struct_type* s) {}
973 
setCefAudioParametersTraits974   static inline void set(const struct_type* src,
975                          struct_type* target,
976                          bool copy) {
977     *target = *src;
978   }
979 };
980 
981 ///
982 // Class representing CefAudioParameters settings
983 ///
984 typedef CefStructBase<CefAudioParametersTraits> CefAudioParameters;
985 
986 struct CefMediaSinkDeviceInfoTraits {
987   typedef cef_media_sink_device_info_t struct_type;
988 
initCefMediaSinkDeviceInfoTraits989   static inline void init(struct_type* s) {}
990 
clearCefMediaSinkDeviceInfoTraits991   static inline void clear(struct_type* s) {
992     cef_string_clear(&s->ip_address);
993     cef_string_clear(&s->model_name);
994   }
995 
setCefMediaSinkDeviceInfoTraits996   static inline void set(const struct_type* src,
997                          struct_type* target,
998                          bool copy) {
999     cef_string_set(src->ip_address.str, src->ip_address.length,
1000                    &target->ip_address, copy);
1001     target->port = src->port;
1002     cef_string_set(src->model_name.str, src->model_name.length,
1003                    &target->model_name, copy);
1004   }
1005 };
1006 
1007 ///
1008 // Class representing MediaSink device info.
1009 ///
1010 typedef CefStructBase<CefMediaSinkDeviceInfoTraits> CefMediaSinkDeviceInfo;
1011 
1012 #endif  // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
1013