1 // Copyright (c) 2010 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_MAC_H_ 31 #define CEF_INCLUDE_INTERNAL_CEF_MAC_H_ 32 #pragma once 33 34 #include "include/internal/cef_types_mac.h" 35 #include "include/internal/cef_types_wrappers.h" 36 37 // Handle types. 38 #define CefCursorHandle cef_cursor_handle_t 39 #define CefEventHandle cef_event_handle_t 40 #define CefWindowHandle cef_window_handle_t 41 42 struct CefMainArgsTraits { 43 typedef cef_main_args_t struct_type; 44 initCefMainArgsTraits45 static inline void init(struct_type* s) {} clearCefMainArgsTraits46 static inline void clear(struct_type* s) {} 47 setCefMainArgsTraits48 static inline void set(const struct_type* src, 49 struct_type* target, 50 bool copy) { 51 target->argc = src->argc; 52 target->argv = src->argv; 53 } 54 }; 55 56 // Class representing CefExecuteProcess arguments. 57 class CefMainArgs : public CefStructBase<CefMainArgsTraits> { 58 public: 59 typedef CefStructBase<CefMainArgsTraits> parent; 60 CefMainArgs()61 CefMainArgs() : parent() {} CefMainArgs(const cef_main_args_t & r)62 explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {} CefMainArgs(const CefMainArgs & r)63 explicit CefMainArgs(const CefMainArgs& r) : parent(r) {} CefMainArgs(int argc,char ** argv)64 CefMainArgs(int argc, char** argv) : parent() { 65 this->argc = argc; 66 this->argv = argv; 67 } 68 }; 69 70 struct CefWindowInfoTraits { 71 typedef cef_window_info_t struct_type; 72 initCefWindowInfoTraits73 static inline void init(struct_type* s) {} 74 clearCefWindowInfoTraits75 static inline void clear(struct_type* s) { 76 cef_string_clear(&s->window_name); 77 } 78 setCefWindowInfoTraits79 static inline void set(const struct_type* src, 80 struct_type* target, 81 bool copy) { 82 cef_string_set(src->window_name.str, src->window_name.length, 83 &target->window_name, copy); 84 target->bounds = src->bounds; 85 target->hidden = src->hidden; 86 target->parent_view = src->parent_view; 87 target->windowless_rendering_enabled = src->windowless_rendering_enabled; 88 target->shared_texture_enabled = src->shared_texture_enabled; 89 target->external_begin_frame_enabled = src->external_begin_frame_enabled; 90 target->view = src->view; 91 } 92 }; 93 94 // Class representing window information. 95 class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { 96 public: 97 typedef CefStructBase<CefWindowInfoTraits> parent; 98 CefWindowInfo()99 CefWindowInfo() : parent() {} CefWindowInfo(const cef_window_info_t & r)100 explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} CefWindowInfo(const CefWindowInfo & r)101 explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} 102 103 /// 104 // Create the browser as a child view. 105 /// SetAsChild(CefWindowHandle parent,const CefRect & bounds)106 void SetAsChild(CefWindowHandle parent, const CefRect& bounds) { 107 parent_view = parent; 108 this->bounds = bounds; 109 hidden = false; 110 } 111 112 /// 113 // Create the browser using windowless (off-screen) rendering. No view 114 // will be created for the browser and all rendering will occur via the 115 // CefRenderHandler interface. The |parent| value will be used to identify 116 // monitor info and to act as the parent view for dialogs, context menus, 117 // etc. If |parent| is not provided then the main screen monitor will be used 118 // and some functionality that requires a parent view may not function 119 // correctly. In order to create windowless browsers the 120 // CefSettings.windowless_rendering_enabled value must be set to true. 121 // Transparent painting is enabled by default but can be disabled by setting 122 // CefBrowserSettings.background_color to an opaque value. 123 /// SetAsWindowless(CefWindowHandle parent)124 void SetAsWindowless(CefWindowHandle parent) { 125 windowless_rendering_enabled = true; 126 parent_view = parent; 127 } 128 }; 129 130 #endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_ 131