Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Add webview event for security state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
diracdeltas committed Nov 9, 2016
1 parent 6227151 commit ca0aefe
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,26 @@ void WebContents::DidFinishNavigation(
}
}

void WebContents::SecurityStyleChanged(
content::SecurityStyle security_style,
const content::SecurityStyleExplanations& explanations) {
std::string type = "unknown";
switch (security_style) {
case content::SECURITY_STYLE_UNAUTHENTICATED:
case content::SECURITY_STYLE_AUTHENTICATION_BROKEN:
type = "insecure";
break;
case content::SECURITY_STYLE_WARNING:
type = "warning";
break;
case content::SECURITY_STYLE_AUTHENTICATED:
type = "secure";
break;
default: break;
}
Emit("did-change-security", type);

This comment has been minimized.

Copy link
@bridiver

bridiver Nov 9, 2016

Collaborator

I missed this the first time through, but can we make this security-style-changed? A lot of the existing electron events are really confusing because they don't match the observer/delegate method names

}

void WebContents::TitleWasSet(content::NavigationEntry* entry,
bool explicit_set) {
if (entry)
Expand Down
3 changes: 3 additions & 0 deletions atom/browser/api/atom_api_web_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
void WebContentsDestroyed() override;
void NavigationEntryCommitted(
const content::LoadCommittedDetails& load_details) override;
void SecurityStyleChanged(
content::SecurityStyle security_style,
const content::SecurityStyleExplanations& explanations) override;
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& urls) override;
Expand Down
1 change: 1 addition & 0 deletions lib/browser/guest-view-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let supportedWebViewEvents = [
'will-navigate',
'did-navigate',
'did-navigate-in-page',
'did-change-security',
'close',
'crashed',
'gpu-crashed',
Expand Down
1 change: 1 addition & 0 deletions lib/renderer/web-view/guest-view-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var WEB_VIEW_EVENTS = {
'gpu-crashed': [],
'plugin-crashed': ['name', 'version'],
'destroyed': [],
'did-change-security': ['securityState'],
'page-title-updated': ['title', 'explicitSet'],
'page-favicon-updated': ['favicons'],
'enter-html-full-screen': [],
Expand Down

1 comment on commit ca0aefe

@bsclifton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.