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

Broadcast EV certificate information to the frontend #377

Merged
merged 2 commits into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 62 additions & 9 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,59 @@ struct Converter<blink::WebSecurityStyle> {
}
};

template<>
struct Converter<security_state::SecurityInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
security_state::SecurityInfo val) {
mate::Dictionary dict(isolate, v8::Object::New(isolate));
// see components/security_state/core/security_state.h
switch (val.security_level) {
case security_state::NONE:
dict.Set("securityLevel", "none");
break;
case security_state::HTTP_SHOW_WARNING:
dict.Set("securityLevel", "http-show-warning");
break;
case security_state::EV_SECURE:
dict.Set("securityLevel", "ev-secure");
break;
case security_state::SECURE:
dict.Set("securityLevel", "secure");
break;
case security_state::SECURE_WITH_POLICY_INSTALLED_CERT:
// Currently used only on ChromeOS.
break;
case security_state::DANGEROUS:
dict.Set("securityLevel", "dangerous");
break;
}

if (val.certificate)
dict.Set("certificate", val.certificate);

switch (val.mixed_content_status) {
case security_state::CONTENT_STATUS_UNKNOWN:
dict.Set("mixedContentStatus", "content-status-unkown");
break;
case security_state::CONTENT_STATUS_NONE:
dict.Set("mixedContentStatus", "content-status-none");
break;
case security_state::CONTENT_STATUS_DISPLAYED:
dict.Set("mixedContentStatus", "content-status-displayed");
break;
case security_state::CONTENT_STATUS_RAN:
dict.Set("mixedContentStatus", "content-status-ran");
break;
case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
dict.Set("mixedContentStatus", "content-status-displayed-and-ran");
break;
}

// TODO(darkdh): add more info
return dict.GetHandle();
}
};

template<>
struct Converter<content::ServiceWorkerCapability> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
Expand Down Expand Up @@ -1360,15 +1413,15 @@ void WebContents::DidFinishNavigation(

void WebContents::DidChangeVisibleSecurityState() {
content::SecurityStyleExplanations explanations;
blink::WebSecurityStyle security_style =
web_contents()->GetDelegate()->GetSecurityStyle(
web_contents(), &explanations);
if (explanations.displayed_mixed_content &&
security_style == blink::kWebSecurityStyleNeutral) {
Emit("security-style-changed", "passive-mixed-content");
} else {
Emit("security-style-changed", security_style);
}
blink::WebSecurityStyle security_style = GetSecurityStyle(web_contents(),
&explanations);
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents());
DCHECK(helper);
security_state::SecurityInfo security_info;
helper->GetSecurityInfo(&security_info);

Emit("security-style-changed", security_style, security_info);
}

void WebContents::TitleWasSet(content::NavigationEntry* entry,
Expand Down
4 changes: 4 additions & 0 deletions atom/common/native_mate_converters/net_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ v8::Local<v8::Value> Converter<net::X509Certificate>::ToV8(
dict.Set("data", encoded_data);
dict.Set("issuerName", val.issuer().GetDisplayName());
dict.Set("subjectName", val.subject().GetDisplayName());
if (!val.subject().organization_names.empty())
dict.Set("organizationNames", val.subject().organization_names);
if (!val.subject().country_name.empty())
dict.Set("countryName", val.subject().country_name);
dict.Set("serialNumber", base::HexEncode(val.serial_number().data(),
val.serial_number().size()));
dict.Set("validStart", val.valid_start().ToDoubleT());
Expand Down
2 changes: 1 addition & 1 deletion lib/renderer/web-view/guest-view-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var WEB_VIEW_EVENTS = {
'plugin-crashed': ['name', 'version'],
'will-destroy': [],
'destroyed': [],
'security-style-changed': ['securityState'],
'security-style-changed': ['securityState', 'securityInfo'],
'page-favicon-updated': ['favicons'],
'enter-html-full-screen': [],
'leave-html-full-screen': [],
Expand Down