| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.document; | |
| 6 | |
| 7 import android.app.Activity; | |
| 8 import android.content.Context; | |
| 9 import android.content.Intent; | |
| 10 import android.os.Bundle; | |
| 11 | |
| 12 import org.chromium.content.browser.crypto.CipherFactory; | |
| 13 | |
| 14 /** | |
| 15 * An activity responsible for retaining the incognito cipher key for the durati
on of an incognito | |
| 16 * session. The activity gets brought forward for two reasons: to restore the ci
pher key before a | |
| 17 * new incognito window is launched or to save the current cipher key. If brough
t forward to | |
| 18 * restore, the activity is passed an intent and options to call after the resto
re process is | |
| 19 * complete. Otherwise the activity just puts itself in background causing onSav
eInstanceState to | |
| 20 * get called and save the cipher keys to the activity's bundle. | |
| 21 */ | |
| 22 public class CipherKeyActivity extends Activity { | |
| 23 | |
| 24 /** | |
| 25 * An intent name for specifying the next intent to invoke. | |
| 26 */ | |
| 27 public static final String FORWARD_INTENT = "forward_intent"; | |
| 28 | |
| 29 /** | |
| 30 * An options Bundle to use with intent specified by "forward_intent". | |
| 31 */ | |
| 32 public static final String FORWARD_OPTIONS = "forward_options"; | |
| 33 | |
| 34 /** | |
| 35 * Generates an intent to {@link CipherKeyActivity} to restore cipher keys f
rom the bundle | |
| 36 * if possible. | |
| 37 * @param context The context to use. | |
| 38 * @param forwardIntent The intent cipher key activity will call when it's d
one. | |
| 39 * @param options The options to pass into startActivity call of the forward
intent. | |
| 40 * @return The intent. | |
| 41 */ | |
| 42 public static Intent createIntent(Context context, Intent forwardIntent, Bun
dle options) { | |
| 43 Intent intent = new Intent(context, CipherKeyActivity.class); | |
| 44 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 45 if (forwardIntent != null) intent.putExtra(FORWARD_INTENT, forwardIntent
); | |
| 46 if (options != null) intent.putExtra(FORWARD_OPTIONS, options); | |
| 47 return intent; | |
| 48 } | |
| 49 | |
| 50 @Override | |
| 51 protected void onCreate(Bundle savedInstanceState) { | |
| 52 super.onCreate(savedInstanceState); | |
| 53 if (savedInstanceState != null) { | |
| 54 CipherFactory.getInstance().restoreFromBundle(savedInstanceState); | |
| 55 } | |
| 56 Intent nextIntent = (Intent) getIntent().getParcelableExtra(FORWARD_INTE
NT); | |
| 57 if (nextIntent != null) { | |
| 58 startActivity(nextIntent, (Bundle) getIntent().getParcelableExtra(FO
RWARD_OPTIONS)); | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 @Override | |
| 63 public void onResume() { | |
| 64 super.onResume(); | |
| 65 moveTaskToBack(true); | |
| 66 } | |
| 67 | |
| 68 @Override | |
| 69 protected void onSaveInstanceState(Bundle outState) { | |
| 70 super.onSaveInstanceState(outState); | |
| 71 CipherFactory.getInstance().saveToBundle(outState); | |
| 72 } | |
| 73 | |
| 74 } | |
| OLD | NEW |