Merge pull request #7353 from timvandermeij/chromium-regression

Resolve a regression in the Chromium extension's preferences handling
This commit is contained in:
Tim van der Meij 2016-05-25 00:43:50 +02:00
commit 78359d8b03
2 changed files with 34 additions and 0 deletions

View File

@ -80,6 +80,21 @@ body {
</div>
</template>
<template id="externalLinkTarget-template">
<div class="settings-row">
<label>
<span></span>
<select>
<option value="0">Default</option>
<option value="1">Current window/tab</option>
<option value="2">New window/tab</option>
<option value="3">Parent window/tab</option>
<option value="4">Top window/tab</option>
</select>
</label>
</div>
</template>
<script src="options.js"></script>
</body>
</html>

View File

@ -74,6 +74,8 @@ Promise.all([
renderPreference = renderDefaultZoomValue(prefSchema.title);
} else if (prefName === 'sidebarViewOnLoad') {
renderPreference = renderSidebarViewOnLoad(prefSchema.title);
} else if (prefName === 'externalLinkTarget') {
renderPreference = renderExternalLinkTarget(prefSchema.title);
} else {
// Should NEVER be reached. Only happens if a new type of preference is
// added to the storage manifest.
@ -190,3 +192,20 @@ function renderSidebarViewOnLoad(shortDescription) {
}
return renderPreference;
}
function renderExternalLinkTarget(shortDescription) {
var wrapper = importTemplate('externalLinkTarget-template');
var select = wrapper.querySelector('select');
select.onchange = function() {
chrome.storage.local.set({
externalLinkTarget: parseInt(this.value)
});
};
wrapper.querySelector('span').textContent = shortDescription;
document.getElementById('settings-boxes').appendChild(wrapper);
function renderPreference(value) {
select.value = value;
}
return renderPreference;
}