Add configuation option to show/hide top level menu

Some sites may want to disable top level menu. Provide an option to do
that.

Change-Id: I83dd0a4cbae25475e9258242f8e5400ffb7444d8
diff --git a/src/main/java/com/googlesource/gerrit/plugins/javamelody/Module.java b/src/main/java/com/googlesource/gerrit/plugins/javamelody/Module.java
index e300143..291fbf1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/javamelody/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/javamelody/Module.java
@@ -15,19 +15,33 @@
 package com.googlesource.gerrit.plugins.javamelody;
 
 import com.google.gerrit.extensions.annotations.Exports;
+import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.config.CapabilityDefinition;
 import com.google.gerrit.extensions.registration.DynamicSet;
 import com.google.gerrit.extensions.webui.TopMenu;
+import com.google.gerrit.server.config.PluginConfig;
+import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
 
 public class Module extends AbstractModule {
 
+  private final PluginConfig cfg;
+
+  @Inject
+  public Module(PluginConfigFactory cfgFactory,
+      @PluginName String pluginName) {
+    this.cfg = cfgFactory.getFromGerritConfig(pluginName);
+  }
+
   @Override
   protected void configure() {
     bind(CapabilityDefinition.class)
       .annotatedWith(Exports.named(MonitoringCapability.ID))
       .to(MonitoringCapability.class);
-    DynamicSet.bind(binder(), TopMenu.class)
-      .to(MonitoringTopMenu.class);
+    if (cfg.getBoolean("allowTopMenu", true)) {
+      DynamicSet.bind(binder(), TopMenu.class)
+        .to(MonitoringTopMenu.class);
+    }
   }
 }
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
new file mode 100644
index 0000000..789350d
--- /dev/null
+++ b/src/main/resources/Documentation/config.md
@@ -0,0 +1,16 @@
+Configuration
+=============
+
+The configuration of the @PLUGIN@ plugin is done in the `gerrit.config`
+file.
+
+```
+  [plugin "@PLUGIN@"]
+    allowTopMenu = false
+```
+
+<a id="allowTopMenu">
+`plugin.@PLUGIN@.allowTopMenu`
+:	Whether it is allowed to show top menu in Gerrit UI.
+	By default true.
+