• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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->x = src->x;
85     target->y = src->y;
86     target->width = src->width;
87     target->height = src->height;
88     target->hidden = src->hidden;
89     target->parent_view = src->parent_view;
90     target->windowless_rendering_enabled = src->windowless_rendering_enabled;
91     target->shared_texture_enabled = src->shared_texture_enabled;
92     target->external_begin_frame_enabled = src->external_begin_frame_enabled;
93     target->view = src->view;
94   }
95 };
96 
97 // Class representing window information.
98 class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
99  public:
100   typedef CefStructBase<CefWindowInfoTraits> parent;
101 
CefWindowInfo()102   CefWindowInfo() : parent() {}
CefWindowInfo(const cef_window_info_t & r)103   explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
CefWindowInfo(const CefWindowInfo & r)104   explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
105 
106   ///
107   // Create the browser as a child view.
108   ///
SetAsChild(CefWindowHandle parent,int x,int y,int width,int height)109   void SetAsChild(CefWindowHandle parent, int x, int y, int width, int height) {
110     parent_view = parent;
111     this->x = x;
112     this->y = y;
113     this->width = width;
114     this->height = height;
115     hidden = false;
116   }
117 
118   ///
119   // Create the browser using windowless (off-screen) rendering. No view
120   // will be created for the browser and all rendering will occur via the
121   // CefRenderHandler interface. The |parent| value will be used to identify
122   // monitor info and to act as the parent view for dialogs, context menus,
123   // etc. If |parent| is not provided then the main screen monitor will be used
124   // and some functionality that requires a parent view may not function
125   // correctly. In order to create windowless browsers the
126   // CefSettings.windowless_rendering_enabled value must be set to true.
127   // Transparent painting is enabled by default but can be disabled by setting
128   // CefBrowserSettings.background_color to an opaque value.
129   ///
SetAsWindowless(CefWindowHandle parent)130   void SetAsWindowless(CefWindowHandle parent) {
131     windowless_rendering_enabled = true;
132     parent_view = parent;
133   }
134 };
135 
136 #endif  // CEF_INCLUDE_INTERNAL_CEF_MAC_H_
137