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

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

Issue 2394663002: Blimp: Propagating page loading status to tab (Closed)
Patch Set: dtrainor@ comments Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 org.chromium.base.ObserverList.RewindableIterator; 7 import org.chromium.base.ObserverList.RewindableIterator;
8 import org.chromium.blimp_public.contents.EmptyBlimpContentsObserver; 8 import org.chromium.blimp_public.contents.EmptyBlimpContentsObserver;
9 import org.chromium.ui.base.PageTransition; 9 import org.chromium.ui.base.PageTransition;
10 10
11 /** 11 /**
12 * BlimpContentsObserver used by Tab. 12 * BlimpContentsObserver used by Tab.
13 */ 13 */
14 public class TabBlimpContentsObserver extends EmptyBlimpContentsObserver { 14 public class TabBlimpContentsObserver extends EmptyBlimpContentsObserver {
15 private Tab mTab; 15 private Tab mTab;
16 private boolean mPageIsLoading;
16 17
17 public TabBlimpContentsObserver(Tab tab) { 18 public TabBlimpContentsObserver(Tab tab) {
18 mTab = tab; 19 mTab = tab;
20 mPageIsLoading = false;
19 } 21 }
20 22
21 /** 23 /**
22 * All UI updates related to navigation state should be notified from this m ethod. 24 * All UI updates related to navigation state should be notified from this m ethod.
23 */ 25 */
24 @Override 26 @Override
25 public void onNavigationStateChanged() { 27 public void onNavigationStateChanged() {
26 mTab.updateTitle(); 28 mTab.updateTitle();
27 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); 29 RewindableIterator<TabObserver> observers = mTab.getTabObservers();
28 while (observers.hasNext()) { 30 while (observers.hasNext()) {
29 observers.next().onUrlUpdated(mTab); 31 observers.next().onUrlUpdated(mTab);
30 } 32 }
31 } 33 }
32 34
33 /** 35 /**
34 * Tab can use this to drive what kind of content to show based on the URL. 36 * Tab can use this to drive what kind of content to show based on the URL.
37 * Also sets the loading status of the tab correctly.
35 */ 38 */
36 @Override 39 @Override
37 public void onLoadingStateChanged(boolean loading) { 40 public void onLoadingStateChanged(boolean loading) {
38 // TODO(dtrainor): Investigate if we need to pipe through a more accurat e PageTransition 41 if (loading) {
39 // here. 42 // Passing true for toDifferentDocument to update visuals related to location bar.
40 mTab.handleDidCommitProvisonalLoadForFrame(mTab.getUrl(), PageTransition .TYPED); 43 mTab.onLoadStarted(true);
44 } else {
45 mTab.onLoadStopped();
46 }
47 }
48
49 /**
50 * This method is used to update the status of progress bar.
51 */
52 @Override
53 public void onPageLoadingStateChanged(boolean loading) {
54 mPageIsLoading = loading;
55 if (loading) {
56 mTab.didStartPageLoad(mTab.getUrl(), false);
57
58 // Simulate provisional load start and completion events.
59 mTab.handleDidStartProvisionalLoadForFrame(true, mTab.getUrl());
60
61 // TODO(dtrainor): Investigate if we need to pipe through a more acc urate PageTransition
62 // here.
63 mTab.handleDidCommitProvisonalLoadForFrame(mTab.getUrl(), PageTransi tion.TYPED);
64
65 // Currently, blimp doesn't have a way to calculate the progress. So we are sending a
66 // fake progress value.
67 mTab.notifyLoadProgress(30);
68 } else {
69 mTab.notifyLoadProgress(100);
70 mTab.didFinishPageLoad();
71 }
72 }
73
74 /**
75 * @return a value between 0 and 100 reflecting what percentage of the page load is complete.
76 */
77 public int getMostRecentProgress() {
78 return mPageIsLoading ? 30 : 100;
41 } 79 }
42 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698