diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-18 01:34:14 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-18 01:34:14 +0000 |
commit | 5a468f1d0ff72ccb3dd5e3a53f190e1e87ed9f9d (patch) | |
tree | 81bf99d148e583cc757915dc6df9fd655f614dff /chrome/common/extensions/docs/js/bootstrap.js | |
parent | 62dc1f04051694ae381488ef44fad336c6260ad6 (diff) | |
download | chromium_src-5a468f1d0ff72ccb3dd5e3a53f190e1e87ed9f9d.zip chromium_src-5a468f1d0ff72ccb3dd5e3a53f190e1e87ed9f9d.tar.gz chromium_src-5a468f1d0ff72ccb3dd5e3a53f190e1e87ed9f9d.tar.bz2 |
Extension Docs (No building or testable files)
This adds a warning to extension docs that appears if docs are being viewed in chrome via the file: scheme that view live changes to underlying docs files requires adding a switch to chrome to allow file xhr access
Review URL: http://codereview.chromium.org/997010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/js/bootstrap.js')
-rwxr-xr-x | chrome/common/extensions/docs/js/bootstrap.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/chrome/common/extensions/docs/js/bootstrap.js b/chrome/common/extensions/docs/js/bootstrap.js index 7741df0..738686e 100755 --- a/chrome/common/extensions/docs/js/bootstrap.js +++ b/chrome/common/extensions/docs/js/bootstrap.js @@ -1,9 +1,25 @@ +var fileXHREnabled = function() { + var xhr = new XMLHttpRequest(); + try { + xhr.onreadystatechange = function() {}; + xhr.onerror = function() {}; + xhr.open("GET", "nothing.xml", true); + xhr.send(null); + } catch (e) { + return false; + } + + xhr.abort(); + return true; +}(); + // Regenerate page if we are passed the "?regenerate" search param // or if the user-agent is chrome AND the document is being served // from the file:/// scheme. if (window.location.search == "?regenerate" || (navigator.userAgent.indexOf("Chrome") > -1) && - (window.location.href.match("^file:"))) { + (window.location.href.match("^file:")) && + fileXHREnabled) { // Hide body content initially to minimize flashing. document.write('<style id="hider" type="text/css">'); @@ -23,4 +39,11 @@ if (window.location.search == "?regenerate" || if (location.hash.length > 1) location.href = location.href; } +} else if ((navigator.userAgent.indexOf("Chrome") > -1) && + (window.location.href.match("^file:")) && + !fileXHREnabled) { + window.onload = function() { + // Display the warning to use the --allow-file-access-from-files. + document.getElementById("devModeWarning").style.display = "block"; + } } |