Коммит
a6074f89a3
|
@ -489,6 +489,14 @@ void WebContents::MediaPaused() {
|
|||
Emit("media-paused");
|
||||
}
|
||||
|
||||
void WebContents::DidChangeThemeColor(SkColor theme_color) {
|
||||
std::string hex_theme_color = base::StringPrintf("#%02X%02X%02X",
|
||||
SkColorGetR(theme_color),
|
||||
SkColorGetG(theme_color),
|
||||
SkColorGetB(theme_color));
|
||||
Emit("did-change-theme-color", hex_theme_color);
|
||||
}
|
||||
|
||||
void WebContents::DocumentLoadedInFrame(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
if (!render_frame_host->GetParent())
|
||||
|
|
|
@ -235,6 +235,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
base::ProcessId plugin_pid) override;
|
||||
void MediaStartedPlaying() override;
|
||||
void MediaPaused() override;
|
||||
void DidChangeThemeColor(SkColor theme_color) override;
|
||||
|
||||
// brightray::InspectableWebContentsViewDelegate:
|
||||
void DevToolsFocused() override;
|
||||
|
|
|
@ -26,6 +26,7 @@ supportedWebViewEvents = [
|
|||
'media-started-playing'
|
||||
'media-paused'
|
||||
'found-in-page'
|
||||
'did-change-theme-color'
|
||||
]
|
||||
|
||||
nextInstanceId = 0
|
||||
|
|
|
@ -22,6 +22,7 @@ WEB_VIEW_EVENTS =
|
|||
'plugin-crashed': ['name', 'version']
|
||||
'media-started-playing': []
|
||||
'media-paused': []
|
||||
'did-change-theme-color': ['themeColor']
|
||||
'destroyed': []
|
||||
'page-title-updated': ['title', 'explicitSet']
|
||||
'page-favicon-updated': ['favicons']
|
||||
|
|
|
@ -221,14 +221,6 @@ Emitted when `webContents` wants to do basic auth.
|
|||
|
||||
The usage is the same with [the `login` event of `app`](app.md#event-login).
|
||||
|
||||
### Event: 'media-started-playing'
|
||||
|
||||
Emitted when media starts playing.
|
||||
|
||||
### Event: 'media-paused'
|
||||
|
||||
Emitted when media is paused or done playing.
|
||||
|
||||
### Event: 'found-in-page'
|
||||
|
||||
Returns:
|
||||
|
@ -243,6 +235,22 @@ Returns:
|
|||
Emitted when a result is available for
|
||||
[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.
|
||||
|
||||
### Event: 'media-started-playing'
|
||||
|
||||
Emitted when media starts playing.
|
||||
|
||||
### Event: 'media-paused'
|
||||
|
||||
Emitted when media is paused or done playing.
|
||||
|
||||
### Event: 'did-change-theme-color'
|
||||
|
||||
Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
|
||||
|
||||
```html
|
||||
<meta name='theme-color' content='#ff0000'>
|
||||
```
|
||||
|
||||
## Instance Methods
|
||||
|
||||
The `webContents` object has the following instance methods:
|
||||
|
|
|
@ -634,3 +634,19 @@ Fired when a plugin process is crashed.
|
|||
### Event: 'destroyed'
|
||||
|
||||
Fired when the WebContents is destroyed.
|
||||
|
||||
### Event: 'media-started-playing'
|
||||
|
||||
Emitted when media starts playing.
|
||||
|
||||
### Event: 'media-paused'
|
||||
|
||||
Emitted when media is paused or done playing.
|
||||
|
||||
### Event: 'did-change-theme-color'
|
||||
|
||||
Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
|
||||
|
||||
```html
|
||||
<meta name='theme-color' content='#ff0000'>
|
||||
```
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta name="theme-color" content="#ffeedd">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -406,3 +406,10 @@ describe '<webview> tag', ->
|
|||
webview.addEventListener 'did-finish-load', listener2
|
||||
webview.src = "file://#{fixtures}/pages/content.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
describe 'did-change-theme-color event', ->
|
||||
it 'emits when theme color changes', (done) ->
|
||||
webview.addEventListener 'did-change-theme-color', (e) ->
|
||||
done()
|
||||
webview.src = "file://#{fixtures}/pages/theme-color.html"
|
||||
document.body.appendChild webview
|
||||
|
|
Загрузка…
Ссылка в новой задаче