diff options
author | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 21:19:10 +0000 |
---|---|---|
committer | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 21:19:10 +0000 |
commit | b8bdc7b6f21c232c6183b560d6de3717304e4503 (patch) | |
tree | 30eba1c2365c84a46ca9ea3e4a11cab27e04da68 /chrome | |
parent | e8f95f6ac5f672fed00fe92be8e36929a3fc2e7d (diff) | |
download | chromium_src-b8bdc7b6f21c232c6183b560d6de3717304e4503.zip chromium_src-b8bdc7b6f21c232c6183b560d6de3717304e4503.tar.gz chromium_src-b8bdc7b6f21c232c6183b560d6de3717304e4503.tar.bz2 |
Remove the last of the old samples.
BUG=26106
TEST=none
TBR=finnur
Review URL: http://codereview.chromium.org/386023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
9 files changed, 0 insertions, 589 deletions
diff --git a/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html b/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html deleted file mode 100644 index 7421ad6..0000000 --- a/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html +++ /dev/null @@ -1,88 +0,0 @@ -<html> -<script> -var dump = function(obj, indent) { - if (indent === undefined) - indent = ""; - if (typeof obj == "object") { - var ret = "{<br/>"; - var child_indent = indent + " "; - for (var item in obj) { - var child = null; - try { - child = obj[item]; - } catch (e) { - child = '<error>'; - } - ret += child_indent + item + ": " + dump(child, indent + " "); - } - return ret + indent + "}" + "<br/>"; - } else { - return obj.toString() + "<br/>"; - } -} - -var testMoveBookmarks = function(event) { - testMoveBookmarks2(event); -} - -var testMoveBookmarks2 = function(event) { - console.log(testMoveBookmarks2.caller.name); - if (event.shiftKey) { - // TODO - it would be nice to have a mechanism to do this built-in to a - // context menu. - window.location.reload(); - return; - } - console.log("testMoveBookmarks2"); - chrome.bookmarks.getChildren('0', function(root_children) { - var bookmark_bar = root_children[0]; // bookmarks bar is always first - chrome.bookmarks.getChildren(bookmark_bar.id, function(bar_children) { - var folder_search = []; - bar_children.forEach(function(child) { - if (child.title == "folder" && child.url == undefined) { - folder_search.push(child); - } - }); - if (folder_search.length == 1) { - console.log('moving children out of "folder"'); - var folder = folder_search[0]; - chrome.bookmarks.getChildren(folder_search[0].id, - function(folder_children) { - folder_children.forEach(function(child) { - chrome.bookmarks.move(child.id, - {'parentId': bookmark_bar.id}); - }); - }); - chrome.bookmarks.remove(folder.id); - } else if (folder_search.length == 0) { - console.log('creating "folder" and moving children into it'); - chrome.bookmarks.create({'parentId': bookmark_bar.id, - 'title': 'folder'}, - function(folder) { - chrome.bookmarks.search("oog", function(oog_search) { - oog_search.forEach(function(oog_match) { - chrome.bookmarks.move(oog_match.id, - {'parentId': folder.id}) - }); - }); - }); - } else { - console.log("my puny code wasn't written to handle this"); - } - }); - }); -}; - -var dumpBookmarks = function(event) { - chrome.tabs.create({url:"bookmark_view.html"}); -}; -</script> -<body> -<div class="toolstrip-button" onclick="dumpBookmarks(window.event);"> -<span>Dump Bookmarks</span> -</div> -<div class="toolstrip-button" onclick="testMoveBookmarks(window.event);"> -<span>Test Move</span> -</div> -</body> -</html> diff --git a/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html b/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html deleted file mode 100644 index 163f2e4..0000000 --- a/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html +++ /dev/null @@ -1,152 +0,0 @@ -<!DOCTYPE HTML> -<title>Bookmark View</title> -<style> - -.bookmark { - margin-left: 5px; - padding: 2px; -} - -.bookmark_title { - display: inline; - border: 1px solid white; - padding: 0px 3px; -} - -.bookmark_title:hover { - background-color: silver; - border: 1px solid black; -} - -.event-log { - font-family: monospace; -} - -ul { - padding-left: 10px; -} - -</style> -<script> -// XXX Hack: When you call window.open('chrome-extension://...'), the window is -// first navigated to about:blank, and then to the final URL. This confuses the -// code that sets up our v8 extensions, and we don't end up with them running. -// -// If we noticed this happened, reload ourselves, which should fix it. -if (!chrome.bookmarks) - location.reload(); - -var logEvent = function(name, id, data) { - var log = document.getElementById("event-log"); - log.innerHTML = name + ": " + id + ", " + JSON.stringify(data) + "<br>" + - log.innerHTML; - console.log("got event: " + name); -} - -chrome.bookmarks.onCreated.addListener(function(id, data) { - logEvent("onBookmarkCreated", id, data); -}); - -chrome.bookmarks.onRemoved.addListener(function(id, data) { - logEvent("onBookmarkRemoved", id, data); -}); - -chrome.bookmarks.onChanged.addListener(function(id, data) { - logEvent("onBookmarkChanged", id, data); -}); - -chrome.bookmarks.onMoved.addListener(function(id, data) { - logEvent("onBookmarkMoved", id, data); -}); - -chrome.bookmarks.onChildrenReordered.addListener(function(id, data) { - logEvent("onBookmarkChildrenReordered", id, data); -}); - -var prefix = "bookmark_"; - -var toggleBookmark = function(event) { - event.stopPropagation(); - var node = event.currentTarget; - var id_str = node.id; - if (id_str < prefix.length) - return; - var id = id_str.substring(prefix.length); - console.log("toggle: " + id); - //console.dir(event); - if (node.childNodes.length > 1) { - var i = 0; - while (node.childNodes.length > i) { - var child = node.childNodes.item(i); - if (child.tagName == "UL") - node.removeChild(child); - else - i++; - } - } else { - chrome.bookmarks.getChildren(id, function(children) { - console.dir(children); - addBookmarks(children, node); - }); - } -}; - -var addBookmark = function(bookmark, parent) { - var child = document.createElement('li'); - child.className = 'bookmark'; - child.id = prefix + bookmark.id; - child.addEventListener('click', toggleBookmark, false); - var text = bookmark.title; - if (bookmark.dateAdded) - text += " (" + new Date(bookmark.dateAdded) + ")"; - if (bookmark.url && bookmark.url.length) { - var link = document.createElement('a'); - link.href = bookmark.url; - link.innerHTML = text; - link.className = 'bookmark_title'; - child.appendChild(link); - } else { - var title = document.createElement('div'); - title.innerHTML = text; - title.className = 'bookmark_title'; - child.appendChild(title); - } - parent.appendChild(child); -}; - -var addBookmarks = function(bookmarks, parent) { - console.log("addBookmarks " + parent.id); - var list = document.createElement("ul"); - parent.appendChild(list); - bookmarks.forEach(function(bookmark) { addBookmark(bookmark, list); }); -}; - -var testGetTree = function(results) { - console.log("testGetTree:"); - console.dir(results); - function get_children(node) { - console.log(node.title); - node.children.forEach(get_children); - }; - results.forEach(get_children); -}; - -var loadBookmarks = function() { - var container = document.getElementById('container'); - var rootElement = document.createElement("div"); - var rootId = '0'; - rootElement.id = prefix + rootId; - // root element is empty / invisible, just an id to be looked up - container.appendChild(rootElement); - chrome.bookmarks.getChildren(rootId, function(children) { - addBookmarks(children, rootElement); - }); - chrome.bookmarks.getTree(testGetTree); -}; - -</script> -<body onload="loadBookmarks()"> -<div id="container"> -</div> -<div id="event-log"></div> -</body> diff --git a/chrome/test/data/extensions/samples/bookmarks/manifest.json b/chrome/test/data/extensions/samples/bookmarks/manifest.json deleted file mode 100644 index c6319e8..0000000 --- a/chrome/test/data/extensions/samples/bookmarks/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{
- "name": "BookmarksAPI",
- "description": "Bookmarks API test",
- "version": "0.1",
- "toolstrips": ["bookmark_api.html"],
- "permissions": ["bookmarks"]
-}
diff --git a/chrome/test/data/extensions/samples/youtube_popular/latest_yt_popular_video.html b/chrome/test/data/extensions/samples/youtube_popular/latest_yt_popular_video.html deleted file mode 100644 index 8299f15..0000000 --- a/chrome/test/data/extensions/samples/youtube_popular/latest_yt_popular_video.html +++ /dev/null @@ -1,14 +0,0 @@ -<html> -<head> -<link rel="stylesheet" type="text/css" href="styles.css"> -<script type="text/javascript" src="map.js"></script> -<script type="text/javascript" src="manage_video.js"></script> -</head> -<body onload="start()" onclick="showYTLatest()"> - <div> - <img src="youtube.png" style="width:24; height:24"> - <span>Popular on YouTube<span style="display: inline-block;" - id="newCount"></span> - </div> -</body> -</html> diff --git a/chrome/test/data/extensions/samples/youtube_popular/manage_video.js b/chrome/test/data/extensions/samples/youtube_popular/manage_video.js deleted file mode 100644 index 3129cc4..0000000 --- a/chrome/test/data/extensions/samples/youtube_popular/manage_video.js +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2009 Google Inc. All Rights Reserved. - -/** - * @fileoverview This file contains js that continues collect Popular video - * from YouTube and displays them when needed. - * @author lzheng@chromium.com (Lei Zheng) - */ - -const YT_POLL_INTERVAL = 1000 * 600; // 10 minute -var json_url_popular = 'http://gdata.youtube.com/feeds/api/standardfeeds/' + - 'most_popular?time=today&alt=json-in-script&format=5&max-results=50&' + - 'callback=processVideos'; - -// This holds all videos when browser starts. -var YT_existing_video_map = new Map(); -// This holds all popular videos after browser starts. -var YT_latest_video_map = new Map(); - -var YT_reqCount = 0; - -const YT_MAX_VIDEOS = 500; - -var YT_start_time = Date(); - -/** - * Class that holds video information that will be displayed. - * @param {string} video_url Video Url from Gdata for a given video. - * @param {string} thumb_url The url to access thumbnails. - * @param {string} title Title of the video. - * @param {string} description The description of the video. - */ -function videoEntry(video_url, thumb_url, title, description) { - this.video_url = video_url; - this.thumb_url = thumb_url; - this.title = title; - this.description = description; - this.time = Date(); -} - -/** - * Dump what's in the video_map to html. - * @param {Map} video_map The Map that contains video information. - * @return {string} The html output. - */ -function outputMap(video_map) { - var keys = video_map.keys() || []; - var output = '<table>'; - for (var i = 0; i < keys.length; ++i) { - console.log(keys[i]); - var title = video_map.get(keys[i]).title; - var playerUrl = video_map.get(keys[i]).video_url; - var thumbnailUrl = video_map.get(keys[i]).thumb_url; - var time = video_map.get(keys[i]).time; - var description = video_map.get(keys[i]).description; - if (i % 3 == 0) { - if (i != 0) { - output += '</tr>'; - } - output += '<tr>'; - } - output += '<td><a href = \' ' + playerUrl + '\' target=\'_black\'\'>' + - '<img src="'+ thumbnailUrl + '" width="130" height="97"/><br />' + - '<span class="titlec">' + title + '...</span><br /></a><br />' + - '<font size=2>' + description + '... </font></td>'; - } - output += '</tr></table>'; - return output; -} - -/** - * Display popular videos when and after browser started. - */ -function showYTLatest() { - var new_win = window.open(); - var html = ['<html><head><title>New Popular YouTube Videos</title><style>', - '.titlec { font-size: small;}ul.videos li { float: left; ', - 'width: 10em; margin-bottom: 1em;}ul.videos{ ', - 'margin-bottom: 1em; padding-left : 0em; margin-left: 0em; ', - 'list-style: none;}</style></head><body>']; - console.log('show my videos total: ' + YT_latest_video_map.size()); - html.push('<div id="videos"><font size="5" color="green">', - YT_latest_video_map.size(), - '</font> new popular videos after you start', - ' your browser at: <font size="1">', YT_start_time, - '</font><ul>'); - - html.push(outputMap(YT_latest_video_map)); - html.push('</ul></div>'); - - html.push('<div id="videos"><font size="5" color="green">', - YT_existing_video_map.size(), - '</font> popular videos when you start your browser at: ', - '<font size="1">', YT_start_time, '</font><ul>'); - html.push(outputMap(YT_existing_video_map)); - html.push('</ul></div>'); - html.push('</body></html>'); - console.log('html: ' + html.join('')); - new_win.document.write(html.join('')); -} - -/** - * Callback function for GDataJson and schedule the next gdata call. - * Extract data from Gdata and store them if needed. - * @param {Gdata} gdata Gdata from YouTube. - */ -function processVideos(gdata) { - var feed = gdata.feed; - var entries = feed.entry || []; - console.log('process videos total: ' + entries.length - + 'reqCount=' + YT_reqCount); - var first_run = false; - - if (YT_existing_video_map.size() == 0) { - first_run = true; - } - for (var i = 0; i < entries.length; i++) { - var title = entries[i].title.$t.substr(0,20); - var thumb_url = entries[i].media$group.media$thumbnail[0].url; - var video_url = entries[i].media$group.media$player[0].url; - var description = - entries[i].media$group.media$description.$t.substr(0, 100); - if (first_run == true) { - YT_existing_video_map.insert( - title, - new videoEntry(video_url, thumb_url, title, description)); - console.log(title); - } else { - if (YT_existing_video_map.get(title) == null) { - // This is new, keep it - if (YT_latest_video_map.size() < YT_MAX_VIDEOS) { - YT_latest_video_map.insert( - title, - new videoEntry(video_url, thumb_url, title, description)); - } else { - console.log('Too many new videos'); - } - } - } - } - - // Schedule the next call - document.getElementById('newCount').innerHTML = '(was ' + - YT_existing_video_map.size() + ', new ' + - YT_latest_video_map.size() + ')'; - var gdata_json = document.getElementById('gdata_json'); - - // cleanup the json script inserted in fetchJSON - document.getElementsByTagName('body')[0].removeChild(gdata_json); - scheduleRequest(); -} - -/** - * Fetch gdata via JSON. - */ -function fetchJSON() { - var scr = document.createElement('script'); - scr.setAttribute('language', 'JavaScript'); - scr.setAttribute('src', json_url_popular + '&reqCount=' + YT_reqCount); - scr.setAttribute('id', 'gdata_json'); - ++YT_reqCount; - document.getElementsByTagName('body')[0].appendChild(scr); -} - -/** - * Where the extension starts. - */ -function start() { - window.setTimeout(fetchJSON, 0); -} - -/** - * Schedule the fetchJSON call. - */ -function scheduleRequest() { - window.setTimeout(fetchJSON, YT_POLL_INTERVAL); -} diff --git a/chrome/test/data/extensions/samples/youtube_popular/manifest.json b/chrome/test/data/extensions/samples/youtube_popular/manifest.json deleted file mode 100644 index 1f2783d..0000000 --- a/chrome/test/data/extensions/samples/youtube_popular/manifest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "What's new?", - "version": "0.2", - "description": "Track latest YouTube Videos", - "permissions": [ - "http://www.youtube.com/*" - ], - "toolstrips": [ - "latest_yt_popular_video.html" - ] -} diff --git a/chrome/test/data/extensions/samples/youtube_popular/map.js b/chrome/test/data/extensions/samples/youtube_popular/map.js deleted file mode 100644 index bfaaa1c..0000000 --- a/chrome/test/data/extensions/samples/youtube_popular/map.js +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @fileoverview This file contains js create a helper Map object - * @author lzheng@chromium.com (Lei Zheng) - */ - -/** - * A Map class that implemeted using two arrays. - */ -Map = function() { - /** - * Array that hold all Keys. - * @private - */ - this.keysArray = []; // Keys - /** - * Array that hold all values. - * @private - */ - this.valsArray = []; // Values - - /** - * Index of where to insert new entries in key and value array. - * @private - */ - this.mapIndex_ = 0; -}; - -/** - * Insert a key, value pair to map. - * @param {object} key An object that supports "==". - * @param {object} value The entry in map. - */ -Map.prototype.insert = function(key, value) { - var index = this.findIndex(key); - if (index == -1) { - this.keysArray[this.mapIndex_] = key; - this.valsArray[this.mapIndex_] = value; - ++this.mapIndex_; - } - else { - this.valsArray[index] = value; - } -}; - -/** - * Get the entry associated with a key. - * @param {object} key for the entry. - * @return {object} The entry in map. - */ -Map.prototype.keys = function() { - return this.keysArray; -}; - -/** - * Get the entry associated with a key. - * @param {object} key for the entry. - * @return {object} The entry in map. - */ -Map.prototype.get = function(key) { - var index = this.findIndex(key); - if (index != -1) { - return this.valsArray[index]; - } - return null; -}; - - - -/** - * Remove an entry associated with a key. - * @param {object} key for the entry. - */ -Map.prototype.remove = function(key) { - var index = this.findIndex(key); - if (index != -1) { - this.keysArray = this.removeFromArray(keysArray, index); - this.valsArray = this.removeFromAarry(valsArray, index); - --this.mapIndex_; - } - return; -}; - -/** - * Get the total entries in the map. - * @return {int} The total number of entries. - */ -Map.prototype.size = function() { - return this.mapIndex_; -}; - -/** - * Clear up everything in the map. - */ -Map.clear = function() { - this.mapIndex_ = 0; - this.keysArray = []; - this.valsArray = []; -}; - -/** - * Find the index associated with a key. - * @private - * @param {object} key for the entry. - * @return {int} The index of this entry. - */ -Map.prototype.findIndex = function(key) { - var result = -1; - for (var i = 0; i < this.keysArray.length; i++) { - if (this.keysArray[i] == key) { - result = i; - break; - } - } - return result; -}; - -/** - * @private - * Remove an entry from the map. - * @param {int} index The index of the entry. - */ -Map.prototype.removeAt = function(array, index) { - var first_half = array.slice(0, index); - var second_half = array.slice(index + 1); - return first_half.concat(second_half); -} diff --git a/chrome/test/data/extensions/samples/youtube_popular/styles.css b/chrome/test/data/extensions/samples/youtube_popular/styles.css deleted file mode 100644 index d84c626..0000000 --- a/chrome/test/data/extensions/samples/youtube_popular/styles.css +++ /dev/null @@ -1,15 +0,0 @@ -.titlec { - font-size: small; -} -ul.videos li { - float: left; - width: 10em; - margin-bottom: 1em; -} -ul.videos -{ - margin-bottom: 1em; - padding-left : 0em; - margin-left: 0em; - list-style: none; -} diff --git a/chrome/test/data/extensions/samples/youtube_popular/youtube.png b/chrome/test/data/extensions/samples/youtube_popular/youtube.png Binary files differdeleted file mode 100644 index c7d988a..0000000 --- a/chrome/test/data/extensions/samples/youtube_popular/youtube.png +++ /dev/null |