| 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 "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "jni/SecurityStateModel_jni.h" | 10 #include "jni/SecurityStateModel_jni.h" |
| 11 | 11 |
| 12 using base::android::JavaParamRef; | 12 using base::android::JavaParamRef; |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 bool RegisterSecurityStateModelAndroid(JNIEnv* env) { | 15 bool RegisterSecurityStateModelAndroid(JNIEnv* env) { |
| 16 return RegisterNativesImpl(env); | 16 return RegisterNativesImpl(env); |
| 17 } | 17 } |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 jint GetSecurityLevelForWebContents( | 20 jint GetSecurityLevelForWebContents( |
| 21 JNIEnv* env, | 21 JNIEnv* env, |
| 22 const JavaParamRef<jclass>& jcaller, | 22 const JavaParamRef<jclass>& jcaller, |
| 23 const JavaParamRef<jobject>& jweb_contents) { | 23 const JavaParamRef<jobject>& jweb_contents) { |
| 24 content::WebContents* web_contents = | 24 content::WebContents* web_contents = |
| 25 content::WebContents::FromJavaWebContents(jweb_contents); | 25 content::WebContents::FromJavaWebContents(jweb_contents); |
| 26 DCHECK(web_contents); | 26 DCHECK(web_contents); |
| 27 ChromeSecurityStateModelClient::CreateForWebContents(web_contents); | 27 SecurityStateTabHelper::CreateForWebContents(web_contents); |
| 28 ChromeSecurityStateModelClient* model_client = | 28 SecurityStateTabHelper* helper = |
| 29 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 29 SecurityStateTabHelper::FromWebContents(web_contents); |
| 30 DCHECK(model_client); | 30 DCHECK(helper); |
| 31 security_state::SecurityStateModel::SecurityInfo security_info; | 31 security_state::SecurityStateModel::SecurityInfo security_info; |
| 32 model_client->GetSecurityInfo(&security_info); | 32 helper->GetSecurityInfo(&security_info); |
| 33 return security_info.security_level; | 33 return security_info.security_level; |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 jboolean IsDeprecatedSHA1Present(JNIEnv* env, | 37 jboolean IsDeprecatedSHA1Present(JNIEnv* env, |
| 38 const JavaParamRef<jclass>& jcaller, | 38 const JavaParamRef<jclass>& jcaller, |
| 39 const JavaParamRef<jobject>& jweb_contents) { | 39 const JavaParamRef<jobject>& jweb_contents) { |
| 40 content::WebContents* web_contents = | 40 content::WebContents* web_contents = |
| 41 content::WebContents::FromJavaWebContents(jweb_contents); | 41 content::WebContents::FromJavaWebContents(jweb_contents); |
| 42 DCHECK(web_contents); | 42 DCHECK(web_contents); |
| 43 ChromeSecurityStateModelClient::CreateForWebContents(web_contents); | 43 SecurityStateTabHelper::CreateForWebContents(web_contents); |
| 44 ChromeSecurityStateModelClient* model_client = | 44 SecurityStateTabHelper* helper = |
| 45 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 45 SecurityStateTabHelper::FromWebContents(web_contents); |
| 46 DCHECK(model_client); | 46 DCHECK(helper); |
| 47 security_state::SecurityStateModel::SecurityInfo security_info; | 47 security_state::SecurityStateModel::SecurityInfo security_info; |
| 48 model_client->GetSecurityInfo(&security_info); | 48 helper->GetSecurityInfo(&security_info); |
| 49 return security_info.sha1_deprecation_status != | 49 return security_info.sha1_deprecation_status != |
| 50 security_state::SecurityStateModel::NO_DEPRECATED_SHA1; | 50 security_state::SecurityStateModel::NO_DEPRECATED_SHA1; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 jboolean IsPassiveMixedContentPresent( | 54 jboolean IsPassiveMixedContentPresent( |
| 55 JNIEnv* env, | 55 JNIEnv* env, |
| 56 const JavaParamRef<jclass>& jcaller, | 56 const JavaParamRef<jclass>& jcaller, |
| 57 const JavaParamRef<jobject>& jweb_contents) { | 57 const JavaParamRef<jobject>& jweb_contents) { |
| 58 content::WebContents* web_contents = | 58 content::WebContents* web_contents = |
| 59 content::WebContents::FromJavaWebContents(jweb_contents); | 59 content::WebContents::FromJavaWebContents(jweb_contents); |
| 60 DCHECK(web_contents); | 60 DCHECK(web_contents); |
| 61 ChromeSecurityStateModelClient::CreateForWebContents(web_contents); | 61 SecurityStateTabHelper::CreateForWebContents(web_contents); |
| 62 ChromeSecurityStateModelClient* model_client = | 62 SecurityStateTabHelper* helper = |
| 63 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 63 SecurityStateTabHelper::FromWebContents(web_contents); |
| 64 DCHECK(model_client); | 64 DCHECK(helper); |
| 65 security_state::SecurityStateModel::SecurityInfo security_info; | 65 security_state::SecurityStateModel::SecurityInfo security_info; |
| 66 model_client->GetSecurityInfo(&security_info); | 66 helper->GetSecurityInfo(&security_info); |
| 67 return security_info.mixed_content_status == | 67 return security_info.mixed_content_status == |
| 68 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED || | 68 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED || |
| 69 security_info.mixed_content_status == | 69 security_info.mixed_content_status == |
| 70 security_state::SecurityStateModel:: | 70 security_state::SecurityStateModel:: |
| 71 CONTENT_STATUS_DISPLAYED_AND_RAN; | 71 CONTENT_STATUS_DISPLAYED_AND_RAN; |
| 72 } | 72 } |
| OLD | NEW |