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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/document/IncognitoDocumentActivity.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/document/IncognitoDocumentActivity.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/document/IncognitoDocumentActivity.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/document/IncognitoDocumentActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..e1e46c94e99fcf5e207576241c12166a80b1661a
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/document/IncognitoDocumentActivity.java
@@ -0,0 +1,101 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.document;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+
+import org.chromium.chrome.browser.cookies.CookiesFetcher;
+import org.chromium.content.browser.crypto.CipherFactory;
+import org.chromium.content.browser.crypto.CipherFactory.CipherDataObserver;
+
+/**
+ * {@link DocumentActivity} for incognito tabs.
+ */
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+public class IncognitoDocumentActivity extends DocumentActivity {
+ /**
+ * Responsible for observing when cipher data generation is complete and saving
+ * the new cipher data in the CipherKeyActivity.
+ */
+ private static class CipherKeySaver implements CipherDataObserver {
+ private final Context mContext;
+
+ public CipherKeySaver(Context context) {
+ mContext = context;
+ CipherFactory.getInstance().addCipherDataObserver(this);
+ }
+
+ @Override
+ public void onCipherDataGenerated() {
+ mContext.startActivity(
+ CipherKeyActivity.createIntent(mContext, null, null));
+ CipherFactory.getInstance().removeCipherDataObserver(this);
+ }
+ }
+
+ private static CipherKeySaver sCipherKeySaver;
+
+ private static void maybeCreateCipherKeySaver(Context context) {
+ if (sCipherKeySaver == null && !CipherFactory.getInstance().hasCipher()) {
+ sCipherKeySaver = new CipherKeySaver(context);
+ }
+ }
+
+ @Override
+ protected boolean isIncognito() {
+ return true;
+ }
+
+ @Override
+ public void preInflationStartup() {
+ CipherFactory.getInstance().restoreFromBundle(getSavedInstanceState());
+ maybeCreateCipherKeySaver(this);
+ super.preInflationStartup();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ IncognitoNotificationManager.updateIncognitoNotification(
+ ChromeLauncherActivity.getRemoveAllIncognitoTabsIntent(this));
+ }
+
+ @Override
+ public void onResumeWithNative() {
+ super.onResumeWithNative();
+ CookiesFetcher.restoreCookies(this);
+ }
+
+ @Override
+ public void onPauseWithNative() {
+ CookiesFetcher.persistCookies(this);
+ super.onPauseWithNative();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ CipherFactory.getInstance().saveToBundle(outState);
+
+ // Save out the URL that was originally used to spawn this activity because we don't pass it
+ // in through the Intent.
+ String initialUrl = determineInitialUrl(determineTabId());
+ outState.putString(KEY_INITIAL_URL, initialUrl);
+ }
+
+ @Override
+ protected String determineInitialUrl(int tabId) {
+ // Check if the URL was saved in the Bundle.
+ if (getSavedInstanceState() != null) {
+ String initialUrl = getSavedInstanceState().getString(KEY_INITIAL_URL);
+ if (initialUrl != null) return initialUrl;
+ }
+
+ return super.determineInitialUrl(tabId);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698