Problem with Twitter

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Problem with Twitter

Postby BobM » Tue Nov 22, 2016 1:43 am

Hi Marshall

This problem (or something similar) has been touched upon in forum thread http://magpcss.org/ceforum/viewtopic.php?f=6&t=14340 .

When viewing a Twitter user page in CefClient, say https://twitter.com/BarackObama, if you are not logged into Twitter then clicking on a tweet shows the replies etc. However if you are logged into Twitter, the clicks are ignored. The thread above says this is to do with Notifications not being implemented in CEF.

Is this correct?
If so, can notifications be implemented in CEF?
A suggested resolution was to inject object into the page on load. Can you or someone explain that in more detail please?
Any other suggestions?

Viewing Twitter is an integral part of our application. This may be a Twitter problem but is there any way to handle this better? I don't like my chances of arguing with Twitter.

TIA, Bob
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: Problem with Twitter

Postby Czarek » Tue Nov 22, 2016 5:50 am

BobM wrote:...
The thread above says this is to do with Notifications not being implemented in CEF.

Is this correct?
If so, can notifications be implemented in CEF?
A suggested resolution was to inject object into the page on load. Can you or someone explain that in more detail please?
...


See https://en.wikipedia.org/wiki/Mock_object
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Problem with Twitter

Postby BobM » Wed Nov 23, 2016 1:48 am

Thanks Czarek,

After supplying a (more than minimal) Notification mock object as below, Twitter now appears to function correctly (logged in or not). Despite that Twitter appears to work fine, does this seem a reasonable and complete solution (recognizing the limitation of all Notification requests from any web page will be denied). I would be happy with this and can look at fully implementing Notification api perhaps down the track.

Thanks, Bob

Code: Select all
void ClientAppRenderer::OnContextCreated(CefRefPtr<CefBrowser> browser,
                                         CefRefPtr<CefFrame> frame,
                                         CefRefPtr<CefV8Context> context)
{
  std::string jscode =
    "window.Notification = function(title, options){"
    "  this.permission = 'denied';"
    "};"
    "window.Notification.requestPermission = function(){"
    "  return new Promise(function(resolve, reject) { resolve('denied'); })"
    "};";

  frame->ExecuteJavaScript(jscode, frame->GetURL(), NULL);

  DelegateSet::iterator it = delegates_.begin();
  for (; it != delegates_.end(); ++it)
    (*it)->OnContextCreated(this, browser, frame, context);
}
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 49 guests