| 
    
      
  | 
  
 Chromium Code Reviews
        
  DescriptionHook up new distillability with Clank UI
Use the new push-based distillability test (http://crrev.com/1414283006/)
in Clank to replace the old query-based one.
BUG=509869, 525797
Committed: https://crrev.com/031f209e63525bf838dcaf55f7b292e192d1a990
Cr-Commit-Position: refs/heads/master@{#359742}
   
  Patch Set 1 : #Patch Set 2 : merge master and fix #
 Messages
    Total messages: 31 (18 generated)
     
  
  
 Patchset #1 (id:1) has been deleted 
 wychen@chromium.org changed reviewers: + mdjones@chromium.org 
 PTAL 
 lgtm 
 Description was changed from ========== Hook up new distillability with Clank UI BUG=509869 ========== to ========== Hook up new distillability with Clank UI BUG=509869, 525797 ========== 
 Description was changed from ========== Hook up new distillability with Clank UI BUG=509869, 525797 ========== to ========== Hook up new distillability with Clank UI Use the new push-based distillability test (http://crrev.com/1414283006/) in Clank to replace the old query-based one. BUG=509869, 525797 ========== 
 The CQ bit was checked by wychen@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1422023005/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1422023005/40001 
 The CQ bit was unchecked by commit-bot@chromium.org 
 Dry run: Try jobs failed on following builders: ios_rel_device_ninja on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios_rel_device_ni...) mac_chromium_compile_dbg_ng on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_gn_rel on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_gn_r...) mac_chromium_rel_ng on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...) 
 The CQ bit was checked by wychen@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1422023005/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1422023005/60001 
 The CQ bit was unchecked by commit-bot@chromium.org 
 Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_32_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) win_chromium_compile_dbg_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_comp...) win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...) 
 The CQ bit was checked by wychen@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1422023005/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1422023005/80001 
 The CQ bit was unchecked by commit-bot@chromium.org 
 Dry run: Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...) 
 Patchset #4 (id:80001) has been deleted 
 Patchset #3 (id:60001) has been deleted 
 Patchset #2 (id:40001) has been deleted 
 The CQ bit was checked by wychen@chromium.org 
 CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1422023005/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1422023005/20001 
 The CQ bit was unchecked by commit-bot@chromium.org 
 Failed to apply patch for
chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java:
While running git apply --index -3 -p1;
  error: patch failed:
chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java:80
  Falling back to three-way merge...
  Applied patch to
'chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java'
with conflicts.
  U
chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
Patch:      
chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
Index:
chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
diff --git
a/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
index
d1c7dfa4eac9fd9c97007e5d07f09ce1e94d2b61..597d22ef4d30ebb29a6bea58999c10702865efe2
100644
---
a/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
+++
b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java
@@ -80,6 +80,8 @@ public class ReaderModeManager extends EmptyTabObserver
      */
     private boolean mIsUmaRecorded;
 
+    private boolean mIsCallbackSet;
+
     private WebContentsObserver mWebContentsObserver;
 
     private final Tab mTab;
@@ -96,6 +98,7 @@ public class ReaderModeManager extends EmptyTabObserver
                 ? ApiCompatibilityUtils.getColor(
                         context.getResources(), R.color.reader_mode_header_bg)
                 : 0;
+        mIsCallbackSet = false;
     }
 
     // EmptyTabObserver:
