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

Side by Side Diff: ui/accessibility/extensions/longdesc/background.js

Issue 593293002: Initial checkin of accessibility extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix license issues Created 6 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 /* Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
4
5 var ariaDescribedAt = '';
6 var longDesc = '';
7
8 /**
9 * This is called when the extension is first loaded, so that it can be
10 * immediately used in all already-open tabs. It's not needed for any
11 * new tabs that open after that, the content script will be automatically
12 * injected into any new tab.
13 */
14 chrome.windows.getAll({'populate': true}, function(windows) {
15 for (var i = 0; i < windows.length; i++) {
16 var tabs = windows[i].tabs;
17 for (var j = 0; j < tabs.length; j++) {
18 chrome.tabs.executeScript(
19 tabs[j].id,
20 {file: 'lastRightClick.js'});
21 }
22 }
23 });
24
25 /**
26 * Add context menu item when the extension is installed.
27 */
28 chrome.contextMenus.create({
29 "title": "More information...",
30 "contexts": ["all"],
31 "id": "moreInfo",
32 "onclick": contextMenuClicked,
33 "enabled": false
34 });
35
36 /**
37 * Add listener for messages from content script.
38 * Enable/disable the context menu item.
39 */
40 chrome.runtime.onMessage.addListener(
41 function (request, sender, sendResponse) {
42 if (request.enabled) {
43 ariaDescribedAt = request.ariaDescribedAt;
44 longDesc = request.longDesc;
45 }
46 chrome.contextMenus.update('moreInfo', {
47 "enabled": request.enabled
48 });
49 });
50
51 /**
52 * Event handler for when a context menu item is clicked.
53 * aria-describedat is given a higher priority.
54 * No need to strip the URL of leading/trailing white space
55 * because Chrome takes care of this.
56 *
57 * @param info
58 * @param tab
59 */
60 function contextMenuClicked(info, tab) {
61 if (ariaDescribedAt !== '') {
62 chrome.tabs.create({url: ariaDescribedAt});
63 } else if (longDesc !== '') {
64 chrome.tabs.create({url: longDesc});
65 }
66 }
OLDNEW
« no previous file with comments | « ui/accessibility/extensions/highcontrast/popup.js ('k') | ui/accessibility/extensions/longdesc/icon.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698