Add front-end support to enable two-up view status.

Implement a two-up view toggle button in PDF Viewer's zoom toolbar.
This button is available when feature "pdf-two-up-view" is enabled.

Bug: 51472
Change-Id: Icf6867e2897f1090b6b9fd8e9494006f648ffdd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2012837
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748840}
diff --git a/chrome/browser/extensions/api/resources_private/resources_private_api.cc b/chrome/browser/extensions/api/resources_private/resources_private_api.cc
index 4820771c..24faa79 100644
--- a/chrome/browser/extensions/api/resources_private/resources_private_api.cc
+++ b/chrome/browser/extensions/api/resources_private/resources_private_api.cc
@@ -60,6 +60,8 @@
     {"tooltipPrint", IDS_PDF_TOOLTIP_PRINT},
     {"tooltipFitToPage", IDS_PDF_TOOLTIP_FIT_PAGE},
     {"tooltipFitToWidth", IDS_PDF_TOOLTIP_FIT_WIDTH},
+    {"tooltipTwoUpViewEnable", IDS_PDF_TOOLTIP_TWO_UP_VIEW_ENABLE},
+    {"tooltipTwoUpViewDisable", IDS_PDF_TOOLTIP_TWO_UP_VIEW_DISABLE},
     {"tooltipZoomIn", IDS_PDF_TOOLTIP_ZOOM_IN},
     {"tooltipZoomOut", IDS_PDF_TOOLTIP_ZOOM_OUT},
 #if defined(OS_CHROMEOS)
@@ -130,6 +132,9 @@
   dict->SetKey("pdfAnnotationsEnabled",
                base::Value(base::FeatureList::IsEnabled(
                    chrome_pdf::features::kPDFAnnotations)));
+  dict->SetKey("pdfTwoUpViewEnabled",
+               base::Value(base::FeatureList::IsEnabled(
+                   chrome_pdf::features::kPDFTwoUpView)));
 
   bool enable_printing = true;
 #if defined(OS_CHROMEOS)
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc
index 8dac1cf..4f46584 100644
--- a/chrome/browser/pdf/pdf_extension_test.cc
+++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -803,6 +803,10 @@
 }
 #endif
 
+IN_PROC_BROWSER_TEST_F(PDFExtensionTest, TwoUpViewFeature) {
+  RunTestsInJsModule("two_up_view_feature_test.js", "test.pdf");
+}
+
 // TODO(tsepez): See https://crbug.com/696650.
 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_NoBeep) {
   // Block the exact query from pdf/main.js while still allowing enough
diff --git a/chrome/browser/resources/pdf/BUILD.gn b/chrome/browser/resources/pdf/BUILD.gn
index b22ef90..f93045f 100644
--- a/chrome/browser/resources/pdf/BUILD.gn
+++ b/chrome/browser/resources/pdf/BUILD.gn
@@ -95,6 +95,7 @@
 
 js_library("pdf_viewer") {
   deps = [
+    ":constants",
     ":controller",
     ":metrics",
     ":navigator",
diff --git a/chrome/browser/resources/pdf/constants.js b/chrome/browser/resources/pdf/constants.js
index 6131aa1a..70da3e82 100644
--- a/chrome/browser/resources/pdf/constants.js
+++ b/chrome/browser/resources/pdf/constants.js
@@ -12,3 +12,12 @@
   FIT_TO_WIDTH: 'fit-to-width',
   FIT_TO_HEIGHT: 'fit-to-height',
 };
+
+/**
+ * Enumeration of two up view actions.
+ * @enum {string}
+ */
+export const TwoUpViewAction = {
+  TWO_UP_VIEW_ENABLE: 'two-up-view-enable',
+  TWO_UP_VIEW_DISABLE: 'two-up-view-disable',
+};
diff --git a/chrome/browser/resources/pdf/controller.js b/chrome/browser/resources/pdf/controller.js
index 5f6d2de..9eccd835 100644
--- a/chrome/browser/resources/pdf/controller.js
+++ b/chrome/browser/resources/pdf/controller.js
@@ -91,6 +91,9 @@
   /** @abstract */
   rotateCounterclockwise() {}
 
+  /** @abstract */
+  setTwoUpView(enableTwoUpView) {}
+
   /** Triggers printing of the current document. */
   print() {}
 
@@ -175,6 +178,11 @@
   }
 
   /** @override */
+  setTwoUpView(enableTwoUpView) {
+    // TODO(dstockwell): Implement two up view.
+  }
+
+  /** @override */
   viewportChanged() {
     this.inkHost_.viewportChanged();
   }
@@ -334,6 +342,14 @@
   }
 
   /** @override */
