Пример #1
0
        public CefV8Value ExecFunction(NativeJsContext context, char[] argAsJsonChars)
        {
            unsafe
            {
                fixed(char *first = &argAsJsonChars[0])
                {
                    CefV8Value value = new CefV8Value(Cef3Binder.MyCefJs_ExecJsFunctionWithContext(this.Ptr, context.Ptr, first));

                    return(value);
                }
            }
        }
Пример #2
0
        public void SetSize(int w, int h)
        {
            JsValue a0 = new JsValue();

            a0.I32 = w;
            JsValue a1 = new JsValue();

            a1.I32 = h;
            JsValue ret;

            Cef3Binder.MyCefBwCall2(_myCefBw.ptr, (int)CefBwCallMsg.CefBw_SetSize, out ret, ref a0, ref a1);
        }
Пример #3
0
        public static void CopyStdStringList(IntPtr stdStringList, System.Collections.Generic.List <string> outputList)
        {
            int listCount;

            Cef3Binder.GetListCount(2, stdStringList, out listCount);
            for (int i = 0; i < listCount; ++i)
            {
                JsValue value = new JsValue();
                Cef3Binder.GetListElement(2, stdStringList, i, ref value);
                outputList.Add(CopyStringAndDestroyNativeSide(ref value));
            }
        }
Пример #4
0
        public CefV8Value ExecFunction(NativeJsContext context, string argAsJsonString)
        {
            unsafe
            {
                char[] chars = argAsJsonString.ToCharArray();
                fixed(char *first = &chars[0])
                {
                    CefV8Value value = new CefV8Value(Cef3Binder.MyCefJs_ExecJsFunctionWithContext(this.Ptr, context.Ptr, first));

                    return(value);
                }
            }
        }
Пример #5
0
 public void ShowDevTools()
 {
     if (cefDevWindow == null)
     {
         cefDevWindow = new MyCefDevWindow();
         IWindowForm devForm = Cef3Binder.CreateBlankForm(800, 600);
         devForm.Text = "Developer Tool";
         devForm.Show();
         Cef3Binder.MyCefShowDevTools(this.myCefBrowser,
                                      cefDevWindow.GetMyCefBrowser(),
                                      devForm.GetHandle());
     }
 }
Пример #6
0
        public static void CopyStdInt64ListAndDestroyNativeSide(IntPtr stdInt64List, System.Collections.Generic.List <long> outputList)
        {
            int listCount;

            Cef3Binder.GetListCount(1, stdInt64List, out listCount);
            for (int i = 0; i < listCount; ++i)
            {
                JsValue value = new JsValue();
                Cef3Binder.GetListElement(1, stdInt64List, i, ref value);
                outputList.Add(value.I64);
            }
            Cef3Binder.MyCefDeletePtr(stdInt64List);
        }
Пример #7
0
 public string GetUrl()
 {
     unsafe
     {
         char[] buffer       = new char[255];
         int    actualLength = 0;
         fixed(char *buffer_head = &buffer[0])
         {
             Cef3Binder.MyCefFrame_GetUrl(Ptr, buffer_head, 255, ref actualLength);
             return(new string(buffer_head));
         }
     }
 }
Пример #8
0
        public void PostData2(string url, byte[] data, int len)
        {
            //CefRefPtr<CefRequest> request(CefRequest::Create());
            //MyCefStringHolder* url = (MyCefStringHolder*)v1->ptr;
            //request->SetURL(url->value);
            ////Add post data to request, the correct method and content-type header will be set by CEF
            //CefRefPtr<CefPostDataElement> postDataElement(CefPostDataElement::Create());


            //char* buffer1 = new char[v2->i32];
            //memcpy_s(buffer1, v2->i32, v2->ptr, v2->i32);
            //postDataElement->SetToBytes(v2->i32, buffer1);
            ////------

            //CefRefPtr<CefPostData> postData(CefPostData::Create());
            //postData->AddElement(postDataElement);
            //request->SetPostData(postData);

            ////add custom header (for test)
            //CefRequest::HeaderMap headerMap;
            //headerMap.insert(
            //    std::make_pair("X-My-Header", "My Header Value"));
            //request->SetHeaderMap(headerMap);

            ////load request
            //myBw->bwWindow->GetBrowser()->GetMainFrame()->LoadRequest(request);

            //delete buffer1;
            JsValue a0 = new JsValue();
            JsValue a1 = new JsValue();
            JsValue ret;

            var v_url = NativeMyCefStringHolder.CreateHolder(url);

            a0.Ptr = v_url.nativePtr;
            //
            unsafe
            {
                fixed(byte *buffer = &data[0])
                {
                    a1.Ptr = new IntPtr(buffer);
                    a1.I32 = data.Length;

                    Cef3Binder.MyCefBwCall2(_myCefBw.ptr, (int)CefBwCallMsg.CefBw_PostData, out ret, ref a0, ref a1);
                }
            }


            v_url.Dispose();
        }
