Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ssl / security_state_model_android.cc
blob50448899e86fe9aaf64f1fd776b9e80a0f177f9b
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"
12 // static
13 bool RegisterSecurityStateModelAndroid(JNIEnv* env) {
14 return RegisterNativesImpl(env);
17 // static
18 jint GetSecurityLevelForWebContents(
19 JNIEnv* env,
20 const JavaParamRef<jclass>& jcaller,
21 const JavaParamRef<jobject>& jweb_contents) {
22 content::WebContents* web_contents =
23 content::WebContents::FromJavaWebContents(jweb_contents);
24 DCHECK(web_contents);
25 SecurityStateModel::CreateForWebContents(web_contents);
26 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents);
27 DCHECK(model);
28 return model->security_info().security_level;
31 // static
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);
37 DCHECK(web_contents);
38 SecurityStateModel::CreateForWebContents(web_contents);
39 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents);
40 DCHECK(model);
41 return model->security_info().sha1_deprecation_status !=
42 SecurityStateModel::NO_DEPRECATED_SHA1;
45 // static
46 jboolean IsPassiveMixedContentPresent(
47 JNIEnv* env,
48 const JavaParamRef<jclass>& jcaller,
49 const JavaParamRef<jobject>& jweb_contents) {
50 content::WebContents* web_contents =
51 content::WebContents::FromJavaWebContents(jweb_contents);
52 DCHECK(web_contents);
53 SecurityStateModel::CreateForWebContents(web_contents);
54 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents);
55 DCHECK(model);
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;