+  setTwoUpView(enableTwoUpView) {
+    this.postMessage_({
+      type: 'setTwoUpView',
+      enableTwoUpView: enableTwoUpView,
+    });
+  }
+
+  /** @override */
   print() {
     this.postMessage_({type: 'print'});
   }
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-button.html b/chrome/browser/resources/pdf/elements/viewer-zoom-button.html
index 6eab6174..f51075c 100644
--- a/chrome/browser/resources/pdf/elements/viewer-zoom-button.html
+++ b/chrome/browser/resources/pdf/elements/viewer-zoom-button.html
@@ -77,6 +77,7 @@
     </style>
     <div id="wrapper">
       <cr-icon-button iron-icon="[[visibleIcon_]]" on-click="fireClick_"
-          aria-label$="[[visibleTooltip_]]" title="[[visibleTooltip_]]">
+          aria-label$="[[visibleTooltip_]]" title="[[visibleTooltip_]]"
+          disabled="[[disabled]]">
       </cr-icon-button>
     </div>
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-button.js b/chrome/browser/resources/pdf/elements/viewer-zoom-button.js
index 306ba40..3182b90 100644
--- a/chrome/browser/resources/pdf/elements/viewer-zoom-button.js
+++ b/chrome/browser/resources/pdf/elements/viewer-zoom-button.js
@@ -25,6 +25,11 @@
       observer: 'delayChanged_',
     },
 
+    disabled: {
+      type: Boolean,
+      value: false,
+    },
+
     /**
      * Icons to be displayed on the FAB. Multiple icons should be separated with
      * spaces, and will be cycled through every time the FAB is clicked.
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.html b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.html
index 887999ea..ab6a4d4 100644
--- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.html
+++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.html
@@ -1,4 +1,4 @@
-    <style>
+    <style include="cr-hidden-style">
       :host {
         --button-position-offset: 48px;
         bottom: 0;
@@ -44,21 +44,33 @@
         display: block;
       }
 
+      /*
+       * A larger gap between the fit button and the two-up view button
+       * and above the bottom two zoom buttons.
+       */
+      #two-up-view-button,
+      #zoom-in-button {
+        margin-top: 24px;
+      }
+
       /* A small gap between the zoom in/zoom out buttons. */
       #zoom-out-button {
         margin-top: 10px;
       }
-
-      /* A larger gap between the fit button and bottom two buttons. */
-      #zoom-in-button {
-        margin-top: 24px;
-      }
     </style>
     <div id="zoom-buttons">
-      <viewer-zoom-button id="fit-button" on-fabclick="fitToggle" delay="100"
+      <viewer-zoom-button id="fit-button" on-fabclick="fitToggle"
+          delay="[[fitButtonDelay_]]"
           keyboard-navigation-active="[[keyboardNavigationActive_]]"
           icons="pdf:fullscreen-exit cr:fullscreen">
       </viewer-zoom-button>
+      <!-- TODO(crbug.com/51472): Change icons for two-up-view-button -->
+      <!-- once they are finalized. -->
+      <viewer-zoom-button id="two-up-view-button" delay="100"
+          disabled="[[annotationMode]]" hidden$="[[!twoUpViewEnabled]]"
+          on-fabclick="twoUpViewToggle_"
+          keyboard-navigation-active="[[keyboardNavigationActive_]]"
+          icons="pdf:create pdf:eraser"></viewer-zoom-button>
       <viewer-zoom-button id="zoom-in-button" icons="pdf:add"
           keyboard-navigation-active="[[keyboardNavigationActive_]]"
           on-fabclick="zoomIn" delay="50"></viewer-zoom-button>
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.js b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.js
index 47e8fef2..ec5e991 100644
--- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.js
+++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar.js
@@ -8,7 +8,7 @@
 
 import {assert} from 'chrome://resources/js/assert.m.js';
 import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
