summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 23:57:05 +0000
committerarv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 23:57:05 +0000
commitd7aef10706a8e8b5da86d48113136887b3ca97a1 (patch)
treef9f85ff357373ce24d5379a29252cf674f944a89
parent3ae1e408f443a920b449106e45fa868ce75beae7 (diff)
downloadchromium_src-d7aef10706a8e8b5da86d48113136887b3ca97a1.zip
chromium_src-d7aef10706a8e8b5da86d48113136887b3ca97a1.tar.gz
chromium_src-d7aef10706a8e8b5da86d48113136887b3ca97a1.tar.bz2
Fix issue where error pages inserted HTML from a template but the
string from the template was used with JST instead of the i18n template and therefore it did not get recursively processed. Also make sure we can support recursive handling of setting innerHTML with the i18n template engine. BUG=17377 TEST=Navigate to http://ponderer.org/tests/redirect-loop.py The error page should show: The webpage at http://ponderer.org/tests/redirect-loop.py has ... Review URL: http://codereview.chromium.org/155884 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21240 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd10
-rw-r--r--chrome/browser/resources/i18n_template.js33
2 files changed, 25 insertions, 18 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index fcae759..d929b0f 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -2715,13 +2715,13 @@ each locale. -->
</message>
<message name="IDS_ERRORPAGES_SUGGESTION_RELOAD" desc="When a page fails to load, we provide a suggestion that the user try reloading the page later">
- &lt;a i18n-values="href:reloadUrl"&gt;Reload&lt;/a&gt; this web page later.
+ &lt;a jsvalues="href:reloadUrl"&gt;Reload&lt;/a&gt; this web page later.
</message>
<message name="IDS_ERRORPAGES_SUGGESTION_HOMEPAGE" desc="When a page fails to load, sometimes we provide a suggesting of trying just the hostname of the site.">
Go to the homepage of the site:
</message>
<message name="IDS_ERRORPAGES_SUGGESTION_LEARNMORE" desc="When a web page fails to load, we provide a link to the help center to learn more about the failure.">
- <ph name="BEGIN_LINK">&lt;a i18n-values="href:learnMoreUrl"&gt;</ph>Learn more<ph name="END_LINK">&lt;/a&gt;</ph> about this problem.
+ <ph name="BEGIN_LINK">&lt;a jsvalues="href:learnMoreUrl"&gt;</ph>Learn more<ph name="END_LINK">&lt;/a&gt;</ph> about this problem.
</message>
<message name="IDS_ERRORPAGES_TITLE_NOT_AVAILABLE" desc="Title of the error page when we can't connect to a site.">
@@ -2743,13 +2743,13 @@ each locale. -->
This webpage has a redirect loop.
</message>
<message name="IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE" desc="Summary in the error page when we can't connect to a site.">
- The webpage at &lt;strong i18n-content="failedUrl"&gt;&lt;/strong&gt; might be temporarily down or it may have moved permanently to a new web address.
+ The webpage at &lt;strong jscontent="failedUrl"&gt;&lt;/strong&gt; might be temporarily down or it may have moved permanently to a new web address.
</message>
<message name="IDS_ERRORPAGES_SUMMARY_NOT_FOUND" desc="Summary in the error page when the server returns a 404.">
- No webpage was found for the web address: &lt;strong i18n-content="failedUrl"&gt;&lt;/strong&gt;
+ No webpage was found for the web address: &lt;strong jscontent="failedUrl"&gt;&lt;/strong&gt;
</message>
<message name="IDS_ERRORPAGES_SUMMARY_TOO_MANY_REDIRECTS" desc="Summary in the error page when there are too many URL redirects.">
- The webpage at &lt;strong i18n-content="failedUrl"&gt;&lt;/strong&gt; has resulted in
+ The webpage at &lt;strong jscontent="failedUrl"&gt;&lt;/strong&gt; has resulted in
too many redirects. Clearing your cookies for this site may fix the problem. If
not, it is possibly a server configuration issue and not a problem with your
computer.
diff --git a/chrome/browser/resources/i18n_template.js b/chrome/browser/resources/i18n_template.js
index 7a367f7..00289028 100644
--- a/chrome/browser/resources/i18n_template.js
+++ b/chrome/browser/resources/i18n_template.js
@@ -56,6 +56,11 @@ var i18nTemplate = (function() {
}
if (object) {
object[path] = value;
+ // In case we set innerHTML (ignoring others) we need to
+ // recursively check the content
+ if (path == 'innerHTML') {
+ process(element, obj);
+ }
}
} else {
element.setAttribute(propName, value);
@@ -71,21 +76,23 @@ var i18nTemplate = (function() {
}
var selector = '[' + attributeNames.join('],[') + ']';
- return {
- /**
- * Processes a DOM tree with the {@code obj} map.
- */
- process: function(node, obj) {
- var elements = node.querySelectorAll(selector);
- for (var element, i = 0; element = elements[i]; i++) {
- for (var j = 0; j < attributeNames.length; j++) {
- var name = attributeNames[j];
- var att = element.getAttribute(name);
- if (att != null) {
- handlers[name](element, att, obj);
- }
+ /**
+ * Processes a DOM tree with the {@code obj} map.
+ */
+ function process(node, obj) {
+ var elements = node.querySelectorAll(selector);
+ for (var element, i = 0; element = elements[i]; i++) {
+ for (var j = 0; j < attributeNames.length; j++) {
+ var name = attributeNames[j];
+ var att = element.getAttribute(name);
+ if (att != null) {
+ handlers[name](element, att, obj);
}
}
}
+ }
+
+ return {
+ process: process
};
})();