diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 05c2683b260a..461a66c4b2f1 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -490,13 +490,11 @@ void WebContents::MediaPaused() { } 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); + 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( diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 7e41b02ae664..2057b515c025 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -235,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 + +``` + ## Instance Methods The `webContents` object has the following instance methods: diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 0eda48824636..0c79083c112d 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -647,4 +647,6 @@ Emitted when media is paused or done playing. Emitted when a page's theme color changes. This is usually due to encountering a meta tag: - +```html + +``` diff --git a/spec/fixtures/pages/theme-color.html b/spec/fixtures/pages/theme-color.html new file mode 100644 index 000000000000..57c49f337337 --- /dev/null +++ b/spec/fixtures/pages/theme-color.html @@ -0,0 +1,7 @@ + +
+ + + + + diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index c0578d05053b..d6c1a2de7b97 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -406,3 +406,10 @@ describe '