Pass user agent along like http referrer and set user agent in C++
This commit is contained in:
parent
4a8d7c1819
commit
e4d90f747f
3 changed files with 14 additions and 6 deletions
|
@ -418,6 +418,10 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||||
params.referrer = content::Referrer(http_referrer.GetAsReferrer(),
|
params.referrer = content::Referrer(http_referrer.GetAsReferrer(),
|
||||||
blink::WebReferrerPolicyDefault);
|
blink::WebReferrerPolicyDefault);
|
||||||
|
|
||||||
|
std::string user_agent;
|
||||||
|
if (options.Get("useragent", &user_agent))
|
||||||
|
this->SetUserAgent(user_agent);
|
||||||
|
|
||||||
params.transition_type = ui::PAGE_TRANSITION_TYPED;
|
params.transition_type = ui::PAGE_TRANSITION_TYPED;
|
||||||
params.should_clear_history_list = true;
|
params.should_clear_history_list = true;
|
||||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||||
|
|
|
@ -58,8 +58,11 @@ createGuest = (embedder, params) ->
|
||||||
max = width: params.maxwidth, height: params.maxheight
|
max = width: params.maxwidth, height: params.maxheight
|
||||||
@setAutoSize params.autosize, min, max
|
@setAutoSize params.autosize, min, max
|
||||||
if params.src
|
if params.src
|
||||||
if params.httpreferrer
|
opts = {}
|
||||||
@loadUrl params.src, {httpreferrer: params.httpreferrer}
|
opts.httpreferrer = params.httpreferrer if params.httpreferrer
|
||||||
|
opts.useragent = params.useragent if params.useragent
|
||||||
|
if params.httpreferrer or params.useragent
|
||||||
|
@loadUrl params.src, opts
|
||||||
else
|
else
|
||||||
@loadUrl params.src
|
@loadUrl params.src
|
||||||
if params.allowtransparency?
|
if params.allowtransparency?
|
||||||
|
|
|
@ -158,13 +158,14 @@ class SrcAttribute extends WebViewAttribute
|
||||||
return
|
return
|
||||||
|
|
||||||
# Navigate to |this.src|.
|
# Navigate to |this.src|.
|
||||||
|
opts = {}
|
||||||
httpreferrer = @webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
httpreferrer = @webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
||||||
urlOptions = if httpreferrer then {httpreferrer} else {}
|
if httpreferrer then opts.httpreferrer = httpreferrer
|
||||||
|
|
||||||
useragent = @webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
useragent = @webViewImpl.attributes[webViewConstants.ATTRIBUTE_USERAGENT].getValue()
|
||||||
|
if useragent then opts.useragent = useragent
|
||||||
|
|
||||||
guestContents = remote.getGuestWebContents(@webViewImpl.guestInstanceId)
|
guestContents = remote.getGuestWebContents(@webViewImpl.guestInstanceId)
|
||||||
guestContents.setUserAgent(guestContents) if guestContents
|
|
||||||
guestContents.loadUrl @getValue(), urlOptions
|
guestContents.loadUrl @getValue(), urlOptions
|
||||||
|
|
||||||
# Attribute specifies HTTP referrer.
|
# Attribute specifies HTTP referrer.
|
||||||
|
@ -175,7 +176,7 @@ class HttpReferrerAttribute extends WebViewAttribute
|
||||||
# Attribute specifies HTTP referrer.
|
# Attribute specifies HTTP referrer.
|
||||||
class UserAgentAttribute extends WebViewAttribute
|
class UserAgentAttribute extends WebViewAttribute
|
||||||
constructor: (webViewImpl) ->
|
constructor: (webViewImpl) ->
|
||||||
super webViewConstants.ATTRIBUTE_HTTPREFERRER, webViewImpl
|
super webViewConstants.ATTRIBUTE_USERAGENT, webViewImpl
|
||||||
|
|
||||||
# Attribute that set preload script.
|
# Attribute that set preload script.
|
||||||
class PreloadAttribute extends WebViewAttribute
|
class PreloadAttribute extends WebViewAttribute
|
||||||
|
|
Loading…
Reference in a new issue