Коммит
a6074f89a3
|
@ -489,6 +489,14 @@ void WebContents::MediaPaused() {
|
||||||
Emit("media-paused");
|
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(
|
void WebContents::DocumentLoadedInFrame(
|
||||||
content::RenderFrameHost* render_frame_host) {
|
content::RenderFrameHost* render_frame_host) {
|
||||||
if (!render_frame_host->GetParent())
|
if (!render_frame_host->GetParent())
|
||||||
|
|
|
@ -235,6 +235,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
base::ProcessId plugin_pid) override;
|
base::ProcessId plugin_pid) override;
|
||||||
void MediaStartedPlaying() override;
|
void MediaStartedPlaying() override;
|
||||||
void MediaPaused() override;
|
void MediaPaused() override;
|
||||||
|
void DidChangeThemeColor(SkColor theme_color) override;
|
||||||
|
|
||||||
// brightray::InspectableWebContentsViewDelegate:
|
// brightray::InspectableWebContentsViewDelegate:
|
||||||
void DevToolsFocused() override;
|
void DevToolsFocused() override;
|
||||||
|
|
|
@ -26,6 +26,7 @@ supportedWebViewEvents = [
|
||||||
'media-started-playing'
|
'media-started-playing'
|
||||||
'media-paused'
|
'media-paused'
|
||||||
'found-in-page'
|
'found-in-page'
|
||||||
|
'did-change-theme-color'
|
||||||
]
|
]
|
||||||
|
|
||||||
nextInstanceId = 0
|
nextInstanceId = 0
|
||||||
|
|
|
@ -22,6 +22,7 @@ WEB_VIEW_EVENTS =
|
||||||
'plugin-crashed': ['name', 'version']
|
'plugin-crashed': ['name', 'version']
|
||||||
'media-started-playing': []
|
'media-started-playing': []
|
||||||
'media-paused': []
|
'media-paused': []
|
||||||
|
'did-change-theme-color': ['themeColor']
|
||||||
'destroyed': []
|
'destroyed': []
|
||||||
'page-title-updated': ['title', 'explicitSet']
|
'page-title-updated': ['title', 'explicitSet']
|
||||||
'page-favicon-updated': ['favicons']
|
'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).
|
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'
|
### Event: 'found-in-page'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -243,6 +235,22 @@ Returns:
|
||||||
Emitted when a result is available for
|
Emitted when a result is available for
|
||||||
[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.
|
[`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
|
## Instance Methods
|
||||||
|
|
||||||
The `webContents` object has the following instance methods:
|
The `webContents` object has the following instance methods:
|
||||||
|
|
|
@ -634,3 +634,19 @@ Fired when a plugin process is crashed.
|
||||||
### Event: 'destroyed'
|
### Event: 'destroyed'
|
||||||
|
|
||||||
Fired when the WebContents is 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.addEventListener 'did-finish-load', listener2
|
||||||
webview.src = "file://#{fixtures}/pages/content.html"
|
webview.src = "file://#{fixtures}/pages/content.html"
|
||||||
document.body.appendChild webview
|
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
|
||||||
|
|
Загрузка…
Ссылка в новой задаче