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

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

Issue 23794002: Store the Activity and the ApplicationContext in Tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
index 3aa1b9a431ba2b009f86ed46aa9780d8f3a6eacc..6dd7b17e13a07316e5e81273f57d0750e73f5ecb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
@@ -4,6 +4,7 @@
package org.chromium.chrome.browser;
+import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
@@ -47,8 +48,13 @@ public abstract class TabBase implements NavigationClient {
/** Whether or not this tab is an incognito tab. */
private final boolean mIncognito;
- /** The {@link Context} used to create {@link View}s or other Android components. This is
- * purposely an application Context not an activity Context. */
+ /** An Application {@link Context}. Unlike {@link #mContext}, this is the only one that is
+ * publicly exposed to help prevent leaking the {@link Activity}. */
+ private final Context mApplicationContext;
+
+ /** The {@link Context} used to create {@link View}s and other Android components. Unlike
+ * {@link #mApplicationContext}, this is not publicly exposed to help prevent leaking the
+ * {@link Activity}. */
private final Context mContext;
/** Gives {@link TabBase} a way to interact with the Android window. */
@@ -110,9 +116,14 @@ public abstract class TabBase implements NavigationClient {
* @param window An instance of a {@link WindowAndroid}.
*/
public TabBase(int id, boolean incognito, Context context, WindowAndroid window) {
+ // We need a valid Activity Context to build the ContentView with.
+ assert context == null || context instanceof Activity;
+
mId = generateValidId(id);
mIncognito = incognito;
- mContext = context != null ? context.getApplicationContext() : null;
+ // TODO(dtrainor): Only store application context here.
+ mContext = context;
+ mApplicationContext = context != null ? context.getApplicationContext() : null;
mWindowAndroid = window;
}
@@ -220,7 +231,7 @@ public abstract class TabBase implements NavigationClient {
* @return The application {@link Context} associated with this tab.
*/
protected Context getApplicationContext() {
- return mContext;
+ return mApplicationContext;
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698