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

Unified Diff: chrome/common/extensions/docs/examples/api/topsites/basic/popup.js

Issue 25389003: [DocServer] Updated Top Sites Sample Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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/common/extensions/docs/examples/api/topsites/basic/popup.js
diff --git a/chrome/common/extensions/docs/examples/api/topsites/basic/popup.js b/chrome/common/extensions/docs/examples/api/topsites/basic/popup.js
new file mode 100644
index 0000000000000000000000000000000000000000..d16ca046d6e7dd46c0fbd8e8d9663545886fd302
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/topsites/basic/popup.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
not at google - send to devlin 2013/10/01 15:04:36 it would be nice if this file were detected as a m
François Beaufort 2013/10/02 12:44:59 I've played as much as possible with "git cl uploa
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Event listener for clicks on links in a browser action popup.
+// Open the link in a new tab of the current window.
+function onAnchorClick(event) {
+ chrome.tabs.create({ url: event.srcElement.href });
+ return false;
+}
+
+// Given an array of URLs, build a DOM list of these URLs in the
+// browser action popup.
+function buildPopupDom(data) {
not at google - send to devlin 2013/10/01 15:04:36 s/data/historyItems/
François Beaufort 2013/10/02 12:44:59 Done.
+ var popupDiv = document.getElementById("mostVisited_div");
+
+ var ol = document.createElement('ol');
+ popupDiv.appendChild(ol);
+
+ for (var i = 0; i < data.length; i++) {
+ var a = document.createElement('a');
+ a.href = data[i].url;
+ a.appendChild(document.createTextNode(data[i].title));
+ a.addEventListener('click', onAnchorClick);
+
+ var li = document.createElement('li');
+ li.appendChild(a);
+
+ ol.appendChild(li);
not at google - send to devlin 2013/10/01 15:04:36 i'm gonna nitpick here for no other reason than DO
+ }
+}
+
+chrome.topSites.get(function(historyItems) {
+ buildPopupDom(historyItems);
+});
not at google - send to devlin 2013/10/01 15:04:36 cleanup: chrome.topSites.get(buildPopupDom);

Powered by Google App Engine
This is Rietveld 408576698