Bug 827740 - Deny requests for more indexedDB quota from content. r=fabrice
authorBen Turner <bent.mozilla@gmail.com>
Wed, 09 Jan 2013 08:24:56 -0800
changeset 118244 08c6579a454b2cfd2c11780dbf5df8d11b8da1de
parent 118243 beb820e9f59030750020923098359abb6ab5c117
child 118245 b143f74ed255b6f4f5537710675c6a9b95cb0804
push id20944
push userfdesre@mozilla.com
push dateWed, 09 Jan 2013 16:25:11 +0000
treeherdermozilla-inbound@08c6579a454b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs827740
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 827740 - Deny requests for more indexedDB quota from content. r=fabrice
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -264,16 +264,17 @@ var shell = {
     window.addEventListener('mozfullscreenchange', this);
     window.addEventListener('sizemodechange', this);
     this.contentBrowser.addEventListener('mozbrowserloadstart', this, true);
 
     CustomEventManager.init();
     WebappsHelper.init();
     AccessFu.attach(window);
     UserAgentOverrides.init();
+    IndexedDBPromptHelper.init();
 
     // XXX could factor out into a settings->pref map.  Not worth it yet.
     SettingsListener.observe("debug.fps.enabled", false, function(value) {
       Services.prefs.setBoolPref("layers.acceleration.draw-fps", value);
     });
     SettingsListener.observe("debug.paint-flashing.enabled", false, function(value) {
       Services.prefs.setBoolPref("nglayout.debug.paint_flashing", value);
     });
@@ -301,16 +302,17 @@ var shell = {
       this.timer.cancel();
       this.timer = null;
     }
 
 #ifndef MOZ_WIDGET_GONK
     delete Services.audioManager;
 #endif
     UserAgentOverrides.uninit();
+    IndexedDBPromptHelper.uninit();
   },
 
   // If this key event actually represents a hardware button, filter it here
   // and send a mozChromeEvent with detail.type set to xxx-button-press or
   // xxx-button-release instead.
   filterHardwareKeys: function shell_filterHardwareKeys(evt) {
     var type;
     switch (evt.keyCode) {
@@ -831,16 +833,47 @@ var WebappsHelper = {
           id: id,
           app: json.app
         });
         break;
     }
   }
 }
 
+let IndexedDBPromptHelper = {
+  _quotaPrompt: "indexedDB-quota-prompt",
+  _quotaResponse: "indexedDB-quota-response",
+
+  init:
+  function IndexedDBPromptHelper_init() {
+    Services.obs.addObserver(this, this._quotaPrompt, false);
+  },
+
+  uninit:
+  function IndexedDBPromptHelper_uninit() {
+    Services.obs.removeObserver(this, this._quotaPrompt, false);
+  },
+
+  observe:
+  function IndexedDBPromptHelper_observe(subject, topic, data) {
+    if (topic != this._quotaPrompt) {
+      throw new Error("Unexpected topic!");
+    }
+
+    let observer = subject.QueryInterface(Ci.nsIInterfaceRequestor)
+                          .getInterface(Ci.nsIObserver);
+    let responseTopic = this._quotaResponse;
+
+    setTimeout(function() {
+      observer.observe(null, responseTopic,
+                       Ci.nsIPermissionManager.DENY_ACTION);
+    }, 0);
+  }
+}
+
 let RemoteDebugger = {
   _promptDone: false,
   _promptAnswer: false,
 
   prompt: function debugger_prompt() {
     this._promptDone = false;
 
     shell.sendChromeEvent({