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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return base::android::ConvertUTF16ToJavaString( | 43 return base::android::ConvertUTF16ToJavaString( |
44 env, | 44 env, |
45 toolbar_model_->GetCorpusNameForMobile()); | 45 toolbar_model_->GetCorpusNameForMobile()); |
46 } | 46 } |
47 | 47 |
48 jboolean ToolbarModelAndroid::WouldReplaceURL(JNIEnv* env, jobject obj) { | 48 jboolean ToolbarModelAndroid::WouldReplaceURL(JNIEnv* env, jobject obj) { |
49 return toolbar_model_->WouldReplaceURL(); | 49 return toolbar_model_->WouldReplaceURL(); |
50 } | 50 } |
51 | 51 |
52 content::WebContents* ToolbarModelAndroid::GetActiveWebContents() const { | 52 content::WebContents* ToolbarModelAndroid::GetActiveWebContents() const { |
| 53 #if !defined(USE_AURA) |
53 JNIEnv* env = base::android::AttachCurrentThread(); | 54 JNIEnv* env = base::android::AttachCurrentThread(); |
54 ScopedJavaLocalRef<jobject> jdelegate = weak_java_delegate_.get(env); | 55 ScopedJavaLocalRef<jobject> jdelegate = weak_java_delegate_.get(env); |
55 if (!jdelegate.obj()) | 56 if (!jdelegate.obj()) |
56 return NULL; | 57 return NULL; |
57 ScopedJavaLocalRef<jobject> jweb_contents = | 58 ScopedJavaLocalRef<jobject> jweb_contents = |
58 Java_ToolbarModelDelegate_getActiveWebContents(env, jdelegate.obj()); | 59 Java_ToolbarModelDelegate_getActiveWebContents(env, jdelegate.obj()); |
59 return content::WebContents::FromJavaWebContents(jweb_contents.obj()); | 60 return content::WebContents::FromJavaWebContents(jweb_contents.obj()); |
| 61 #else |
| 62 return NULL; |
| 63 #endif |
60 } | 64 } |
61 | 65 |
62 // static | 66 // static |
63 bool ToolbarModelAndroid::RegisterToolbarModelAndroid(JNIEnv* env) { | 67 bool ToolbarModelAndroid::RegisterToolbarModelAndroid(JNIEnv* env) { |
64 return RegisterNativesImpl(env); | 68 return RegisterNativesImpl(env); |
65 } | 69 } |
66 | 70 |
67 // static | 71 // static |
68 jlong Init(JNIEnv* env, jobject obj, jobject delegate) { | 72 jlong Init(JNIEnv* env, jobject obj, jobject delegate) { |
69 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate); | 73 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate); |
70 return reinterpret_cast<intptr_t>(toolbar_model); | 74 return reinterpret_cast<intptr_t>(toolbar_model); |
71 } | 75 } |
72 | 76 |
73 // Temporary method to allow us to surface a SHA-1 deprecation string on Android | 77 // Temporary method to allow us to surface a SHA-1 deprecation string on Android |
74 // in M42. This duplicates a subset of the logic from | 78 // in M42. This duplicates a subset of the logic from |
75 // ToolbarModelImpl::GetSecurityLevelForWebContents() and | 79 // ToolbarModelImpl::GetSecurityLevelForWebContents() and |
76 // WebsiteSettings::Init(), which should really be refactored. | 80 // WebsiteSettings::Init(), which should really be refactored. |
77 // This is at the wrong layer, and needs to be refactored (along with desktop): | 81 // This is at the wrong layer, and needs to be refactored (along with desktop): |
78 // https://crbug.com/471390 | 82 // https://crbug.com/471390 |
79 | 83 |
80 // static | 84 // static |
81 jboolean IsDeprecatedSHA1Present(JNIEnv* env, | 85 jboolean IsDeprecatedSHA1Present(JNIEnv* env, |
82 jclass jcaller, | 86 jclass jcaller, |
83 jobject jweb_contents) { | 87 jobject jweb_contents) { |
| 88 #if !defined(USE_AURA) |
84 content::WebContents* web_contents = | 89 content::WebContents* web_contents = |
85 content::WebContents::FromJavaWebContents(jweb_contents); | 90 content::WebContents::FromJavaWebContents(jweb_contents); |
86 DCHECK(web_contents); | 91 DCHECK(web_contents); |
87 | 92 |
88 content::NavigationEntry* entry = | 93 content::NavigationEntry* entry = |
89 web_contents->GetController().GetVisibleEntry(); | 94 web_contents->GetController().GetVisibleEntry(); |
90 if (!entry) | 95 if (!entry) |
91 return false; | 96 return false; |
92 | 97 |
93 const content::SSLStatus& ssl = entry->GetSSL(); | 98 const content::SSLStatus& ssl = entry->GetSSL(); |
94 if (ssl.security_style == content::SECURITY_STYLE_AUTHENTICATED) { | 99 if (ssl.security_style == content::SECURITY_STYLE_AUTHENTICATED) { |
95 scoped_refptr<net::X509Certificate> cert; | 100 scoped_refptr<net::X509Certificate> cert; |
96 // NOTE: This constant needs to be kept in sync with | 101 // NOTE: This constant needs to be kept in sync with |
97 // ToolbarModelImpl::GetSecurityLevelForWebContents(). | 102 // ToolbarModelImpl::GetSecurityLevelForWebContents(). |
98 static const int64_t kJanuary2016 = INT64_C(13096080000000000); | 103 static const int64_t kJanuary2016 = INT64_C(13096080000000000); |
99 if (content::CertStore::GetInstance()->RetrieveCert(ssl.cert_id, &cert) && | 104 if (content::CertStore::GetInstance()->RetrieveCert(ssl.cert_id, &cert) && |
100 (ssl.cert_status & net::CERT_STATUS_SHA1_SIGNATURE_PRESENT) && | 105 (ssl.cert_status & net::CERT_STATUS_SHA1_SIGNATURE_PRESENT) && |
101 cert->valid_expiry() > base::Time::FromInternalValue(kJanuary2016)) { | 106 cert->valid_expiry() > base::Time::FromInternalValue(kJanuary2016)) { |
102 return true; | 107 return true; |
103 } | 108 } |
104 } | 109 } |
105 return false; | 110 return false; |
| 111 #else |
| 112 return false; |
| 113 #endif |
106 } | 114 } |
OLD | NEW |