Bug 595810 Part 8c: implement indexedDB doorhanger r=Ian

This commit is contained in:
Neil Rashbrook 2011-02-03 21:07:32 +00:00
Родитель 0943f2e22e
Коммит 54786dcec1
7 изменённых файлов: 125 добавлений и 4 удалений

Просмотреть файл

@ -79,6 +79,7 @@ panel[for="urlbar"] {
#notification-popup-box[anchorid="notification-popup-box"] > #default-notification-icon,
#notification-popup-box[anchorid="geo-notification-icon"] > #geo-notification-icon,
#notification-popup-box[anchorid="addons-notification-icon"] > #addons-notification-icon,
#notification-popup-box[anchorid="indexedDB-notification-icon"] > #indexedDB-notification-icon,
#notification-popup-box[anchorid="password-notification-icon"] > #password-notification-icon {
display: -moz-box;
}

Просмотреть файл

@ -318,6 +318,7 @@
<image id="default-notification-icon" class="notification-anchor-icon" role="button"/>
<image id="geo-notification-icon" class="notification-anchor-icon" role="button"/>
<image id="addons-notification-icon" class="notification-anchor-icon" role="button"/>
<image id="indexedDB-notification-icon" class="notification-anchor-icon" role="button"/>
<image id="password-notification-icon" class="notification-anchor-icon" role="button"/>
</box>
<deck id="page-proxy-deck"

Просмотреть файл

