Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: chrome/browser/resources/bluetooth_internals/sidebar.js

Issue 2576603002: bluetooth: Add device details page with basic properties to internals page. (Closed)
Patch Set: Add CSS for handling long device names Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/bluetooth_internals/sidebar.js
diff --git a/chrome/browser/resources/bluetooth_internals/sidebar.js b/chrome/browser/resources/bluetooth_internals/sidebar.js
index f060e713979238a4cd899271606dd828771254f6..9071614f354ab3291f120a6a1abddd7ab1f1ddf4 100644
--- a/chrome/browser/resources/bluetooth_internals/sidebar.js
+++ b/chrome/browser/resources/bluetooth_internals/sidebar.js
@@ -7,6 +7,9 @@
*/
cr.define('sidebar', function() {
+ /** @typedef {{pageName: string, text: string}} */
+ var SidebarItem;
+
/** @const {!cr.ui.pageManager.PageManager}*/
var PageManager = cr.ui.pageManager.PageManager;
@@ -40,6 +43,23 @@ cr.define('sidebar', function() {
__proto__: PageManager.Observer.prototype,
/**
+ * Adds a new list item to the sidebar using the given |item|.
+ * @param {!SidebarItem} item
+ */
+ addItem: function(item) {
+ var sidebarItem = document.createElement('li');
+ sidebarItem.dataset.pageName = item.pageName.toLowerCase();
+
+ var button = document.createElement('button');
+ button.classList.add('custom-appearance');
+ button.textContent = item.text;
+ button.addEventListener('click', this.onItemClick_.bind(this));
+ sidebarItem.appendChild(button);
+
+ this.sidebarList_.appendChild(sidebarItem);
+ },
+
+ /**
* Closes the sidebar. Only applies to layouts with window width <= 600px.
*/
close: function() {
@@ -58,6 +78,16 @@ cr.define('sidebar', function() {
},
/**
+ * Removes a sidebar item where |pageName| matches the item's pageName.
+ * @param {string} pageName
+ */
+ removeItem: function(pageName) {
+ pageName = pageName.toLowerCase();
+ var query = 'li[data-page-name="' + pageName + '"]';
+ this.sidebarList_.removeChild(this.sidebarList_.querySelector(query));
+ },
+
+ /**
* Called when a page is navigated to.
* @override
* @param {string} path The path of the page being visited.

Powered by Google App Engine
This is Rietveld 408576698