Merge "Plugin endpoint parameters"
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
index bcd2378..a2a1c0b 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
@@ -40,20 +40,41 @@
 
     _initDecoration(name, plugin) {
       const el = document.createElement(name);
-      el.plugin = plugin;
-      el.content = this.getContentChildren()[0];
+      this._initProperties(el, plugin, this.getContentChildren().find(
+          el => el.nodeName !== 'GR-ENDPOINT-PARAM'));
       this._appendChild(el);
       return el;
     },
 
     _initReplacement(name, plugin) {
-      this.getContentChildren().forEach(node => node.remove());
+      this.getContentChildNodes().forEach(node => node.remove());
       const el = document.createElement(name);
-      el.plugin = plugin;
+      this._initProperties(el, plugin);
       this._appendChild(el);
       return el;
     },
 
+    _getEndpointParams() {
+      return Polymer.dom(this).querySelectorAll('gr-endpoint-param').map(el => {
+        return {name: el.getAttribute('name'), value: el.value};
+      });
+    },
+
+    /**
+     * @param {!Element} el
+     * @param {!Object} plugin
+     * @param {!Element=} opt_content
+     */
+    _initProperties(el, plugin, opt_content) {
+      el.plugin = plugin;
+      if (opt_content) {
+        el.content = opt_content;
+      }
+      for (const {name, value} of this._getEndpointParams()) {
+        el[name] = value;
+      }
+    },
+
     _appendChild(el) {
       Polymer.dom(this.root).appendChild(el);
     },
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
index e7d1930..578989e 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
@@ -22,10 +22,13 @@
 <script src="../../../bower_components/web-component-tester/browser.js"></script>
 <link rel="import" href="../../../test/common-test-setup.html"/>
 <link rel="import" href="gr-endpoint-decorator.html">
+<link rel="import" href="../gr-endpoint-param/gr-endpoint-param.html">
 
 <test-fixture id="basic">
   <template>
-    <gr-endpoint-decorator name="foo"></gr-endpoint-decorator>
+    <gr-endpoint-decorator name="foo">
+      <gr-endpoint-param name="someparam" value="barbar"></gr-endpoint-param>
+    </gr-endpoint-decorator>
   </template>
 </test-fixture>
 
@@ -44,6 +47,7 @@
       domHookStub = {
         handleInstanceAttached: sandbox.stub(),
         handleInstanceDetached: sandbox.stub(),
+        getPublicAPI: () => domHookStub,
       };
       sandbox.stub(
           GrDomHooksManager.prototype, 'getDomHook').returns(domHookStub);
@@ -53,6 +57,7 @@
         plugin = p;
         plugin.registerCustomComponent('foo', 'some-module');
         plugin.registerCustomComponent('foo', 'other-module', {replace: true});
+        plugin.registerCustomComponent('bar', 'some-module');
       }, '0.1', 'http://some/plugin/url.html');
 
       sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
@@ -110,5 +115,11 @@
         done();
       });
     });
+
+    test('params', () => {
+      const instance = document.createElement('foo');
+      element._initProperties(instance, plugin);
+      assert.equal(instance.someparam, 'barbar');
+    });
   });
 </script>
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.html b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.html
new file mode 100644
index 0000000..1aa9e7c
--- /dev/null
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.html
@@ -0,0 +1,21 @@
+<!--
+Copyright (C) 2017 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<link rel="import" href="../../../bower_components/polymer/polymer.html">
+
+<dom-module id="gr-endpoint-param">
+  <script src="gr-endpoint-param.js"></script>
+</dom-module>
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js
new file mode 100644
index 0000000..5a2ab59
--- /dev/null
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+(function() {
+  'use strict';
+
+  Polymer({
+    is: 'gr-endpoint-param',
+    properties: {
+      name: String,
+      value: Object,
+    },
+  });
+})();
diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html
index 7c8b6ff..c748a9b 100644
--- a/polygerrit-ui/app/test/index.html
+++ b/polygerrit-ui/app/test/index.html
@@ -102,6 +102,7 @@
     'diff/gr-syntax-layer/gr-syntax-layer_test.html',
     'diff/gr-syntax-lib-loader/gr-syntax-lib-loader_test.html',
     'plugins/gr-attribute-helper/gr-attribute-helper_test.html',
+    'plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html',
     'plugins/gr-event-helper/gr-event-helper_test.html',
     'plugins/gr-external-style/gr-external-style_test.html',
     'plugins/gr-plugin-host/gr-plugin-host_test.html',