fix getFavcion api in webview to return dataUrl

This commit is contained in:
deepak1556 2015-04-25 09:00:24 +05:30
parent 36819e2638
commit 05be71e9bc
5 changed files with 13 additions and 9 deletions

View file

@ -7,7 +7,6 @@
#include <string>
#include <vector>
#include <set>
#include "atom/browser/api/event_emitter.h"
#include "brightray/browser/default_web_contents_delegate.h"

View file

@ -158,9 +158,8 @@ class SrcAttribute extends WebViewAttribute
domEvent = new Event('will-navigate')
domEvent['url'] = @getValue()
domEvent.cancelable = true
self = @
domEvent.preventDefault = () ->
self.setValueIgnoreMutation ''
domEvent.preventDefault = () =>
@setValueIgnoreMutation ''
@webViewImpl.webviewNode.dispatchEvent domEvent
unless @webViewImpl.guestInstanceId?

View file

@ -236,7 +236,6 @@ registerWebViewElement = ->
methods = [
"getUrl"
"getTitle"
"getFavicon"
"isLoading"
"isWaitingForResponse"
"stop"
@ -277,6 +276,13 @@ registerWebViewElement = ->
remote.getGuestWebContents(internal.guestInstanceId)[m] args...
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',
prototype: proto

View file

@ -671,7 +671,7 @@ Emitted when a redirect was received while requesting a resource.
### Event: 'page-favicon-updated'
* `event` Event
* `favicons` [String]
* `favicons` Array - Array of Urls
Emitted when page receives favicon urls.
@ -728,7 +728,7 @@ Returns the title of web page.
### WebContents.getFavicon()
Returns the favicon of web page as `nativeImage`.
Returns the favicon of web page as [NativeImage](native-image.md).
### WebContents.isLoading()

View file

@ -132,7 +132,7 @@ Returns the title of guest page.
### `<webview>`.getFavicon()
Returns the favicon of guest page as `nativeImage`.
Returns the favicon of guest page as dataUrl.
### `<webview>`.isLoading()
@ -347,7 +347,7 @@ url.
### page-favicon-updated
* `favicons` [String]
* `favicons` Array - Array of Urls
Fired when page receives favicon urls.