@@ -219,21 +222,6 @@ public class ReaderModeManager extends EmptyTabObserver
     private WebContentsObserver createWebContentsObserver(WebContents
webContents) {
         return new WebContentsObserver(webContents) {
             @Override
-            public void didFinishLoad(long frameId, String validatedUrl,
boolean isMainFrame) {
-                if (!isMainFrame) return;
-                if (DomDistillerUrlUtils.isDistilledPage(mTab.getUrl()))
return;
-                updateStatusBasedOnReaderModeCriteria(true);
-            }
-
-            @Override
-            public void didFailLoad(boolean isProvisionalLoad, boolean
isMainFrame, int errorCode,
-                        String description, String failingUrl, boolean
wasIgnoredByHandler) {
-                if (!isMainFrame) return;
-                if (DomDistillerUrlUtils.isDistilledPage(mTab.getUrl()))
return;
-                updateStatusBasedOnReaderModeCriteria(true);
-            }
-
-            @Override
             public void didStartProvisionalLoadForFrame(long frameId, long
parentFrameId,
                     boolean isMainFrame, String validatedUrl, boolean
isErrorPage,
                     boolean isIframeSrcdoc) {
@@ -260,8 +248,7 @@ public class ReaderModeManager extends EmptyTabObserver
                                 mReaderModePageUrl))) {
                     mReaderModeStatus = NOT_POSSIBLE;
                     mIsUmaRecorded = false;
-                    // Do not call updateStatusBasedOnReaderModeCriteria here.
-                    // For ADABOOST_MODEL, it is unlikely to get valid info at
this event.
+                    if (!mIsCallbackSet) setDistillabilityCallback();
                 }
                 mReaderModePageUrl = null;
                 if (mReaderModePanel != null)
mReaderModePanel.updateBottomButtonBar();
@@ -269,22 +256,22 @@ public class ReaderModeManager extends EmptyTabObserver
         };
     }
 
-    // Updates reader mode status based on whether or not the page should be
viewed in reader mode.
-    private void updateStatusBasedOnReaderModeCriteria(final boolean
forceRecord) {
+    // Set the callback for updating reader mode status based on whether or not
the page should
+    // be viewed in reader mode.
+    private void setDistillabilityCallback() {
         if (mTab.getWebContents() == null) return;
         if (mTab.getContentViewCore() == null) return;
 
-        DistillablePageUtils.isPageDistillable(mTab.getWebContents(),
-                mTab.getContentViewCore().getIsMobileOptimizedHint(),
-                new DistillablePageUtils.PageDistillableCallback() {
+        DistillablePageUtils.setDelegate(mTab.getWebContents(),
+                new DistillablePageUtils.PageDistillableDelegate() {
                     @Override
-                    public void onIsPageDistillableResult(boolean
isDistillable) {
+                    public void onIsPageDistillableResult(boolean
isDistillable, boolean isLast) {
                         if (isDistillable) {
                             mReaderModeStatus = POSSIBLE;
                         } else {
                             mReaderModeStatus = NOT_POSSIBLE;
                         }
-                        if (!mIsUmaRecorded && (mReaderModeStatus == POSSIBLE
|| forceRecord)) {
+                        if (!mIsUmaRecorded && (mReaderModeStatus == POSSIBLE
|| isLast)) {
                             mIsUmaRecorded = true;
                             RecordHistogram.recordBooleanHistogram(
                                     "DomDistiller.PageDistillable",
mReaderModeStatus == POSSIBLE);
@@ -292,6 +279,7 @@ public class ReaderModeManager extends EmptyTabObserver
                         if (mReaderModePanel != null)
mReaderModePanel.updateBottomButtonBar();
                     }
                 });
+        mIsCallbackSet = true;
     }
 
     private ContextualSearchManager getContextualSearchManager(Tab tab) {
          
 The CQ bit was unchecked by commit-bot@chromium.org 
 The CQ bit was checked by wychen@chromium.org 
 The patchset sent to the CQ was uploaded after l-g-t-m from mdjones@chromium.org Link to the patchset: https://codereview.chromium.org/1422023005/#ps100001 (title: "merge master and fix") 
 CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1422023005/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1422023005/100001 
 
            
              
                Message was sent while issue was closed.
              
            
             
          
        Committed patchset #2 (id:100001) 
 
            
              
                Message was sent while issue was closed.
              
            
             
          
        Patchset 2 (id:??) landed as https://crrev.com/031f209e63525bf838dcaf55f7b292e192d1a990 Cr-Commit-Position: refs/heads/master@{#359742}  | 
    ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
