10

Planning to use chrome custom tabs, however before I start I wanted to know if its possible to intercept the request and set any headers in the request similar to WebViews ?

Read through the documentation and could not find any examples or references. All I could find is the onNavigationEvent callback that tells what url browser is trying to load.

Also is it possible to stop navigation for any url if required ?

ksarmalkar
  • 1,884
  • 1
  • 16
  • 21
  • As a matter of curiosity, could you expand on why you want to set custom headers and stop the navigation? – andreban Nov 17 '15 at 10:30
  • Sure, my use case is that I want to add some headers if website is in certain domain for e.g. xyz.com (for tracking purposes) but not add those headers for any other domain. I don't have any use case to stop navigation as of now but was jut curious if we could possibly do that in case we want to prevent the user from going to some competitor website via web deep linking. – ksarmalkar Nov 17 '15 at 19:17

2 Answers2

4

As of recent updates of the library, you can now add Bundle and pass it to the CustomTabsIntent intent as extra with key Browser.EXTRA_HEADERS

Bundle headers = new Bundle();
headers.putString("header1", "value1");
headers.putString("header2", "value2");
customTabsIntent.intent.putExtra(Browser.EXTRA_HEADERS, headers);
  • 1
    Unfortunately this does not work anymore. It seems this functionality is broken. See https://bugs.chromium.org/p/chromium/issues/detail?id=770186 – Pepijn Oct 11 '17 at 14:38
-1

As of today, it is not possible to set custom request headers. It's not possible to stop the navigation.

andreban
  • 4,621
  • 1
  • 20
  • 49