blob: 5f1c1786aad008109491a0c18887d3960ca467ed [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ssl/security_state_model_android.h"
#include "base/logging.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "components/security_state/core/security_state.h"
#include "content/public/browser/web_contents.h"
#include "jni/SecurityStateModel_jni.h"
using base::android::JavaParamRef;
// static
bool RegisterSecurityStateModelAndroid(JNIEnv* env) {
return RegisterNativesImpl(env);
}
// static
jint GetSecurityLevelForWebContents(
JNIEnv* env,
const JavaParamRef<jclass>& jcaller,
const JavaParamRef<jobject>& jweb_contents) {
content::WebContents* web_contents =
content::WebContents::FromJavaWebContents(jweb_contents);
DCHECK(web_contents);
SecurityStateTabHelper::CreateForWebContents(web_contents);
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
security_state::SecurityInfo security_info;
helper->GetSecurityInfo(&security_info);
return security_info.security_level;
}