Page 1 of 1

How to detect if browser instance is of devtools?

PostPosted: Tue Nov 12, 2013 6:30 am
by sriharshav
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 15693 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?

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

PostPosted: Tue Nov 12, 2013 9:39 am
by magreenblatt
Via the url: frame->GetURL()

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

PostPosted: Tue Nov 12, 2013 1:48 pm
by sriharshav
Oh! that is quite simple. Thanks.

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

PostPosted: Wed Sep 10, 2014 4:49 am
by Tiph
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