summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples/api/i18n/cld/background.html
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/extensions/docs/examples/api/i18n/cld/background.html')
-rw-r--r--chrome/common/extensions/docs/examples/api/i18n/cld/background.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/examples/api/i18n/cld/background.html b/chrome/common/extensions/docs/examples/api/i18n/cld/background.html
new file mode 100644
index 0000000..cfb1fac
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/i18n/cld/background.html
@@ -0,0 +1,32 @@
+<!--
+Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+source code is governed by a BSD-style license that can be found in the
+LICENSE file.
+-->
+
+<script>
+var selectedId = -1;
+function refreshLanguage() {
+ chrome.tabs.detectLanguage(null, function(language) {
+ console.log(language);
+ if (language == " invalid_language_code")
+ language = "???";
+ chrome.browserAction.setBadgeText({"text": language, tabId: selectedId});
+ });
+}
+
+chrome.tabs.onUpdated.addListener(function(tabId, props) {
+ if (props.status == "complete" && tabId == selectedId)
+ refreshLanguage();
+});
+
+chrome.tabs.onSelectionChanged.addListener(function(tabId, props) {
+ selectedId = tabId;
+ refreshLanguage();
+});
+
+chrome.tabs.getSelected(null, function(tab) {
+ selectedId = tab.id;
+ refreshLanguage();
+});
+</script>