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

Side by Side Diff: chrome/browser/resources/extensions/create_node.js

Issue 893453002: Stop rebuilding all elements in chrome://extensions to preserve focus on refresh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DNC - Apply feedback before merging back into 1 file Created 5 years, 10 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 // TODO(hcarmona): Remove this temporary file.
2
3 /**
4 * Synthesizes and initializes an HTML element for the extension metadata
5 * given in |extension|.
6 * @param {ExtensionData} extension A dictionary of extension metadata.
7 * @private
8 */
9 createNode_: function(extension) {
10 var template = $('template-collection').querySelector(
11 '.extension-list-item-wrapper');
12 var node = template.cloneNode(true);
13 node.id = extension.id;
14
15 // The 'Show Browser Action' button.
16 this.addListener_('click', node, '.show-button', function(e) {
17 chrome.send('extensionSettingsShowButton', [extension.id]);
18 });
19
20 // The 'allow in incognito' checkbox.
21 this.addListener_('change', node, '.incognito-control input',
22 function(e) {
23 var butterBar = node.querySelector('.butter-bar');
24 var checked = e.target.checked;
25 if (!this.butterbarShown_) {
26 butterBar.hidden = !checked || extension.is_hosted_app;
27 this.butterbarShown_ = !butterBar.hidden;
28 } else
29 butterBar.hidden = true;
30 chrome.send('extensionSettingsEnableIncognito',
31 [extension.id, String(checked)]);
32 }.bind(this));
33
34 // The 'collect errors' checkbox. This should only be visible if the
35 // error console is enabled - we can detect this by the existence of the
36 // |errorCollectionEnabled| property.
37 this.addListener_('change', node, '.error-collection-control input',
38 function(e) {
39 chrome.send('extensionSettingsEnableErrorCollection',
40 [extension.id, String(e.target.checked)]);
41 });
42
43 // The 'allow on all urls' checkbox. This should only be visible if
44 // active script restrictions are enabled. If they are not enabled, no
45 // extensions should want all urls.
46 this.addListener_('click', node, '.all-urls-control', function(e) {
47 chrome.send('extensionSettingsAllowOnAllUrls',
48 [extension.id, String(e.target.checked)]);
49 });
50
51 // The 'allow file:// access' checkbox.
52 this.addListener_('click', node, '.file-access-control', function(e) {
53 chrome.send('extensionSettingsAllowFileAccess',
54 [extension.id, String(e.target.checked)]);
55 });
56
57 // The 'Options' button or link, depending on its behaviour.
58 // Set an href to get the correct mouse-over appearance (link,
59 // footer) - but the actual link opening is done through chrome.send
60 // with a preventDefault().
61 node.querySelector('.options-link').setAttribute(
62 'href', extension.optionsPageHref);
63 this.addListener_('click', node, '.options-link', function(e) {
64 chrome.send('extensionSettingsOptions', [extension.id]);
65 e.preventDefault();
66 });
67
68 this.addListener_('click', node, '.options-button', function(e) {
69 this.showEmbeddedExtensionOptions_(extension.id, false);
70 e.preventDefault();
71 }.bind(this));
72
73 // The 'Permissions' link.
74 this.addListener_('click', node, '.permissions-link', function(e) {
75 chrome.send('extensionSettingsPermissions', [extension.id]);
76 e.preventDefault();
77 });
78
79 // The 'Reload' link.
80 this.addListener_('click', node, '.reload-link', function(e) {
81 chrome.send('extensionSettingsReload', [extension.id]);
82 extensionReloadedTimestamp[extension.id] = Date.now();
83 });
84
85 // The 'Launch' link.
86 this.addListener_('click', node, '.launch-link', function(e) {
87 chrome.send('extensionSettingsLaunch', [extension.id]);
88 });
89
90 // The 'Reload' terminated link.
91 this.addListener_('click', node, '.terminated-reload-link', function(e) {
92 chrome.send('extensionSettingsReload', [extension.id]);
93 });
94
95 // The 'Repair' corrupted link.
96 this.addListener_('click', node, '.corrupted-repair-button', function(e) {
97 chrome.send('extensionSettingsRepair', [extension.id]);
98 });
99
100 // The 'Enabled' checkbox.
101 this.addListener_('click', node, '.enable-checkbox input', function(e) {
102 var checked = e.target.checked;
103 chrome.send('extensionSettingsEnable', [extension.id, String(checked)]);
104
105 // This may seem counter-intuitive (to not set/clear the checkmark)
106 // but this page will be updated asynchronously if the extension
107 // becomes enabled/disabled. It also might not become enabled or
108 // disabled, because the user might e.g. get prompted when enabling
109 // and choose not to.
110 e.preventDefault();
111 });
112
113 // 'Remove' button.
114 var trashTemplate = $('template-collection').querySelector('.trash');
115 var trash = trashTemplate.cloneNode(true);
116 trash.title = loadTimeData.getString('extensionUninstall');
117 trash.addEventListener('click', function(e) {
118 chrome.send('extensionSettingsUninstall', [extension.id]);
119 });
120 node.querySelector('.enable-controls').appendChild(trash);
121
122 // Developer mode ////////////////////////////////////////////////////////
123
124 // The path, if provided by unpacked extension.
125 this.addListener_('click', node, '.load-path a:nth-of-type(1)',
126 function(e) {
127 chrome.send('extensionSettingsShowPath', [String(extension.id)]);
128 e.preventDefault();
129 });
130
131 this.appendChild(node);
132 this.updateNode_(extension, node);
133 },
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698