-import {FittingType} from '../constants.js';
+import {FittingType, TwoUpViewAction} from '../constants.js';
 
 /**
  * @typedef {{
@@ -21,14 +21,31 @@
 const FIT_TO_PAGE_BUTTON_STATE = 0;
 const FIT_TO_WIDTH_BUTTON_STATE = 1;
 
+const TWO_UP_VIEW_DISABLED_STATE = 0;
+const TWO_UP_VIEW_ENABLED_STATE = 1;
+
 Polymer({
   is: 'viewer-zoom-toolbar',
 
   _template: html`{__html_template__}`,
 
   properties: {
+    /** Whether the viewer is currently in annotation mode. */
+    annotationMode: {
+      type: Boolean,
+      value: false,
+    },
+
     isPrintPreview: Boolean,
 
+    twoUpViewEnabled: Boolean,
+
+    /** @private */
+    fitButtonDelay_: {
+      type: Number,
+      computed: 'computeFitButtonDelay_(twoUpViewEnabled)',
+    },
+
     /** @private */
     keyboardNavigationActive_: {
       type: Boolean,
@@ -36,6 +53,15 @@
     },
   },
 
+  /**
+   * @param {boolean} twoUpViewEnabled Whether two-up view button is enabled.
+   * @return {number} Delay for :qthe fit button.
+   * @private
+   */
+  computeFitButtonDelay_(twoUpViewEnabled) {
+    return twoUpViewEnabled ? 150 : 100;
+  },
+
   listeners: {
     'focus': 'onFocus_',
     'keyup': 'onKeyUp_',
@@ -81,12 +107,16 @@
    * Change button tooltips to match any changes to localized strings.
    * @param {!{tooltipFitToPage: string,
    *           tooltipFitToWidth: string,
+   *           tooltipTwoUpViewEnable: string,
+   *           tooltipTwoUpViewDisable: string,
    *           tooltipZoomIn: string,
    *           tooltipZoomOut: string}} strings
    */
   setStrings(strings) {
     this.$['fit-button'].tooltips =
         [strings.tooltipFitToPage, strings.tooltipFitToWidth];
+    this.$['two-up-view-button'].tooltips =
+        [strings.tooltipTwoUpViewEnable, strings.tooltipTwoUpViewDisable];
     this.$['zoom-in-button'].tooltips = [strings.tooltipZoomIn];
     this.$['zoom-out-button'].tooltips = [strings.tooltipZoomOut];
   },
@@ -140,6 +170,20 @@
   },
 
   /**
+   * Handle clicks of the two-up-view button.
+   * @private
+   */
+  twoUpViewToggle_: function() {
+    assert(this.twoUpViewEnabled);
+    const twoUpViewAction = this.$['two-up-view-button'].activeIndex ===
+            TWO_UP_VIEW_DISABLED_STATE ?
+        TwoUpViewAction.TWO_UP_VIEW_ENABLE :
+        TwoUpViewAction.TWO_UP_VIEW_DISABLE;
+
+    this.fire('two-up-view-changed', twoUpViewAction);
+  },
+
+  /**
    * Handle clicks of the zoom-in-button.
    */
   zoomIn() {
@@ -157,6 +201,7 @@
     if (!this.visible_) {
       this.visible_ = true;
       this.$['fit-button'].show();
+      this.$['two-up-view-button'].show();
       this.$['zoom-in-button'].show();
       this.$['zoom-out-button'].show();
     }
@@ -166,6 +211,7 @@
     if (this.visible_) {
       this.visible_ = false;
       this.$['fit-button'].hide();
+      this.$['two-up-view-button'].hide();
       this.$['zoom-in-button'].hide();
       this.$['zoom-out-button'].hide();
     }
diff --git a/chrome/browser/resources/pdf/pdf_viewer.js b/chrome/browser/resources/pdf/pdf_viewer.js
index 633aa5d..7e5593a 100644
--- a/chrome/browser/resources/pdf/pdf_viewer.js
+++ b/chrome/browser/resources/pdf/pdf_viewer.js
@@ -9,7 +9,7 @@
 import {$, hasKeyModifiers, isRTL} from 'chrome://resources/js/util.m.js';
 
 import {BrowserApi} from './browser_api.js';
-import {FittingType} from './constants.js';
+import {FittingType, TwoUpViewAction} from './constants.js';
 import {ContentController, InkController, MessageData, PluginController, PrintPreviewParams} from './controller.js';
 import {Bookmark} from './elements/viewer-bookmark.js';
 import {FitToChangedEvent} from './elements/viewer-zoom-toolbar.js';
@@ -334,6 +334,10 @@
         e => this.fitToChanged_(
             /** @type {!CustomEvent<FitToChangedEvent>} */ (e)));
     this.zoomToolbar_.addEventListener(
+        'two-up-view-changed',
+        e => this.twoUpViewChanged_(
+            /** @type {!CustomEvent<!TwoUpViewAction>} */ (e)));
+    this.zoomToolbar_.addEventListener(
         'zoom-in', () => this.viewport_.zoomIn());
     this.zoomToolbar_.addEventListener(
         'zoom-out', () => this.viewport_.zoomOut());
