Add did-change-theme-color event to webview

This commit is contained in:
Brian R. Bondy 2015-12-22 17:16:00 -05:00
parent e14d472934
commit 11b2015535
6 changed files with 27 additions and 8 deletions

View file

@ -489,6 +489,16 @@ void WebContents::MediaPaused() {
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(
content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent())

View file

@ -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;

View file

@ -26,6 +26,7 @@ supportedWebViewEvents = [
'media-started-playing'
'media-paused'
'found-in-page'
'did-change-theme-color'
]
nextInstanceId = 0

View file

@ -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']

View file

@ -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:

View file

@ -634,3 +634,17 @@ 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:
<meta name='theme-color' content='#ff0000'>