Пример #9
0
        public void PrintToPdf(string filename)
        {
            MyCefCallback cb = null;

            cb = new MyCefCallback((id, args) =>
            {
                //remove after finish
                var metArg = new NativeCallArgs(args);
                int isOK   = metArg.GetArgAsInt32(1);
                tmpCallbacks.Remove(cb);
            });
            tmpCallbacks.Add(cb);
            //
            Cef3Binder.MyCefPrintToPdf(_myCefBw.ptr, IntPtr.Zero, filename, cb);
        }
Пример #10
0
        public void SetOutput(int index, byte[] buffer)
        {
            //output

            unsafe
            {
                fixed(byte *b = &buffer[0])
                {
                    Cef3Binder.MyCefMetArgs_SetResultAsByteBuffer(this._argPtr,
                                                                  index,
                                                                  new IntPtr(b),
                                                                  buffer.Length);
                }
            }
        }
Пример #11
0
        public void PrintToPdf(string pdfConfig, string filename)
        {
            IntPtr        nativePdfConfig = Cef3Binder.MyCefCreatePdfPrintSetting(pdfConfig);
            MyCefCallback cb = null;

            cb = new MyCefCallback((id, args) =>
            {
                //remove after finish
                var metArg = new NativeCallArgs(args);
                int isOK   = metArg.GetArgAsInt32(1);
                tmpCallbacks.Remove(cb);
            });
            tmpCallbacks.Add(cb);
            //
            Cef3Binder.MyCefPrintToPdf(_myCefBw.ptr, nativePdfConfig, filename, cb);
        }
Пример #12
0
        public void CopyBufferToBufferHolder(int index, byte[] data)
        {
            int len = data.Length;

            unsafe
            {
                IntPtr bufferHolderPtr;
                fixed(byte *head = &data[0])
                {
                    //native side copy the managed data and store at the native side
                    bufferHolderPtr = Cef3Binder.MyCefCreateBufferHolderWithInitData(len, head);
                }

                SetAsIntPtr(this.rawNativeArgs, index, bufferHolderPtr);
            }
        }
Пример #13
0
 public void ShowDevTools()
 {
     if (devForm == null)
     {
         devForm      = Cef3Binder.CreateBlankForm(800, 600);
         devForm.Text = "Developer Tool";
         devForm.Show();
         devForm.FormClosed += DevForm_FormClosed;
     }
     if (cefDevWindow == null)
     {
         cefDevWindow = new MyCefDevWindow();
         Cef3Binder.MyCefShowDevTools(_myCefBw.ptr,
                                      cefDevWindow.GetMyCefBrowser(),
                                      devForm.GetHandle());
     }
 }
Пример #14
0
        public string ReadArgAsString(int index)
        {
            //Cef3Binder.MyCefJs_MetReadArgAsString(this.argPtr,index,)
            int acutalLen = 0;

            unsafe
            {
                int   BUFF_LEN = 256;
                char *buffHead = stackalloc char[BUFF_LEN];
                Cef3Binder.MyCefJs_MetReadArgAsString(argPtr, index, buffHead, BUFF_LEN, ref acutalLen);
                if (acutalLen > BUFF_LEN)
                {
                    //read more
                }
                return(new string(buffHead, 0, acutalLen));
            }
        }
Пример #15
0
        public string GetRequest()
        {
            //get request from native string

            int acutalLen = 0;

            unsafe
            {
                int   BUFF_LEN = 256;
                char *buffHead = stackalloc char[BUFF_LEN];
                Cef3Binder.MyCefStringHolder_Read(_requestCefStringHolder, buffHead, BUFF_LEN, ref acutalLen);
                if (acutalLen > BUFF_LEN)
                {
                    //read more
                }
                return(new string(buffHead, 0, acutalLen));
            }
        }
Пример #16
0
        public string ReadValueAsString()
        {
            const int BUFF_LEN = 512;

            char[] charBuff = new char[BUFF_LEN];
            unsafe
            {
                fixed(char *head = &charBuff[0])
                {
                    int actualLen = 0;

                    Cef3Binder.MyCefJs_CefV8Value_ReadAsString(this.Ptr, head, BUFF_LEN, ref actualLen);
                    if (actualLen > BUFF_LEN)
                    {
                        //read more
                    }
                    return(new string(charBuff, 0, actualLen));
                }
            }
        }
