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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java

Issue 159173002: Refactor ActivityStatus to not store current activity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Comments Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java b/chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java
index c22e7dcb6862facaa23d7cc21ec2919345326805..b692c10bbd1cc93f3c47ac6578d49d099225ff47 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java
@@ -16,6 +16,7 @@ import org.chromium.base.ActivityStatus;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
+import org.chromium.ui.base.WindowAndroid;
import java.security.Principal;
import java.security.PrivateKey;
@@ -80,7 +81,7 @@ class SSLClientCertificateRequest extends AsyncTask<Void, Void, Void>
// Executed in a background thread, can call blocking APIs.
X509Certificate[] chain = null;
PrivateKey key = null;
- Context context = ActivityStatus.getActivity().getApplicationContext();
+ Context context = ActivityStatus.getApplicationContext();
try {
key = KeyChain.getPrivateKey(context, mAlias);
chain = KeyChain.getCertificateChain(context, mAlias);
@@ -123,25 +124,33 @@ class SSLClientCertificateRequest extends AsyncTask<Void, Void, Void>
/**
* Create a new asynchronous request to select a client certificate.
*
- * @param nativePtr The native object responsible for this request.
- * @param keyTypes The list of supported key exchange types.
+ * @param nativePtr The native object responsible for this request.
+ * @param window A WindowAndroid instance.
+ * @param keyTypes The list of supported key exchange types.
* @param encodedPrincipals The list of CA DistinguishedNames.
- * @param hostName The server host name is available (empty otherwise).
- * @param port The server port if available (0 otherwise).
- * @return true on success.
+ * @param hostName The server host name is available (empty otherwise).
+ * @param port The server port if available (0 otherwise).
+ * @return true on success.
* Note that nativeOnSystemRequestComplete will be called iff this method returns true.
*/
@CalledByNative
- private static boolean selectClientCertificate(int nativePtr, String[] keyTypes,
- byte[][] encodedPrincipals, String hostName, int port) {
+ private static boolean selectClientCertificate(int nativePtr, WindowAndroid window,
+ String[] keyTypes, byte[][] encodedPrincipals, String hostName, int port) {
ThreadUtils.assertOnUiThread();
- Activity activity = ActivityStatus.getActivity();
- if (activity == null) {
+ Context context = window.getContext();
+ if (context == null) {
Log.w(TAG, "No active Chromium main activity!?");
return false;
}
+ if (!(context instanceof Activity)) {
Ted C 2014/02/13 04:38:44 combine this with the null check above since null
David Trainor- moved to gerrit 2014/02/14 19:13:36 Done.
+ Log.w(TAG, "Context not activity.");
+ return false;
+ }
+ Activity activity = (Activity) context;
+
+
Ted C 2014/02/13 04:38:44 one too many blank lines
David Trainor- moved to gerrit 2014/02/14 19:13:36 Done.
// Build the list of principals from encoded versions.
Principal[] principals = null;
if (encodedPrincipals.length > 0) {

Powered by Google App Engine
This is Rietveld 408576698