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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java

Issue 1381003004: Better distinguish didFinishLoad and didStopLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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.toolbar; 5 package org.chromium.chrome.browser.toolbar;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.drawable.Drawable; 8 import android.graphics.drawable.Drawable;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.Looper; 10 import android.os.Looper;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 public void onDidNavigateMainFrame(Tab tab, String url, String baseU rl, 303 public void onDidNavigateMainFrame(Tab tab, String url, String baseU rl,
304 boolean isNavigationToDifferentPage, boolean isFragmentNavig ation, 304 boolean isNavigationToDifferentPage, boolean isFragmentNavig ation,
305 int statusCode) { 305 int statusCode) {
306 if (isNavigationToDifferentPage) { 306 if (isNavigationToDifferentPage) {
307 mToolbar.onNavigatedToDifferentPage(); 307 mToolbar.onNavigatedToDifferentPage();
308 } 308 }
309 } 309 }
310 310
311 @Override 311 @Override
312 public void onPageLoadStarted(Tab tab, String url) { 312 public void onPageLoadStarted(Tab tab, String url) {
313 updateButtonStatus();
314 updateTabLoadingState(true);
315 mLoadProgressSimulator.cancel();
316
317 if (NativePageFactory.isNativePageUrl(url, tab.isIncognito())) { 313 if (NativePageFactory.isNativePageUrl(url, tab.isIncognito())) {
318 finishLoadProgress(false); 314 finishLoadProgress(false);
319 } else {
320 mToolbar.startLoadProgress();
321 setLoadProgress(0.0f);
322 } 315 }
323 } 316 }
324 317
325 @Override 318 @Override
326 public void onPageLoadFinished(Tab tab) {
327 Tab currentTab = mToolbarModel.getTab();
328 updateTabLoadingState(true);
329
330 // If we made some progress, fast-forward to complete, otherwise just dismiss any
331 // MINIMUM_LOAD_PROGRESS that had been set.
332 if (currentTab.getProgress() > MINIMUM_LOAD_PROGRESS) setLoadPro gress(1.0f);
333 finishLoadProgress(true);
334 }
335
336 @Override
337 public void onPageLoadFailed(Tab tab, int errorCode) {
338 updateTabLoadingState(true);
339 finishLoadProgress(false);
340 }
341
342 @Override
343 public void onTitleUpdated(Tab tab) { 319 public void onTitleUpdated(Tab tab) {
344 mLocationBar.setTitleToPageTitle(); 320 mLocationBar.setTitleToPageTitle();
345 } 321 }
346 322
347 @Override 323 @Override
348 public void onUrlUpdated(Tab tab) { 324 public void onUrlUpdated(Tab tab) {
349 // Update the SSL security state as a result of this notificatio n as it will 325 // Update the SSL security state as a result of this notificatio n as it will
350 // sometimes be the only update we receive. 326 // sometimes be the only update we receive.
351 updateTabLoadingState(true); 327 updateTabLoadingState(true);
352 328
353 // A URL update is a decent enough indicator that the toolbar wi dget is in 329 // A URL update is a decent enough indicator that the toolbar wi dget is in
354 // a stable state to capture its bitmap for use in fullscreen. 330 // a stable state to capture its bitmap for use in fullscreen.
355 mControlContainer.setReadyForBitmapCapture(true); 331 mControlContainer.setReadyForBitmapCapture(true);
356 } 332 }
357 333
358 @Override 334 @Override
359 public void onCrash(Tab tab, boolean sadTabShown) { 335 public void onCrash(Tab tab, boolean sadTabShown) {
360 updateTabLoadingState(false); 336 updateTabLoadingState(false);
361 updateButtonStatus(); 337 updateButtonStatus();
362 finishLoadProgress(false); 338 finishLoadProgress(false);
363 } 339 }
364 340
365 @Override 341 @Override
342 public void onLoadStarted(Tab tab, boolean toDifferentDocument) {
343 if (!toDifferentDocument) return;
344 updateButtonStatus();
345 updateTabLoadingState(true);
346 mLoadProgressSimulator.cancel();
347
348 mToolbar.startLoadProgress();
349 setLoadProgress(0.0f);
350 }
351
352 @Override
353 public void onLoadStopped(Tab tab, boolean toDifferentDocument) {
354 if (!toDifferentDocument) return;
355 updateTabLoadingState(true);
356
357 // If we made some progress, fast-forward to complete, otherwise just dismiss any
358 // MINIMUM_LOAD_PROGRESS that had been set.
359 if (tab.getProgress() > MINIMUM_LOAD_PROGRESS && tab.getProgress () < 1.0f) {
360 setLoadProgress(1.0f);
361 }
362 finishLoadProgress(true);
363 }
364
365 @Override
366 public void onLoadProgressChanged(Tab tab, int progress) { 366 public void onLoadProgressChanged(Tab tab, int progress) {
367 // TODO(kkimlabs): Investigate using float progress all the way up to Blink. 367 // TODO(kkimlabs): Investigate using float progress all the way up to Blink.
368 setLoadProgress(progress / 100.0f); 368 setLoadProgress(progress / 100.0f);
369 } 369 }
370 370
371 @Override 371 @Override
372 public void onContentChanged(Tab tab) { 372 public void onContentChanged(Tab tab) {
373 mToolbar.onTabContentViewChanged(); 373 mToolbar.onTabContentViewChanged();
374 } 374 }
375 375
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 } 1083 }
1084 1084
1085 /** 1085 /**
1086 * Cancels simulating load progress. 1086 * Cancels simulating load progress.
1087 */ 1087 */
1088 public void cancel() { 1088 public void cancel() {
1089 mHandler.removeMessages(MSG_ID_UPDATE_PROGRESS); 1089 mHandler.removeMessages(MSG_ID_UPDATE_PROGRESS);
1090 } 1090 }
1091 } 1091 }
1092 } 1092 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698