@@ -641,6 +645,7 @@
    */
   async annotationModeToggled_(e) {
     const annotationMode = e.detail.value;
+    this.zoomToolbar_.annotationMode = annotationMode;
     if (annotationMode) {
       // Enter annotation mode.
       assert(this.currentController_ === this.pluginController_);
@@ -657,6 +662,7 @@
         } catch (e) {
           // The user aborted entering annotation mode. Revert to the plugin.
           this.toolbar_.annotationMode = false;
+          this.zoomToolbar_.annotationMode = false;
           this.updateProgress_(100);
           return;
         }
@@ -702,6 +708,7 @@
       return;
     }
     this.toolbar_.toggleAnnotation();
+    this.zoomToolbar_.annotationMode = false;
     await this.loaded;
   }
 
@@ -727,6 +734,22 @@
   }
 
   /**
+   * Changes two up view mode for the controller. Controller will trigger
+   * layout update later, which will update the viewport accordingly.
+   * @param {!CustomEvent<!TwoUpViewAction>} e
+   * @private
+   */
+  twoUpViewChanged_(e) {
+    this.currentController_.setTwoUpView(
+        e.detail === TwoUpViewAction.TWO_UP_VIEW_ENABLE);
+    this.toolbarManager_.forceHideTopToolbar();
+    this.toolbar_.annotationAvailable =
+        (e.detail !== TwoUpViewAction.TWO_UP_VIEW_ENABLE);
+
+    // TODO(crbug.com/51472): Record to metrics.
+  }
+
+  /**
    * Sends a 'documentLoaded' message to the PDFScriptingAPI if the document has
    * finished loading.
    * @private
@@ -918,6 +941,8 @@
         loadTimeData.getBoolean('pdfAnnotationsEnabled');
     $('toolbar').printingEnabled = loadTimeData.getBoolean('printingEnabled');
     $('zoom-toolbar').setStrings(strings);
+    $('zoom-toolbar').twoUpViewEnabled =
+        loadTimeData.getBoolean('pdfTwoUpViewEnabled') && !this.isPrintPreview_;
     // Display the zoom toolbar after the UI text direction is set, to ensure it
     // appears on the correct side of the PDF viewer.
     $('zoom-toolbar').hidden = false;
diff --git a/chrome/browser/resources/pdf/viewport.js b/chrome/browser/resources/pdf/viewport.js
index 26733b04..3796717 100644
--- a/chrome/browser/resources/pdf/viewport.js
+++ b/chrome/browser/resources/pdf/viewport.js
@@ -19,7 +19,12 @@
  */
 let DocumentDimensions;
 
-/** @typedef {{defaultPageOrientation: number}} */
+/**
+ * @typedef {{
+ *   defaultPageOrientation: number,
+ *   twoUpViewEnabled: boolean,
+ * }}
+ */
 export let LayoutOptions;
 
 /** @typedef {{x: number, y: number}} */
@@ -136,12 +141,6 @@
     /** @private {!FittingType} */
     this.fittingType_ = FittingType.NONE;
 
-    /**
-     * |twoUpView_| should be in sync with |two_up_view_| in PDFiumEngine.
-     * @private {boolean}
-     */
-    this.twoUpView_ = false;
-
     /** @private {number} */
     this.prevScale_ = 1;
 
