Geolocation UI. Bug 444665. r=mfinkle
authordougt@dougt-ubuntu
Wed, 16 Jul 2008 17:07:43 -0700
changeset 64757 a30400d55c971dd61eb4ab91f0af61da38124c68
parent 64756 aed3ced86b565a9217aacea6db39e3b2738bcb27
child 64758 efac7cd909ccb9c69e56c5f74ede953d52495c93
push id19389
push userffxbld
push dateWed, 06 Apr 2011 21:33:21 +0000
treeherdermozilla-central@8e9f90073a20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs444665
Geolocation UI. Bug 444665. r=mfinkle
mobile/chrome/content/browser.js
mobile/chrome/locale/en-US/browser.properties
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -98,16 +98,18 @@ var Browser = {
     this._content.addEventListener("overpan", this, false);
     this._content.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver.onUpdatePageReport, false);
     BrowserUI.init();
 
     this._progressController = new ProgressController(this.content);
 
     this._spatialNavigation  = new SpatialNavigation(this.content);
 
+    this.setupGeolocationPrompt();
+
     Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
 
     // Determine the initial launch page
     var whereURI = null;
     try {
       // Use a homepage
       whereURI = this.prefs.getCharPref("browser.startup.homepage");
     }
@@ -132,16 +134,52 @@ var Browser = {
     }
 
     if (whereURI) {
       var self = this;
       setTimeout(function() { self.content.browser.loadURI(whereURI, null, null, false); }, 10);
     }
   },
 
+  setupGeolocationPrompt: function() {
+    var geolocationService = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationService);
+    geolocationService.prompt = function(request) {
+
+      var notificationBox = Browser.getNotificationBox();
+      var notification = notificationBox.getNotificationWithValue("geolocation");
+
+      if (!notification) {
+        var bundle_browser = document.getElementById("bundle_browser");
+        var buttons = [{
+            label: bundle_browser.getString("gelocation.exactLocation"),
+            accessKey: bundle_browser.getString("gelocation.exactLocationKey"),
+            callback: function(){request.allow()},
+          },
+          {
+            label: bundle_browser.getString("gelocation.neighborhoodLocation"),
+            accessKey: bundle_browser.getString("gelocation.neighborhoodLocationKey"),
+            callback: function(){request.allowButFuzz()},
+          },
+          {
+            label: bundle_browser.getString("gelocation.nothingLocation"),
+            accessKey: bundle_browser.getString("gelocation.nothingLocationKey"),
+            callback: function(){request.cancel()},
+          }];
+
+        var message = bundle_browser.getFormattedString("geolocation.requestMessage", [request.requestingURI.spec]);      
+        notificationBox.appendNotification(message,
+                                           "geolocation",
+                                           null, // todo "chrome://browser/skin/Info.png",
+                                           notificationBox.PRIORITY_INFO_HIGH,
+                                           buttons);
+        return 1;
+      }
+    };
+  },
+
   get content() {
     return this._content;
   },
 
   /**
    * Return the currently active <browser> object, since a <deckbrowser> may
    * have more than one
    */
--- a/mobile/chrome/locale/en-US/browser.properties
+++ b/mobile/chrome/locale/en-US/browser.properties
@@ -11,8 +11,17 @@ popupButtonNeverWarn.accesskey=N
 identity.identified.verifier=Verified by: %S
 identity.identified.verified_by_you=You have added a security exception for this site
 identity.identified.state_and_country=%S, %S
 identity.identified.title_with_country=%S (%S)
 identity.encrypted=Your connection to this web site is encrypted to prevent eavesdropping.
 identity.unencrypted=Your connection to this web site is not encrypted.
 identity.unknown.tooltip=This web site does not supply identity information.
 identity.ownerUnknown2=(unknown)
+
+# Geolocation UI
+gelocation.exactLocation=Exact Location (within 10 feet)
+gelocation.exactLocationKey=E
+gelocation.neighborhoodLocation=Neighborhood (within 1 mile)
+gelocation.neighborhoodLocationKey=N
+gelocation.nothingLocation=Nothing
+gelocation.nothingLocationKey=C
+geolocation.requestMessage=%S wants to know where you are.  Tell them: