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

Unified Diff: ui/keyboard/resources/elements/kb-keyboard.html

Issue 23819032: Dynamically load keyboard layouts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove console log. 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
« no previous file with comments | « no previous file | ui/keyboard/resources/index.html » ('j') | ui/keyboard/resources/index.html » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/keyboard/resources/elements/kb-keyboard.html
diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html
index 2082a84aeae47c3f43cce2b60a858114f4d40ce6..8c4f45488009d27e46787be45c078a6414e15282 100644
--- a/ui/keyboard/resources/elements/kb-keyboard.html
+++ b/ui/keyboard/resources/elements/kb-keyboard.html
@@ -479,7 +479,24 @@
keyboard.appendChild(flattenKeysets(keysets.content));
this.selectDefaultKeyset();
} else {
- console.error('Unable to find layout ' + this.layout);
+ // Add link for the keysets if missing from the document. Force
+ // a layout change after resolving the import of the link.
+ var query = 'link[id=' + this.layout + ']';
+ if (!document.querySelector(query)) {
+ // Layout has not beeen loaded yet.
+ var link = document.createElement('link');
+ link.id = this.layout;
+ link.setAttribute('rel', 'import');
+ link.setAttribute('href', 'layouts/' + this.layout + '.html');
+ document.head.appendChild(link);
+
+ // Load content for the new link element.
+ var self = this;
+ HTMLImports.importer.load(document, function() {
+ HTMLImports.parser.parseLink(link);
bshe 2013/09/06 21:12:21 would it enter infinite loop if failed to load?
kevers 2013/09/09 15:44:04 We do a check for an existing link element before
+ self.layoutChanged();
+ });
+ }
}
}
this.classList.remove('caps-locked');
« no previous file with comments | « no previous file | ui/keyboard/resources/index.html » ('j') | ui/keyboard/resources/index.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698