Make HttpCanonicalWebUrlProvider extendable

Change HttpCanonicalWebUrlProvider constructor access to `protected` to
make this clas extendable. This way plugins like virtualhost can change
value of `canonicalWebUrl` based on the HTTP context request.

The problem with different canonical web urls comes into play when
virtualhost and download-commands plugins are used together. When
looking at the virtual host site and opening `Downloads` dialog, the
main host canononical web url will be used in download urls. This may
confuse users.

In order to fix that problem we need to make the default
HttpCanonicalWebUrlProvider extendable. Then we can bind it to a custom
implemenation in virtualhost plugin.

Bug: Issue 299833801
Release-Notes: Allow modules to provide different logic for the HTTP canonicalWebUrl
Change-Id: I8321b153782e0bf8131c66ebe477902a434c6dc1
diff --git a/java/com/google/gerrit/common/UsedAt.java b/java/com/google/gerrit/common/UsedAt.java
index 91a4da6..5ea5177 100644
--- a/java/com/google/gerrit/common/UsedAt.java
+++ b/java/com/google/gerrit/common/UsedAt.java
@@ -46,7 +46,8 @@
     PLUGIN_PULL_REPLICATION,
     PLUGIN_SERVICEUSER,
     PLUGIN_WEBSESSION_FLATFILE,
-    MODULE_GIT_REFS_FILTER
+    MODULE_GIT_REFS_FILTER,
+    MODULE_VIRTUALHOST
   }
 
   /** Reference to the project that uses the method annotated with this annotation. */
diff --git a/java/com/google/gerrit/httpd/HttpCanonicalWebUrlProvider.java b/java/com/google/gerrit/httpd/HttpCanonicalWebUrlProvider.java
index 6943faa..85dc200 100644
--- a/java/com/google/gerrit/httpd/HttpCanonicalWebUrlProvider.java
+++ b/java/com/google/gerrit/httpd/HttpCanonicalWebUrlProvider.java
@@ -14,6 +14,8 @@
 
 package com.google.gerrit.httpd;
 
+import com.google.gerrit.common.UsedAt;
+import com.google.gerrit.common.UsedAt.Project;
 import com.google.gerrit.server.config.CanonicalWebUrlProvider;
 import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.inject.Inject;
@@ -30,7 +32,8 @@
   private Provider<HttpServletRequest> requestProvider;
 
   @Inject
-  HttpCanonicalWebUrlProvider(@GerritServerConfig Config config) {
+  @UsedAt(Project.MODULE_VIRTUALHOST)
+  protected HttpCanonicalWebUrlProvider(@GerritServerConfig Config config) {
     super(config);
   }