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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java

Issue 418133012: Add button to page info to revoke user certificate decisions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits from pkasting and rsesek Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.app.Dialog; 7 import android.app.Dialog;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.DialogInterface; 9 import android.content.DialogInterface;
10 import android.content.Intent; 10 import android.content.Intent;
(...skipping 24 matching lines...) Expand all
35 private static final String HELP_URL = 35 private static final String HELP_URL =
36 "http://www.google.com/support/chrome/bin/answer.py?answer=95617"; 36 "http://www.google.com/support/chrome/bin/answer.py?answer=95617";
37 private static final int DESCRIPTION_TEXT_SIZE_SP = 12; 37 private static final int DESCRIPTION_TEXT_SIZE_SP = 12;
38 private final Context mContext; 38 private final Context mContext;
39 private final Dialog mDialog; 39 private final Dialog mDialog;
40 private final LinearLayout mContainer; 40 private final LinearLayout mContainer;
41 private final WebContents mWebContents; 41 private final WebContents mWebContents;
42 private final int mPaddingWide, mPaddingThin; 42 private final int mPaddingWide, mPaddingThin;
43 private TextView mCertificateViewer, mMoreInfoLink; 43 private TextView mCertificateViewer, mMoreInfoLink;
44 private ViewGroup mCertificateLayout, mDescriptionLayout; 44 private ViewGroup mCertificateLayout, mDescriptionLayout;
45 private TextView mResetCertDecisions;
45 private String mLinkUrl; 46 private String mLinkUrl;
47 private final long mNativeWebsiteSettingsPopup;
Ted C 2014/07/28 20:15:49 I would move this up with the other final fields.
jww 2014/08/06 00:51:47 Done.
46 48
47 private WebsiteSettingsPopup(Context context, WebContents webContents) { 49 private WebsiteSettingsPopup(Context context, WebContents webContents) {
48 mContext = context; 50 mContext = context;
49 mWebContents = webContents; 51 mWebContents = webContents;
50 52
51 mContainer = new LinearLayout(mContext); 53 mContainer = new LinearLayout(mContext);
52 mContainer.setOrientation(LinearLayout.VERTICAL); 54 mContainer.setOrientation(LinearLayout.VERTICAL);
53 mContainer.setBackgroundColor(Color.WHITE); 55 mContainer.setBackgroundColor(Color.WHITE);
54 mPaddingWide = (int) context.getResources().getDimension( 56 mPaddingWide = (int) context.getResources().getDimension(
55 R.dimen.certificate_viewer_padding_wide); 57 R.dimen.certificate_viewer_padding_wide);
56 mPaddingThin = (int) context.getResources().getDimension( 58 mPaddingThin = (int) context.getResources().getDimension(
57 R.dimen.certificate_viewer_padding_thin); 59 R.dimen.certificate_viewer_padding_thin);
58 mContainer.setPadding(mPaddingWide, mPaddingWide + mPaddingThin, mPaddin gWide, 60 mContainer.setPadding(mPaddingWide, mPaddingWide + mPaddingThin, mPaddin gWide,
59 mPaddingWide); 61 mPaddingWide);
60 62
61 mDialog = new Dialog(mContext); 63 mDialog = new Dialog(mContext);
62 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 64 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
63 mDialog.setCanceledOnTouchOutside(true); 65 mDialog.setCanceledOnTouchOutside(true);
64 // This needs to come after other member initialization. 66 // This needs to come after other member initialization.
65 final long nativeWebsiteSettingsPopup = nativeInit(this, webContents); 67 mNativeWebsiteSettingsPopup = nativeInit(this, webContents);
66 final WebContentsObserverAndroid webContentsObserver = 68 final WebContentsObserverAndroid webContentsObserver =
67 new WebContentsObserverAndroid(mWebContents) { 69 new WebContentsObserverAndroid(mWebContents) {
68 @Override 70 @Override
69 public void navigationEntryCommitted() { 71 public void navigationEntryCommitted() {
70 // If a navigation is committed (e.g. from in-page redirect), th e data we're 72 // If a navigation is committed (e.g. from in-page redirect), th e data we're
71 // showing is stale so dismiss the dialog. 73 // showing is stale so dismiss the dialog.
72 mDialog.dismiss(); 74 mDialog.dismiss();
73 } 75 }
74 }; 76 };
75 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { 77 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
76 @Override 78 @Override
77 public void onDismiss(DialogInterface dialog) { 79 public void onDismiss(DialogInterface dialog) {
78 assert nativeWebsiteSettingsPopup != 0; 80 assert mNativeWebsiteSettingsPopup != 0;
79 webContentsObserver.detachFromWebContents(); 81 webContentsObserver.detachFromWebContents();
80 nativeDestroy(nativeWebsiteSettingsPopup); 82 nativeDestroy(mNativeWebsiteSettingsPopup);
81 } 83 }
82 }); 84 });
83 } 85 }
84 86
85 /** 87 /**
86 * Adds certificate section, which contains an icon, a headline, a 88 * Adds certificate section, which contains an icon, a headline, a
87 * description and a label for certificate info link. 89 * description and a label for certificate info link.
88 */ 90 */
89 @CalledByNative 91 @CalledByNative
90 private void addCertificateSection(int enumeratedIconId, String headline, St ring description, 92 private void addCertificateSection(int enumeratedIconId, String headline, St ring description,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 mCertificateViewer.setText(label); 135 mCertificateViewer.setText(label);
134 mCertificateViewer.setTextColor( 136 mCertificateViewer.setTextColor(
135 mContext.getResources().getColor(R.color.website_settings_popup_ text_link)); 137 mContext.getResources().getColor(R.color.website_settings_popup_ text_link));
136 mCertificateViewer.setTextSize(DESCRIPTION_TEXT_SIZE_SP); 138 mCertificateViewer.setTextSize(DESCRIPTION_TEXT_SIZE_SP);
137 mCertificateViewer.setOnClickListener(this); 139 mCertificateViewer.setOnClickListener(this);
138 mCertificateViewer.setPadding(0, mPaddingWide, 0, mPaddingWide); 140 mCertificateViewer.setPadding(0, mPaddingWide, 0, mPaddingWide);
139 mCertificateLayout.addView(mCertificateViewer); 141 mCertificateLayout.addView(mCertificateViewer);
140 } 142 }
141 143
142 @CalledByNative 144 @CalledByNative
145 private void addResetCertDecisionsButton(String label) {
146 assert mNativeWebsiteSettingsPopup != 0;
147 assert mResetCertDecisions == null;
148 mResetCertDecisions = new TextView(mContext);
149 mResetCertDecisions.setText(label);
150 mResetCertDecisions.setTextColor(
151 mContext.getResources().getColor(R.color.website_settings_popup_ text_link));
152 mResetCertDecisions.setTextSize(DESCRIPTION_TEXT_SIZE_SP);
153 mResetCertDecisions.setOnClickListener(this);
154 mResetCertDecisions.setPadding(0, 0, 0, mPaddingWide);
155 mCertificateLayout.addView(mResetCertDecisions);
Ted C 2014/07/28 20:15:50 I find it kind of odd that this is a text view tha
jww 2014/08/06 00:51:47 As per pkasting's comment, I've changed these all
156 }
157
158 @CalledByNative
143 private void addMoreInfoLink(String linkText) { 159 private void addMoreInfoLink(String linkText) {
144 addUrl(linkText, HELP_URL); 160 addUrl(linkText, HELP_URL);
145 } 161 }
146 162
147 /** Adds a section containing a description and a hyperlink. */ 163 /** Adds a section containing a description and a hyperlink. */
148 private void addUrl(String label, String url) { 164 private void addUrl(String label, String url) {
149 mMoreInfoLink = new TextView(mContext); 165 mMoreInfoLink = new TextView(mContext);
150 mLinkUrl = url; 166 mLinkUrl = url;
151 mMoreInfoLink.setText(label); 167 mMoreInfoLink.setText(label);
152 mMoreInfoLink.setTextColor( 168 mMoreInfoLink.setTextColor(
(...skipping 26 matching lines...) Expand all
179 return; 195 return;
180 } 196 }
181 CertificateViewer.showCertificateChain(mContext, certChain); 197 CertificateViewer.showCertificateChain(mContext, certChain);
182 } else if (mMoreInfoLink == v) { 198 } else if (mMoreInfoLink == v) {
183 try { 199 try {
184 Intent i = Intent.parseUri(mLinkUrl, Intent.URI_INTENT_SCHEME); 200 Intent i = Intent.parseUri(mLinkUrl, Intent.URI_INTENT_SCHEME);
185 i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); 201 i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
186 i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName ()); 202 i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName ());
187 mContext.startActivity(i); 203 mContext.startActivity(i);
188 } catch (URISyntaxException ex) {} 204 } catch (URISyntaxException ex) {}
205 } else if (mResetCertDecisions == v) {
206 nativeResetCertDecisions(mNativeWebsiteSettingsPopup, mWebContents);
Ted C 2014/07/28 20:15:49 +2 indent since you're in java land
jww 2014/08/06 00:51:47 Done.
189 } 207 }
190 } 208 }
191 209
192 /** 210 /**
193 * Shows a WebsiteSettings dialog for the provided WebContents. 211 * Shows a WebsiteSettings dialog for the provided WebContents.
194 * 212 *
195 * The popup adds itself to the view hierarchy which owns the reference whil e it's 213 * The popup adds itself to the view hierarchy which owns the reference whil e it's
196 * visible. 214 * visible.
197 * 215 *
198 * @param context Context which is used for launching a dialog. 216 * @param context Context which is used for launching a dialog.
199 * @param webContents The WebContents for which to show Website information. This 217 * @param webContents The WebContents for which to show Website information. This
200 * information is retrieved for the visible entry. 218 * information is retrieved for the visible entry.
201 */ 219 */
202 @SuppressWarnings("unused") 220 @SuppressWarnings("unused")
203 public static void show(Context context, WebContents webContents) { 221 public static void show(Context context, WebContents webContents) {
204 new WebsiteSettingsPopup(context, webContents); 222 new WebsiteSettingsPopup(context, webContents);
205 } 223 }
206 224
207 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents); 225 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents);
208 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); 226 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid);
227 private native void nativeResetCertDecisions(long nativeWebsiteSettingsPopup Android, WebContents webContents);
Ted C 2014/07/28 20:15:49 line length limit in java is 100, so you need to w
jww 2014/08/06 00:51:47 Done.
209 private native byte[][] nativeGetCertificateChain(WebContents webContents); 228 private native byte[][] nativeGetCertificateChain(WebContents webContents);
210 } 229 }
OLDNEW
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | chrome/browser/ui/android/website_settings_popup_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698