@@ -220,9 +219,13 @@
     return this.rotations_;
   }
 
-  /** @param {boolean} twoUpView The new two up view state to set. */
-  setTwoUpView(twoUpView) {
-    this.twoUpView_ = twoUpView;
+  /** @return {boolean} Whether viewport is in two-up view mode. */
+  twoUpViewEnabled() {
+    const options = this.getLayoutOptions();
+    if (options === undefined) {
+      return false;
+    }
+    return options.twoUpViewEnabled;
   }
 
   /**
@@ -677,7 +680,7 @@
   getLastPageInViewport_(viewportRect) {
     const pageAtY = this.getPageAtY_(viewportRect.y + viewportRect.height);
 
-    if (!this.twoUpView_ || pageAtY % 2 === 1 ||
+    if (!this.twoUpViewEnabled() || pageAtY % 2 === 1 ||
         pageAtY + 1 >= this.pageDimensions_.length) {
       return pageAtY;
     }
@@ -1070,7 +1073,8 @@
    */
   goToNextPage() {
     const currentPage = this.getMostVisiblePage();
-    const nextPageOffset = (this.twoUpView_ && currentPage % 2 === 0) ? 2 : 1;
+    const nextPageOffset =
+        (this.twoUpViewEnabled() && currentPage % 2 === 0) ? 2 : 1;
     this.goToPage(currentPage + nextPageOffset);
   }
 
@@ -1082,7 +1086,7 @@
     const currentPage = this.getMostVisiblePage();
     let previousPageOffset = -1;
 
-    if (this.twoUpView_) {
+    if (this.twoUpViewEnabled()) {
       previousPageOffset = (currentPage % 2 === 0) ? -2 : -3;
     }
 
diff --git a/chrome/test/data/pdf/two_up_view_feature_test.js b/chrome/test/data/pdf/two_up_view_feature_test.js
new file mode 100644
index 0000000..1bb1964
--- /dev/null
+++ b/chrome/test/data/pdf/two_up_view_feature_test.js
@@ -0,0 +1,36 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+chrome.test.runTests([
+  function testTwoUpViewFeatureDisabled() {
+    const toolbar = document.body.querySelector('#zoom-toolbar');
+    toolbar.twoUpViewEnabled = false;
+
+    const twoUpButton = toolbar.shadowRoot.querySelector('#two-up-view-button');
+    chrome.test.assertTrue(!!twoUpButton);
+    chrome.test.assertTrue(twoUpButton.hidden);
+
+    const fitButton = toolbar.shadowRoot.querySelector('#fit-button');
+    chrome.test.assertTrue(!!fitButton);
+    chrome.test.assertEq(100, fitButton.delay);
+
+    chrome.test.succeed();
+  },
+
+
+  function testTwoUpViewFeatureEnabled() {
+    const toolbar = document.body.querySelector('#zoom-toolbar');
+    toolbar.twoUpViewEnabled = true;
+
+    const twoUpButton = toolbar.shadowRoot.querySelector('#two-up-view-button');
+    chrome.test.assertTrue(!!twoUpButton);
+    chrome.test.assertFalse(twoUpButton.hidden);
+
+    const fitButton = toolbar.shadowRoot.querySelector('#fit-button');
+    chrome.test.assertTrue(!!fitButton);
+    chrome.test.assertEq(150, fitButton.delay);
+
+    chrome.test.succeed();
+  },
+]);
diff --git a/chrome/test/data/pdf/viewport_test.js b/chrome/test/data/pdf/viewport_test.js
index 305ac2ff..bdc0baf 100644
--- a/chrome/test/data/pdf/viewport_test.js
+++ b/chrome/test/data/pdf/viewport_test.js
@@ -240,9 +240,9 @@
   function testGetMostVisiblePageForTwoUpView() {
     const mockWindow = new MockWindow(400, 500);
     const viewport = getZoomableViewport(mockWindow, new MockSizer(), 0, 1, 0);
-    viewport.setTwoUpView(true);
 
-    const documentDimensions = new MockDocumentDimensions(100, 100);
+    const documentDimensions = new MockDocumentDimensions(
+        100, 100, {defaultPageOrientation: 0, twoUpViewEnabled: true});
     documentDimensions.addPageForTwoUpView(100, 0, 300, 400);
     documentDimensions.addPageForTwoUpView(400, 0, 400, 300);
     documentDimensions.addPageForTwoUpView(0, 400, 400, 250);
@@ -601,9 +601,9 @@
     const mockCallback = new MockViewportChangedCallback();
     const viewport = getZoomableViewport(mockWindow, mockSizer, 0, 1, 0);
     viewport.setViewportChangedCallback(mockCallback.callback);
-    viewport.setTwoUpView(true);
 
-    const documentDimensions = new MockDocumentDimensions(800, 750);
+    const documentDimensions = new MockDocumentDimensions(
+        800, 750, {defaultPageOrientation: 0, twoUpViewEnabled: true});
     documentDimensions.addPageForTwoUpView(200, 0, 200, 150);
     documentDimensions.addPageForTwoUpView(400, 0, 400, 200);
     documentDimensions.addPageForTwoUpView(100, 200, 300, 250);
@@ -706,9 +706,9 @@
     const mockCallback = new MockViewportChangedCallback();
     const viewport = getZoomableViewport(mockWindow, mockSizer, 0, 1, 0);
     viewport.setViewportChangedCallback(mockCallback.callback);
-    viewport.setTwoUpView(true);
 
-    const documentDimensions = new MockDocumentDimensions(800, 750);
+    const documentDimensions = new MockDocumentDimensions(
+        800, 750, {defaultPageOrientation: 0, twoUpViewEnabled: true});
     documentDimensions.addPageForTwoUpView(200, 0, 200, 150);
     documentDimensions.addPageForTwoUpView(400, 0, 400, 200);
     documentDimensions.addPageForTwoUpView(100, 200, 300, 250);
@@ -1053,10 +1053,11 @@
 
     chrome.test.assertEq(undefined, viewport.getLayoutOptions());
 
-    viewport.setDocumentDimensions(
-        new MockDocumentDimensions(50, 50, {defaultPageOrientation: 1}));
+    viewport.setDocumentDimensions(new MockDocumentDimensions(
+        50, 50, {defaultPageOrientation: 1, twoUpViewEnabled: true}));
     chrome.test.assertEq(
-        {defaultPageOrientation: 1}, viewport.getLayoutOptions());
+        {defaultPageOrientation: 1, twoUpViewEnabled: true},
+        viewport.getLayoutOptions());
 
     viewport.setDocumentDimensions(new MockDocumentDimensions(50, 50));
     chrome.test.assertEq(undefined, viewport.getLayoutOptions());
diff --git a/components/pdf_strings.grdp b/components/pdf_strings.grdp
index 822b2e9..406d802 100644
--- a/components/pdf_strings.grdp
+++ b/components/pdf_strings.grdp
@@ -46,6 +46,15 @@
     <message name="IDS_PDF_TOOLTIP_FIT_WIDTH" desc="Button tooltip for the button which zooms a PDF so that the width of a single page fills the window horizontally">
       Fit to width
     </message>
+    <!-- TODO(nigi): Remove the translateable="false" attributes for messages
+    IDS_PDF_TOOLTIP_TWO_UP_VIEW_ENABLE and IDS_PDF_TOOLTIP_TWO_UP_VIEW_DISABLE
+    once their tooltips are finalized. -->
+    <message name="IDS_PDF_TOOLTIP_TWO_UP_VIEW_ENABLE" desc="Button tooltip for the button which enables displaying two pages of a PDF on the screen horizontally" translateable="false">
+      Enable two-up view
+    </message>
+    <message name="IDS_PDF_TOOLTIP_TWO_UP_VIEW_DISABLE" desc="Button tooltip for the button which stops displaying two pages of a PDF on the screen horizontally" translateable="false">
+      Disable two-up view
+    </message>
     <message name="IDS_PDF_TOOLTIP_ZOOM_IN" desc="Button tooltip for the button which zooms in a PDF, so that the document appears larger">
       Zoom in
     </message>
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 5348dc9..bfea6e9 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -1740,6 +1740,7 @@
 }
 
 void OutOfProcessInstance::SetTwoUpView(bool enable_two_up_view) {
+  DCHECK(base::FeatureList::IsEnabled(features::kPDFTwoUpView));
   engine_->SetTwoUpView(enable_two_up_view);
 }