Deprecate the page-title-set event
We have two names for the same event, page-title-updated wins.
This commit is contained in:
parent
c95117fb22
commit
e5974e44ed
6 changed files with 24 additions and 18 deletions
|
@ -520,9 +520,9 @@ void WebContents::DidNavigateMainFrame(
|
||||||
void WebContents::TitleWasSet(content::NavigationEntry* entry,
|
void WebContents::TitleWasSet(content::NavigationEntry* entry,
|
||||||
bool explicit_set) {
|
bool explicit_set) {
|
||||||
if (entry)
|
if (entry)
|
||||||
Emit("-page-title-set", entry->GetTitle(), explicit_set);
|
Emit("-page-title-updated", entry->GetTitle(), explicit_set);
|
||||||
else
|
else
|
||||||
Emit("-page-title-set", "", explicit_set);
|
Emit("-page-title-updated", "", explicit_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DidUpdateFaviconURL(
|
void WebContents::DidUpdateFaviconURL(
|
||||||
|
|
|
@ -32,7 +32,7 @@ BrowserWindow::_init = ->
|
||||||
@emit 'crashed'
|
@emit 'crashed'
|
||||||
|
|
||||||
# Change window title to page title.
|
# Change window title to page title.
|
||||||
@webContents.on 'page-title-set', (event, title, explicitSet) =>
|
@webContents.on 'page-title-updated', (event, title, explicitSet) =>
|
||||||
@emit 'page-title-updated', event, title
|
@emit 'page-title-updated', event, title
|
||||||
@setTitle title unless event.defaultPrevented
|
@setTitle title unless event.defaultPrevented
|
||||||
|
|
||||||
|
|
|
@ -76,13 +76,15 @@ wrapWebContents = (webContents) ->
|
||||||
# until next tick.
|
# until next tick.
|
||||||
setImmediate => @emit 'did-fail-load', args...
|
setImmediate => @emit 'did-fail-load', args...
|
||||||
|
|
||||||
# Delays the page-title-set event to next tick.
|
# Delays the page-title-updated event to next tick.
|
||||||
webContents.on '-page-title-set', (args...) ->
|
webContents.on '-page-title-updated', (args...) ->
|
||||||
setImmediate => @emit 'page-title-set', args...
|
setImmediate => @emit 'page-title-updated', args...
|
||||||
|
|
||||||
# Deprecated.
|
# Deprecated.
|
||||||
deprecate.rename webContents, 'loadUrl', 'loadURL'
|
deprecate.rename webContents, 'loadUrl', 'loadURL'
|
||||||
deprecate.rename webContents, 'getUrl', 'getURL'
|
deprecate.rename webContents, 'getUrl', 'getURL'
|
||||||
|
deprecate.event webContents, 'page-title-set', 'page-title-updated', (args...) ->
|
||||||
|
@emit 'page-title-set', args...
|
||||||
|
|
||||||
webContents.printToPDF = (options, callback) ->
|
webContents.printToPDF = (options, callback) ->
|
||||||
printingSetting =
|
printingSetting =
|
||||||
|
|
|
@ -19,7 +19,7 @@ supportedWebViewEvents = [
|
||||||
'gpu-crashed'
|
'gpu-crashed'
|
||||||
'plugin-crashed'
|
'plugin-crashed'
|
||||||
'destroyed'
|
'destroyed'
|
||||||
'page-title-set'
|
'page-title-updated'
|
||||||
'page-favicon-updated'
|
'page-favicon-updated'
|
||||||
'enter-html-full-screen'
|
'enter-html-full-screen'
|
||||||
'leave-html-full-screen'
|
'leave-html-full-screen'
|
||||||
|
|
|
@ -21,23 +21,27 @@ WEB_VIEW_EVENTS =
|
||||||
'gpu-crashed': []
|
'gpu-crashed': []
|
||||||
'plugin-crashed': ['name', 'version']
|
'plugin-crashed': ['name', 'version']
|
||||||
'destroyed': []
|
'destroyed': []
|
||||||
'page-title-set': ['title', 'explicitSet']
|
'page-title-updated': ['title', 'explicitSet']
|
||||||
'page-favicon-updated': ['favicons']
|
'page-favicon-updated': ['favicons']
|
||||||
'enter-html-full-screen': []
|
'enter-html-full-screen': []
|
||||||
'leave-html-full-screen': []
|
'leave-html-full-screen': []
|
||||||
|
|
||||||
dispatchEvent = (webView, event, args...) ->
|
DEPRECATED_EVENTS =
|
||||||
throw new Error("Unknown event #{event}") unless WEB_VIEW_EVENTS[event]?
|
'page-title-updated': 'page-title-set'
|
||||||
domEvent = new Event(event)
|
|
||||||
for f, i in WEB_VIEW_EVENTS[event]
|
dispatchEvent = (webView, eventName, eventKey, args...) ->
|
||||||
|
if DEPRECATED_EVENTS[eventName]?
|
||||||
|
dispatchEvent webView, DEPRECATED_EVENTS[eventName], eventKey, args...
|
||||||
|
domEvent = new Event(eventName)
|
||||||
|
for f, i in WEB_VIEW_EVENTS[eventKey]
|
||||||
domEvent[f] = args[i]
|
domEvent[f] = args[i]
|
||||||
webView.dispatchEvent domEvent
|
webView.dispatchEvent domEvent
|
||||||
webView.onLoadCommit domEvent if event == 'load-commit'
|
webView.onLoadCommit domEvent if eventName is 'load-commit'
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
registerEvents: (webView, viewInstanceId) ->
|
registerEvents: (webView, viewInstanceId) ->
|
||||||
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}", (event, domEvent, args...) ->
|
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}", (event, eventName, args...) ->
|
||||||
dispatchEvent webView, domEvent, args...
|
dispatchEvent webView, eventName, eventName, args...
|
||||||
|
|
||||||
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}", (event, channel, args...) ->
|
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}", (event, channel, args...) ->
|
||||||
domEvent = new Event('ipc-message')
|
domEvent = new Event('ipc-message')
|
||||||
|
|
|
@ -452,15 +452,15 @@ Fired when a redirect was received while requesting a resource.
|
||||||
|
|
||||||
Fired when document in the given frame is loaded.
|
Fired when document in the given frame is loaded.
|
||||||
|
|
||||||
### Event: 'page-title-set'
|
### Event: 'page-title-updated'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
* `title` String
|
* `title` String
|
||||||
* `explicitSet` Boolean
|
* `explicitSet` Boolean
|
||||||
|
|
||||||
Fired when page title is set during navigation. `explicitSet` is false when title is synthesised from file
|
Fired when page title is set during navigation. `explicitSet` is false when
|
||||||
url.
|
title is synthesised from file url.
|
||||||
|
|
||||||
### Event: 'page-favicon-updated'
|
### Event: 'page-favicon-updated'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue