1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ssl/security_state_model_android.h"
7 #include "base/logging.h"
8 #include "chrome/browser/ssl/security_state_model.h"
9 #include "content/public/browser/web_contents.h"
10 #include "jni/SecurityStateModel_jni.h"
13 bool RegisterSecurityStateModelAndroid(JNIEnv
* env
) {
14 return RegisterNativesImpl(env
);
18 jint
GetSecurityLevelForWebContents(
20 const JavaParamRef
<jclass
>& jcaller
,
21 const JavaParamRef
<jobject
>& jweb_contents
) {
22 content::WebContents
* web_contents
=
23 content::WebContents::FromJavaWebContents(jweb_contents
);
25 SecurityStateModel::CreateForWebContents(web_contents
);
26 SecurityStateModel
* model
= SecurityStateModel::FromWebContents(web_contents
);
28 return model
->security_info().security_level
;
32 jboolean
IsDeprecatedSHA1Present(JNIEnv
* env
,
33 const JavaParamRef
<jclass
>& jcaller
,
34 const JavaParamRef
<jobject
>& jweb_contents
) {
35 content::WebContents
* web_contents
=
36 content::WebContents::FromJavaWebContents(jweb_contents
);
38 SecurityStateModel::CreateForWebContents(web_contents
);
39 SecurityStateModel
* model
= SecurityStateModel::FromWebContents(web_contents
);
41 return model
->security_info().sha1_deprecation_status
!=
42 SecurityStateModel::NO_DEPRECATED_SHA1
;
46 jboolean
IsPassiveMixedContentPresent(
48 const JavaParamRef
<jclass
>& jcaller
,
49 const JavaParamRef
<jobject
>& jweb_contents
) {
50 content::WebContents
* web_contents
=
51 content::WebContents::FromJavaWebContents(jweb_contents
);
53 SecurityStateModel::CreateForWebContents(web_contents
);
54 SecurityStateModel
* model
= SecurityStateModel::FromWebContents(web_contents
);
56 return model
->security_info().mixed_content_status
==
57 SecurityStateModel::DISPLAYED_MIXED_CONTENT
||
58 model
->security_info().mixed_content_status
==
59 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT
;