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

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

Issue 1039013002: Use fallback URL more extensively (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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.tab; 5 package org.chromium.chrome.browser.tab;
6 6
7 import android.content.ComponentName; 7 import android.content.ComponentName;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.os.SystemClock; 10 import android.os.SystemClock;
(...skipping 23 matching lines...) Expand all
34 private Intent mInitialIntent; 34 private Intent mInitialIntent;
35 // A resolver list which includes all resolvers of |mInitialIntent|. 35 // A resolver list which includes all resolvers of |mInitialIntent|.
36 private final HashSet<ComponentName> mCachedResolvers = new HashSet<Componen tName>(); 36 private final HashSet<ComponentName> mCachedResolvers = new HashSet<Componen tName>();
37 private boolean mIsInitialIntentHeadingToChrome; 37 private boolean mIsInitialIntentHeadingToChrome;
38 38
39 private long mLastNewUrlLoadingTime; 39 private long mLastNewUrlLoadingTime;
40 private boolean mIsOnEffectiveRedirectChain; 40 private boolean mIsOnEffectiveRedirectChain;
41 private int mInitialNavigationType; 41 private int mInitialNavigationType;
42 private int mLastCommittedEntryIndexBeforeStartingNavigation; 42 private int mLastCommittedEntryIndexBeforeStartingNavigation;
43 43
44 private boolean mShouldStayInChromeUntilNewUrlLoading; 44 private boolean mShouldNotOverrideUrlLoadingUntilNewUrlLoading;
45 45
46 private final Context mContext; 46 private final Context mContext;
47 47
48 public TabRedirectHandler(Context context) { 48 public TabRedirectHandler(Context context) {
49 mContext = context; 49 mContext = context;
50 } 50 }
51 51
52 /** 52 /**
53 * Updates |mIntentHistory| and |mLastIntentUpdatedTime|. If |intent| comes from chrome and 53 * Updates |mIntentHistory| and |mLastIntentUpdatedTime|. If |intent| comes from chrome and
54 * currently |mIsOnEffectiveIntentRedirectChain| is true, that means |intent | was sent from 54 * currently |mIsOnEffectiveIntentRedirectChain| is true, that means |intent | was sent from
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 /** 91 /**
92 * Resets all variables except timestamps. 92 * Resets all variables except timestamps.
93 */ 93 */
94 public void clear() { 94 public void clear() {
95 clearIntentHistory(); 95 clearIntentHistory();
96 mInitialNavigationType = NAVIGATION_TYPE_NONE; 96 mInitialNavigationType = NAVIGATION_TYPE_NONE;
97 mIsOnEffectiveRedirectChain = false; 97 mIsOnEffectiveRedirectChain = false;
98 mLastCommittedEntryIndexBeforeStartingNavigation = 0; 98 mLastCommittedEntryIndexBeforeStartingNavigation = 0;
99 mShouldStayInChromeUntilNewUrlLoading = false; 99 mShouldNotOverrideUrlLoadingUntilNewUrlLoading = false;
100 } 100 }
101 101
102 public void setShouldStayInChromeUntilNewUrlLoading() { 102 public void setShouldNotOverrideUrlLoadingUntilNewUrlLoading() {
103 mShouldStayInChromeUntilNewUrlLoading = true; 103 mShouldNotOverrideUrlLoadingUntilNewUrlLoading = true;
104 } 104 }
105 105
106 /** 106 /**
107 * Updates new url loading information to trace navigation. 107 * Updates new url loading information to trace navigation.
108 * A time based heuristic is used to determine if this loading is an effecti ve redirect or not 108 * A time based heuristic is used to determine if this loading is an effecti ve redirect or not
109 * if core of |pageTransType| is LINK. 109 * if core of |pageTransType| is LINK.
110 * 110 *
111 * http://crbug.com/322567 : Trace navigation started from an external app. 111 * http://crbug.com/322567 : Trace navigation started from an external app.
112 * http://crbug.com/331571 : Trace navigation started from user typing to do not override such 112 * http://crbug.com/331571 : Trace navigation started from user typing to do not override such
113 * navigation. 113 * navigation.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } else if (pageTransitionCore == PageTransition.TYPED) { 147 } else if (pageTransitionCore == PageTransition.TYPED) {
148 mInitialNavigationType = NAVIGATION_TYPE_FROM_USER_TYPING; 148 mInitialNavigationType = NAVIGATION_TYPE_FROM_USER_TYPING;
149 mIsOnEffectiveRedirectChain = false; 149 mIsOnEffectiveRedirectChain = false;
150 clearIntentHistory(); 150 clearIntentHistory();
151 } else { 151 } else {
152 mInitialNavigationType = NAVIGATION_TYPE_OTHER; 152 mInitialNavigationType = NAVIGATION_TYPE_OTHER;
153 mIsOnEffectiveRedirectChain = false; 153 mIsOnEffectiveRedirectChain = false;
154 clearIntentHistory(); 154 clearIntentHistory();
155 } 155 }
156 mLastCommittedEntryIndexBeforeStartingNavigation = lastCommittedEntr yIndex; 156 mLastCommittedEntryIndexBeforeStartingNavigation = lastCommittedEntr yIndex;
157 mShouldStayInChromeUntilNewUrlLoading = false; 157 mShouldNotOverrideUrlLoadingUntilNewUrlLoading = false;
158 } else if (mInitialNavigationType != NAVIGATION_TYPE_NONE) { 158 } else if (mInitialNavigationType != NAVIGATION_TYPE_NONE) {
159 // Redirect chain starts from the second url loading. 159 // Redirect chain starts from the second url loading.
160 mIsOnEffectiveRedirectChain = true; 160 mIsOnEffectiveRedirectChain = true;
161 } 161 }
162 } 162 }
163 163
164 /** 164 /**
165 * @return whether on effective intent redirect chain or not. 165 * @return whether on effective intent redirect chain or not.
166 */ 166 */
167 public boolean isOnEffectiveIntentRedirectChain() { 167 public boolean isOnEffectiveIntentRedirectChain() {
168 return mInitialNavigationType == NAVIGATION_TYPE_FROM_INTENT && mIsOnEff ectiveRedirectChain; 168 return mInitialNavigationType == NAVIGATION_TYPE_FROM_INTENT && mIsOnEff ectiveRedirectChain;
169 } 169 }
170 170
171 /** 171 /**
172 * @return whether we should stay in Chrome or not. There are two different
173 */
174 public boolean shouldStayInChrome() {
175 return mIsInitialIntentHeadingToChrome
176 || mInitialNavigationType == NAVIGATION_TYPE_FROM_USER_TYPING;
177 }
178
179 /**
172 * @return whether we should stay in Chrome or not. 180 * @return whether we should stay in Chrome or not.
173 */ 181 */
174 public boolean shouldStayInChrome() { 182 public boolean shouldNotOverrideUrlLoading() {
175 return mIsInitialIntentHeadingToChrome 183 return mShouldNotOverrideUrlLoadingUntilNewUrlLoading;
176 || mInitialNavigationType == NAVIGATION_TYPE_FROM_USER_TYPING
177 || mShouldStayInChromeUntilNewUrlLoading;
178 } 184 }
179 185
180 /** 186 /**
181 * @return whether on navigation or not. 187 * @return whether on navigation or not.
182 */ 188 */
183 public boolean isOnNavigation() { 189 public boolean isOnNavigation() {
184 return mInitialNavigationType != NAVIGATION_TYPE_NONE; 190 return mInitialNavigationType != NAVIGATION_TYPE_NONE;
185 } 191 }
186 192
187 /** 193 /**
(...skipping 18 matching lines...) Expand all
206 mCachedResolvers.addAll(IntentUtils.getIntentHandlers(mContext, mIni tialIntent)); 212 mCachedResolvers.addAll(IntentUtils.getIntentHandlers(mContext, mIni tialIntent));
207 } 213 }
208 for (ComponentName name : newList) { 214 for (ComponentName name : newList) {
209 if (!mCachedResolvers.contains(name)) { 215 if (!mCachedResolvers.contains(name)) {
210 return true; 216 return true;
211 } 217 }
212 } 218 }
213 return false; 219 return false;
214 } 220 }
215 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698