[lacros] Introduce WebContentsCanGoBackObserver class

... to server Exo's system wide back gesture behavior.

This CL introduces a new AuraSurface request named set_can_go_back()
(see components/exo/wayland/protocol/aura-shell.xml).

Flow summary:

  WebContentsCanGoBackObserver
    (watches webcontents-level b/f and visibility changes)
             |
             | (informs)
             |
             |           (IPC / Wayland)
       WaylandExtension -----------------> ZAuraShell (Exo)
                                                      ^
                                                      |
                                                      | (asks)
                                                      |
                                                     Ash
Details:

On lacros side:
---------------

1) WebContentsCanGoBackObserver class: An instance is created by
TabHelpers for every WebContents instance. The class overrides
WebContentsObserver's OnVisibilityChanged() and NavigationEntryCommitted().
This way, it watches for visibility and b/f changes, and
notifies the respective Ozone/Wayland window whether it can go back as
per its navigation list or not. It allows server side to implement
features like "minimize the window on back gesture", for example. The
ui::WaylandExtensions path is used for the lacros/chrome -> ash/chrome IPC.

NOTE: The existing BrowserCommandController::UpdateCommandsForTabState()
method has the exactly same behavior: it watches for visibility and
back/forward changes to set the "BACK BUTTON" as active or not, for
the currently active tab.

On Exo/Ash side:
---------------

2) aura_surface_set_can_go_back() calls
   AuraSurface::SetCanGoBack() calls
   Surface::SetCanGoBack() calls
   ShellSurfaceBase::SetCanGoBack()

3) ShellSurfaceBase::SetCanGoBack() sets the existing
aura::Window property ash::kMinimizeOnBackKey, accordingly.

4) The property is checked in ash::ShouldMinimizeTopWindowOnBack()
when Ash is handling a system wife back-gesture.

BUG=1173793

Change-Id: Iaa102f22bb2cf517b1e42257d11e5a093cba8d3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2786770
Auto-Submit: Antonio Gomes <[email protected]>
Commit-Queue: Antonio Gomes <[email protected]>
Reviewed-by: Nico Weber <[email protected]>
Reviewed-by: Hidehiko Abe <[email protected]>
Reviewed-by: Mitsuru Oshima (Slow - Gardening) <[email protected]>
Reviewed-by: Xiaoqian Dai <[email protected]>
Cr-Commit-Position: refs/heads/master@{#873341}
diff --git a/components/exo/wayland/zaura_shell.h b/components/exo/wayland/zaura_shell.h
index 5028f27..abdb0548 100644
--- a/components/exo/wayland/zaura_shell.h
+++ b/components/exo/wayland/zaura_shell.h
@@ -17,7 +17,7 @@
 namespace exo {
 namespace wayland {
 
-constexpr uint32_t kZAuraShellVersion = 18;
+constexpr uint32_t kZAuraShellVersion = 19;
 
 // Adds bindings to the Aura Shell. Normally this implies Ash on ChromeOS
 // builds. On non-ChromeOS builds the protocol provides access to Aura windowing
@@ -49,6 +49,8 @@
   void SetSnapRight();
   void UnsetSnap();
   void SetWindowSessionId(int32_t window_session_id);
+  void SetCanGoBack();
+  void UnsetCanGoBack();
 
   // Overridden from SurfaceObserver:
   void OnSurfaceDestroying(Surface* surface) override;