|
72 | 72 | #include "content/public/browser/render_widget_host.h"
|
73 | 73 | #include "content/public/browser/render_widget_host_view.h"
|
74 | 74 | #include "content/public/browser/resource_request_details.h"
|
| 75 | +#include "content/public/browser/security_style_explanations.h" |
75 | 76 | #include "content/public/browser/service_worker_context.h"
|
76 | 77 | #include "content/public/browser/site_instance.h"
|
77 | 78 | #include "content/public/browser/storage_partition.h"
|
@@ -199,6 +200,51 @@ struct Converter<atom::api::WebContents::Type> {
|
199 | 200 | }
|
200 | 201 | };
|
201 | 202 |
|
| 203 | +template<> |
| 204 | +struct Converter<content::SecurityStyle> { |
| 205 | + static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, |
| 206 | + content::SecurityStyle val) { |
| 207 | + std::string type; |
| 208 | + switch (val) { |
| 209 | + case content::SECURITY_STYLE_UNAUTHENTICATED: |
| 210 | + type = "insecure"; |
| 211 | + break; |
| 212 | + case content::SECURITY_STYLE_AUTHENTICATION_BROKEN: |
| 213 | + type = "broken"; |
| 214 | + break; |
| 215 | + case content::SECURITY_STYLE_WARNING: |
| 216 | + type = "warning"; |
| 217 | + break; |
| 218 | + case content::SECURITY_STYLE_AUTHENTICATED: |
| 219 | + type = "secure"; |
| 220 | + break; |
| 221 | + default: |
| 222 | + type = "unknown"; |
| 223 | + break; |
| 224 | + } |
| 225 | + return mate::ConvertToV8(isolate, type); |
| 226 | + } |
| 227 | + |
| 228 | + static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, |
| 229 | + content::SecurityStyle* out) { |
| 230 | + std::string type; |
| 231 | + if (!ConvertFromV8(isolate, val, &type)) |
| 232 | + return false; |
| 233 | + if (type == "insecure") { |
| 234 | + *out = content::SECURITY_STYLE_UNAUTHENTICATED; |
| 235 | + } else if (type == "broken") { |
| 236 | + *out = content::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 237 | + } else if (type == "warning") { |
| 238 | + *out = content::SECURITY_STYLE_WARNING; |
| 239 | + } else if (type == "secure") { |
| 240 | + *out = content::SECURITY_STYLE_AUTHENTICATED; |
| 241 | + } else { |
| 242 | + return false; |
| 243 | + } |
| 244 | + return true; |
| 245 | + } |
| 246 | +}; |
| 247 | + |
202 | 248 | } // namespace mate
|
203 | 249 |
|
204 | 250 |
|
@@ -893,21 +939,13 @@ void WebContents::DidFinishNavigation(
|
893 | 939 | void WebContents::SecurityStyleChanged(
|
894 | 940 | content::SecurityStyle security_style,
|
895 | 941 | const content::SecurityStyleExplanations& explanations) {
|
896 |
| - std::string type = "unknown"; |
897 |
| - switch (security_style) { |
898 |
| - case content::SECURITY_STYLE_UNAUTHENTICATED: |
899 |
| - case content::SECURITY_STYLE_AUTHENTICATION_BROKEN: |
900 |
| - type = "insecure"; |
901 |
| - break; |
902 |
| - case content::SECURITY_STYLE_WARNING: |
903 |
| - type = "warning"; |
904 |
| - break; |
905 |
| - case content::SECURITY_STYLE_AUTHENTICATED: |
906 |
| - type = "secure"; |
907 |
| - break; |
908 |
| - default: break; |
| 942 | + if (explanations.ran_insecure_content) { |
| 943 | + Emit("security-style-changed", "active-mixed-content"); |
| 944 | + } else if (explanations.displayed_insecure_content) { |
| 945 | + Emit("security-style-changed", "passive-mixed-content"); |
| 946 | + } else { |
| 947 | + Emit("security-style-changed", security_style); |
909 | 948 | }
|
910 |
| - Emit("did-change-security", type); |
911 | 949 | }
|
912 | 950 |
|
913 | 951 | void WebContents::TitleWasSet(content::NavigationEntry* entry,
|
|
0 commit comments