| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/android/toolbar/toolbar_model_android.h" | 5 #include "chrome/browser/ui/android/toolbar/toolbar_model_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return RegisterNativesImpl(env); | 64 return RegisterNativesImpl(env); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // static | 67 // static |
| 68 jlong Init(JNIEnv* env, | 68 jlong Init(JNIEnv* env, |
| 69 const JavaParamRef<jobject>& obj, | 69 const JavaParamRef<jobject>& obj, |
| 70 const JavaParamRef<jobject>& delegate) { | 70 const JavaParamRef<jobject>& delegate) { |
| 71 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate); | 71 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate); |
| 72 return reinterpret_cast<intptr_t>(toolbar_model); | 72 return reinterpret_cast<intptr_t>(toolbar_model); |
| 73 } | 73 } |
| 74 | |
| 75 // Temporary method to allow us to surface a SHA-1 deprecation string on Android | |
| 76 // in M42. This duplicates a subset of the logic from | |
| 77 // ToolbarModelImpl::GetSecurityLevelForWebContents() and | |
| 78 // WebsiteSettings::Init(), which should really be refactored. | |
| 79 // This is at the wrong layer, and needs to be refactored (along with desktop): | |
| 80 // https://crbug.com/471390 | |
| 81 | |
| 82 // static | |
| 83 jboolean IsDeprecatedSHA1Present(JNIEnv* env, | |
| 84 const JavaParamRef<jclass>& jcaller, | |
| 85 const JavaParamRef<jobject>& jweb_contents) { | |
| 86 content::WebContents* web_contents = | |
| 87 content::WebContents::FromJavaWebContents(jweb_contents); | |
| 88 DCHECK(web_contents); | |
| 89 | |
| 90 content::NavigationEntry* entry = | |
| 91 web_contents->GetController().GetVisibleEntry(); | |
| 92 if (!entry) | |
| 93 return false; | |
| 94 | |
| 95 const content::SSLStatus& ssl = entry->GetSSL(); | |
| 96 if (ssl.security_style == content::SECURITY_STYLE_AUTHENTICATED) { | |
| 97 scoped_refptr<net::X509Certificate> cert; | |
| 98 // NOTE: This constant needs to be kept in sync with | |
| 99 // ToolbarModelImpl::GetSecurityLevelForWebContents(). | |
| 100 static const int64_t kJanuary2016 = INT64_C(13096080000000000); | |
| 101 if (content::CertStore::GetInstance()->RetrieveCert(ssl.cert_id, &cert) && | |
| 102 (ssl.cert_status & net::CERT_STATUS_SHA1_SIGNATURE_PRESENT) && | |
| 103 cert->valid_expiry() > base::Time::FromInternalValue(kJanuary2016)) { | |
| 104 return true; | |
| 105 } | |
| 106 } | |
| 107 return false; | |
| 108 } | |
| OLD | NEW |