OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/website_settings_popup_android.h" | 5 #include "chrome/browser/ui/android/website_settings_popup_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "chrome/browser/android/resource_mapper.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/website_settings/website_settings.h" | 13 #include "chrome/browser/ui/website_settings/website_settings.h" |
13 #include "content/public/browser/android/content_view_core.h" | 14 #include "content/public/browser/android/content_view_core.h" |
14 #include "content/public/browser/cert_store.h" | 15 #include "content/public/browser/cert_store.h" |
15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/ssl_status.h" | 19 #include "content/public/common/ssl_status.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "jni/WebsiteSettingsPopup_jni.h" | 21 #include "jni/WebsiteSettingsPopup_jni.h" |
21 #include "net/cert/x509_certificate.h" | 22 #include "net/cert/x509_certificate.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/gfx/android/java_bitmap.h" | |
24 | 24 |
25 using base::android::CheckException; | 25 using base::android::CheckException; |
26 using base::android::ConvertUTF8ToJavaString; | 26 using base::android::ConvertUTF8ToJavaString; |
27 using base::android::ConvertUTF16ToJavaString; | 27 using base::android::ConvertUTF16ToJavaString; |
28 using base::android::GetClass; | 28 using base::android::GetClass; |
29 using base::android::ScopedJavaLocalRef; | 29 using base::android::ScopedJavaLocalRef; |
30 using content::CertStore; | 30 using content::CertStore; |
31 using content::WebContents; | 31 using content::WebContents; |
32 using gfx::ConvertToJavaBitmap; | |
33 | 32 |
34 static jobjectArray GetCertificateChain(JNIEnv* env, | 33 static jobjectArray GetCertificateChain(JNIEnv* env, |
35 jobject obj, | 34 jobject obj, |
36 jobject view) { | 35 jobject view) { |
37 content::WebContents* contents = | 36 content::WebContents* contents = |
38 content::ContentViewCore::GetNativeContentViewCore(env, view)-> | 37 content::ContentViewCore::GetNativeContentViewCore(env, view)-> |
39 GetWebContents(); | 38 GetWebContents(); |
40 int cert_id = contents->GetController().GetActiveEntry()->GetSSL().cert_id; | 39 int cert_id = contents->GetController().GetActiveEntry()->GetSSL().cert_id; |
41 scoped_refptr<net::X509Certificate> cert; | 40 scoped_refptr<net::X509Certificate> cert; |
42 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert); | 41 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 98 |
100 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { | 99 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { |
101 delete this; | 100 delete this; |
102 } | 101 } |
103 | 102 |
104 void WebsiteSettingsPopupAndroid::SetIdentityInfo( | 103 void WebsiteSettingsPopupAndroid::SetIdentityInfo( |
105 const IdentityInfo& identity_info) { | 104 const IdentityInfo& identity_info) { |
106 JNIEnv* env = base::android::AttachCurrentThread(); | 105 JNIEnv* env = base::android::AttachCurrentThread(); |
107 | 106 |
108 { | 107 { |
109 const gfx::Image& icon_image = WebsiteSettingsUI::GetIdentityIcon( | 108 int icon_id = ResourceMapper::MapFromChromiumId( |
110 identity_info.identity_status); | 109 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); |
111 // Creates a java version of the bitmap and makes a copy of the pixels | |
112 ScopedJavaLocalRef<jobject> icon = ConvertToJavaBitmap( | |
113 icon_image.ToSkBitmap()); | |
114 | 110 |
115 // The headline and the certificate dialog link of the site's identity | 111 // The headline and the certificate dialog link of the site's identity |
116 // section is only displayed if the site's identity was verified. If the | 112 // section is only displayed if the site's identity was verified. If the |
117 // site's identity was verified, then the headline contains the organization | 113 // site's identity was verified, then the headline contains the organization |
118 // name from the provided certificate. If the organization name is not | 114 // name from the provided certificate. If the organization name is not |
119 // available than the hostname of the site is used instead. | 115 // available than the hostname of the site is used instead. |
120 std::string headline; | 116 std::string headline; |
121 if (identity_info.cert_id) { | 117 if (identity_info.cert_id) { |
122 headline = identity_info.site_identity; | 118 headline = identity_info.site_identity; |
123 } | 119 } |
124 | 120 |
125 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 121 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
126 env, identity_info.identity_status_description); | 122 env, identity_info.identity_status_description); |
127 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon.obj(), | 123 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon_id, |
128 ConvertUTF8ToJavaString(env, headline).obj(), description.obj()); | 124 ConvertUTF8ToJavaString(env, headline).obj(), description.obj()); |
129 | 125 |
130 string16 certificate_label = | 126 string16 certificate_label = |
131 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); | 127 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); |
132 if (!certificate_label.empty()) { | 128 if (!certificate_label.empty()) { |
133 Java_WebsiteSettingsPopup_setCertificateViewer(env, popup_jobject_.obj(), | 129 Java_WebsiteSettingsPopup_setCertificateViewer(env, popup_jobject_.obj(), |
134 ConvertUTF16ToJavaString(env, certificate_label).obj()); | 130 ConvertUTF16ToJavaString(env, certificate_label).obj()); |
135 } | 131 } |
136 | 132 |
137 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj()); | 133 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj()); |
138 } | 134 } |
139 | 135 |
140 { | 136 { |
141 const gfx::Image& icon_image = WebsiteSettingsUI::GetConnectionIcon( | 137 int icon_id = ResourceMapper::MapFromChromiumId( |
142 identity_info.connection_status); | 138 WebsiteSettingsUI::GetConnectionIconID( |
143 ScopedJavaLocalRef<jobject> icon = ConvertToJavaBitmap( | 139 identity_info.connection_status)); |
144 icon_image.ToSkBitmap()); | |
145 | 140 |
146 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 141 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
147 env, identity_info.connection_status_description); | 142 env, identity_info.connection_status_description); |
148 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon.obj(), | 143 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon_id, |
149 NULL, description.obj()); | 144 NULL, description.obj()); |
150 | 145 |
151 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj()); | 146 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj()); |
152 } | 147 } |
153 | 148 |
154 Java_WebsiteSettingsPopup_addMoreInfoLink(env, popup_jobject_.obj(), | 149 Java_WebsiteSettingsPopup_addMoreInfoLink(env, popup_jobject_.obj(), |
155 ConvertUTF8ToJavaString( | 150 ConvertUTF8ToJavaString( |
156 env, l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)).obj()); | 151 env, l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)).obj()); |
157 Java_WebsiteSettingsPopup_show(env, popup_jobject_.obj()); | 152 Java_WebsiteSettingsPopup_show(env, popup_jobject_.obj()); |
158 } | 153 } |
159 | 154 |
160 void WebsiteSettingsPopupAndroid::SetCookieInfo( | 155 void WebsiteSettingsPopupAndroid::SetCookieInfo( |
161 const CookieInfoList& cookie_info_list) { | 156 const CookieInfoList& cookie_info_list) { |
(...skipping 14 matching lines...) Expand all Loading... |
176 void WebsiteSettingsPopupAndroid::SetFirstVisit( | 171 void WebsiteSettingsPopupAndroid::SetFirstVisit( |
177 const string16& first_visit) { | 172 const string16& first_visit) { |
178 NOTIMPLEMENTED(); | 173 NOTIMPLEMENTED(); |
179 } | 174 } |
180 | 175 |
181 // static | 176 // static |
182 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( | 177 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( |
183 JNIEnv* env) { | 178 JNIEnv* env) { |
184 return RegisterNativesImpl(env); | 179 return RegisterNativesImpl(env); |
185 } | 180 } |
OLD | NEW |