OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/ssl/security_state_model_android.h" |
| 6 |
| 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" |
| 11 |
| 12 // static |
| 13 bool RegisterSecurityStateModelAndroid(JNIEnv* env) { |
| 14 return RegisterNativesImpl(env); |
| 15 } |
| 16 |
| 17 // static |
| 18 void SecurityStateChanged(JNIEnv* env, jclass jcaller, jobject jweb_contents) { |
| 19 content::WebContents* web_contents = |
| 20 content::WebContents::FromJavaWebContents(jweb_contents); |
| 21 DCHECK(web_contents); |
| 22 SecurityStateModel::CreateForWebContents(web_contents); |
| 23 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents); |
| 24 DCHECK(model); |
| 25 model->SecurityStateChanged(); |
| 26 } |
| 27 |
| 28 // static |
| 29 jint GetSecurityLevelForWebContents(JNIEnv* env, |
| 30 jclass jcaller, |
| 31 jobject jweb_contents) { |
| 32 content::WebContents* web_contents = |
| 33 content::WebContents::FromJavaWebContents(jweb_contents); |
| 34 DCHECK(web_contents); |
| 35 SecurityStateModel::CreateForWebContents(web_contents); |
| 36 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents); |
| 37 DCHECK(model); |
| 38 return model->security_info().security_level; |
| 39 } |
| 40 |
| 41 // static |
| 42 jboolean IsDeprecatedSHA1Present(JNIEnv* env, |
| 43 jclass jcaller, |
| 44 jobject jweb_contents) { |
| 45 content::WebContents* web_contents = |
| 46 content::WebContents::FromJavaWebContents(jweb_contents); |
| 47 DCHECK(web_contents); |
| 48 SecurityStateModel::CreateForWebContents(web_contents); |
| 49 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents); |
| 50 DCHECK(model); |
| 51 return model->security_info().sha1_deprecation_status != |
| 52 SecurityStateModel::NO_DEPRECATED_SHA1; |
| 53 } |
| 54 |
| 55 // static |
| 56 jboolean IsPassiveMixedContentPresent(JNIEnv* env, |
| 57 jclass jcaller, |
| 58 jobject jweb_contents) { |
| 59 content::WebContents* web_contents = |
| 60 content::WebContents::FromJavaWebContents(jweb_contents); |
| 61 DCHECK(web_contents); |
| 62 SecurityStateModel::CreateForWebContents(web_contents); |
| 63 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents); |
| 64 DCHECK(model); |
| 65 return model->security_info().mixed_content_status == |
| 66 SecurityStateModel::DISPLAYED_MIXED_CONTENT || |
| 67 model->security_info().mixed_content_status == |
| 68 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; |
| 69 } |
OLD | NEW |