diff options
author | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 21:29:11 +0000 |
---|---|---|
committer | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 21:29:11 +0000 |
commit | 5e85b6df11e8a98a7384a9b2a84471e3de85011f (patch) | |
tree | 8bfd4b28fde39723c8963dc6a9256bcf12caa366 | |
parent | 6c8dcc3cb5d7f6b0523fd44b6a72aa42b911a575 (diff) | |
download | chromium_src-5e85b6df11e8a98a7384a9b2a84471e3de85011f.zip chromium_src-5e85b6df11e8a98a7384a9b2a84471e3de85011f.tar.gz chromium_src-5e85b6df11e8a98a7384a9b2a84471e3de85011f.tar.bz2 |
Moving samples into docs/examples.
Also did a little cleanup of a few of the samples.
More cleanup still to go...
BUG=26106
TEST=none
Review URL: http://codereview.chromium.org/390013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31714 0039d316-1c4b-4281-b951-d872f2087c98
56 files changed, 450 insertions, 866 deletions
diff --git a/chrome/common/extensions/docs/examples/README.txt b/chrome/common/extensions/docs/examples/README.txt new file mode 100644 index 0000000..834cae2 --- /dev/null +++ b/chrome/common/extensions/docs/examples/README.txt @@ -0,0 +1,6 @@ +Chromium Extension Examples + +The directory structure is as follows: +* api/ - trivial extensions focused on a single API package +* extensions/ - full featured extensions spanning multiple API packages +* tutorials/ - multi-step walkthroughs referenced inline in the docs diff --git a/chrome/test/data/extensions/samples/print_browser_action/background.html b/chrome/common/extensions/docs/examples/api/browserAction/print/background.html index 5b3f930..5b3f930 100644 --- a/chrome/test/data/extensions/samples/print_browser_action/background.html +++ b/chrome/common/extensions/docs/examples/api/browserAction/print/background.html diff --git a/chrome/common/extensions/docs/examples/api/browserAction/print/manifest.json b/chrome/common/extensions/docs/examples/api/browserAction/print/manifest.json new file mode 100644 index 0000000..0949549 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/browserAction/print/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "Print this page", + "description": "Adds a print button to the browser.", + "version": "1.1", + "background_page": "background.html", + "permissions": [ + "tabs", "http://*/*", "https://*/*" + ], + "browser_action": { + "default_title": "Print this page", + "default_icon": "print_16x16.png" + } +}
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/print_browser_action/print_16x16.png b/chrome/common/extensions/docs/examples/api/browserAction/print/print_16x16.png Binary files differindex d145964..d145964 100644 --- a/chrome/test/data/extensions/samples/print_browser_action/print_16x16.png +++ b/chrome/common/extensions/docs/examples/api/browserAction/print/print_16x16.png diff --git a/chrome/test/data/extensions/samples/set_page_color/icon.png b/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/icon.png Binary files differindex 1f1c906..1f1c906 100755 --- a/chrome/test/data/extensions/samples/set_page_color/icon.png +++ b/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/icon.png diff --git a/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/manifest.json b/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/manifest.json new file mode 100755 index 0000000..83e9052 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "A browser action with a popup that changes the page color.", + "version": "1.0", + "permissions": [ + "tabs", "http://*/*", "https://*/*" + ], + "browser_action": { + "default_title": "Set this page's color.", + "default_icon": "icon.png", + "popup": "popup.html" + } +}
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/set_page_color/popup.html b/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/popup.html index 62de0ed..f82fded 100644 --- a/chrome/test/data/extensions/samples/set_page_color/popup.html +++ b/chrome/common/extensions/docs/examples/api/browserAction/set_page_color/popup.html @@ -1,52 +1,52 @@ -<style>
-body {
- overflow: hidden;
- margin: 0px;
- padding: 0px;
- background: white;
-}
-
-div:first-child {
- margin-top: 0px;
-}
-
-div {
- cursor: pointer;
- text-align: center;
- padding: 1px 3px;
- font: menu;
- width: 100px;
- margin-top: 1px;
- background: #cccccc;
-}
-div:hover {
- background: #aaaaaa;
-}
-#red {
- border: 1px solid red;
- color: red;
-}
-#blue {
- border: 1px solid blue;
- color: blue;
-}
-#green {
- border: 1px solid green;
- color: green;
-}
-#yellow {
- border: 1px solid yellow;
- color: yellow;
-}
-</style>
-<script>
-function click(color) {
- chrome.tabs.executeScript(null,
- {code:"document.body.bgColor='" + color.id + "'"});
- window.close();
-}
-</script>
-<div onclick="click(this)" id="red">red</div>
-<div onclick="click(this)" id="blue">blue</div>
-<div onclick="click(this)" id="green">green</div>
-<div onclick="click(this)" id="yellow">yellow</div>
+<style> +body { + overflow: hidden; + margin: 0px; + padding: 0px; + background: white; +} + +div:first-child { + margin-top: 0px; +} + +div { + cursor: pointer; + text-align: center; + padding: 1px 3px; + font: menu; + width: 100px; + margin-top: 1px; + background: #cccccc; +} +div:hover { + background: #aaaaaa; +} +#red { + border: 1px solid red; + color: red; +} +#blue { + border: 1px solid blue; + color: blue; +} +#green { + border: 1px solid green; + color: green; +} +#yellow { + border: 1px solid yellow; + color: yellow; +} +</style> +<script> +function click(color) { + chrome.tabs.executeScript(null, + {code:"document.body.style.backgroundColor='" + color.id + "'"}); + window.close(); +} +</script> +<div onclick="click(this)" id="red">red</div> +<div onclick="click(this)" id="blue">blue</div> +<div onclick="click(this)" id="green">green</div> +<div onclick="click(this)" id="yellow">yellow</div> diff --git a/chrome/test/data/extensions/samples/cld/toolstrip.html b/chrome/common/extensions/docs/examples/api/i18n/cld/background.html index 03851c2b..cfb1fac 100644 --- a/chrome/test/data/extensions/samples/cld/toolstrip.html +++ b/chrome/common/extensions/docs/examples/api/i18n/cld/background.html @@ -4,33 +4,29 @@ source code is governed by a BSD-style license that can be found in the LICENSE file. --> -<html> - <head> - <script> - +<script> var selectedId = -1; function refreshLanguage() { - console.log("refeshing..."); chrome.tabs.detectLanguage(null, function(language) { - document.getElementById("languageDiv").innerHTML = language; + console.log(language); + if (language == " invalid_language_code") + language = "???"; + chrome.browserAction.setBadgeText({"text": language, tabId: selectedId}); }); } chrome.tabs.onUpdated.addListener(function(tabId, props) { - console.log("updated: " + tabId); - if (prop.status == "complete" && tabId == selectedId) + if (props.status == "complete" && tabId == selectedId) refreshLanguage(); }); chrome.tabs.onSelectionChanged.addListener(function(tabId, props) { - console.log("selection: " + tabId); selectedId = tabId; refreshLanguage(); }); - </script> - </head> - <body onload="refreshLanguage();"> - <div id="languageDiv" class="toolstrip-button" onclick="refreshLanguage();"> - </div> - </body> -</html>
\ No newline at end of file + +chrome.tabs.getSelected(null, function(tab) { + selectedId = tab.id; + refreshLanguage(); +}); +</script> diff --git a/chrome/common/extensions/docs/examples/api/i18n/cld/manifest.json b/chrome/common/extensions/docs/examples/api/i18n/cld/manifest.json new file mode 100644 index 0000000..f974838 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/i18n/cld/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "CLD", + "description": "Displays the language of a tab", + "version": "0.1", + "background_page": "background.html", + "permissions": [ + "tabs" + ], + "browser_action": { + "default_name": "Page Language" + } +} diff --git a/chrome/test/data/extensions/samples/override_igoogle/manifest.json b/chrome/common/extensions/docs/examples/api/override/override_igoogle/manifest.json index 461da24..461da24 100644 --- a/chrome/test/data/extensions/samples/override_igoogle/manifest.json +++ b/chrome/common/extensions/docs/examples/api/override/override_igoogle/manifest.json diff --git a/chrome/test/data/extensions/samples/override_igoogle/redirect.html b/chrome/common/extensions/docs/examples/api/override/override_igoogle/redirect.html index 35117f4..35117f4 100644 --- a/chrome/test/data/extensions/samples/override_igoogle/redirect.html +++ b/chrome/common/extensions/docs/examples/api/override/override_igoogle/redirect.html diff --git a/chrome/test/data/extensions/samples/test_page_action/background.html b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/background.html index 2b77a66..9986850 100644 --- a/chrome/test/data/extensions/samples/test_page_action/background.html +++ b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/background.html @@ -2,42 +2,49 @@ <head> <script> var lastTabId = 0; - var visible = false; - chrome.tabs.onUpdated.addListener(function(tabId, p) { + var tab_clicks = {}; + + chrome.tabs.onSelectionChanged.addListener(function(tabId) { lastTabId = tabId; - chrome.pageAction.show(tabId); + chrome.pageAction.show(lastTabId); + }); + + chrome.tabs.getSelected(null, function(tab) { + lastTabId = tab.id; + chrome.pageAction.show(lastTabId); }); - + // Called when the user clicks on the page action. - var clicks = 0; - var text = ""; - chrome.pageAction.onClicked.addListener(function(_, info) { + chrome.pageAction.onClicked.addListener(function(tab) { + var clicks = tab_clicks[tab.id] || 0; chrome.pageAction.setIcon({path: "icon" + (clicks + 1) + ".png", - tabId: info.tabId}); + tabId: tab.id}); if (clicks % 2) { - chrome.pageAction.show(info.tabId); + chrome.pageAction.show(tab.id); } else { - chrome.pageAction.hide(info.tabId); - setTimeout(function() { chrome.pageAction.show(info.tabId); }, 200); + chrome.pageAction.hide(tab.id); + setTimeout(function() { chrome.pageAction.show(tab.id); }, 200); } - chrome.pageAction.setTitle({title: "click:" + clicks, tabId: info.tabId}); - text += clicks.toString(); + chrome.pageAction.setTitle({title: "click:" + clicks, tabId: tab.id}); // We only have 2 icons, but cycle through 3 icons to test the // out-of-bounds index bug. clicks++; if (clicks > 3) clicks = 0; + tab_clicks[tab.id] = clicks; }); - var i = 0; + var i = 0; window.setInterval(function() { + var clicks = tab_clicks[lastTabId] || 0; + // Don't animate while in "click" mode. if (clicks > 0) return; // Don't do anything if we don't have a tab yet. if (lastTabId == 0) return; - + i++; chrome.pageAction.setIcon({imageData: draw(i*2, i*4), tabId: lastTabId}); }, 50); diff --git a/chrome/test/data/extensions/samples/test_page_action/icon1.png b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/icon1.png Binary files differindex 9a79a46..9a79a46 100755 --- a/chrome/test/data/extensions/samples/test_page_action/icon1.png +++ b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/icon1.png diff --git a/chrome/test/data/extensions/samples/test_page_action/icon2.png b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/icon2.png Binary files differindex 8d3f710..8d3f710 100755 --- a/chrome/test/data/extensions/samples/test_page_action/icon2.png +++ b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/icon2.png diff --git a/chrome/test/data/extensions/samples/test_page_action/manifest.json b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/manifest.json index 5a374e8..5a374e8 100644 --- a/chrome/test/data/extensions/samples/test_page_action/manifest.json +++ b/chrome/common/extensions/docs/examples/api/pageAction/set_icon/manifest.json diff --git a/chrome/common/extensions/docs/examples/api/tabs/inspector/background.html b/chrome/common/extensions/docs/examples/api/tabs/inspector/background.html new file mode 100644 index 0000000..314dc3c --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/tabs/inspector/background.html @@ -0,0 +1,5 @@ +<script> +chrome.browserAction.onClicked.addListener(function(tab) { + chrome.tabs.create({url:chrome.extension.getURL("tabs_api.html")}); +}); +</script>
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/tabs/jstemplate_compiled.js b/chrome/common/extensions/docs/examples/api/tabs/inspector/jstemplate_compiled.js index 2f62b31..2f62b31 100644 --- a/chrome/test/data/extensions/samples/tabs/jstemplate_compiled.js +++ b/chrome/common/extensions/docs/examples/api/tabs/inspector/jstemplate_compiled.js diff --git a/chrome/common/extensions/docs/examples/api/tabs/inspector/manifest.json b/chrome/common/extensions/docs/examples/api/tabs/inspector/manifest.json new file mode 100644 index 0000000..1cf3576 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/tabs/inspector/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "Tab Inspector", + "description": "Utility for working with the extension tabs api", + "version": "0.1", + "permissions": ["tabs"], + "background_page": "background.html", + "browser_action": { + "default_title": "show tab inspector" + } +} diff --git a/chrome/test/data/extensions/samples/tabs/tabs_api.html b/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html index 4a784e3..e8047ab 100644 --- a/chrome/test/data/extensions/samples/tabs/tabs_api.html +++ b/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html @@ -1,6 +1,6 @@ <html> <head> -<script src="jstemplate_compiled.js" type="text/javascript"></script> +<script src="jstemplate_compiled.js" type="text/javascript"></script> <script> tabs = {}; @@ -48,7 +48,7 @@ function updateTabData(id) { url: document.getElementById('url_' + id).value, selected: document.getElementById('selected_' + id).value ? true : false } - + return retval; } @@ -58,10 +58,10 @@ function updateTab(id){ } catch (e) { alert(e); } -} +} function moveTabData(id) { - return { + return { 'index': parseInt(document.getElementById('index_' + id).value), 'windowId': parseInt(document.getElementById('windowId_' + id).value) } @@ -80,8 +80,8 @@ function createTabData(id) { 'windowId': parseInt(document.getElementById('windowId_' + id).value), 'index': parseInt(document.getElementById('index_' + id).value), 'url': document.getElementById('url_' + id).value, - 'selected': document.getElementById('selected_' + id).value ? true : false - } + 'selected': document.getElementById('selected_' + id).value ? true : false + } } function createTab() { @@ -91,7 +91,7 @@ function createTab() { delete args.windowId; if (!isInt(args.index)) delete args.index; - + try { chrome.tabs.create(args); } catch (e) { @@ -102,7 +102,7 @@ function createTab() { function updateAll() { try { for (var i = 0; i < tabIds.length; i++) { - chrome.tabs.update(tabIds[i], updateTabData(tabIds[i])); + chrome.tabs.update(tabIds[i], updateTabData(tabIds[i])); } } catch(e) { alert(e); @@ -113,7 +113,7 @@ function moveAll() { appendToLog('moving all'); try { for (var i = 0; i < tabIds.length; i++) { - chrome.tabs.move(tabIds[i], moveTabData(tabIds[i])); + chrome.tabs.move(tabIds[i], moveTabData(tabIds[i])); } } catch(e) { alert(e); @@ -174,7 +174,7 @@ function refreshTab(tabId) { chrome.tabs.get(tabId, function(tab) { var input = new JsExprContext(tab); var output = document.getElementById('tab_' + tab.id); - jstProcess(input, output); + jstProcess(input, output); appendToLog('tab refreshed -- tabId: ' + tab.id + ' url: ' + tab.url); }); } @@ -207,7 +207,7 @@ function createWindow() { 'height': parseInt(document.getElementById('new_window_height').value), 'url': document.getElementById('new_window_url').value } - + if (!isInt(args.left)) delete args.left; if (!isInt(args.top)) @@ -218,7 +218,7 @@ function createWindow() { delete args.height; if (!args.url) delete args.url; - + try { chrome.windows.create(args); } catch(e) { @@ -233,7 +233,6 @@ function refreshWindow(windowId) { var input = new JsExprContext(window); var output = document.getElementById('window_' + window.id); jstProcess(input, output); - appendToLog('window refreshed -- windowId: ' + window.id + ' tab count:' + window.tabs.length); }); }); @@ -246,7 +245,6 @@ function updateWindowData(id) { width: parseInt(document.getElementById('width_' + id).value), height: parseInt(document.getElementById('height_' + id).value) } - if (!isInt(retval.left)) delete retval.left; if (!isInt(retval.top)) @@ -255,7 +253,7 @@ function updateWindowData(id) { delete retval.width; if (!isInt(retval.height)) delete retval.height; - + return retval; } @@ -281,7 +279,7 @@ function refreshSelectedTab(windowId) { chrome.tabs.getSelected(windowId, function(tab) { var input = new JsExprContext(tab); var output = document.getElementById('tab_' + tab.id); - jstProcess(input, output); + jstProcess(input, output); appendToLog('selected tab refreshed -- tabId: ' + tab.id + ' url:' + tab.url); }); } @@ -290,9 +288,9 @@ function refreshSelectedTab(windowId) { </head> <body onload="bootStrap();"> <div id="windowList"> - <div style="background-color: #AAEEEE; margin: 4px; padding: 8px; margin: 20px" jsselect="$this" + <div style="background-color: #AAEEEE; margin: 4px; padding: 8px; margin: 20px" jsselect="$this" jsvalues="id:'window_' + id"> - <div style="font-style: italic; width: 80px; display: inline-block"> + <div style="font-style: italic; width: 80px; display: inline-block"> Window: <span jscontent="id"></span> </div> <div style="display: inline-block"> @@ -309,7 +307,7 @@ function refreshSelectedTab(windowId) { <div style="background-color: #EEEEEE; margin: 8px; padding: 4px" jsvalues="id:'tab_' + id"> <div style="margin: 8px"> <div style="font-style: italic; width: 80px; display: inline-block" jscontent="'TabId: ' + id"></div> - <div style="width: 300px; display: inline-block"> + <div style="width: 300px; display: inline-block"> index: <input style="width: 20px" type="text" jsvalues="value:$this.index;id:'index_' + id" /> windowId: <input style="width: 20px" type="text" jsvalues="value:windowId;id:'windowId_' + id" /> <button onclick="moveTab(this.jstdata);" jsvalues=".jstdata:id">Move</button> @@ -340,7 +338,7 @@ function refreshSelectedTab(windowId) { <div style="background-color: #EEEEBB; margin: 20px; padding: 8px"> <h3 style="text-align: center; margin: 8px"> Create Window</h3> <div style="margin: 8px"> - <div style="width: 300px; display: inline-block"> + <div style="width: 300px; display: inline-block"> left: <input style="width: 20px" type="text" id="new_window_left" /> top: <input style="width: 20px" type="text" id="new_window_top" /> width: <input style="width: 20px" type="text" id="new_window_width" /> @@ -358,7 +356,7 @@ function refreshSelectedTab(windowId) { <div style="background-color: #EEEEAA; margin: 20px; padding: 8px"> <h3 style="text-align: center; margin: 8px"> Create Tab</h3> <div style="margin: 8px"> - <div style="width: 300px; display: inline-block"> + <div style="width: 300px; display: inline-block"> index: <input style="width: 20px" type="text" id="index_new" /> windowId: <input style="width: 20px" type="text" id="windowId_new" /> <button onclick="moveTab(this.jstdata);" jsvalues=".jstdata:id">Move</button> diff --git a/chrome/test/data/extensions/samples/screenshot/background.html b/chrome/common/extensions/docs/examples/api/tabs/screenshot/background.html index 2955688..2955688 100644 --- a/chrome/test/data/extensions/samples/screenshot/background.html +++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/background.html diff --git a/chrome/test/data/extensions/samples/screenshot/camera.png b/chrome/common/extensions/docs/examples/api/tabs/screenshot/camera.png Binary files differindex be26c39..be26c39 100755 --- a/chrome/test/data/extensions/samples/screenshot/camera.png +++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/camera.png diff --git a/chrome/test/data/extensions/samples/screenshot/manifest.json b/chrome/common/extensions/docs/examples/api/tabs/screenshot/manifest.json index 37fdbf0..37fdbf0 100755 --- a/chrome/test/data/extensions/samples/screenshot/manifest.json +++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/manifest.json diff --git a/chrome/test/data/extensions/samples/screenshot/screenshot.html b/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.html index 408d13d..408d13d 100644 --- a/chrome/test/data/extensions/samples/screenshot/screenshot.html +++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.html diff --git a/chrome/test/data/extensions/samples/screenshot/screenshot.js b/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js index 5d47a99..5d47a99 100755 --- a/chrome/test/data/extensions/samples/screenshot/screenshot.js +++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/screenshot.js diff --git a/chrome/test/data/extensions/samples/screenshot/white.png b/chrome/common/extensions/docs/examples/api/tabs/screenshot/white.png Binary files differindex 06d8aca..06d8aca 100644 --- a/chrome/test/data/extensions/samples/screenshot/white.png +++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot/white.png diff --git a/chrome/test/data/extensions/samples/buildbot/bg.html b/chrome/common/extensions/docs/examples/extensions/buildbot/bg.html index 50671d1..1324fb1 100644 --- a/chrome/test/data/extensions/samples/buildbot/bg.html +++ b/chrome/common/extensions/docs/examples/extensions/buildbot/bg.html @@ -3,7 +3,7 @@ var statusURL = "http://chromium-status.appspot.com/current"; function updateStatus(text) { // Page outputs a line like this: - // <div class="Notice">Tree is open (issue -> person) </div> + // <div class="Notice">Tree is open (issue -> person) </div> // Although what's in the <div> is arbitrary and typed by a person. var results = (new RegExp('"Notice"[^>]*>(.*)<', 'g')).exec(text); if (!results || results.index < 0) { diff --git a/chrome/test/data/extensions/samples/buildbot/chromium.png b/chrome/common/extensions/docs/examples/extensions/buildbot/chromium.png Binary files differindex cc9fb60..cc9fb60 100755 --- a/chrome/test/data/extensions/samples/buildbot/chromium.png +++ b/chrome/common/extensions/docs/examples/extensions/buildbot/chromium.png diff --git a/chrome/test/data/extensions/samples/buildbot/icon.png b/chrome/common/extensions/docs/examples/extensions/buildbot/icon.png Binary files differindex b3c3474..b3c3474 100755 --- a/chrome/test/data/extensions/samples/buildbot/icon.png +++ b/chrome/common/extensions/docs/examples/extensions/buildbot/icon.png diff --git a/chrome/test/data/extensions/samples/buildbot/manifest.json b/chrome/common/extensions/docs/examples/extensions/buildbot/manifest.json index 5e0349c..5e0349c 100644 --- a/chrome/test/data/extensions/samples/buildbot/manifest.json +++ b/chrome/common/extensions/docs/examples/extensions/buildbot/manifest.json diff --git a/chrome/test/data/extensions/samples/buildbot/popup.html b/chrome/common/extensions/docs/examples/extensions/buildbot/popup.html index 8814a80..d5b913d 100644 --- a/chrome/test/data/extensions/samples/buildbot/popup.html +++ b/chrome/common/extensions/docs/examples/extensions/buildbot/popup.html @@ -1,218 +1,218 @@ -<head>
-<script>
-var botRoot = "http://build.chromium.org/buildbot";
-//var botRoot = "http://chrome-buildbot.corp.google.com:8010";
-var waterfallURL = botRoot + "/waterfall/bot_status.json?json=1";
-var botList;
-var checkinResults;
-var bots;
-var failures;
-
-function updateBotList(text) {
- var results = (new RegExp('(.*)<\/body>', 'g')).exec(text);
- if (!results || results.index < 0) {
- console.log("Error: couldn't find bot JSON");
- console.log(text);
- return;
- }
- var data;
- try {
- data = JSON.parse(results[1]);
- } catch (e) {
- console.dir(e);
- console.log(text);
- return;
- }
- if (!data) {
- throw new Error("JSON parse fail: " + results[1]);
- }
- botList = data[0];
- checkinResults = data[1];
-
- failures = botList.filter(function(bot) {
- return (bot.color != "success");
- });
- displayFailures();
-}
-
-function displayFailures() {
- var html = "";
- if (failures.length == 0) {
- html = "<a href='' onClick='showConsole()' class='open'>" +
- "The tree is completely green.</a> (no way!)";
- } else {
- html = "<div><a class='closed' href='' onClick='showFailures()'>" +
- "failures:</a></div>";
- failures.forEach(function(bot, i) {
- html += "<div class='bot " + bot.color +
- "' onclick='showBot(" + i + ")'>" +
- bot.title + "</div>";
- });
- }
- bots.innerHTML = html;
-}
-
-function showURL(url) {
- window.open(url);
- window.event.stopPropagation();
-}
-
-function showBot(botIndex) {
- var bot = failures[botIndex];
- var url = botRoot + "/waterfall/waterfall?builder=" + bot.name;
- showURL(url);
-}
-
-function showConsole() {
- var url = botRoot + "/waterfall/console";
- showURL(url);
-}
-
-function showTry() {
- var url = botRoot + "/try-server/waterfall";
- showURL(url);
-}
-
-function showFyi() {
- var url = botRoot + "/waterfall.fyi/console";
- showURL(url);
-}
-
-function showFailures() {
- var url = botRoot + "/waterfall/waterfall?show_events=true&failures_only=true";
- showURL(url);
-}
-
-function requestURL(url, callback) {
- console.log("requestURL: " + url);
- var xhr = new XMLHttpRequest();
- try {
- xhr.onreadystatechange = function(state) {
- if (xhr.readyState == 4) {
- var text = xhr.responseText;
- //console.log(text);
- callback(text);
- }
- }
-
- xhr.onerror = function(error) {
- console.log("xhr error: " + JSON.stringify(error));
- console.dir(error);
- }
-
- xhr.open("GET", url, true);
- xhr.send({});
- } catch(e) {
- console.log("exception: " + e);
- }
-}
-window.onload = function() {
- bots = document.getElementById("bots");
-
- // XHR from onload winds up blocking the load, so we put it in a setTimeout.
- window.setTimeout(requestURL, 0, waterfallURL, updateBotList);
-}
-
-function toggle_size() {
- if (document.body.className == "big") {
- document.body.className = "small";
- } else {
- document.body.className = "big";
- }
-}
-
-</script>
-<style>
-body {
- font: menu;
- overflow: hidden;
-}
-
-#links {
- background-color: #efefef;
- border: 1px solid #cccccc;
- -webkit-border-radius: 5px;
- margin-top: 1px;
- padding: 3px;
- white-space: nowrap;
- text-align: center;
-}
-
-a {
- text-decoration: underline;
- color: #444;
-}
-
-a:hover {
- color: black;
- cursor: pointer;
-}
-
-body.big .bot {
- -webkit-transition: all .5s ease-out;
- margin: 20px;
-}
-
-body.small .bot {
- -webkit-transition: all .5s ease-out;
-}
-
-.bot {
- cursor: pointer;
- -webkit-border-radius: 5px;
- margin-top: 1px;
- padding: 3px;
- white-space: nowrap;
-}
-
-.bot:hover {
- border: 2px solid black;
- padding: 2px;
-}
-
-.open {
- color: green;
-}
-
-.closed {
- color: red;
-}
-
-.running {
- background-color: rgb(255, 252, 108);
- border: 1px solid rgb(197, 197, 109);
-}
-
-.notstarted {
- border: 1px solid rgb(170, 170, 170);
-}
-
-.failure {
- background-color: rgb(233, 128, 128);
- border: 1px solid rgb(167, 114, 114);
-}
-
-.warnings {
- background-color: rgb(255, 195, 67);
- border: 1px solid rgb(194, 157, 70);
-}
-
-.success {
- background-color: rgb(143, 223, 95);
- border: 1px solid rgb(79, 133, 48);
-}
-
-.exception {
- background-color: rgb(224, 176, 255);
- border: 1px solid rgb(172, 160, 179);
-}
-</style>
-</head>
-<body onClick="toggle_size()">
-<div id="links">
-<a href="" onclick='showConsole()'>console</a> -
-<a href="" onclick='showTry()'>try</a> -
-<a href="" onclick='showFyi()'>fyi</a>
-</div>
-<div id="bots">Loading....</div>
+<head> +<script> +var botRoot = "http://build.chromium.org/buildbot"; +//var botRoot = "http://chrome-buildbot.corp.google.com:8010"; +var waterfallURL = botRoot + "/waterfall/bot_status.json?json=1"; +var botList; +var checkinResults; +var bots; +var failures; + +function updateBotList(text) { + var results = (new RegExp('(.*)<\/body>', 'g')).exec(text); + if (!results || results.index < 0) { + console.log("Error: couldn't find bot JSON"); + console.log(text); + return; + } + var data; + try { + data = JSON.parse(results[1]); + } catch (e) { + console.dir(e); + console.log(text); + return; + } + if (!data) { + throw new Error("JSON parse fail: " + results[1]); + } + botList = data[0]; + checkinResults = data[1]; + + failures = botList.filter(function(bot) { + return (bot.color != "success"); + }); + displayFailures(); +} + +function displayFailures() { + var html = ""; + if (failures.length == 0) { + html = "<a href='' onclick='showConsole()' class='open'>" + + "The tree is completely green.</a> (no way!)"; + } else { + html = "<div><a class='closed' href='' onclick='showFailures()'>" + + "failures:</a></div>"; + failures.forEach(function(bot, i) { + html += "<div class='bot " + bot.color + + "' onclick='showBot(" + i + ")'>" + + bot.title + "</div>"; + }); + } + bots.innerHTML = html; +} + +function showURL(url) { + window.open(url); + window.event.stopPropagation(); +} + +function showBot(botIndex) { + var bot = failures[botIndex]; + var url = botRoot + "/waterfall/waterfall?builder=" + bot.name; + showURL(url); +} + +function showConsole() { + var url = botRoot + "/waterfall/console"; + showURL(url); +} + +function showTry() { + var url = botRoot + "/try-server/waterfall"; + showURL(url); +} + +function showFyi() { + var url = botRoot + "/waterfall.fyi/console"; + showURL(url); +} + +function showFailures() { + var url = botRoot + "/waterfall/waterfall?show_events=true&failures_only=true"; + showURL(url); +} + +function requestURL(url, callback) { + console.log("requestURL: " + url); + var xhr = new XMLHttpRequest(); + try { + xhr.onreadystatechange = function(state) { + if (xhr.readyState == 4) { + var text = xhr.responseText; + //console.log(text); + callback(text); + } + } + + xhr.onerror = function(error) { + console.log("xhr error: " + JSON.stringify(error)); + console.dir(error); + } + + xhr.open("GET", url, true); + xhr.send({}); + } catch(e) { + console.log("exception: " + e); + } +} +window.onload = function() { + bots = document.getElementById("bots"); + + // XHR from onload winds up blocking the load, so we put it in a setTimeout. + window.setTimeout(requestURL, 0, waterfallURL, updateBotList); +} + +function toggle_size() { + if (document.body.className == "big") { + document.body.className = "small"; + } else { + document.body.className = "big"; + } +} + +</script> +<style> +body { + font: menu; + overflow: hidden; +} + +#links { + background-color: #efefef; + border: 1px solid #cccccc; + -webkit-border-radius: 5px; + margin-top: 1px; + padding: 3px; + white-space: nowrap; + text-align: center; +} + +a { + text-decoration: underline; + color: #444; +} + +a:hover { + color: black; + cursor: pointer; +} + +body.big .bot { + -webkit-transition: all .5s ease-out; + margin: 20px; +} + +body.small .bot { + -webkit-transition: all .5s ease-out; +} + +.bot { + cursor: pointer; + -webkit-border-radius: 5px; + margin-top: 1px; + padding: 3px; + white-space: nowrap; +} + +.bot:hover { + border: 2px solid black; + padding: 2px; +} + +.open { + color: green; +} + +.closed { + color: red; +} + +.running { + background-color: rgb(255, 252, 108); + border: 1px solid rgb(197, 197, 109); +} + +.notstarted { + border: 1px solid rgb(170, 170, 170); +} + +.failure { + background-color: rgb(233, 128, 128); + border: 1px solid rgb(167, 114, 114); +} + +.warnings { + background-color: rgb(255, 195, 67); + border: 1px solid rgb(194, 157, 70); +} + +.success { + background-color: rgb(143, 223, 95); + border: 1px solid rgb(79, 133, 48); +} + +.exception { + background-color: rgb(224, 176, 255); + border: 1px solid rgb(172, 160, 179); +} +</style> +</head> +<body onclick="toggle_size()"> +<div id="links"> +<a href="" onclick='showConsole()'>console</a> - +<a href="" onclick='showTry()'>try</a> - +<a href="" onclick='showFyi()'>fyi</a> +</div> +<div id="bots">Loading....</div> </body>
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/gmail_browser_action/background.html b/chrome/common/extensions/docs/examples/extensions/gmail/background.html index ee1ae40..eea77b6 100644 --- a/chrome/test/data/extensions/samples/gmail_browser_action/background.html +++ b/chrome/common/extensions/docs/examples/extensions/gmail/background.html @@ -75,7 +75,7 @@ function init() { chrome.browserAction.setIcon({path: "gmail_logged_in.png"}); loadingAnimation.start(); - + startRequest(); } @@ -180,7 +180,7 @@ function ease(x) { function animateFlip() { rotation += 1/animationFrames; drawIconAtRotation(); - + if (rotation <= 1) { setTimeout("animateFlip()", animationSpeed); } else { @@ -207,7 +207,7 @@ function drawIconAtRotation() { Math.ceil(canvas.width/2), Math.ceil(canvas.height/2)); canvasContext.rotate(2*Math.PI*ease(rotation)); - canvasContext.drawImage(loggedInImage, + canvasContext.drawImage(loggedInImage, -Math.ceil(canvas.width/2), -Math.ceil(canvas.height/2)); canvasContext.restore(); diff --git a/chrome/test/data/extensions/samples/gmail_browser_action/gmail_logged_in.png b/chrome/common/extensions/docs/examples/extensions/gmail/gmail_logged_in.png Binary files differindex 8d5e256..8d5e256 100644 --- a/chrome/test/data/extensions/samples/gmail_browser_action/gmail_logged_in.png +++ b/chrome/common/extensions/docs/examples/extensions/gmail/gmail_logged_in.png diff --git a/chrome/test/data/extensions/samples/gmail_browser_action/gmail_not_logged_in.png b/chrome/common/extensions/docs/examples/extensions/gmail/gmail_not_logged_in.png Binary files differindex 582d262..582d262 100644 --- a/chrome/test/data/extensions/samples/gmail_browser_action/gmail_not_logged_in.png +++ b/chrome/common/extensions/docs/examples/extensions/gmail/gmail_not_logged_in.png diff --git a/chrome/test/data/extensions/samples/gmail_browser_action/icon_128.png b/chrome/common/extensions/docs/examples/extensions/gmail/icon_128.png Binary files differindex 1ddc33b..1ddc33b 100755 --- a/chrome/test/data/extensions/samples/gmail_browser_action/icon_128.png +++ b/chrome/common/extensions/docs/examples/extensions/gmail/icon_128.png diff --git a/chrome/test/data/extensions/samples/gmail_browser_action/manifest.json b/chrome/common/extensions/docs/examples/extensions/gmail/manifest.json index 3dc942f..3dc942f 100644 --- a/chrome/test/data/extensions/samples/gmail_browser_action/manifest.json +++ b/chrome/common/extensions/docs/examples/extensions/gmail/manifest.json diff --git a/chrome/test/data/extensions/samples/mappy/icon.png b/chrome/common/extensions/docs/examples/extensions/mappy/icon.png Binary files differindex 40ebbff..40ebbff 100755 --- a/chrome/test/data/extensions/samples/mappy/icon.png +++ b/chrome/common/extensions/docs/examples/extensions/mappy/icon.png diff --git a/chrome/test/data/extensions/samples/mappy/manifest.json b/chrome/common/extensions/docs/examples/extensions/mappy/manifest.json index dbcfe06..344920f 100755 --- a/chrome/test/data/extensions/samples/mappy/manifest.json +++ b/chrome/common/extensions/docs/examples/extensions/mappy/manifest.json @@ -6,7 +6,7 @@ "content_scripts": [ { "matches": ["http://*/*"], "js": ["mappy_content_script.js"] } ], - "permissions": [ + "permissions": [ "tabs", "http://maps.google.com/*" ], diff --git a/chrome/test/data/extensions/samples/mappy/mappy_content_script.js b/chrome/common/extensions/docs/examples/extensions/mappy/mappy_content_script.js index 7e17af7..7e17af7 100755 --- a/chrome/test/data/extensions/samples/mappy/mappy_content_script.js +++ b/chrome/common/extensions/docs/examples/extensions/mappy/mappy_content_script.js diff --git a/chrome/test/data/extensions/samples/mappy/marker.png b/chrome/common/extensions/docs/examples/extensions/mappy/marker.png Binary files differindex aa45f4d..aa45f4d 100755 --- a/chrome/test/data/extensions/samples/mappy/marker.png +++ b/chrome/common/extensions/docs/examples/extensions/mappy/marker.png diff --git a/chrome/test/data/extensions/samples/mappy/popup.html b/chrome/common/extensions/docs/examples/extensions/mappy/popup.html index 409b216..409b216 100644 --- a/chrome/test/data/extensions/samples/mappy/popup.html +++ b/chrome/common/extensions/docs/examples/extensions/mappy/popup.html diff --git a/chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html b/chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html new file mode 100644 index 0000000..5cf5fab --- /dev/null +++ b/chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html @@ -0,0 +1,45 @@ +<style> +img { + margin:5px; + border:2px solid black; + vertical-align:middle; + width:75px; + height:75px; +} +</style> + +<script> +var req = new XMLHttpRequest(); +req.open( + "GET", + "http://api.flickr.com/services/rest/?" + + "method=flickr.photos.search&" + + "api_key=90485e931f687a9b9c2a66bf58a3861a&" + + "text=hello%20world&" + + "safe_search=1&" + // 1 is "safe" + "content_type=1&" + // 1 is "photos only" + "sort=relevance&" + // another good one is "interestingness-desc" + "per_page=95", + true); +req.onload = showPhotos; +req.send(null); + +function showPhotos() { + var photos = req.responseXML.getElementsByTagName("photo"); + + for (var i = 0, photo; photo = photos[i]; i++) { + var img = document.createElement("image"); + img.src = constructImageURL(photo); + document.body.appendChild(img); + } +} + +// See: http://www.flickr.com/services/api/misc.urls.html +function constructImageURL(photo) { + return "http://farm" + photo.getAttribute("farm") + + ".static.flickr.com/" + photo.getAttribute("server") + + "/" + photo.getAttribute("id") + + "_" + photo.getAttribute("secret") + + "_s.jpg"; +} +</script> diff --git a/chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json b/chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json new file mode 100644 index 0000000..3170bf4 --- /dev/null +++ b/chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "My First Extension", + "version": "1.0", + "description": "The first extension that I made.", + "toolstrips": [ + "my_toolstrip.html" + ], + "permissions": [ + "http://api.flickr.com/" + ] +} diff --git a/chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html b/chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html new file mode 100644 index 0000000..a6b70d5 --- /dev/null +++ b/chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html @@ -0,0 +1,3 @@ +<div class="toolstrip-button" onclick="window.open('hello_world.html')"> + <span>Hello, World!</span> +</div> diff --git a/chrome/common/extensions/docs/samples.html b/chrome/common/extensions/docs/samples.html index ccb422c..4fdaebc 100644 --- a/chrome/common/extensions/docs/samples.html +++ b/chrome/common/extensions/docs/samples.html @@ -223,7 +223,7 @@ </p><p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dmihcahmgecmbnbcchbopgniflfhgnkff%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0"><img src="images/google-mail-checker-capture.png" width="243" height="170" style="margin-bottom:0.5em"></a><br> <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dmihcahmgecmbnbcchbopgniflfhgnkff%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0">Install</a> -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/gmail_browser_action/">Source code</a></b> +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/extensions/gmail/">Source code</a></b> <br><br> </p><p>Features used: @@ -244,7 +244,7 @@ </p><p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dafmppjmdopaajlhgcddfhfhfgincjeih%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0"><img src="images/buildbot-capture.png" style="margin-bottom:0.5em" width="336" height="288"></a><br> <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dafmppjmdopaajlhgcddfhfhfgincjeih%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0">Install</a> -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/buildbot/">Source code</a></b> +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/extensions/buildbot/">Source code</a></b> <br><br> @@ -267,7 +267,7 @@ </p><p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0"><img src="images/subscribe-cap2.png" style="margin-bottom:0.5em" width="566" height="327"></a><br> <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0">Install</a> -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/subscribe_page_action/">Source code</a></b> +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/subscribe_page_action/">Source code</a></b> <br><br> </p><p>Features used: diff --git a/chrome/common/extensions/docs/static/samples.html b/chrome/common/extensions/docs/static/samples.html index 3a48d5d..92a8faa 100644 --- a/chrome/common/extensions/docs/static/samples.html +++ b/chrome/common/extensions/docs/static/samples.html @@ -8,7 +8,7 @@ <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dmihcahmgecmbnbcchbopgniflfhgnkff%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0"><img src="images/google-mail-checker-capture.png" width="243" height="170" style="margin-bottom:0.5em"></a><br> <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dmihcahmgecmbnbcchbopgniflfhgnkff%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0">Install</a> -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/gmail_browser_action/">Source code</a></b> +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/extensions/gmail/">Source code</a></b> <br><br> <p>Features used: @@ -29,7 +29,7 @@ <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dafmppjmdopaajlhgcddfhfhfgincjeih%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0"><img src="images/buildbot-capture.png" style="margin-bottom:0.5em" width="336" height="288"></a><br> <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dafmppjmdopaajlhgcddfhfhfgincjeih%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0">Install</a> -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/buildbot/">Source code</a></b> +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/extensions/buildbot/">Source code</a></b> <br><br> @@ -52,7 +52,7 @@ <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0"><img src="images/subscribe-cap2.png" style="margin-bottom:0.5em" width="566" height="327"></a><br> <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US&prod=chrome&prodversion=4.0.238.0">Install</a> -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/subscribe_page_action/">Source code</a></b> +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/subscribe_page_action/">Source code</a></b> <br><br> <p>Features used: diff --git a/chrome/test/data/extensions/samples/buildbot/buildbot.html b/chrome/test/data/extensions/samples/buildbot/buildbot.html deleted file mode 100644 index 7da1dba..0000000 --- a/chrome/test/data/extensions/samples/buildbot/buildbot.html +++ /dev/null @@ -1,251 +0,0 @@ -<script> -var botRoot = "http://build.chromium.org/buildbot/waterfall"; -//var botRoot = "http://chrome-buildbot.corp.google.com:8010"; -var statusURL = "http://chromium-status.appspot.com/current"; -var waterfallURL = botRoot + "/bot_status.json?json=1"; -var botList; -var checkinResults; -var bots; -var lastChecked; - -function updateStatus(text) { - // Page outputs a line like this: - // <div class="Notice">Tree is open (issue -> person) </div> - // Although what's in the <div> is arbitrary and typed by a person. - var results = (new RegExp('"Notice"[^>]*>(.*)<', 'g')).exec(text); - if (!results || results.index < 0) { - throw new Error("couldn't find status div in " + text); - } - var status = results[1]; - var div = document.getElementById("status"); - div.title = status; - var open = /open/i; - if (open.exec(status)) { - div.innerHTML = "tree: open "; - div.className = "open"; - } else { - div.innerHTML = "tree: closed"; - div.className = "closed"; - } -} - -function updateBotList(text) { - var results = (new RegExp('(.*)<\/body>', 'g')).exec(text); - if (!results || results.index < 0) { - console.log("Error: couldn't find bot JSON"); - console.log(text); - return; - } - var data; - try { - data = JSON.parse(results[1]); - } catch (e) { - console.dir(e); - console.log(text); - return; - } - if (!data) { - throw new Error("JSON parse fail: " + results[1]); - } - botList = data[0]; - checkinResults = data[1]; - displayBotList(); -} - -function botClicked(botIndex) { - var bot = botList[botIndex]; - var url = botRoot + "/waterfall?builder=" + bot.name; - window.open(url); - window.event.stopPropagation(); -} - -function displayBotList() { - if (!botList) { - console.log("botList is null"); - return; - } - var html = ""; - if (bots.className == "visible") { - botList.forEach(function(bot, i) { - html += "<div class='bot " + bot.color + - "' onclick='botClicked(" + i + ")' " + - "title='" + bot.title + "'></div>"; - }); - } - bots.innerHTML = html; - - var numBots = botList.length; - var botWidth = numBots * 8 + 2; - var style = document.getElementById("bots-visible"); - style.innerText = "#bots.visible { width:" + botWidth + "px;}"; -} - -function requestStatus() { - requestURL(statusURL, updateStatus); - setTimeout(requestStatus, 120000); -} - -function requestURL(url, callback) { - console.log("requestURL: " + url); - var xhr = new XMLHttpRequest(); - try { - xhr.onreadystatechange = function(state) { - if (xhr.readyState == 4) { - var text = xhr.responseText; - //console.log(text); - callback(text); - } - } - - xhr.onerror = function(error) { - console.log("xhr error: " + JSON.stringify(error)); - console.dir(error); - } - - xhr.open("GET", url, true); - xhr.send({}); - } catch(e) { - console.log("exception: " + e); - } -} - -function showBots() { - var now = new Date(); - // Don't ever refetch the bot list more frequently than every 60 seconds. - if (!lastChecked || (now - lastChecked) > 60000) { - lastChecked = now; - requestURL(waterfallURL, updateBotList); - } - hoverTimerId = null; - bots.className = "visible"; -} - -function hideBots() { - bots.className = ""; -} - -var hoverTimerId = null; - -window.addEventListener("mouseover", function(e) { - if (hoverTimerId) { - hoverTimerId = window.clearTimeout(hoverTimerId); - } else if (bots.className != "visible") { - hoverTimerId = window.setTimeout(function() { - hoverTimerId = null; - showBots(); - }, 500); - } -}, false); - -window.addEventListener("mouseout", function(e) { - if (hoverTimerId) { - hoverTimerId = window.clearTimeout(hoverTimerId); - } else if (bots.className != "") { - hoverTimerId = window.setTimeout(function() { - hoverTimerId = null; - hideBots(); - }, 100); - } -}, false); - -window.addEventListener("click", function() { - window.open(botRoot); -}, false); - -window.onload = function() { - // This is weird, but somehow doing an XHR -- even though it is - // asynchronous!! -- in onload delays the initial render from happening. - window.setTimeout(requestStatus, 10); - bots = document.getElementById("bots"); -} -</script> - -<style id="bots-visible"> -#bots.visible { - width:1px; -} -</style> - -<style> -#status { - font-weight:bold; -} - -#change { - font-weight:bold; -} - -.open { - color: green; -} - -.closed { - color: red; -} - -#bots { - height: 100%; - /* We would rather this be zero, but a rendering bug in WebKit causes the - offset width of the document to sometimes be caluculated incorrectly that - way. */ - width: 1px; - -webkit-transition: width .2s linear; - display:-webkit-box; - -webkit-box-align:center; /* center content vertically */ - overflow: hidden; -} - -.bot { - line-height: 100%; - cursor: pointer; - -webkit-border-radius: 2px; - display:-webkit-box; - width: 6px; - height: 15px; -} - -.bot:first-child { - /* Since #bots is 1px wide, this is necessary so that we don't show the first - pixel of the first bot. */ - margin-left:1px; -} - -.running { - background-color: rgb(255, 252, 108); - border: 1px solid rgb(197, 197, 109); -} - -.notstarted { - /* background-color: white; */ - border: 1px solid rgb(170, 170, 170); -} - -.failure { - background-color: rgb(233, 128, 128); - border: 1px solid rgb(167, 114, 114); -} - -.warnings { - background-color: rgb(255, 195, 67); - border: 1px solid rgb(194, 157, 70); -} - -.success { - background-color: rgb(143, 223, 95); - border: 1px solid rgb(79, 133, 48); -} - -.exception { - background-color: rgb(224, 176, 255); - border: 1px solid rgb(172, 160, 179); -} - -</style> - -<div class="toolstrip-button"> - <span id="status" class="open"> - <span style="color:#ff6600">loading...</span> - </span> -</div> -<div id="bots"> -</div> diff --git a/chrome/test/data/extensions/samples/cld/manifest.json b/chrome/test/data/extensions/samples/cld/manifest.json deleted file mode 100644 index c0f20f2..0000000 --- a/chrome/test/data/extensions/samples/cld/manifest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "CLD", - "description": "Returns language of a tab", - "version": "0.1", - "toolstrips": ["toolstrip.html"] -} diff --git a/chrome/test/data/extensions/samples/gmail/gmail-128x128.png b/chrome/test/data/extensions/samples/gmail/gmail-128x128.png Binary files differdeleted file mode 100755 index ad851a6..0000000 --- a/chrome/test/data/extensions/samples/gmail/gmail-128x128.png +++ /dev/null diff --git a/chrome/test/data/extensions/samples/gmail/gmail.png b/chrome/test/data/extensions/samples/gmail/gmail.png Binary files differdeleted file mode 100644 index 24180e0..0000000 --- a/chrome/test/data/extensions/samples/gmail/gmail.png +++ /dev/null diff --git a/chrome/test/data/extensions/samples/gmail/gmail_checker.html b/chrome/test/data/extensions/samples/gmail/gmail_checker.html deleted file mode 100644 index 0f89b33..0000000 --- a/chrome/test/data/extensions/samples/gmail/gmail_checker.html +++ /dev/null @@ -1,145 +0,0 @@ -<html> -<head> -<link rel="stylesheet" type="text/css" href="styles.css"> -<script> -var gmail = "http://mail.google.com/"; -var gmailAtomRef = "http://mail.google.com/mail/feed/atom"; -var pollInterval = 1000 * 60; // 1 minute -var requestTimeout = 1000 * 5; // 5 seconds -var unreadCount; - -function init() { - window.setTimeout(startRequest, 0); -} - -function scheduleRequest() { - window.setTimeout(startRequest, pollInterval); -} - -// ajax stuff -function startRequest() { - getInboxCount( - function(count) { - toggleLoggedInState(); - updateUnreadCount(count); - scheduleRequest(); - }, - function() { - toggleLoggedOutState(); - scheduleRequest(); - } - ); -} - -function getInboxCount(onSuccess, onError) { - var xhr = new XMLHttpRequest(); - var abortTimerId = window.setTimeout(function() { - xhr.abort(); - onError(); - }, requestTimeout); - - function handleSuccess(count) { - window.clearTimeout(abortTimerId); - onSuccess(count); - } - - function handleError() { - window.clearTimeout(abortTimerId); - onError(); - } - - try { - console.log("request.."); - xhr.onreadystatechange = function(){ - console.log("readystate: " + xhr.readyState); - if (xhr.readyState == 4) { - console.log("responseText: " + xhr.responseText.substring(0, 200) + - "..."); - if (xhr.responseXML) { - var xmlDoc = xhr.responseXML; - var fullCountSet = xmlDoc.evaluate("/gmail:feed/gmail:fullcount", - xmlDoc, gmailNSResolver, XPathResult.ANY_TYPE, null); - var fullCountNode = fullCountSet.iterateNext(); - if (fullCountNode) { - handleSuccess(fullCountNode.textContent); - } else { - console.log("fullcount not found!"); - console.error("Error: feed retrieved, but no <fullcount> node " + - "found"); - handleError(); - } - } else { - console.log("No responseXML!"); - } - } - } - - xhr.onerror = function(error) { - console.log("error"); - console.log(error); - handleError(); - } - - xhr.open("GET", gmailAtomRef, true); - xhr.send(null); - } catch(e) { - console.log("ex: " + e); - console.error("exception: " + e); - handleError(); - } -} - -function gmailNSResolver(prefix) { - if(prefix == 'gmail') { - return 'http://purl.org/atom/ns#'; - } -} - -// ui stuff -function toggleLoggedInState() { - document.getElementById("notLoggedIn").style.display = "none"; - document.getElementById("loggedIn").style.display = ""; -} - -function toggleLoggedOutState() { - document.getElementById("loggedIn").style.display = "none"; - document.getElementById("notLoggedIn").style.display = ""; -} - -function updateUnreadCount(count) { - if (unreadCount != count) { - unreadCount = count; - startFlip(); - } -} - -function goToInbox() { - chrome.tabs.create({url: gmail}); -} - -// animation -function startFlip() { - document.getElementById("unreadCount").className = 'mid-flip'; - setTimeout(midFlip, 500); -} - -function midFlip() { - document.getElementById("unreadCount").className = 'post-flip'; - document.getElementById("unreadCount").innerHTML = "(" + unreadCount + ")"; - setTimeout(endFlip, 500); -} - -function endFlip() { - document.getElementById("unreadCount").className = 'base-flip'; -} - -</script> -</head> -<body onload="init()" onclick="goToInbox()"> - <div class="toolstrip-button"> - <img src="gmail.png" style="width:auto; height:auto"> - <span id="notLoggedIn" style="display:none;">Login</span> - <span id="loggedIn">Gmail - Inbox <span style="display: inline-block;" id="unreadCount" class="base-flip"></span></span> - </div> -</body> -</html> diff --git a/chrome/test/data/extensions/samples/gmail/manifest.json b/chrome/test/data/extensions/samples/gmail/manifest.json deleted file mode 100644 index b5c2dc1..0000000 --- a/chrome/test/data/extensions/samples/gmail/manifest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "Gmail Checker", - "version": "0.2", - "description": "Displays number of unread Gmail messages", - "icons": { "128": "gmail-128x128.png" }, - "permissions": [ - "http://*.google.com/", - "https://*.google.com/", - "tabs" - ], - "toolstrips": [ - "gmail_checker.html" - ] -}
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/gmail/styles.css b/chrome/test/data/extensions/samples/gmail/styles.css deleted file mode 100644 index 5587c1f..0000000 --- a/chrome/test/data/extensions/samples/gmail/styles.css +++ /dev/null @@ -1,16 +0,0 @@ -.base-flip { - opacity: 1; -} - -.mid-flip { - opacity: .1; - color:red; - -webkit-transform: rotate(180deg) scale(1.3); - -webkit-transition: all .5s ease-in; -} - -.post-flip { - opacity: 1; - -webkit-transform: rotate(360deg) scale(1); - -webkit-transition: all .5s ease-out; -} diff --git a/chrome/test/data/extensions/samples/mappy/mappy_toolstrip.html b/chrome/test/data/extensions/samples/mappy/mappy_toolstrip.html deleted file mode 100644 index 88d1d52..0000000 --- a/chrome/test/data/extensions/samples/mappy/mappy_toolstrip.html +++ /dev/null @@ -1,71 +0,0 @@ -<style> -.chrome-toolstrip #map { - display: none; -} - -.chrome-toolstrip #button { - display: block; -} - -.chrome-mole #map { - display: block; -} - -.chrome-mole #button { - display: none; -} - -#map { - width: 512px; - height: 512px; -} -</style> -<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w&sensor=false" - type="text/javascript"></script> -<script> -var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w"; - -function expand(url) { - var map = document.getElementById("map"); - map.src = url; - chrome.toolstrip.expand({height:512}, function() {}); -} - -function collapse() { - chrome.toolstrip.collapse({}, function() {}); -} - -function gclient_geocode(address) { - var geocoder = new GClientGeocoder(); - geocoder.getLatLng(address, function(point) { - if (!point) { - console.log(address + " not found"); - } else { - var latlng = point.toUrlValue(); - var url = "http://maps.google.com/staticmap?center=" + latlng + - "&markers=" + latlng + "&zoom=14" + - "&size=512x512&sensor=false&key=" + maps_key; - expand(url); - } - }); -} - -function map() { - chrome.tabs.getSelected(null, function(tab) { - var port = chrome.tabs.connect(tab.id); - if (!port) { - console.log("no port"); - } else { - port.onMessage.addListener(function(data) { - var address = data.values[0]; - gclient_geocode(address); - }); - port.postMessage({message: "hello tab: " + tab.id}); - } - }); -}; -</script> -<div id="button" class="toolstrip-button" onclick="map()"> -<span>Mappy</span> -</div> -<img id="map" onclick="collapse()"> diff --git a/chrome/test/data/extensions/samples/print_browser_action/manifest.json b/chrome/test/data/extensions/samples/print_browser_action/manifest.json deleted file mode 100644 index 697c94e..0000000 --- a/chrome/test/data/extensions/samples/print_browser_action/manifest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "Print this page browser action extension", - "description": "This extension adds a print button to the toolstrip", - "version": "1.0", - "background_page": "background.html", - "permissions": [ - "tabs", "http://*/*", "https://*/*" - ], - "browser_action": { - "name": "Print this page", - "icons": ["print_16x16.png"] - } -}
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/set_page_color/manifest.json b/chrome/test/data/extensions/samples/set_page_color/manifest.json deleted file mode 100755 index f4ad151..0000000 --- a/chrome/test/data/extensions/samples/set_page_color/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "A browser action with a popup that changes the page color.", - "version": "1.0", - "permissions": [ - "tabs", "http://*/*" - ], - "browser_action": { - "name": "Set this page's color.", - "icons": ["icon.png"], - "popup": { "path": "popup.html", "height": 79 } - } -}
\ No newline at end of file diff --git a/chrome/test/data/extensions/samples/tabs/manifest.json b/chrome/test/data/extensions/samples/tabs/manifest.json deleted file mode 100644 index 4583e66..0000000 --- a/chrome/test/data/extensions/samples/tabs/manifest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "TabsAPI", - "description": "Utility for working with the extension tabs api", - "version": "0.1", - "permissions": ["tabs"] -} |