Displays slow page max threshold on interventions internals NQ tab

Updates Network Quality tab with slow page max threshold.

Bug: 924574
Change-Id: Ia543e88115ac51f288b740bcc4992b3e3f65569e
Reviewed-on: https://chromium-review.googlesource.com/c/1430744
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
Commit-Queue: Doug Arnett <dougarnett@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#627516}(cherry picked from commit ac27c056de3741e2265bb5a69aec8560d5c6b93a)
Reviewed-on: https://chromium-review.googlesource.com/c/1452069
Reviewed-by: Doug Arnett <dougarnett@chromium.org>
Cr-Commit-Position: refs/branch-heads/3683@{#162}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
diff --git a/chrome/browser/resources/interventions_internals/index.html b/chrome/browser/resources/interventions_internals/index.html
index f8d0ad4..dba1b625 100644
--- a/chrome/browser/resources/interventions_internals/index.html
+++ b/chrome/browser/resources/interventions_internals/index.html
@@ -103,6 +103,10 @@
         Estimated effective connection type:
         <span id="nqe-type">N/A</span>
       </div>
+      <div id="nqe-slow-page-threshold">
+        Slow page maximum threshold:
+        <span id="max-intervention-type">N/A</span>
+      </div>
       <div id="nqe-logs">
         <div class="table-name">Network Quality Change Log</div>
         <table id="nqe-logs-table">
diff --git a/chrome/browser/resources/interventions_internals/index.js b/chrome/browser/resources/interventions_internals/index.js
index 41ee656..c25c1ef 100644
--- a/chrome/browser/resources/interventions_internals/index.js
+++ b/chrome/browser/resources/interventions_internals/index.js
@@ -555,12 +555,18 @@
    *
    * @override
    * @param {string} type The string representation of estimated ECT.
+   * @param {string} maxInterventionType The string representation of the
+   * session's maximum ECT threshold for interventions.
    */
-  onEffectiveConnectionTypeChanged: function(type) {
+  updateEffectiveConnectionType: function(type, maxInterventionType) {
     // Change the current ECT.
     const ectType = $('nqe-type');
     ectType.textContent = type;
 
+    // Set the session maximum ECT for interventions.
+    const maxInterventionEctType = $('max-intervention-type');
+    maxInterventionEctType.textContent = maxInterventionType;
+
     const now = getTimeFormat(Date.now());
 
     // Log ECT changed event to ECT change log.
diff --git a/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom b/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom
index 0b39e90..7e520156 100644
--- a/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom
+++ b/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom
@@ -88,9 +88,11 @@
   OnBlacklistCleared(int64 time);
 
   // Notify the page on the new estimated effective connection type is |type|.
-  // This is called by InterventionsInternalsPageHandler when the estimate
-  // network quality changes.
-  OnEffectiveConnectionTypeChanged(string type);
+  // Also reports the session's maximum intervention effective connection type
+  // |max_intervention_type| for slow pages. This method is called by
+  // InterventionsInternalsPageHandler when the estimate network quality
+  // changes.
+  UpdateEffectiveConnectionType(string type, string max_intervention_type);
 
   // Notify the page on whether the blacklist decision is considered or ignored.
   // This method is called by InterventionsInternalsPageHandler when the status
diff --git a/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc b/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
index e8700f43..a9542d86 100644
--- a/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
+++ b/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
@@ -150,7 +150,10 @@
     return;
   }
   std::string ect_name = net::GetNameForEffectiveConnectionType(type);
-  page_->OnEffectiveConnectionTypeChanged(ect_name);
+  std::string max_intervention_ect_name =
+      net::GetNameForEffectiveConnectionType(
+          previews::params::GetSessionMaxECTThreshold());
+  page_->UpdateEffectiveConnectionType(ect_name, max_intervention_ect_name);
 
   // Log change ECT event.
   previews::PreviewsLogger::MessageLog message(
diff --git a/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc b/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
index 775a30f..cbfd3a3 100644
--- a/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
+++ b/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
@@ -157,7 +157,9 @@
   void OnBlacklistCleared(int64_t time) override {
     blacklist_cleared_time_ = time;
   }
-  void OnEffectiveConnectionTypeChanged(const std::string& type) override {
+  void UpdateEffectiveConnectionType(
+      const std::string& type,
+      const std::string& max_intervention_type) override {
     // Ignore.
     // TODO(thanhdle): Add integration test to test behavior of the pipeline end
     // to end. crbug.com/777936
diff --git a/chrome/test/data/webui/interventions_internals_browsertest.js b/chrome/test/data/webui/interventions_internals_browsertest.js
index 240d11d..db92c50 100644
--- a/chrome/test/data/webui/interventions_internals_browsertest.js
+++ b/chrome/test/data/webui/interventions_internals_browsertest.js
@@ -601,7 +601,7 @@
     let pageImpl = new InterventionsInternalPageImpl(null);
     let ectTypes = ['type1', 'type2', 'type3'];
     ectTypes.forEach((type) => {
-      pageImpl.onEffectiveConnectionTypeChanged(type);
+      pageImpl.updateEffectiveConnectionType(type, 'max');
       let actual = $('nqe-type').textContent;
       expectEquals(type, actual);
     });