OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/page_info/connection_info_popup_android.h" | 5 #include "chrome/browser/ui/android/page_info/connection_info_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/android/resource_mapper.h" |
11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ssl/security_state_tab_helper.h" | 13 #include "chrome/browser/ssl/security_state_tab_helper.h" |
14 #include "chrome/browser/ui/page_info/website_settings.h" | 14 #include "chrome/browser/ui/page_info/page_info.h" |
15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
16 #include "components/security_state/core/security_state.h" | 16 #include "components/security_state/core/security_state.h" |
17 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/ssl_status.h" | 21 #include "content/public/browser/ssl_status.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "jni/ConnectionInfoPopup_jni.h" | 23 #include "jni/ConnectionInfoPopup_jni.h" |
24 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
(...skipping 14 matching lines...) Expand all Loading... |
39 const JavaParamRef<jobject>& java_web_contents) { | 39 const JavaParamRef<jobject>& java_web_contents) { |
40 content::WebContents* web_contents = | 40 content::WebContents* web_contents = |
41 content::WebContents::FromJavaWebContents(java_web_contents); | 41 content::WebContents::FromJavaWebContents(java_web_contents); |
42 | 42 |
43 return reinterpret_cast<intptr_t>( | 43 return reinterpret_cast<intptr_t>( |
44 new ConnectionInfoPopupAndroid(env, obj, web_contents)); | 44 new ConnectionInfoPopupAndroid(env, obj, web_contents)); |
45 } | 45 } |
46 | 46 |
47 ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid( | 47 ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid( |
48 JNIEnv* env, | 48 JNIEnv* env, |
49 jobject java_website_settings_pop, | 49 jobject java_page_info_pop, |
50 WebContents* web_contents) { | 50 WebContents* web_contents) { |
51 // Important to use GetVisibleEntry to match what's showing in the omnibox. | 51 // Important to use GetVisibleEntry to match what's showing in the omnibox. |
52 content::NavigationEntry* nav_entry = | 52 content::NavigationEntry* nav_entry = |
53 web_contents->GetController().GetVisibleEntry(); | 53 web_contents->GetController().GetVisibleEntry(); |
54 if (nav_entry == nullptr) | 54 if (nav_entry == nullptr) |
55 return; | 55 return; |
56 | 56 |
57 popup_jobject_.Reset(env, java_website_settings_pop); | 57 popup_jobject_.Reset(env, java_page_info_pop); |
58 | 58 |
59 SecurityStateTabHelper* helper = | 59 SecurityStateTabHelper* helper = |
60 SecurityStateTabHelper::FromWebContents(web_contents); | 60 SecurityStateTabHelper::FromWebContents(web_contents); |
61 DCHECK(helper); | 61 DCHECK(helper); |
62 | 62 |
63 security_state::SecurityInfo security_info; | 63 security_state::SecurityInfo security_info; |
64 helper->GetSecurityInfo(&security_info); | 64 helper->GetSecurityInfo(&security_info); |
65 | 65 |
66 presenter_.reset(new WebsiteSettings( | 66 presenter_.reset(new PageInfo( |
67 this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 67 this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
68 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, | 68 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, |
69 nav_entry->GetURL(), security_info)); | 69 nav_entry->GetURL(), security_info)); |
70 } | 70 } |
71 | 71 |
72 ConnectionInfoPopupAndroid::~ConnectionInfoPopupAndroid() { | 72 ConnectionInfoPopupAndroid::~ConnectionInfoPopupAndroid() { |
73 } | 73 } |
74 | 74 |
75 void ConnectionInfoPopupAndroid::Destroy(JNIEnv* env, | 75 void ConnectionInfoPopupAndroid::Destroy(JNIEnv* env, |
76 const JavaParamRef<jobject>& obj) { | 76 const JavaParamRef<jobject>& obj) { |
77 delete this; | 77 delete this; |
78 } | 78 } |
79 | 79 |
80 void ConnectionInfoPopupAndroid::ResetCertDecisions( | 80 void ConnectionInfoPopupAndroid::ResetCertDecisions( |
81 JNIEnv* env, | 81 JNIEnv* env, |
82 const JavaParamRef<jobject>& obj, | 82 const JavaParamRef<jobject>& obj, |
83 const JavaParamRef<jobject>& java_web_contents) { | 83 const JavaParamRef<jobject>& java_web_contents) { |
84 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 84 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
85 } | 85 } |
86 | 86 |
87 void ConnectionInfoPopupAndroid::SetIdentityInfo( | 87 void ConnectionInfoPopupAndroid::SetIdentityInfo( |
88 const IdentityInfo& identity_info) { | 88 const IdentityInfo& identity_info) { |
89 JNIEnv* env = base::android::AttachCurrentThread(); | 89 JNIEnv* env = base::android::AttachCurrentThread(); |
90 | 90 |
91 { | 91 { |
92 int icon_id = ResourceMapper::MapFromChromiumId( | 92 int icon_id = ResourceMapper::MapFromChromiumId( |
93 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); | 93 PageInfoUI::GetIdentityIconID(identity_info.identity_status)); |
94 | 94 |
95 // The headline and the certificate dialog link of the site's identity | 95 // The headline and the certificate dialog link of the site's identity |
96 // section is only displayed if the site's identity was verified. If the | 96 // section is only displayed if the site's identity was verified. If the |
97 // site's identity was verified, then the headline contains the organization | 97 // site's identity was verified, then the headline contains the organization |
98 // name from the provided certificate. If the organization name is not | 98 // name from the provided certificate. If the organization name is not |
99 // available than the hostname of the site is used instead. | 99 // available than the hostname of the site is used instead. |
100 std::string headline; | 100 std::string headline; |
101 if (identity_info.certificate) { | 101 if (identity_info.certificate) { |
102 headline = identity_info.site_identity; | 102 headline = identity_info.site_identity; |
103 } | 103 } |
104 | 104 |
105 ScopedJavaLocalRef<jstring> description = | 105 ScopedJavaLocalRef<jstring> description = |
106 ConvertUTF8ToJavaString(env, identity_info.identity_status_description); | 106 ConvertUTF8ToJavaString(env, identity_info.identity_status_description); |
107 base::string16 certificate_label; | 107 base::string16 certificate_label; |
108 | 108 |
109 // Only show the certificate viewer link if the connection actually used a | 109 // Only show the certificate viewer link if the connection actually used a |
110 // certificate. | 110 // certificate. |
111 if (identity_info.identity_status != | 111 if (identity_info.identity_status != |
112 WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT) { | 112 PageInfo::SITE_IDENTITY_STATUS_NO_CERT) { |
113 certificate_label = | 113 certificate_label = |
114 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); | 114 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); |
115 } | 115 } |
116 | 116 |
117 Java_ConnectionInfoPopup_addCertificateSection( | 117 Java_ConnectionInfoPopup_addCertificateSection( |
118 env, popup_jobject_, icon_id, ConvertUTF8ToJavaString(env, headline), | 118 env, popup_jobject_, icon_id, ConvertUTF8ToJavaString(env, headline), |
119 description, ConvertUTF16ToJavaString(env, certificate_label)); | 119 description, ConvertUTF16ToJavaString(env, certificate_label)); |
120 | 120 |
121 if (identity_info.show_ssl_decision_revoke_button) { | 121 if (identity_info.show_ssl_decision_revoke_button) { |
122 base::string16 reset_button_label = l10n_util::GetStringUTF16( | 122 base::string16 reset_button_label = l10n_util::GetStringUTF16( |
123 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); | 123 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); |
124 Java_ConnectionInfoPopup_addResetCertDecisionsButton( | 124 Java_ConnectionInfoPopup_addResetCertDecisionsButton( |
125 env, popup_jobject_, | 125 env, popup_jobject_, |
126 ConvertUTF16ToJavaString(env, reset_button_label)); | 126 ConvertUTF16ToJavaString(env, reset_button_label)); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 { | 130 { |
131 int icon_id = ResourceMapper::MapFromChromiumId( | 131 int icon_id = ResourceMapper::MapFromChromiumId( |
132 WebsiteSettingsUI::GetConnectionIconID( | 132 PageInfoUI::GetConnectionIconID(identity_info.connection_status)); |
133 identity_info.connection_status)); | |
134 | 133 |
135 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 134 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
136 env, identity_info.connection_status_description); | 135 env, identity_info.connection_status_description); |
137 Java_ConnectionInfoPopup_addDescriptionSection(env, popup_jobject_, icon_id, | 136 Java_ConnectionInfoPopup_addDescriptionSection(env, popup_jobject_, icon_id, |
138 nullptr, description); | 137 nullptr, description); |
139 } | 138 } |
140 | 139 |
141 Java_ConnectionInfoPopup_addMoreInfoLink( | 140 Java_ConnectionInfoPopup_addMoreInfoLink( |
142 env, popup_jobject_, | 141 env, popup_jobject_, |
143 ConvertUTF8ToJavaString( | 142 ConvertUTF8ToJavaString( |
(...skipping 11 matching lines...) Expand all Loading... |
155 ChosenObjectInfoList chosen_object_info_list) { | 154 ChosenObjectInfoList chosen_object_info_list) { |
156 NOTIMPLEMENTED(); | 155 NOTIMPLEMENTED(); |
157 } | 156 } |
158 | 157 |
159 // static | 158 // static |
160 bool | 159 bool |
161 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( | 160 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( |
162 JNIEnv* env) { | 161 JNIEnv* env) { |
163 return RegisterNativesImpl(env); | 162 return RegisterNativesImpl(env); |
164 } | 163 } |
OLD | NEW |