@ -160,14 +160,14 @@
var requestor = aSubject.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
var contentWindow = requestor.getInterface(Components.interfaces.nsIDOMWindow);
if (contentWindow.top == browser.contentWindow)
this.promptIndexedDB(requestor, contentWindow, "usage", aData);
this.promptIndexedDB(requestor, contentWindow, "quota", aData);
break;
case "indexedDB-quota-cancel":
var requestor = aSubject.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
var contentWindow = requestor.getInterface(Components.interfaces.nsIDOMWindow);
if (contentWindow.top == browser.contentWindow)
this.cancelIndexedDB(requestor, contentWindow, "usage", aData);
this.cancelIndexedDB(requestor, contentWindow, "quota", aData);
break;
case "addon-install-blocked":
@ -538,7 +538,7 @@
nsIPermissionManager.DENY_ACTION);
}
}];
var box = this.appendNotification(message, aTopic, null,
var box = this.appendNotification(message, "indexedDB-" + aTopic + "-prompt", null,
this.PRIOITY_INFO_HIGH, buttons);
box.timeout = setTimeout(function() {
observer.observe(null, "indexedDB-" + aTopic + "-response",
@ -557,7 +557,7 @@
<parameter name="aData"/>
<body>
<![CDATA[
var popupNotification = this.getNotificationWithValue(aTopic);
var popupNotification = this.getNotificationWithValue("indexedDB-" + aTopic + "-prompt");
if (popupNotification) {
clearTimeout(popupNotification.timeout);
this.removeNotification(popupNotification);
@ -1105,6 +1105,83 @@
</body>
</method>
<method name="promptIndexedDB">
<parameter name="aRequestor"/>
<parameter name="aWindow"/>
<parameter name="aTopic"/>
<parameter name="aData"/>
<body>
<![CDATA[
var host = aWindow.document.documentURIObject.asciiHost;
var message = this._stringBundle.formatStringFromName("offlineApps." + aTopic, [host, aData], 2);
var observer = aRequestor.getInterface(Components.interfaces.nsIObserver);
var nsIPermissionManager = Components.interfaces.nsIPermissionManager;
var mainAction = {
label: this._stringBundle.GetStringFromName("offlineApps.allow"),
accessKey: this._stringBundle.GetStringFromName("offlineApps.allow.accesskey"),
callback: function allowIndexedDB() {
clearTimeout(notification.timeout);
observer.observe(null, "indexedDB-" + aTopic + "-response",
nsIPermissionManager.ALLOW_ACTION);
}
};
var secondaryActions = [{
label: this._stringBundle.GetStringFromName("offlineApps.deny"),
accessKey: this._stringBundle.GetStringFromName("offlineApps.deny.accesskey"),
callback: function denyIndexedDB() {
clearTimeout(notification.timeout);
observer.observe(null, "indexedDB-" + aTopic + "-response",
nsIPermissionManager.DENY_ACTION);
}
}];
function notificationTimedOut() {
observer.observe(null, "indexedDB-" + aTopic + "-response",
nsIPermissionManager.UNKNOWN_ACTION);
notification.remove();
}
var options = {
eventCallback: function(state) {
if (notification) {
// Always clear the timeout up front. If the doorhanger was
// temporarily dismissed, we'll set a new 30 second timeout
// to automatically cancel the request. If the doorhanger
// gets redisplayed we don't want it to time out unless it
// gets dismissed again. And if the doorhanger gets removed
// then we aren't interested in it any more.
clearTimeout(timeout);
if (state == "dismissed")
timeout = setTimeout(notificationTimedOut, 30000);
}
}
};
var notification =
PopupNotifications.show(this.activeBrowser,
"indexedDB-" + aTopic + "-prompt",
message, "indexedDB-notification-icon",
mainAction, secondaryActions, options);
var timeout = setTimeout(notificationTimedOut, 300000); // 5 minutes
]]>
</body>
</method>
<method name="cancelIndexedDB">
<parameter name="aRequestor"/>
<parameter name="aWindow"/>
<parameter name="aTopic"/>
<parameter name="aData"/>
<body>
<![CDATA[
var popupNotification = PopupNotifications.getNotification("indexedDB-" + aTopic + "-prompt", this.activeBrowser);
if (popupNotification)
popupNotification.remove(); // eventCallback clears the timeout
var observer = aRequestor.getInterface(Components.interfaces.nsIObserver);
observer.observe(null, "indexedDB-" + aTopic + "-response",
nsIPermissionManager.UNKNOWN_ACTION);
]]>
</body>
</method>
<method name="addonInstallBlocked">
<parameter name="installInfo"/>
<body>

Просмотреть файл

@ -320,6 +320,12 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
height: 32px;
}
.popup-notification-icon[popupid="indexedDB-permissions-prompt"],
.popup-notification-icon[popupid="indexedDB-quota-prompt"] {
list-style-image: url("chrome://global/skin/icons/question64.png");
}
.popup-notification-icon[popupid="password-change"],
.popup-notification-icon[popupid="password-save"] {
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
}
@ -352,6 +358,12 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
height: 16px;
}
#indexedDB-notification-icon {
list-style-image: url("chrome://global/skin/icons/question-16.png");
width: 16px;
height: 16px;
}
#password-notification-icon {
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
width: 16px;

Просмотреть файл

@ -362,6 +362,12 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
height: 32px;
}
.popup-notification-icon[popupid="indexedDB-permissions-prompt"],
.popup-notification-icon[popupid="indexedDB-quota-prompt"] {
list-style-image: url("chrome://global/skin/icons/question64.png");
}
.popup-notification-icon[popupid="password-change"],
.popup-notification-icon[popupid="password-save"] {
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
}
@ -393,6 +399,12 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
height: 16px;
}
#indexedDB-notification-icon {
list-style-image: url("chrome://global/skin/icons/question-16.png");
width: 16px;
height: 16px;
}
#password-notification-icon {
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
width: 16px;

Просмотреть файл

@ -68,6 +68,10 @@ notification[type="critical"] {
/* Popup notifications */
popupnotification {
background-color: #C7D0D9;
}
.popup-notification-description {
max-width: 248px;
margin-top: 4px !important;

Просмотреть файл

@ -547,6 +547,14 @@ toolbar[mode="icons"] #search-button > .button-box > .button-text {
height: 32px;
}
.popup-notification-icon[popupid="indexedDB-permissions-prompt"],
.popup-notification-icon[popupid="indexedDB-quota-prompt"] {
list-style-image: url("chrome://global/skin/icons/alert-question.gif");
width: 46px;
height: 36px;
}
.popup-notification-icon[popupid="password-change"],
.popup-notification-icon[popupid="password-save"] {
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
}
@ -578,6 +586,12 @@ toolbar[mode="icons"] #search-button > .button-box > .button-text {
height: 16px;
}
#indexedDB-notification-icon {
list-style-image: url("chrome://global/skin/icons/question-16.png");
width: 16px;
height: 16px;
}
#password-notification-icon {
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
width: 16px;