Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/ui/android/website_settings_popup_android.cc

Issue 14772036: Let Android port access properly sized images (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed header guard comment Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 96
98 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {} 97 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {}
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();
106 ResourceMapper id_mapper;
107 107
108 { 108 {
109 const gfx::Image& icon_image = WebsiteSettingsUI::GetIdentityIcon( 109 int icon_id = id_mapper.MapFromChromiumID(
110 identity_info.identity_status); 110 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 111
115 // The headline and the certificate dialog link of the site's identity 112 // 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 113 // 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 114 // site's identity was verified, then the headline contains the organization
118 // name from the provided certificate. If the organization name is not 115 // name from the provided certificate. If the organization name is not
119 // available than the hostname of the site is used instead. 116 // available than the hostname of the site is used instead.
120 std::string headline; 117 std::string headline;
121 if (identity_info.cert_id) { 118 if (identity_info.cert_id) {
122 headline = identity_info.site_identity; 119 headline = identity_info.site_identity;
123 } 120 }
124 121
125 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( 122 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString(
126 env, identity_info.identity_status_description); 123 env, identity_info.identity_status_description);
127 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon.obj(), 124 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon_id,
128 ConvertUTF8ToJavaString(env, headline).obj(), description.obj()); 125 ConvertUTF8ToJavaString(env, headline).obj(), description.obj());
129 126
130 string16 certificate_label = 127 string16 certificate_label =
131 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); 128 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON);
132 if (!certificate_label.empty()) { 129 if (!certificate_label.empty()) {
133 Java_WebsiteSettingsPopup_setCertificateViewer(env, popup_jobject_.obj(), 130 Java_WebsiteSettingsPopup_setCertificateViewer(env, popup_jobject_.obj(),
134 ConvertUTF16ToJavaString(env, certificate_label).obj()); 131 ConvertUTF16ToJavaString(env, certificate_label).obj());
135 } 132 }
136 133
137 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj()); 134 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj());
138 } 135 }
139 136
140 { 137 {
141 const gfx::Image& icon_image = WebsiteSettingsUI::GetConnectionIcon( 138 int icon_id = id_mapper.MapFromChromiumID(
142 identity_info.connection_status); 139 WebsiteSettingsUI::GetConnectionIconID(
143 ScopedJavaLocalRef<jobject> icon = ConvertToJavaBitmap( 140 identity_info.connection_status));
144 icon_image.ToSkBitmap());
145 141
146 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( 142 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString(
147 env, identity_info.connection_status_description); 143 env, identity_info.connection_status_description);
148 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon.obj(), 144 Java_WebsiteSettingsPopup_addSection(env, popup_jobject_.obj(), icon_id,
149 NULL, description.obj()); 145 NULL, description.obj());
150 146
151 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj()); 147 Java_WebsiteSettingsPopup_addDivider(env, popup_jobject_.obj());
152 } 148 }
153 149
154 Java_WebsiteSettingsPopup_addMoreInfoLink(env, popup_jobject_.obj(), 150 Java_WebsiteSettingsPopup_addMoreInfoLink(env, popup_jobject_.obj(),
155 ConvertUTF8ToJavaString( 151 ConvertUTF8ToJavaString(
156 env, l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)).obj()); 152 env, l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)).obj());
157 Java_WebsiteSettingsPopup_show(env, popup_jobject_.obj()); 153 Java_WebsiteSettingsPopup_show(env, popup_jobject_.obj());
158 } 154 }
159 155
160 void WebsiteSettingsPopupAndroid::SetCookieInfo( 156 void WebsiteSettingsPopupAndroid::SetCookieInfo(
161 const CookieInfoList& cookie_info_list) { 157 const CookieInfoList& cookie_info_list) {
(...skipping 14 matching lines...) Expand all
176 void WebsiteSettingsPopupAndroid::SetFirstVisit( 172 void WebsiteSettingsPopupAndroid::SetFirstVisit(
177 const string16& first_visit) { 173 const string16& first_visit) {
178 NOTIMPLEMENTED(); 174 NOTIMPLEMENTED();
179 } 175 }
180 176
181 // static 177 // static
182 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( 178 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid(
183 JNIEnv* env) { 179 JNIEnv* env) {
184 return RegisterNativesImpl(env); 180 return RegisterNativesImpl(env);
185 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698