fix getFavcion api in webview to return dataUrl
This commit is contained in:
parent
36819e2638
commit
05be71e9bc
5 changed files with 13 additions and 9 deletions
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "atom/browser/api/event_emitter.h"
|
#include "atom/browser/api/event_emitter.h"
|
||||||
#include "brightray/browser/default_web_contents_delegate.h"
|
#include "brightray/browser/default_web_contents_delegate.h"
|
||||||
|
|
|
@ -158,9 +158,8 @@ class SrcAttribute extends WebViewAttribute
|
||||||
domEvent = new Event('will-navigate')
|
domEvent = new Event('will-navigate')
|
||||||
domEvent['url'] = @getValue()
|
domEvent['url'] = @getValue()
|
||||||
domEvent.cancelable = true
|
domEvent.cancelable = true
|
||||||
self = @
|
domEvent.preventDefault = () =>
|
||||||
domEvent.preventDefault = () ->
|
@setValueIgnoreMutation ''
|
||||||
self.setValueIgnoreMutation ''
|
|
||||||
@webViewImpl.webviewNode.dispatchEvent domEvent
|
@webViewImpl.webviewNode.dispatchEvent domEvent
|
||||||
|
|
||||||
unless @webViewImpl.guestInstanceId?
|
unless @webViewImpl.guestInstanceId?
|
||||||
|
|
|
@ -236,7 +236,6 @@ registerWebViewElement = ->
|
||||||
methods = [
|
methods = [
|
||||||
"getUrl"
|
"getUrl"
|
||||||
"getTitle"
|
"getTitle"
|
||||||
"getFavicon"
|
|
||||||
"isLoading"
|
"isLoading"
|
||||||
"isWaitingForResponse"
|
"isWaitingForResponse"
|
||||||
"stop"
|
"stop"
|
||||||
|
@ -277,6 +276,13 @@ registerWebViewElement = ->
|
||||||
remote.getGuestWebContents(internal.guestInstanceId)[m] args...
|
remote.getGuestWebContents(internal.guestInstanceId)[m] args...
|
||||||
proto[m] = createHandler m for m in methods
|
proto[m] = createHandler m for m in methods
|
||||||
|
|
||||||
|
# Return dataUrl instead of nativeImage.
|
||||||
|
proto.getFavicon = (args...) ->
|
||||||
|
internal = v8Util.getHiddenValue this, 'internal'
|
||||||
|
return unless internal
|
||||||
|
favicon = remote.getGuestWebContents(internal.guestInstanceId)['getFavicon'] args...
|
||||||
|
favicon.toDataUrl()
|
||||||
|
|
||||||
window.WebView = webFrame.registerEmbedderCustomElement 'webview',
|
window.WebView = webFrame.registerEmbedderCustomElement 'webview',
|
||||||
prototype: proto
|
prototype: proto
|
||||||
|
|
||||||
|
|
|
@ -671,7 +671,7 @@ Emitted when a redirect was received while requesting a resource.
|
||||||
### Event: 'page-favicon-updated'
|
### Event: 'page-favicon-updated'
|
||||||
|
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `favicons` [String]
|
* `favicons` Array - Array of Urls
|
||||||
|
|
||||||
Emitted when page receives favicon urls.
|
Emitted when page receives favicon urls.
|
||||||
|
|
||||||
|
@ -728,7 +728,7 @@ Returns the title of web page.
|
||||||
|
|
||||||
### WebContents.getFavicon()
|
### WebContents.getFavicon()
|
||||||
|
|
||||||
Returns the favicon of web page as `nativeImage`.
|
Returns the favicon of web page as [NativeImage](native-image.md).
|
||||||
|
|
||||||
### WebContents.isLoading()
|
### WebContents.isLoading()
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ Returns the title of guest page.
|
||||||
|
|
||||||
### `<webview>`.getFavicon()
|
### `<webview>`.getFavicon()
|
||||||
|
|
||||||
Returns the favicon of guest page as `nativeImage`.
|
Returns the favicon of guest page as dataUrl.
|
||||||
|
|
||||||
### `<webview>`.isLoading()
|
### `<webview>`.isLoading()
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ url.
|
||||||
|
|
||||||
### page-favicon-updated
|
### page-favicon-updated
|
||||||
|
|
||||||
* `favicons` [String]
|
* `favicons` Array - Array of Urls
|
||||||
|
|
||||||
Fired when page receives favicon urls.
|
Fired when page receives favicon urls.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue