Chromium Code Reviews| 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(String url, boolean isInMainFrame, boolean is ErrorPage) { |
| 187 boolean isMainFrame, String validatedUrl, boolean isErrorPage) { | 190 if (isInMainFrame) { |
| 188 if (isMainFrame) mTab.didStartPageLoad(validatedUrl, isErrorPage); | 191 mTab.didStartPageLoad(url, isErrorPage); |
| 192 } | |
| 189 | 193 |
| 190 mTab.handleDidStartProvisionalLoadForFrame(isMainFrame, validatedUrl); | 194 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
| 195 while (observers.hasNext()) { | |
| 196 observers.next().onDidStartNavigation(mTab, url, isInMainFrame, isEr rorPage); | |
| 197 } | |
| 191 } | 198 } |
| 192 | 199 |
| 193 @Override | 200 @Override |
| 194 public void didCommitProvisionalLoadForFrame(long frameId, boolean isMainFra me, String url, | 201 public void didFinishNavigation(String url, boolean isInMainFrame, boolean i sErrorPage, |
| 195 int transitionType) { | 202 boolean hasCommitted, boolean isSamePage, boolean isFragmentNavigati on, |
| 196 if (isMainFrame && UmaUtils.isRunningApplicationStart()) { | 203 Integer pageTransition, int errorCode, int httpStatusCode) { |
| 204 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | |
| 205 if (errorCode != 0) { | |
| 206 mTab.updateThemeColorIfNeeded(true); | |
| 207 if (isInMainFrame) mTab.didFailPageLoad(errorCode); | |
| 208 | |
| 209 // TODO(shaktisahu): Find out how to get the description for this er ror. | |
| 210 recordErrorInPolicyAuditor(url, "", errorCode); | |
|
shaktisahu
2017/01/31 01:57:53
I didn't find a way to retrieve the error descript
Ted C
2017/01/31 18:57:48
I wonder if we could just do net::ErrorToShortStri
Bernhard Bauer
2017/02/07 13:19:16
I think error_page::LocalizedError::GetErrorDetail
shaktisahu
2017/02/07 18:08:22
Hmm... but error_page is in components and we may
Ted C
2017/02/08 05:31:15
Why wouldn't we able to use it here? We're in chr
shaktisahu
2017/02/08 06:32:10
Oh, I was trying to add this to web_contents_obser
Bernhard Bauer
2017/02/08 10:26:38
That sounds good to me, thanks!
shaktisahu
2017/02/10 08:07:41
Seems like error_page::LocalizedError::GetErrorDet
| |
| 211 } | |
|
Ted C
2017/01/31 18:57:47
Should we return in the errorCode case?
shaktisahu
2017/02/03 06:56:16
Done.
Yes. In that case I would move the block ha
| |
| 212 | |
| 213 if (isInMainFrame && hasCommitted && UmaUtils.isRunningApplicationStart( )) { | |
| 197 // Current median is 550ms, and long tail is very long. ZoomedIn giv es good view of the | 214 // 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. | 215 // median and ZoomedOut gives a good overview. |
| 199 RecordHistogram.recordCustomTimesHistogram( | 216 RecordHistogram.recordCustomTimesHistogram( |
| 200 "Startup.FirstCommitNavigationTime2.ZoomedIn", | 217 "Startup.FirstCommitNavigationTime2.ZoomedIn", |
| 201 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime (), | 218 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime (), |
| 202 200, 1000, TimeUnit.MILLISECONDS, 100); | 219 200, 1000, TimeUnit.MILLISECONDS, 100); |
| 203 // For ZoomedOut very rarely is it under 50ms and this range matches | 220 // For ZoomedOut very rarely is it under 50ms and this range matches |
| 204 // CustomTabs.IntentToFirstCommitNavigationTime2.ZoomedOut. | 221 // CustomTabs.IntentToFirstCommitNavigationTime2.ZoomedOut. |
| 205 RecordHistogram.recordCustomTimesHistogram( | 222 RecordHistogram.recordCustomTimesHistogram( |
| 206 "Startup.FirstCommitNavigationTime2.ZoomedOut", | 223 "Startup.FirstCommitNavigationTime2.ZoomedOut", |
| 207 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime (), | 224 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime (), |
| 208 50, TimeUnit.MINUTES.toMillis(10), TimeUnit.MILLISECONDS, 50 ); | 225 50, TimeUnit.MINUTES.toMillis(10), TimeUnit.MILLISECONDS, 50 ); |
| 209 UmaUtils.setRunningApplicationStart(false); | 226 UmaUtils.setRunningApplicationStart(false); |
| 210 } | 227 } |
| 211 | 228 |
| 212 if (isMainFrame) { | 229 if (isInMainFrame && hasCommitted) { |
| 213 mTab.setIsTabStateDirty(true); | 230 mTab.setIsTabStateDirty(true); |
| 214 mTab.updateTitle(); | 231 mTab.updateTitle(); |
| 215 } | 232 mTab.handleDidFinishNavigation(url, pageTransition); |
| 216 | 233 mTab.setIsShowingErrorPage(isErrorPage); |
| 217 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | |
| 218 while (observers.hasNext()) { | |
| 219 observers.next().onDidCommitProvisionalLoadForFrame( | |
| 220 mTab, frameId, isMainFrame, url, transitionType); | |
| 221 } | 234 } |
| 222 | 235 |
| 223 observers.rewind(); | 236 observers.rewind(); |
| 224 while (observers.hasNext()) { | 237 while (observers.hasNext()) { |
| 225 observers.next().onUrlUpdated(mTab); | 238 observers.next().onDidFinishNavigation(mTab, url, isInMainFrame, isE rrorPage, |
| 239 hasCommitted, isSamePage, isFragmentNavigation, pageTransiti on, errorCode, | |
| 240 httpStatusCode); | |
| 226 } | 241 } |
| 227 | 242 |
| 228 if (!isMainFrame) return; | 243 if (hasCommitted) { |
| 229 mTab.handleDidCommitProvisonalLoadForFrame(url, transitionType); | 244 observers.rewind(); |
| 230 } | 245 while (observers.hasNext()) { |
| 231 | 246 observers.next().onUrlUpdated(mTab); |
| 232 @Override | 247 } |
| 233 public void didNavigateMainFrame(String url, String baseUrl, | |
| 234 boolean isNavigationToDifferentPage, boolean isFragmentNavigation, i nt statusCode) { | |
| 235 FullscreenManager fullscreenManager = mTab.getFullscreenManager(); | |
| 236 if (isNavigationToDifferentPage && fullscreenManager != null) { | |
| 237 fullscreenManager.setPersistentFullscreenMode(false); | |
| 238 } | 248 } |
| 239 | 249 |
| 240 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 250 FullscreenManager fullscreenManager = mTab.getFullscreenManager(); |
| 241 while (observers.hasNext()) { | 251 if (isInMainFrame && hasCommitted && !isSamePage && fullscreenManager != null) { |
| 242 observers.next().onDidNavigateMainFrame( | 252 fullscreenManager.setPersistentFullscreenMode(false); |
| 243 mTab, url, baseUrl, isNavigationToDifferentPage, | |
| 244 isFragmentNavigation, statusCode); | |
| 245 } | 253 } |
| 246 | 254 |
| 247 mTab.stopSwipeRefreshHandler(); | 255 mTab.stopSwipeRefreshHandler(); |
| 248 } | 256 } |
| 249 | 257 |
| 250 @Override | 258 @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 } | |
| 256 } | |
| 257 | |
| 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 | |
| 271 public void didFirstVisuallyNonEmptyPaint() { | 259 public void didFirstVisuallyNonEmptyPaint() { |
| 272 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 260 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
| 273 while (observers.hasNext()) { | 261 while (observers.hasNext()) { |
| 274 observers.next().didFirstVisuallyNonEmptyPaint(mTab); | 262 observers.next().didFirstVisuallyNonEmptyPaint(mTab); |
| 275 } | 263 } |
| 276 } | 264 } |
| 277 | 265 |
| 278 @Override | 266 @Override |
| 279 public void didChangeThemeColor(int color) { | 267 public void didChangeThemeColor(int color) { |
| 280 mTab.updateThemeColorIfNeeded(true); | 268 mTab.updateThemeColorIfNeeded(true); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 mTab.notifyLoadProgress(mTab.getProgress()); | 301 mTab.notifyLoadProgress(mTab.getProgress()); |
| 314 | 302 |
| 315 mTab.updateFullscreenEnabledState(); | 303 mTab.updateFullscreenEnabledState(); |
| 316 | 304 |
| 317 if (!mTab.maybeShowNativePage(mTab.getUrl(), false)) { | 305 if (!mTab.maybeShowNativePage(mTab.getUrl(), false)) { |
| 318 mTab.showRenderedPage(); | 306 mTab.showRenderedPage(); |
| 319 } | 307 } |
| 320 } | 308 } |
| 321 | 309 |
| 322 @Override | 310 @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() { | 311 public void destroy() { |
| 332 MediaCaptureNotificationService.updateMediaNotificationForTab( | 312 MediaCaptureNotificationService.updateMediaNotificationForTab( |
| 333 mTab.getApplicationContext(), mTab.getId(), 0, mTab.getUrl()); | 313 mTab.getApplicationContext(), mTab.getId(), 0, mTab.getUrl()); |
| 334 super.destroy(); | 314 super.destroy(); |
| 335 } | 315 } |
| 336 } | 316 } |
| OLD | NEW |