OLD | NEW |
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.os.SystemClock; | 7 import android.os.SystemClock; |
8 import android.support.annotation.IntDef; | 8 import android.support.annotation.IntDef; |
9 import android.view.View; | 9 import android.view.View; |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 @Override | 149 @Override |
150 public void didFinishLoad(long frameId, String validatedUrl, boolean isMainF
rame) { | 150 public void didFinishLoad(long frameId, String validatedUrl, boolean isMainF
rame) { |
151 if (isMainFrame) mTab.didFinishPageLoad(); | 151 if (isMainFrame) mTab.didFinishPageLoad(); |
152 PolicyAuditor auditor = | 152 PolicyAuditor auditor = |
153 ((ChromeApplication) mTab.getApplicationContext()).getPolicyAudi
tor(); | 153 ((ChromeApplication) mTab.getApplicationContext()).getPolicyAudi
tor(); |
154 auditor.notifyAuditEvent( | 154 auditor.notifyAuditEvent( |
155 mTab.getApplicationContext(), AuditEvent.OPEN_URL_SUCCESS, valid
atedUrl, ""); | 155 mTab.getApplicationContext(), AuditEvent.OPEN_URL_SUCCESS, valid
atedUrl, ""); |
156 } | 156 } |
157 | 157 |
158 @Override | 158 @Override |
159 public void didFailLoad(boolean isProvisionalLoad, boolean isMainFrame, int
errorCode, | 159 public void didFailLoad( |
160 String description, String failingUrl, boolean wasIgnoredByHandler)
{ | 160 boolean isMainFrame, int errorCode, String description, String faili
ngUrl) { |
161 mTab.updateThemeColorIfNeeded(true); | 161 mTab.updateThemeColorIfNeeded(true); |
162 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 162 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
163 while (observers.hasNext()) { | 163 while (observers.hasNext()) { |
164 observers.next().onDidFailLoad(mTab, isProvisionalLoad, isMainFrame,
errorCode, | 164 observers.next().onDidFailLoad(mTab, isMainFrame, errorCode, descrip
tion, failingUrl); |
165 description, failingUrl); | |
166 } | 165 } |
167 | 166 |
168 if (isMainFrame) mTab.didFailPageLoad(errorCode); | 167 if (isMainFrame) mTab.didFailPageLoad(errorCode); |
169 | 168 |
| 169 recordErrorInPolicyAuditor(failingUrl, description, errorCode); |
| 170 } |
| 171 |
| 172 private void recordErrorInPolicyAuditor(String failingUrl, String descriptio
n, int errorCode) { |
170 PolicyAuditor auditor = | 173 PolicyAuditor auditor = |
171 ((ChromeApplication) mTab.getApplicationContext()).getPolicyAudi
tor(); | 174 ((ChromeApplication) mTab.getApplicationContext()).getPolicyAudi
tor(); |
172 auditor.notifyAuditEvent(mTab.getApplicationContext(), AuditEvent.OPEN_U
RL_FAILURE, | 175 auditor.notifyAuditEvent(mTab.getApplicationContext(), AuditEvent.OPEN_U
RL_FAILURE, |
173 failingUrl, description); | 176 failingUrl, description); |
174 if (errorCode == BLOCKED_BY_ADMINISTRATOR) { | 177 if (errorCode == BLOCKED_BY_ADMINISTRATOR) { |
175 auditor.notifyAuditEvent( | 178 auditor.notifyAuditEvent( |
176 mTab.getApplicationContext(), AuditEvent.OPEN_URL_BLOCKED, f
ailingUrl, ""); | 179 mTab.getApplicationContext(), AuditEvent.OPEN_URL_BLOCKED, f
ailingUrl, ""); |
177 } | 180 } |
178 } | 181 } |
179 | 182 |
180 @Override | 183 @Override |
181 public void titleWasSet(String title) { | 184 public void titleWasSet(String title) { |
182 mTab.updateTitle(title); | 185 mTab.updateTitle(title); |
183 } | 186 } |
184 | 187 |
185 @Override | 188 @Override |
186 public void didStartProvisionalLoadForFrame(long frameId, long parentFrameId
, | 189 public void didStartNavigation( |
187 boolean isMainFrame, String validatedUrl, boolean isErrorPage) { | 190 String url, boolean isInMainFrame, boolean isSamePage, boolean isErr
orPage) { |
188 if (isMainFrame) mTab.didStartPageLoad(validatedUrl, isErrorPage); | 191 if (isInMainFrame && !isSamePage) { |
| 192 mTab.didStartPageLoad(url, isErrorPage); |
| 193 } |
189 | 194 |
190 mTab.handleDidStartProvisionalLoadForFrame(isMainFrame, validatedUrl); | 195 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
| 196 while (observers.hasNext()) { |
| 197 observers.next().onDidStartNavigation( |
| 198 mTab, url, isInMainFrame, isSamePage, isErrorPage); |
| 199 } |
191 } | 200 } |
192 | 201 |
193 @Override | 202 @Override |
194 public void didCommitProvisionalLoadForFrame(long frameId, boolean isMainFra
me, String url, | 203 public void didFinishNavigation(String url, boolean isInMainFrame, boolean i
sErrorPage, |
195 int transitionType) { | 204 boolean hasCommitted, boolean isSamePage, boolean isFragmentNavigati
on, |
196 if (isMainFrame && UmaUtils.isRunningApplicationStart()) { | 205 Integer pageTransition, int errorCode, String errorDescription, int
httpStatusCode) { |
| 206 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
| 207 while (observers.hasNext()) { |
| 208 observers.next().onDidFinishNavigation(mTab, url, isInMainFrame, isE
rrorPage, |
| 209 hasCommitted, isSamePage, isFragmentNavigation, pageTransiti
on, errorCode, |
| 210 httpStatusCode); |
| 211 } |
| 212 |
| 213 if (errorCode != 0) { |
| 214 mTab.updateThemeColorIfNeeded(true); |
| 215 if (isInMainFrame) mTab.didFailPageLoad(errorCode); |
| 216 |
| 217 recordErrorInPolicyAuditor(url, errorDescription, errorCode); |
| 218 return; |
| 219 } |
| 220 |
| 221 if (!hasCommitted) return; |
| 222 if (isInMainFrame && UmaUtils.isRunningApplicationStart()) { |
197 // Current median is 550ms, and long tail is very long. ZoomedIn giv
es good view of the | 223 // Current median is 550ms, and long tail is very long. ZoomedIn giv
es good view of the |
198 // median and ZoomedOut gives a good overview. | 224 // median and ZoomedOut gives a good overview. |
199 RecordHistogram.recordCustomTimesHistogram( | 225 RecordHistogram.recordCustomTimesHistogram( |
200 "Startup.FirstCommitNavigationTime2.ZoomedIn", | 226 "Startup.FirstCommitNavigationTime2.ZoomedIn", |
201 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime
(), | 227 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime
(), |
202 200, 1000, TimeUnit.MILLISECONDS, 100); | 228 200, 1000, TimeUnit.MILLISECONDS, 100); |
203 // For ZoomedOut very rarely is it under 50ms and this range matches | 229 // For ZoomedOut very rarely is it under 50ms and this range matches |
204 // CustomTabs.IntentToFirstCommitNavigationTime2.ZoomedOut. | 230 // CustomTabs.IntentToFirstCommitNavigationTime2.ZoomedOut. |
205 RecordHistogram.recordCustomTimesHistogram( | 231 RecordHistogram.recordCustomTimesHistogram( |
206 "Startup.FirstCommitNavigationTime2.ZoomedOut", | 232 "Startup.FirstCommitNavigationTime2.ZoomedOut", |
207 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime
(), | 233 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime
(), |
208 50, TimeUnit.MINUTES.toMillis(10), TimeUnit.MILLISECONDS, 50
); | 234 50, TimeUnit.MINUTES.toMillis(10), TimeUnit.MILLISECONDS, 50
); |
209 UmaUtils.setRunningApplicationStart(false); | 235 UmaUtils.setRunningApplicationStart(false); |
210 } | 236 } |
211 | 237 |
212 if (isMainFrame) { | 238 if (isInMainFrame) { |
213 mTab.setIsTabStateDirty(true); | 239 mTab.setIsTabStateDirty(true); |
214 mTab.updateTitle(); | 240 mTab.updateTitle(); |
215 } | 241 mTab.handleDidFinishNavigation(url, pageTransition); |
216 | 242 mTab.setIsShowingErrorPage(isErrorPage); |
217 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | |
218 while (observers.hasNext()) { | |
219 observers.next().onDidCommitProvisionalLoadForFrame( | |
220 mTab, frameId, isMainFrame, url, transitionType); | |
221 } | 243 } |
222 | 244 |
223 observers.rewind(); | 245 observers.rewind(); |
224 while (observers.hasNext()) { | 246 while (observers.hasNext()) { |
225 observers.next().onUrlUpdated(mTab); | 247 observers.next().onUrlUpdated(mTab); |
226 } | 248 } |
227 | 249 |
228 if (!isMainFrame) return; | |
229 mTab.handleDidCommitProvisonalLoadForFrame(url, transitionType); | |
230 } | |
231 | |
232 @Override | |
233 public void didNavigateMainFrame(String url, String baseUrl, | |
234 boolean isNavigationToDifferentPage, boolean isFragmentNavigation, i
nt statusCode) { | |
235 FullscreenManager fullscreenManager = mTab.getFullscreenManager(); | 250 FullscreenManager fullscreenManager = mTab.getFullscreenManager(); |
236 if (isNavigationToDifferentPage && fullscreenManager != null) { | 251 if (isInMainFrame && !isSamePage && fullscreenManager != null) { |
237 fullscreenManager.setPersistentFullscreenMode(false); | 252 fullscreenManager.setPersistentFullscreenMode(false); |
238 } | 253 } |
239 | 254 |
240 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 255 if (isInMainFrame) { |
241 while (observers.hasNext()) { | 256 mTab.stopSwipeRefreshHandler(); |
242 observers.next().onDidNavigateMainFrame( | |
243 mTab, url, baseUrl, isNavigationToDifferentPage, | |
244 isFragmentNavigation, statusCode); | |
245 } | |
246 | |
247 mTab.stopSwipeRefreshHandler(); | |
248 } | |
249 | |
250 @Override | |
251 public void didStartNavigation(String url, boolean isInMainFrame, boolean is
ErrorPage) { | |
252 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | |
253 while (observers.hasNext()) { | |
254 observers.next().onDidStartNavigation(mTab, url, isInMainFrame, isEr
rorPage); | |
255 } | 257 } |
256 } | 258 } |
257 | 259 |
258 @Override | |
259 public void didFinishNavigation(String url, boolean isInMainFrame, boolean i
sErrorPage, | |
260 boolean hasCommitted, boolean isSamePage, Integer pageTransition, in
t errorCode) { | |
261 if (isInMainFrame && hasCommitted) mTab.setIsShowingErrorPage(isErrorPag
e); | |
262 | |
263 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | |
264 while (observers.hasNext()) { | |
265 observers.next().onDidFinishNavigation(mTab, url, isInMainFrame, isE
rrorPage, | |
266 hasCommitted, isSamePage, pageTransition, errorCode); | |
267 } | |
268 } | |
269 | |
270 @Override | 260 @Override |
271 public void didFirstVisuallyNonEmptyPaint() { | 261 public void didFirstVisuallyNonEmptyPaint() { |
272 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 262 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
273 while (observers.hasNext()) { | 263 while (observers.hasNext()) { |
274 observers.next().didFirstVisuallyNonEmptyPaint(mTab); | 264 observers.next().didFirstVisuallyNonEmptyPaint(mTab); |
275 } | 265 } |
276 } | 266 } |
277 | 267 |
278 @Override | 268 @Override |
279 public void didChangeThemeColor(int color) { | 269 public void didChangeThemeColor(int color) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 mTab.notifyLoadProgress(mTab.getProgress()); | 303 mTab.notifyLoadProgress(mTab.getProgress()); |
314 | 304 |
315 mTab.updateFullscreenEnabledState(); | 305 mTab.updateFullscreenEnabledState(); |
316 | 306 |
317 if (!mTab.maybeShowNativePage(mTab.getUrl(), false)) { | 307 if (!mTab.maybeShowNativePage(mTab.getUrl(), false)) { |
318 mTab.showRenderedPage(); | 308 mTab.showRenderedPage(); |
319 } | 309 } |
320 } | 310 } |
321 | 311 |
322 @Override | 312 @Override |
323 public void didStartNavigationToPendingEntry(String url) { | |
324 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | |
325 while (observers.hasNext()) { | |
326 observers.next().onDidStartNavigationToPendingEntry(mTab, url); | |
327 } | |
328 } | |
329 | |
330 @Override | |
331 public void destroy() { | 313 public void destroy() { |
332 MediaCaptureNotificationService.updateMediaNotificationForTab( | 314 MediaCaptureNotificationService.updateMediaNotificationForTab( |
333 mTab.getApplicationContext(), mTab.getId(), 0, mTab.getUrl()); | 315 mTab.getApplicationContext(), mTab.getId(), 0, mTab.getUrl()); |
334 super.destroy(); | 316 super.destroy(); |
335 } | 317 } |
336 } | 318 } |
OLD | NEW |