How to support chrome resources?

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.

How to support chrome resources?

Postby gwynjudd » Sun Feb 14, 2016 8:04 pm

Hello,

in chrome, there are a number of very useful URLs that you can visit, e.g.:

chrome://flags/
chrome://chrome-urls/

etc.

These don't seem to be supported in cef. To test this, I got a number of different builds from https://cefbuilds.com/ and then ran cefclient. I entered the urls above and it was redirected to chrome://version/. In the debug.log, I see the messages:

[0215/140417:INFO:chrome_scheme_handler.cc(263)] Reguest for unknown chrome resource: chrome://flags/
[0215/140430:INFO:chrome_scheme_handler.cc(263)] Reguest for unknown chrome resource: chrome://chrome-urls/

Is there any way to make these URLs work?

thanks, Gwyn
gwynjudd
Newbie
 
Posts: 9
Joined: Mon Aug 03, 2015 5:22 pm

Re: How to support chrome resources?

Postby Czarek » Mon Feb 15, 2016 2:18 am

Here is the commit that added chrome://version, credits and license: https://bitbucket.org/chromiumembedded/ ... afceb24d60
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: How to support chrome resources?

Postby cherzog » Wed Jun 27, 2018 6:09 pm

Hello.

I already posted this here...

viewtopic.php?f=14&t=15057

...but I realize now how this might be a better thread.

I'm running the following CEF build:

3.3325.1746.ge81cdf2_windows32

Downloaded from here:

http://opensource.spotify.com/cefbuilds ... 32.tar.bz2

I'm having trouble with chrome:// URLs not working in CEF.

They are being replaced with about:blank.

I downloaded the relevant CEF and Chromium source and debug symbols, and was able to determine that this seems to be happening due to some security filtering.

Here is the top of the call stack at the time when the URL check fails, and the chrome:// URL is replaced with about:blank...

libcef.dll!content::ChildProcessSecurityPolicyImpl::SecurityState::CanCommitURL(const GURL & url) Line 207 C++
libcef.dll!content::ChildProcessSecurityPolicyImpl::CanCommitURL(int child_id, const GURL & url) Line 744 C++
libcef.dll!content::ChildProcessSecurityPolicyImpl::CanRequestURL(int child_id, const GURL & url) Line 663 C++
libcef.dll!content::RenderProcessHostImpl::FilterURL(content::RenderProcessHost * rph, bool url, GURL *) Line 3270 C++
libcef.dll!content::RenderProcessHostImpl::FilterURL(bool url, GURL *) Line 3150 C++
libcef.dll!content::RenderFrameHostImpl::CreateNewWindow() Line 2893 C++

I searched for something I could change in my CEF configuration to prevent this filtering, but I have not yet found anything.

I tried CefAddCrossOriginWhitelistEntry(), but that did not seem to make a difference.

Is it possible that I have some setting which is inadvertently enabling this filtering?

Is anyone aware of something that can be done at the CEF layer to allow the chrome:// URLs to not be filtered out by this security check?

This seems to be the most relevant chunk of code, from child_process_security_policy_impl.cc near line 202:

Code: Select all
  // Determine whether permission has been granted to commit |url|.
  bool CanCommitURL(const GURL& url) {
    DCHECK(!url.SchemeIsBlob() && !url.SchemeIsFileSystem())
        << "inner_url extraction should be done already.";
    // Having permission to a scheme implies permission to all of its URLs.
    SchemeSet::const_iterator scheme_judgment(
        scheme_policy_.find(url.scheme()));
    if (scheme_judgment != scheme_policy_.end())
      return true;

    // Otherwise, check for permission for specific origin.
    if (CanCommitOrigin(url::Origin::Create(url)))
      return true;

    // file:// URLs are more granular.  The child may have been given
    // permission to a specific file but not the file:// scheme in general.
    if (url.SchemeIs(url::kFileScheme)) {
      base::FilePath path;
      if (net::FileURLToFilePath(url, &path))
        return base::ContainsKey(request_file_set_, path);
    }

    return false;  // Unmentioned schemes are disallowed.
  }


Is there some way in CEF to whitelist the chrome scheme?

Am I blocking it somehow unintentionally?

Thanks very much.
cherzog
Newbie
 
Posts: 6
Joined: Tue Jun 26, 2018 6:56 pm

Re: How to support chrome resources?

Postby magreenblatt » Thu Jun 28, 2018 11:28 am

chrome:// URLs work for me in cef_binary_3.3325.1751.ge5b78a5_windows32_client. You can start with chrome://webui-hosts/ to see which ones are supported by CEF.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to support chrome resources?

Postby cherzog » Mon Jul 02, 2018 12:50 pm

Thanks for replying.

Perhaps I have some settings which are different than what you are using, because even 'chrome://webui-hosts/' gets replaced with 'about:blank' in my app.

For my testing, I'm typing the following into the Chrome debugger JS console:

window.open( 'chrome://webui-hosts/');

Does that work for you?

Thanks.
cherzog
Newbie
 
Posts: 6
Joined: Tue Jun 26, 2018 6:56 pm

Re: How to support chrome resources?

Postby magreenblatt » Mon Jul 02, 2018 1:31 pm

You can't load or access chrome:// URLs with JavaScript. You need to navigate the browser directly with LoadURL or similar.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to support chrome resources?

Postby cherzog » Wed Jul 18, 2018 4:36 pm

Thanks very much, magreenblatt.

You were correct.

I now have 'chrome://webrtc-internals' loading correctly in CEF inside a popup browser object.

Code: Select all
CefWindowInfo webRtcInternalsWindowInfo;
webRtcInternalsWindowInfo.SetAsPopup(hWndParent, "WebRTC Internals");

CefBrowserHost::CreateBrowser(webRtcInternalsWindowInfo, this, "chrome://webrtc-internals", browserSettings, nullptr);
cherzog
Newbie
 
Posts: 6
Joined: Tue Jun 26, 2018 6:56 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 89 guests