Bug 1122480 - Part 9 - Link to the data choices prefs. r=rvitillo

This commit is contained in:
Georg Fritzsche 2015-05-13 21:57:05 +02:00
parent 220f89ced2
commit 6c65f40cf5
3 changed files with 48 additions and 0 deletions

View File

@ -126,6 +126,36 @@ function sectionalizeObject(obj) {
return map;
}
/**
* Obtain the main DOMWindow for the current context.
*/
function getMainWindow() {
return window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
}
/**
* Obtain the DOMWindow that can open a preferences pane.
*
* This is essentially "get the browser chrome window" with the added check
* that the supposed browser chrome window is capable of opening a preferences
* pane.
*
* This may return null if we can't find the browser chrome window.
*/
function getMainWindowWithPreferencesPane() {
let mainWindow = getMainWindow();
if (mainWindow && "openAdvancedPreferences" in mainWindow) {
return mainWindow;
} else {
return null;
}
}
let Settings = {
SETTINGS: [
// data upload
@ -149,6 +179,14 @@ let Settings = {
let setting = s;
Preferences.observe(setting.pref, this.render, this);
}
let elements = document.getElementsByClassName("change-data-choices-link");
for (let el of elements) {
el.addEventListener("click", function() {
let mainWindow = getMainWindowWithPreferencesPane();
mainWindow.openAdvancedPreferences("dataChoicesTab");
}, false);
}
},
detachObservers: function() {

View File

@ -35,12 +35,18 @@
<p id="description-upload-enabled" class="description-enabled">&aboutTelemetry.uploadEnabled;</p>
<p id="description-upload-disabled" class="description-disabled">&aboutTelemetry.uploadDisabled;</p>
</td>
<td>
<a href="" class="change-data-choices-link">&aboutTelemetry.changeDataChoices;</a>
</td>
</tr>
<tr>
<td>
<p id="description-extended-recording-enabled" class="description-enabled">&aboutTelemetry.extendedRecordingEnabled;</p>
<p id="description-extended-recording-disabled" class="description-disabled">&aboutTelemetry.extendedRecordingDisabled;</p>
</td>
<td>
<a href="" class="change-data-choices-link">&aboutTelemetry.changeDataChoices;</a>
</td>
</tr>
</table>
</header>

View File

@ -4,6 +4,10 @@
<!ENTITY aboutTelemetry.pageTitle "Telemetry Data">
<!ENTITY aboutTelemetry.changeDataChoices "
Change
">
<!ENTITY aboutTelemetry.uploadEnabled "
FHR data upload is <span>enabled</span>.
">