Get context of second html page

Having problems with building or using the JCEF Java binding? Ask your questions here.

Get context of second html page

Postby rahul » Mon Nov 30, 2015 5:20 am

hi everyone
I have 2 html page and I need to pass value of first html page to second html page then how I will get the context of each window?
rahul
Techie
 
Posts: 11
Joined: Wed Oct 07, 2015 11:59 pm

Re: Get context of second html page

Postby magreenblatt » Mon Nov 30, 2015 3:22 pm

Please be more specific about what you're trying to accomplish.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Get context of second html page

Postby rahul » Mon Nov 30, 2015 10:23 pm

I have two html page.
Details of first page:-
contains file picker which will browse video file only and have play and stop button.
Details of second page:-
contains only canvas

In first page after selecting file when start button is pressed it should send the video frame by frame to my c++ program and there I need to store frame in a buffer
which will transfer to second html page frame by frame. When stop button is pressed in first html page it should stop sending frame to buffer but the number of frames which
buffer contains will continuously send to my second html page.

So my question is how can I get the context of second html page so that I can get frames from first html page and send it to second html page?
rahul
Techie
 
Posts: 11
Joined: Wed Oct 07, 2015 11:59 pm

Re: Get context of second html page

Postby magreenblatt » Tue Dec 01, 2015 10:22 am

rahul wrote:So my question is how can I get the context of second html page so that I can get frames from first html page and send it to second html page?

Do you mean the JavaScript context? Are the pages in the same origin (host + domain)? See https://bitbucket.org/chromiumembedded/ ... gration.md for your options.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Get context of second html page

Postby rahul » Wed Dec 02, 2015 4:12 am

sorry, I was unable to clarify my self.

lets get it in simple way:-
I have two html page both in localhost I want to pass string value from first html page to second html page.
i got value from first html page now I could not able to pass to second html page.
i have tried:-
Code: Select all

 const int64 frame_id =frame->GetIdentifier();  // getting frame id of second html page in OnContextCreated() method

          CefRefPtr<CefBrowser> contextRef1;
          string st = value;     //value from first html page
     CefRefPtr<CefFrame> frame = contextRef1->GetFrame(frame_id );
    CefRefPtr<CefV8Context> context = frame->GetV8Context();
    CefRefPtr<CefV8Context> contextRef2 = context->GetCurrentContext();
    CefRefPtr<CefV8Value> object1 = contextRef2->GetGlobal();
    str = CefV8Value::CreateString(value);
     object1->SetValue("myval", str, V8_PROPERTY_ATTRIBUTE_NONE);





but I couldn't able to get value in second html page.
rahul
Techie
 
Posts: 11
Joined: Wed Oct 07, 2015 11:59 pm

Re: Get context of second html page

Postby magreenblatt » Wed Dec 02, 2015 11:07 am

What is the relationship between the two pages? Are they hosted in separate CefBrowser instances?
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Get context of second html page

Postby rahul » Thu Dec 03, 2015 5:23 am

hi,
thanks for your support.

I have simply created in cefsimple by:-

Code: Select all
 CefRefPtr<CefCommandLine> command_line =
      CefCommandLine::GetGlobalCommandLine();
  url = command_line->GetSwitchValue("url");
  if (url.empty())
  {
    url = "file:///C:/Users/Rahul Ranjan/Desktop/videoStream.html";
   url1 = "file:///C:/Users/Rahul Ranjan/Desktop/videoStream1.html";
  }
  // Create the first browser window.
  CefBrowserHost::CreateBrowser(window_info, handler.get(), url,
                                browser_settings, NULL);
 
  // Create the Second browser window.
  CefBrowserHost::CreateBrowser(window_info, handler.get(), url1,
                                browser_settings, NULL);
rahul
Techie
 
Posts: 11
Joined: Wed Oct 07, 2015 11:59 pm

Re: Get context of second html page

Postby magreenblatt » Thu Dec 03, 2015 10:15 am

With two separate browsers you won't be able to script between them directly. You will need to send the message from the browser to the main process and then to the other browser using IPC or the network stack. See https://bitbucket.org/chromiumembedded/ ... cation-ipc and https://bitbucket.org/chromiumembedded/ ... t-handling
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 25 guests