Пример #17
0
        unsafe static string MyCefJsReadString(JsValue *jsval)
        {
            int actualLen;
            int buffLen = jsval->I32 + 1; //string len

            //check if string is on method-call's frame stack or heap
            if (jsval->Type == JsValueType.NativeCefString)
            {
                char *rawCefString_char16_t;
                Cef3Binder.MyCefStringGetRawPtr(jsval->Ptr, out rawCefString_char16_t, out actualLen);
                return(new string(rawCefString_char16_t, 0, actualLen));
            }
            if (buffLen < 1024)
            {
                char *buffHead = stackalloc char[buffLen];
                Cef3Binder.MyCefStringHolder_Read(jsval->Ptr, buffHead, buffLen, out actualLen);
                if (actualLen > buffLen)
                {
                    //read more
                }
                return(new string(buffHead, 0, actualLen));
            }
            else
            {
                char[] buffHead = new char[buffLen];
                fixed(char *h = &buffHead[0])
                {
                    Cef3Binder.MyCefStringHolder_Read(jsval->Ptr, h, buffLen, out actualLen);
                    if (actualLen > buffLen)
                    {
                        //read more
                    }
                }

                return(new string(buffHead, 0, actualLen));
            }
        }
Пример #18
0
        public void PostData(string url, byte[] data, int len)
        {
            JsValue a0 = new JsValue();
            JsValue a1 = new JsValue();
            JsValue ret;

            var v_url = NativeMyCefStringHolder.CreateHolder(url);

            a0.Ptr = v_url.nativePtr;
            //
            unsafe
            {
                fixed(byte *buffer = &data[0])
                {
                    a1.Ptr = new IntPtr(buffer);
                    a1.I32 = data.Length;

                    Cef3Binder.MyCefBwCall2(_myCefBw.ptr, (int)CefBwCallMsg.CefBw_PostData, out ret, ref a0, ref a1);
                }
            }


            v_url.Dispose();
        }
Пример #19
0
 protected static void DoMessageLoopWork()
 {
     Cef3Binder.MyCefDoMessageLoopWork();
 }
Пример #20
0
 /// <summary>
 /// get global object
 /// </summary>
 /// <returns></returns>
 public CefV8Value GetGlobal()
 {
     return(new CefV8Value(Cef3Binder.MyCefJsGetGlobal(this.Ptr)));
 }
Пример #21
0
 public static NativeJsContext GetCurrentContext()
 {
     return(new NativeJsContext(Cef3Binder.MyCefJsGetCurrentContext()));
 }
Пример #22
0
 public void ExitContext()
 {
     Cef3Binder.MyCefJs_ExitContext(this.Ptr);
 }
Пример #23
0
 public static Cef3FuncHandler CreateFuncHandler(MyCefCallback cefCallback)
 {
     //store in cbs, prevent collected by GC
     cbs.Add(cefCallback);
     return(new Cef3FuncHandler(Cef3Binder.MyCefJs_New_V8Handler(cefCallback)));
 }
Пример #24
0
 public static NativeJsContext GetEnteredContext()
 {
     return(new NativeJsContext(Cef3Binder.MyCefJs_GetEnteredContext()));
 }
Пример #25
0
 public NativeJsContext GetFrameContext()
 {
     return(new NativeJsContext(Cef3Binder.MyCefJsFrameContext(this.Ptr)));
 }
Пример #26
0
 public void ExecJavascript(string src, string url)
 {
     Cef3Binder.MyCefBwExecJavascript2(this.Ptr, src, url);
 }
Пример #27
0
 public void Set(string key, Cef3Func cef3Func)
 {
     Cef3Binder.MyCefJs_CefV8Value_SetValue_ByString(this.Ptr, key, cef3Func.Ptr, (int)CefV8PropertyAttribute.V8_PROPERTY_ATTRIBUTE_READONLY);
 }
Пример #28
0
        public static Cef3Func CreateFunc(string name, Cef3FuncHandler funcHandler)
        {
            IntPtr func = Cef3Binder.MyCefJs_CreateFunction(name, funcHandler.Ptr);

            return(new Cef3Func(func));
        }
Пример #29
0
 public bool IsFunc()
 {
     return(Cef3Binder.MyCefJs_CefV8Value_IsFunc(this.Ptr));
 }
Пример #30
0
 public void EnterContext()
 {
     Cef3Binder.MyCefJs_EnterContext(this.Ptr);
 }