diff --git a/mobile/app/mobile.js b/mobile/app/mobile.js index 8624e135b133..0de257a7ce91 100644 --- a/mobile/app/mobile.js +++ b/mobile/app/mobile.js @@ -263,9 +263,21 @@ pref("privacy.item.formdata", true); pref("privacy.item.downloads", true); pref("privacy.item.passwords", true); pref("privacy.item.sessions", true); +pref("privacy.item.geolocation", true); +pref("privacy.item.siteSettings", true); + pref("plugins.enabled", true); +// URL to the Learn More link XXX this is the firefox one. Bug XXX fixes this. +pref("browser.geolocation.warning.infoURL", "http://%LOCALE%.www.mozilla.com/%LOCALE%/firefox/geolocation/"); + +// base url for the wifi geolocation network provider +pref("geo.wifi.uri", "https://www.google.com/loc/json"); + +// enable geo +pref("geo.enabled", true); + #ifdef WINCE pref("layout.css.dpi", 96); #endif @@ -279,3 +291,4 @@ pref("javascript.options.jit.chrome", true); pref("dom.max_chrome_script_run_time", 30); pref("dom.max_script_run_time", 20); + diff --git a/mobile/chrome/content/browser.css b/mobile/chrome/content/browser.css index 39f0c2e7f673..0ce7b95782ef 100644 --- a/mobile/chrome/content/browser.css +++ b/mobile/chrome/content/browser.css @@ -35,6 +35,10 @@ notification { -moz-binding: url("chrome://browser/content/notification.xml#notification"); } +notification[type="geo"] { + -moz-binding: url("chrome://browser/content/notification.xml#geo-notification"); +} + notification button { -moz-binding: url("chrome://browser/content/notification.xml#notification-button"); } diff --git a/mobile/chrome/content/notification.xml b/mobile/chrome/content/notification.xml index 157263f15035..a0a0c22de160 100644 --- a/mobile/chrome/content/notification.xml +++ b/mobile/chrome/content/notification.xml @@ -1,5 +1,9 @@ - + + %notificationDTD; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + document.getAnonymousElementByAttribute(this, "anonid", "rememberChoice") + + + + + + + diff --git a/mobile/chrome/content/sanitize.js b/mobile/chrome/content/sanitize.js index 709a06cb48fe..5b549692fa42 100644 --- a/mobile/chrome/content/sanitize.js +++ b/mobile/chrome/content/sanitize.js @@ -122,7 +122,57 @@ Sanitizer.prototype = { return true; } }, - + + geolocation: { + clear: function () + { + // clear any network geolocation provider sessions + var psvc = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + try { + var branch = psvc.getBranch("geo.wifi.access_token."); + branch.deleteBranch(""); + + branch = psvc.getBranch("geo.request.remember."); + branch.deleteBranch(""); + } catch (e) {dump(e);} + }, + + get canClear() + { + return true; + } + }, + + siteSettings: { + clear: function () + { + // Clear site-specific permissions like "Allow this site to open popups" + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.removeAll(); + + // Clear site-specific settings like page-zoom level + var cps = Components.classes["@mozilla.org/content-pref/service;1"] + .getService(Components.interfaces.nsIContentPrefService); + cps.removeGroupedPrefs(); + + // Clear "Never remember passwords for this site", which is not handled by + // the permission manager + var pwmgr = Components.classes["@mozilla.org/login-manager;1"] + .getService(Components.interfaces.nsILoginManager); + var hosts = pwmgr.getAllDisabledHosts({}) + for each (var host in hosts) { + pwmgr.setLoginSavingEnabled(host, true); + } + }, + + get canClear() + { + return true; + } + }, + offlineApps: { clear: function () { diff --git a/mobile/chrome/content/sanitize.xul b/mobile/chrome/content/sanitize.xul index 97dd04a2108f..b0ff71604710 100644 --- a/mobile/chrome/content/sanitize.xul +++ b/mobile/chrome/content/sanitize.xul @@ -156,6 +156,9 @@ + + + &sanitizeItems.label; @@ -196,6 +199,13 @@ accesskey="&itemSessions.accesskey;" preference="privacy.item.sessions" onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/> - + + diff --git a/mobile/components/geolocationPrompt.js b/mobile/components/geolocationPrompt.js index ada042dfb075..ba889748bc04 100644 --- a/mobile/components/geolocationPrompt.js +++ b/mobile/components/geolocationPrompt.js @@ -5,6 +5,8 @@ const Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +const kCountBeforeWeRemember = 5; + function GeolocationPrompt() {} GeolocationPrompt.prototype = { @@ -15,6 +17,38 @@ GeolocationPrompt.prototype = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationPrompt]), prompt: function(request) { + var pm = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager); + var result = pm.testExactPermission(request.requestingURI, "geo"); + + if (result == Ci.nsIPermissionManager.ALLOW_ACTION) { + request.allow(); + return; + } + if (result == Ci.nsIPermissionManager.DENY_ACTION) { + request.cancel(); + return; + } + + function setPagePermission(uri, allow) { + var prefService = Cc["@mozilla.org/content-pref/service;1"].getService(Ci.nsIContentPrefService); + + if (! prefService.hasPref(request.requestingURI, "geo.request.remember")) + prefService.setPref(request.requestingURI, "geo.request.remember", 0); + + var count = prefService.getPref(request.requestingURI, "geo.request.remember"); + + if (allow == false) + count--; + else + count++; + + prefService.setPref(request.requestingURI, "geo.request.remember", count); + + if (count == kCountBeforeWeRemember) + pm.add(uri, "geo", Ci.nsIPermissionManager.ALLOW_ACTION); + else if (count == -kCountBeforeWeRemember) + pm.add(uri, "geo", Ci.nsIPermissionManager.DENY_ACTION); + } function getChromeWindow(aWindow) { var chromeWin = aWindow @@ -39,23 +73,32 @@ GeolocationPrompt.prototype = { var browserBundle = bundleService.createBundle("chrome://browser/locale/browser.properties"); var buttons = [{ - label: browserBundle.GetStringFromName("geolocation.exactLocation"), - accessKey: browserBundle.GetStringFromName("geolocation.exactLocationKey"), - callback: function() request.allow() + label: browserBundle.GetStringFromName("geolocation.share"), + accessKey: browserBundle.GetStringFromName("geolocation.share.accessKey"), + callback: function(notification) { + setPagePermission(request.requestingURI, true); + request.allow(); }, - { - label: browserBundle.GetStringFromName("geolocation.nothingLocation"), - accessKey: browserBundle.GetStringFromName("geolocation.nothingLocationKey"), - callback: function() request.cancel() - }]; + }, + { + label: browserBundle.GetStringFromName("geolocation.dontShare"), + accessKey: browserBundle.GetStringFromName("geolocation.dontShare.accessKey"), + callback: function(notification) { + setPagePermission(request.requestingURI, false); + request.cancel(); + }, + }]; - var message = browserBundle.formatStringFromName("geolocation.requestMessage", - [request.requestingURI.spec], 1); - notificationBox.appendNotification(message, - "geolocation", - "chrome://browser/skin/Info.png", - notificationBox.PRIORITY_INFO_HIGH, - buttons); + var message = browserBundle.formatStringFromName("geolocation.siteWantsToKnow", + [request.requestingURI.host], 1); + + var newBar = notificationBox.appendNotification(message, + "geolocation", + "chrome://browser/skin/images/geo-16.png", + notificationBox.PRIORITY_WARNING_MEDIUM, + buttons); + // Make this a geolocation notification. + newBar.setAttribute("type", "geo"); } } }; diff --git a/mobile/locales/en-US/chrome/browser.properties b/mobile/locales/en-US/chrome/browser.properties index d87f650be5ad..df9874a79afa 100644 --- a/mobile/locales/en-US/chrome/browser.properties +++ b/mobile/locales/en-US/chrome/browser.properties @@ -61,17 +61,8 @@ identity.unknown.tooltip=This web site does not supply identity information. identity.ownerUnknown2=(unknown) # Geolocation UI -# LOCALIZATION NOTE (exactLocation, neighborhoodLocation): These do not have to be -# exact value, instead approximations would be fine. -# examples: Neighborhood (within 2 km) -# Exact Location (within 3 m) -# -geolocation.exactLocation=Exact location -geolocation.exactLocation.subLabel=within 10 feet -geolocation.exactLocationKey=E -geolocation.neighborhoodLocation=Neighborhood -geolocation.neighborhoodLocation.subLabel=within 1 mile -geolocation.neighborhoodLocationKey=N -geolocation.nothingLocation=Nothing -geolocation.nothingLocationKey=C -geolocation.requestMessage=%S wants to know where you are. Tell them: +geolocation.share=Share +geolocation.share.accessKey=a +geolocation.dontShare=Don't share +geolocation.dontShare.accessKey=o +geolocation.siteWantsToKnow=%S wants your location. diff --git a/mobile/locales/jar.mn b/mobile/locales/jar.mn index cd5da6aac8a8..d95084423ece 100644 --- a/mobile/locales/jar.mn +++ b/mobile/locales/jar.mn @@ -9,6 +9,7 @@ locale/@AB_CD@/browser/region.properties (%chrome/region.properties) locale/@AB_CD@/browser/preferences.dtd (%chrome/preferences.dtd) locale/@AB_CD@/browser/checkbox.dtd (%chrome/checkbox.dtd) + locale/@AB_CD@/browser/notification.dtd (%chrome/notification.dtd) # Fennec-specific overrides of generic strings * locale/@AB_CD@/browser/netError.dtd (%chrome/overrides/netError.dtd) % override chrome://global/locale/netErrorApp.dtd chrome://browser/locale/netError.dtd diff --git a/mobile/themes/hildon/images/geo-16.png b/mobile/themes/hildon/images/geo-16.png new file mode 100644 index 000000000000..9ae4c5a25748 Binary files /dev/null and b/mobile/themes/hildon/images/geo-16.png differ diff --git a/mobile/themes/hildon/jar.mn b/mobile/themes/hildon/jar.mn index 50d0e7501f1c..2aead1e0e025 100644 --- a/mobile/themes/hildon/jar.mn +++ b/mobile/themes/hildon/jar.mn @@ -59,3 +59,4 @@ classic.jar: images/tab-close.png (images/tab-close.png) images/tag-default-30.png (images/tag-default-30.png) images/star-default-30.png (images/star-default-30.png) + images/geo-16.png (images/geo-16.png) diff --git a/mobile/themes/hildon/notification.css b/mobile/themes/hildon/notification.css index 4dedcc698440..10fe3f0e320e 100644 --- a/mobile/themes/hildon/notification.css +++ b/mobile/themes/hildon/notification.css @@ -3,18 +3,6 @@ notification { color: black; } -notification button { - -moz-appearance: none !important; - background: none !important; - border: 1px solid rgb(192, 192, 160) !important; - -moz-border-radius: 6px !important; - -moz-border-top-colors: rgb(192, 192, 160) !important; - -moz-border-right-colors: rgb(192, 192, 160) !important; - -moz-border-bottom-colors: rgb(192, 192, 160) !important; - -moz-border-left-colors: rgb(192, 192, 160) !important; - margin: 12px 0 12px 6px; -} - .sn-button-text { background: transparent !important; color: black !important; diff --git a/mobile/themes/wince/images/geo-16.png b/mobile/themes/wince/images/geo-16.png new file mode 100644 index 000000000000..9ae4c5a25748 Binary files /dev/null and b/mobile/themes/wince/images/geo-16.png differ diff --git a/mobile/themes/wince/jar.mn b/mobile/themes/wince/jar.mn index 2a3b60df1893..3c0fd21901a0 100644 --- a/mobile/themes/wince/jar.mn +++ b/mobile/themes/wince/jar.mn @@ -36,3 +36,4 @@ classic.jar: images/reload-16.png (images/reload-16.png) images/go-16.png (images/go-16.png) images/newtab-24.png (images/newtab-24.png) + images/geo-16.png (images/geo-16.png) diff --git a/mobile/themes/wince/notification.css b/mobile/themes/wince/notification.css index 4dedcc698440..27bc6c5e6c6c 100644 --- a/mobile/themes/wince/notification.css +++ b/mobile/themes/wince/notification.css @@ -1,20 +1,3 @@ -notification { - background: rgb(255, 255, 176); - color: black; -} - -notification button { - -moz-appearance: none !important; - background: none !important; - border: 1px solid rgb(192, 192, 160) !important; - -moz-border-radius: 6px !important; - -moz-border-top-colors: rgb(192, 192, 160) !important; - -moz-border-right-colors: rgb(192, 192, 160) !important; - -moz-border-bottom-colors: rgb(192, 192, 160) !important; - -moz-border-left-colors: rgb(192, 192, 160) !important; - margin: 12px 0 12px 6px; -} - .sn-button-text { background: transparent !important; color: black !important;