Expose WebPageImportanceSignals to embedder

This CL exposes WebPageImportanceSignals to embedder (Chromium content).
We plan to have Chromium tab discarding logic make decisions based on this.

BUG=520838

Review URL: https://codereview.chromium.org/1345023002

git-svn-id: svn://svn.chromium.org/blink/trunk/public@202436 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/web/WebPageImportanceSignals.h b/web/WebPageImportanceSignals.h
index 6e50ff9..7328c43 100644
--- a/web/WebPageImportanceSignals.h
+++ b/web/WebPageImportanceSignals.h
@@ -9,6 +9,8 @@
 
 namespace blink {
 
+class WebViewClient;
+
 // WebPageImportanceSignals indicate the importance of the page state to user.
 // This signal is propagated to embedder so that it can prioritize preserving
 // state of certain page over the others.
@@ -17,15 +19,18 @@
     WebPageImportanceSignals() { reset(); }
 
     bool hadFormInteraction() const { return m_hadFormInteraction; }
-    void setHadFormInteraction() { m_hadFormInteraction = true; }
+    void setHadFormInteraction();
 
     BLINK_EXPORT void reset();
 #if BLINK_IMPLEMENTATION
     void onCommitLoad();
 #endif
 
+    void setObserver(WebViewClient* observer) { m_observer = observer; }
+
 private:
     bool m_hadFormInteraction : 1;
+    WebViewClient* m_observer = nullptr;
 };
 
 } // namespace blink
diff --git a/web/WebView.h b/web/WebView.h
index fac145a..1bce1b2 100644
--- a/web/WebView.h
+++ b/web/WebView.h
@@ -50,6 +50,7 @@
 class WebDragData;
 class WebFrame;
 class WebHitTestResult;
+class WebPageImportanceSignals;
 class WebPageOverlay;
 class WebPrerendererClient;
 class WebSettings;
@@ -58,10 +59,10 @@
 class WebViewClient;
 struct WebActiveWheelFlingParameters;
 struct WebDeviceEmulationParams;
+struct WebFloatPoint;
 struct WebMediaPlayerAction;
 struct WebPluginAction;
 struct WebPoint;
-struct WebFloatPoint;
 struct WebWindowFeatures;
 
 class WebView : public WebWidget {
@@ -455,6 +456,9 @@
     // Overlay this WebView with a solid color.
     virtual void setPageOverlayColor(WebColor) = 0;
 
+    // Page Importance Signals ----------------------------------------------
+
+    virtual WebPageImportanceSignals* pageImportanceSignals() { return nullptr; }
 
     // i18n -----------------------------------------------------------------
 
diff --git a/web/WebViewClient.h b/web/WebViewClient.h
index d690585..2e8e4ab 100644
--- a/web/WebViewClient.h
+++ b/web/WebViewClient.h
@@ -115,6 +115,9 @@
     // A data url from <canvas> or <img> is passed to the method's argument.
     virtual void saveImageFromDataURL(const WebString&) { }
 
+    // Called when PageImportanceSignals for the WebView is updated.
+    virtual void pageImportanceSignalsChanged() { }
+
     // Editing -------------------------------------------------------------
 
     // These methods allow the client to intercept and overrule editing