How to detect if browser instance is of devtools?

Discussion of current events and participation in intelligent conversation with other CEF users.

How to detect if browser instance is of devtools?

Postby sriharshav » Tue Nov 12, 2013 6:30 am

I have a simple CEF app with an option to open devtools from context menu. Upon click Devtools open as popup window.

In Devtools popup, when I right click on Sources tab without any source, it shows context menu of my application.

DevtoolsContextMenu.png
DevtoolsContextMenu.png (29.78 KiB) Viewed 11293 times


But I would like to clear model in ClientHandler::OnBeforeContextMenu if the browser instance is of Devtools. One simple option in this case could be to check if it is popup with browser->IsPopup(). But that doesn't ensure it to be Devtools. Other option I could think of is by using browser->GetIdentifier() and do some verification.

Would like to know if there is any other way out to detect if browser instance is of devtools?
sriharshav
Newbie
 
Posts: 4
Joined: Sun Sep 29, 2013 11:21 pm

Re: How to detect if browser instance is of devtools?

Postby magreenblatt » Tue Nov 12, 2013 9:39 am

Via the url: frame->GetURL()
magreenblatt
Site Admin
 
Posts: 9831
Joined: Fri May 29, 2009 6:57 pm

Re: How to detect if browser instance is of devtools?

Postby sriharshav » Tue Nov 12, 2013 1:48 pm

Oh! that is quite simple. Thanks.
sriharshav
Newbie
 
Posts: 4
Joined: Sun Sep 29, 2013 11:21 pm

Re: How to detect if browser instance is of devtools?

Postby Tiph » Wed Sep 10, 2014 4:49 am

Hey

I d like to do the same but in the method OnAfterCreated i try to get the url from the main frame and the focused frame but it's always NULL


Code: Select all
   CefString urlDev ("chrome-devtools://devtools/devtools.html");
   
   CefString url (browser->GetFocusedFrame()->GetURL());
   int cmp = url.compare(urlDev);
   if(cmp != 0) {}


Thank for the help
Tiph
Techie
 
Posts: 13
Joined: Mon Aug 11, 2014 12:01 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest