Various fixes of #801
This commit is contained in:
parent
993c52dcd5
commit
fbd74c0e2d
5 changed files with 24 additions and 29 deletions
|
@ -289,11 +289,10 @@ bool WebContents::IsAlive() const {
|
||||||
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||||
content::NavigationController::LoadURLParams params(url);
|
content::NavigationController::LoadURLParams params(url);
|
||||||
|
|
||||||
base::string16 http_referrer;
|
GURL http_referrer;
|
||||||
|
if (options.Get("httpreferrer", &http_referrer))
|
||||||
if (options.Get("httpreferrer", &http_referrer_))
|
params.referrer = content::Referrer(http_referrer.GetAsReferrer(),
|
||||||
params.referrer = content::Referrer(GURL(http_referrer_).GetAsReferrer(),
|
blink::WebReferrerPolicyDefault);
|
||||||
blink::WebReferrerPolicyDefault);
|
|
||||||
|
|
||||||
params.transition_type = content::PAGE_TRANSITION_TYPED;
|
params.transition_type = content::PAGE_TRANSITION_TYPED;
|
||||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||||
|
@ -445,14 +444,14 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||||
template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
|
template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
|
||||||
.SetMethod("destroy", &WebContents::Destroy)
|
.SetMethod("destroy", &WebContents::Destroy)
|
||||||
.SetMethod("isAlive", &WebContents::IsAlive)
|
.SetMethod("isAlive", &WebContents::IsAlive)
|
||||||
.SetMethod("loadUrl", &WebContents::LoadURL)
|
.SetMethod("_loadUrl", &WebContents::LoadURL)
|
||||||
.SetMethod("getUrl", &WebContents::GetURL)
|
.SetMethod("getUrl", &WebContents::GetURL)
|
||||||
.SetMethod("getTitle", &WebContents::GetTitle)
|
.SetMethod("getTitle", &WebContents::GetTitle)
|
||||||
.SetMethod("isLoading", &WebContents::IsLoading)
|
.SetMethod("isLoading", &WebContents::IsLoading)
|
||||||
.SetMethod("isWaitingForResponse", &WebContents::IsWaitingForResponse)
|
.SetMethod("isWaitingForResponse", &WebContents::IsWaitingForResponse)
|
||||||
.SetMethod("stop", &WebContents::Stop)
|
.SetMethod("stop", &WebContents::Stop)
|
||||||
.SetMethod("reload", &WebContents::Reload)
|
.SetMethod("_reload", &WebContents::Reload)
|
||||||
.SetMethod("reloadIgnoringCache", &WebContents::ReloadIgnoringCache)
|
.SetMethod("_reloadIgnoringCache", &WebContents::ReloadIgnoringCache)
|
||||||
.SetMethod("canGoBack", &WebContents::CanGoBack)
|
.SetMethod("canGoBack", &WebContents::CanGoBack)
|
||||||
.SetMethod("canGoForward", &WebContents::CanGoForward)
|
.SetMethod("canGoForward", &WebContents::CanGoForward)
|
||||||
.SetMethod("canGoToOffset", &WebContents::CanGoToOffset)
|
.SetMethod("canGoToOffset", &WebContents::CanGoToOffset)
|
||||||
|
|
|
@ -84,15 +84,14 @@ BrowserWindow.fromId = (id) ->
|
||||||
BrowserWindow.windows.get id
|
BrowserWindow.windows.get id
|
||||||
|
|
||||||
# Helpers.
|
# Helpers.
|
||||||
BrowserWindow::loadUrl = (url, urlOptions={}) -> @webContents.loadUrl url, urlOptions
|
BrowserWindow::loadUrl = -> @webContents.loadUrl.apply @webContents, arguments
|
||||||
|
|
||||||
BrowserWindow::send = -> @webContents.send.apply @webContents, arguments
|
BrowserWindow::send = -> @webContents.send.apply @webContents, arguments
|
||||||
|
|
||||||
# Be compatible with old API.
|
# Be compatible with old API.
|
||||||
BrowserWindow::restart = -> @webContents.reload()
|
BrowserWindow::restart = -> @webContents.reload()
|
||||||
BrowserWindow::getUrl = -> @webContents.getUrl()
|
BrowserWindow::getUrl = -> @webContents.getUrl()
|
||||||
BrowserWindow::reload = (urlOptions={}) -> @webContents.reload(urlOptions)
|
BrowserWindow::reload = -> @webContents.reload.apply @webContents, arguments
|
||||||
BrowserWindow::reloadIgnoringCache = (urlOptions={}) -> @webContents.reloadIgnoringCache(urlOptions)
|
BrowserWindow::reloadIgnoringCache = -> @webContents.reloadIgnoringCache.apply @webContents, arguments
|
||||||
BrowserWindow::getPageTitle = -> @webContents.getTitle()
|
BrowserWindow::getPageTitle = -> @webContents.getTitle()
|
||||||
BrowserWindow::isLoading = -> @webContents.isLoading()
|
BrowserWindow::isLoading = -> @webContents.isLoading()
|
||||||
BrowserWindow::isWaitingForResponse = -> @webContents.isWaitingForResponse()
|
BrowserWindow::isWaitingForResponse = -> @webContents.isWaitingForResponse()
|
||||||
|
|
|
@ -26,12 +26,10 @@ module.exports.wrap = (webContents) ->
|
||||||
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
||||||
webContents.equal = (other) -> @getId() is other.getId()
|
webContents.equal = (other) -> @getId() is other.getId()
|
||||||
|
|
||||||
# Provide a default parameter for urlOptions to be compatible with the old
|
# Provide a default parameter for |urlOptions|.
|
||||||
# API.
|
webContents.loadUrl = (url, urlOptions={}) -> @_loadUrl url, urlOptions
|
||||||
webContents::loadUrl = (url, urlOptions={}) -> loadUrl url, urlOptions
|
webContents.reload = (urlOptions={}) -> @_reload urlOptions
|
||||||
webContents::reload = (urlOptions={}) -> reload(urlOptions)
|
webContents.reloadIgnoringCache = (urlOptions={}) -> @_reloadIgnoringCache urlOptions
|
||||||
webContents::reloadIgnoringCache = (urlOptions={}) ->
|
|
||||||
reloadIgnoringCache(urlOptions)
|
|
||||||
|
|
||||||
# Translate |disposition| to string for 'new-window' event.
|
# Translate |disposition| to string for 'new-window' event.
|
||||||
webContents.on '-new-window', (args..., disposition) ->
|
webContents.on '-new-window', (args..., disposition) ->
|
||||||
|
|
|
@ -47,7 +47,10 @@ 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
|
||||||
@loadUrl params.src, params.urlOptions
|
if params.httpreferrer
|
||||||
|
@loadUrl params.src, {httpreferrer: params.httpreferrer}
|
||||||
|
else
|
||||||
|
@loadUrl params.src
|
||||||
if params.allowtransparency?
|
if params.allowtransparency?
|
||||||
@setAllowTransparency params.allowtransparency
|
@setAllowTransparency params.allowtransparency
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,6 @@ class WebView
|
||||||
# on* Event handlers.
|
# on* Event handlers.
|
||||||
@on = {}
|
@on = {}
|
||||||
|
|
||||||
@urlOptions = {}
|
|
||||||
|
|
||||||
@browserPluginNode = @createBrowserPluginNode()
|
@browserPluginNode = @createBrowserPluginNode()
|
||||||
shadowRoot = @webviewNode.createShadowRoot()
|
shadowRoot = @webviewNode.createShadowRoot()
|
||||||
@partition = new Partition()
|
@partition = new Partition()
|
||||||
|
@ -199,9 +197,9 @@ class WebView
|
||||||
# No setter.
|
# No setter.
|
||||||
enumerable: true
|
enumerable: true
|
||||||
|
|
||||||
@httpReferrer = @webviewNode.getAttribute 'httpreferrer'
|
@httpreferrer = @webviewNode.getAttribute 'httpreferrer'
|
||||||
Object.defineProperty @webviewNode, 'httpreferrer',
|
Object.defineProperty @webviewNode, 'httpreferrer',
|
||||||
get: => @httpReferrer
|
get: => @httpreferrer
|
||||||
set: (value) => @webviewNode.setAttribute 'httpreferrer', value
|
set: (value) => @webviewNode.setAttribute 'httpreferrer', value
|
||||||
enumerable: true
|
enumerable: true
|
||||||
|
|
||||||
|
@ -260,7 +258,7 @@ class WebView
|
||||||
if newValue == '' and oldValue != ''
|
if newValue == '' and oldValue != ''
|
||||||
@webviewNode.setAttribute 'httpreferrer', oldValue
|
@webviewNode.setAttribute 'httpreferrer', oldValue
|
||||||
|
|
||||||
@httpReferrer = newValue
|
@httpreferrer = newValue
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
# If the httpreferrer changes treat it as though the src changes and reload
|
# If the httpreferrer changes treat it as though the src changes and reload
|
||||||
|
@ -386,11 +384,9 @@ class WebView
|
||||||
@createGuest()
|
@createGuest()
|
||||||
return
|
return
|
||||||
|
|
||||||
if @httpReferrer
|
|
||||||
@urlOptions = { "httpreferrer": @httpReferrer }
|
|
||||||
|
|
||||||
# Navigate to |this.src|.
|
# Navigate to |this.src|.
|
||||||
remote.getGuestWebContents(@guestInstanceId).loadUrl @src, @urlOptions
|
urlOptions = if @httpreferrer then {@httpreferrer} else {}
|
||||||
|
remote.getGuestWebContents(@guestInstanceId).loadUrl @src, urlOptions
|
||||||
|
|
||||||
parseAttributes: ->
|
parseAttributes: ->
|
||||||
return unless @elementAttached
|
return unless @elementAttached
|
||||||
|
@ -473,7 +469,7 @@ class WebView
|
||||||
# set via this.onAttach().
|
# set via this.onAttach().
|
||||||
storagePartitionId: @partition.toAttribute()
|
storagePartitionId: @partition.toAttribute()
|
||||||
userAgentOverride: @userAgentOverride
|
userAgentOverride: @userAgentOverride
|
||||||
urlOptions: @urlOptions
|
httpreferrer: @httpreferrer
|
||||||
|
|
||||||
attachWindow: (guestInstanceId, isNewWindow) ->
|
attachWindow: (guestInstanceId, isNewWindow) ->
|
||||||
@guestInstanceId = guestInstanceId
|
@guestInstanceId = guestInstanceId
|
||||||
|
|
Loading…
Reference in a new issue