Making Http Referrer addition better!

- Code cleanup
This commit is contained in:
Frank Hale 2014-11-07 21:54:36 -05:00
parent f56d1ea7b4
commit ef255db069
4 changed files with 15 additions and 26 deletions

View file

@ -291,7 +291,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
base::string16 http_referrer_;
if(options.Get("httpReferrer", &http_referrer_))
if (options.Get("httpreferrer", &http_referrer_))
params.referrer = content::Referrer(GURL(http_referrer_).GetAsReferrer(), blink::WebReferrerPolicyDefault);
params.transition_type = content::PAGE_TRANSITION_TYPED;

View file

@ -11,8 +11,6 @@ BrowserWindow::__proto__ = EventEmitter.prototype
BrowserWindow.windows = new IDWeakMap
BrowserWindow::_init = ->
@urlOptions = {}
# Simulate the application menu on platforms other than OS X.
if process.platform isnt 'darwin'
menu = app.getApplicationMenu()
@ -86,23 +84,15 @@ BrowserWindow.fromId = (id) ->
BrowserWindow.windows.get id
# Helpers.
BrowserWindow::loadUrl = ->
args = [].slice.call arguments
unless args.length > 1
args.push @urlOptions
#TODO: This needs fixing!
@urlOptions = args[1]
@webContents.loadUrl.apply @webContents, args
BrowserWindow::loadUrl = (url, urlOptions={}) -> @webContents.loadUrl url, urlOptions
BrowserWindow::send = -> @webContents.send.apply @webContents, arguments
# Be compatible with old API.
BrowserWindow::restart = -> @webContents.reload()
BrowserWindow::getUrl = -> @webContents.getUrl()
BrowserWindow::reload = -> @webContents.reload(@urlOptions)
BrowserWindow::reloadIgnoringCache = -> @webContents.reloadIgnoringCache(@urlOptions)
BrowserWindow::reload = (urlOptions={}) -> @webContents.reload(urlOptions)
BrowserWindow::reloadIgnoringCache = (urlOptions={}) -> @webContents.reloadIgnoringCache(urlOptions)
BrowserWindow::getPageTitle = -> @webContents.getTitle()
BrowserWindow::isLoading = -> @webContents.isLoading()
BrowserWindow::isWaitingForResponse = -> @webContents.isWaitingForResponse()

View file

@ -7,11 +7,11 @@ frameToGuest = {}
createGuest = (embedder, url, frameName, options) ->
guest = frameToGuest[frameName]
if frameName and guest?
guest.loadUrl url {}
guest.loadUrl url
return guest.id
guest = new BrowserWindow(options)
guest.loadUrl url {}
guest.loadUrl url
# When |embedder| is destroyed we should also destroy attached guest, and if
# guest is closed by user then we should prevent |embedder| from double

View file

@ -199,10 +199,10 @@ class WebView
# No setter.
enumerable: true
@httpReferrer = @webviewNode.getAttribute 'httpReferrer'
Object.defineProperty @webviewNode, 'httpReferrer',
@httpReferrer = @webviewNode.getAttribute 'httpreferrer'
Object.defineProperty @webviewNode, 'httpreferrer',
get: => @httpReferrer
set: (value) => @webviewNode.setAttribute 'httpReferrer', value
set: (value) => @webviewNode.setAttribute 'httpreferrer', value
enumerable: true
# The purpose of this mutation observer is to catch assignment to the src
@ -219,7 +219,7 @@ class WebView
params =
attributes: true,
attributeOldValue: true,
attributeFilter: ['src', 'partition', 'httpReferrer']
attributeFilter: ['src', 'partition', 'httpreferrer']
@srcAndPartitionObserver.observe @webviewNode, params
# This observer monitors mutations to attributes of the <webview> and
@ -253,19 +253,18 @@ class WebView
return unless @guestInstanceId
guestViewInternal.setAllowTransparency @guestInstanceId, @allowtransparency
else if name is 'httpReferrer'
else if name is 'httpreferrer'
oldValue ?= ''
newValue ?= ''
if newValue == '' and oldValue != ''
@webviewNode.setAttribute 'httpReferrer', oldValue
@webviewNode.setAttribute 'httpreferrer', oldValue
@httpReferrer = newValue
result = {}
# I think the right thing to do if you change your referrer is to reload
# the src since I've bundled the referrer in with the parseSrcAttribute.
# I think it makes sense to do that.
# If the httpreferrer changes treat it as though the src changes and reload
# the page with the new httpreferrer.
@parseSrcAttribute result
throw result.error if result.error?
@ -388,7 +387,7 @@ class WebView
return
if @httpReferrer
@urlOptions = { "httpReferrer": @httpReferrer }
@urlOptions = { "httpreferrer": @httpReferrer }
# Navigate to |this.src|.
remote.getGuestWebContents(@guestInstanceId).loadUrl @src, @urlOptions