| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ssl/security_state_model_android.h" | 5 #include "chrome/browser/ssl/security_state_model_android.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 8 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 9 #include "components/security_state/core/security_state.h" |
| 9 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 10 #include "jni/SecurityStateModel_jni.h" | 11 #include "jni/SecurityStateModel_jni.h" |
| 11 | 12 |
| 12 using base::android::JavaParamRef; | 13 using base::android::JavaParamRef; |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 bool RegisterSecurityStateModelAndroid(JNIEnv* env) { | 16 bool RegisterSecurityStateModelAndroid(JNIEnv* env) { |
| 16 return RegisterNativesImpl(env); | 17 return RegisterNativesImpl(env); |
| 17 } | 18 } |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 jint GetSecurityLevelForWebContents( | 21 jint GetSecurityLevelForWebContents( |
| 21 JNIEnv* env, | 22 JNIEnv* env, |
| 22 const JavaParamRef<jclass>& jcaller, | 23 const JavaParamRef<jclass>& jcaller, |
| 23 const JavaParamRef<jobject>& jweb_contents) { | 24 const JavaParamRef<jobject>& jweb_contents) { |
| 24 content::WebContents* web_contents = | 25 content::WebContents* web_contents = |
| 25 content::WebContents::FromJavaWebContents(jweb_contents); | 26 content::WebContents::FromJavaWebContents(jweb_contents); |
| 26 DCHECK(web_contents); | 27 DCHECK(web_contents); |
| 27 ChromeSecurityStateModelClient::CreateForWebContents(web_contents); | 28 SecurityStateTabHelper::CreateForWebContents(web_contents); |
| 28 ChromeSecurityStateModelClient* model_client = | 29 SecurityStateTabHelper* helper = |
| 29 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 30 SecurityStateTabHelper::FromWebContents(web_contents); |
| 30 DCHECK(model_client); | 31 DCHECK(helper); |
| 31 security_state::SecurityStateModel::SecurityInfo security_info; | 32 security_state::SecurityInfo security_info; |
| 32 model_client->GetSecurityInfo(&security_info); | 33 helper->GetSecurityInfo(&security_info); |
| 33 return security_info.security_level; | 34 return security_info.security_level; |
| 34 } | 35 } |
| 35 | 36 |
| 36 // static | 37 // static |
| 37 jboolean IsDeprecatedSHA1Present(JNIEnv* env, | 38 jboolean IsDeprecatedSHA1Present(JNIEnv* env, |
| 38 const JavaParamRef<jclass>& jcaller, | 39 const JavaParamRef<jclass>& jcaller, |
| 39 const JavaParamRef<jobject>& jweb_contents) { | 40 const JavaParamRef<jobject>& jweb_contents) { |
| 40 content::WebContents* web_contents = | 41 content::WebContents* web_contents = |
| 41 content::WebContents::FromJavaWebContents(jweb_contents); | 42 content::WebContents::FromJavaWebContents(jweb_contents); |
| 42 DCHECK(web_contents); | 43 DCHECK(web_contents); |
| 43 ChromeSecurityStateModelClient::CreateForWebContents(web_contents); | 44 SecurityStateTabHelper::CreateForWebContents(web_contents); |
| 44 ChromeSecurityStateModelClient* model_client = | 45 SecurityStateTabHelper* helper = |
| 45 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 46 SecurityStateTabHelper::FromWebContents(web_contents); |
| 46 DCHECK(model_client); | 47 DCHECK(helper); |
| 47 security_state::SecurityStateModel::SecurityInfo security_info; | 48 security_state::SecurityInfo security_info; |
| 48 model_client->GetSecurityInfo(&security_info); | 49 helper->GetSecurityInfo(&security_info); |
| 49 return security_info.sha1_deprecation_status != | 50 return security_info.sha1_deprecation_status != |
| 50 security_state::SecurityStateModel::NO_DEPRECATED_SHA1; | 51 security_state::NO_DEPRECATED_SHA1; |
| 51 } | 52 } |
| 52 | 53 |
| 53 // static | 54 // static |
| 54 jboolean IsPassiveMixedContentPresent( | 55 jboolean IsPassiveMixedContentPresent( |
| 55 JNIEnv* env, | 56 JNIEnv* env, |
| 56 const JavaParamRef<jclass>& jcaller, | 57 const JavaParamRef<jclass>& jcaller, |
| 57 const JavaParamRef<jobject>& jweb_contents) { | 58 const JavaParamRef<jobject>& jweb_contents) { |
| 58 content::WebContents* web_contents = | 59 content::WebContents* web_contents = |
| 59 content::WebContents::FromJavaWebContents(jweb_contents); | 60 content::WebContents::FromJavaWebContents(jweb_contents); |
| 60 DCHECK(web_contents); | 61 DCHECK(web_contents); |
| 61 ChromeSecurityStateModelClient::CreateForWebContents(web_contents); | 62 SecurityStateTabHelper::CreateForWebContents(web_contents); |
| 62 ChromeSecurityStateModelClient* model_client = | 63 SecurityStateTabHelper* helper = |
| 63 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 64 SecurityStateTabHelper::FromWebContents(web_contents); |
| 64 DCHECK(model_client); | 65 DCHECK(helper); |
| 65 security_state::SecurityStateModel::SecurityInfo security_info; | 66 security_state::SecurityInfo security_info; |
| 66 model_client->GetSecurityInfo(&security_info); | 67 helper->GetSecurityInfo(&security_info); |
| 67 return security_info.mixed_content_status == | 68 return security_info.mixed_content_status == |
| 68 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED || | 69 security_state::CONTENT_STATUS_DISPLAYED || |
| 69 security_info.mixed_content_status == | 70 security_info.mixed_content_status == |
| 70 security_state::SecurityStateModel:: | 71 security_state::CONTENT_STATUS_DISPLAYED_AND_RAN; |
| 71 CONTENT_STATUS_DISPLAYED_AND_RAN; | |
| 72 } | 72 } |
| OLD | NEW |