Add did-change-theme-color event to webview
This commit is contained in:
parent
e14d472934
commit
11b2015535
6 changed files with 27 additions and 8 deletions
|
@ -489,6 +489,16 @@ void WebContents::MediaPaused() {
|
||||||
Emit("media-paused");
|
Emit("media-paused");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContents::DidChangeThemeColor(SkColor theme_color) {
|
||||||
|
char themeColor[8] = { 0 };
|
||||||
|
snprintf(themeColor, sizeof(themeColor),
|
||||||
|
"#%02X%02X%02X",
|
||||||
|
SkColorGetR(theme_color),
|
||||||
|
SkColorGetG(theme_color),
|
||||||
|
SkColorGetB(theme_color));
|
||||||
|
Emit("did-change-theme-color", themeColor);
|
||||||
|
}
|
||||||
|
|
||||||
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:
|
||||||
|
|
|
@ -634,3 +634,17 @@ 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:
|
||||||
|
|
||||||
|
<meta name='theme-color' content='#ff0000'>
|
||||||
|
|
Loading…
Reference in a new issue