Backed out changeset 7c45205a61a0 (bug 769285)

This commit is contained in:
Josh Matthews 2012-11-28 11:51:42 -05:00
parent 6f2ad73722
commit 0541a0bcc3
7 changed files with 20 additions and 55 deletions

View File

@ -443,6 +443,10 @@ PrivateBrowsingService.prototype = {
let sdr = Cc["@mozilla.org/security/sdr;1"]. let sdr = Cc["@mozilla.org/security/sdr;1"].
getService(Ci.nsISecretDecoderRing); getService(Ci.nsISecretDecoderRing);
sdr.logoutAndTeardown(); sdr.logoutAndTeardown();
try {
this._prefs.deleteBranch("geo.wifi.access_token.");
} catch (ex) {}
if (!this._inPrivateBrowsing) { if (!this._inPrivateBrowsing) {
// Clear the error console // Clear the error console

View File

@ -392,15 +392,10 @@ nsGeolocationRequest::Cancel()
NS_IMETHODIMP NS_IMETHODIMP
nsGeolocationRequest::Allow() nsGeolocationRequest::Allow()
{ {
nsCOMPtr<nsIDOMWindow> window; nsRefPtr<nsGeolocationService> gs = nsGeolocationService::GetGeolocationService();
GetWindow(getter_AddRefs(window));
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(window);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
bool isPrivate = loadContext && loadContext->UsePrivateBrowsing();
// Kick off the geo device, if it isn't already running // Kick off the geo device, if it isn't already running
nsRefPtr<nsGeolocationService> gs = nsGeolocationService::GetGeolocationService(); nsresult rv = gs->StartDevice();
nsresult rv = gs->StartDevice(isPrivate);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// Location provider error // Location provider error
@ -924,7 +919,7 @@ nsGeolocationService::GetCachedPosition()
} }
nsresult nsresult
nsGeolocationService::StartDevice(bool aRequestPrivate) nsGeolocationService::StartDevice()
{ {
if (!sGeoEnabled || sGeoInitPending) { if (!sGeoEnabled || sGeoInitPending) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
@ -949,7 +944,7 @@ nsGeolocationService::StartDevice(bool aRequestPrivate)
for (int32_t i = 0; i < mProviders.Count(); i++) { for (int32_t i = 0; i < mProviders.Count(); i++) {
mProviders[i]->Startup(); mProviders[i]->Startup();
mProviders[i]->Watch(this, aRequestPrivate); mProviders[i]->Watch(this);
obs->NotifyObservers(mProviders[i], obs->NotifyObservers(mProviders[i],
"geolocation-device-events", "geolocation-device-events",
NS_LITERAL_STRING("starting").get()); NS_LITERAL_STRING("starting").get());

View File

@ -125,7 +125,7 @@ public:
PRBool IsBetterPosition(nsIDOMGeoPosition *aSomewhere); PRBool IsBetterPosition(nsIDOMGeoPosition *aSomewhere);
// Find and startup a geolocation device (gps, nmea, etc.) // Find and startup a geolocation device (gps, nmea, etc.)
nsresult StartDevice(bool aRequestPrivate); nsresult StartDevice();
// Stop the started geolocation device (gps, nmea, etc.) // Stop the started geolocation device (gps, nmea, etc.)
void StopDevice(); void StopDevice();

View File

@ -121,7 +121,7 @@ GPSDProvider.prototype = {
this.transport.close(Components.results.NS_OK); this.transport.close(Components.results.NS_OK);
}, },
watch: function(c, isPrivate) { watch: function(c) {
LOG("watch called\n"); LOG("watch called\n");
try { try {
// Go into "watcher" mode // Go into "watcher" mode

View File

@ -16,9 +16,6 @@ const Cc = Components.classes;
let gLoggingEnabled = false; let gLoggingEnabled = false;
let gTestingEnabled = false; let gTestingEnabled = false;
let gPrivateAccessToken = '';
let gPrivateAccessTime = 0;
function LOG(aMsg) { function LOG(aMsg) {
if (gLoggingEnabled) if (gLoggingEnabled)
{ {
@ -61,11 +58,6 @@ WifiGeoPositionObject.prototype = {
classDescription: "wifi geo location position object"}), classDescription: "wifi geo location position object"}),
}; };
function privateBrowsingObserver(aSubject, aTopic, aData) {
gPrivateAccessToken = '';
gPrivateAccessTime = 0;
}
function WifiGeoPositionProvider() { function WifiGeoPositionProvider() {
try { try {
gLoggingEnabled = Services.prefs.getBoolPref("geo.wifi.logging.enabled"); gLoggingEnabled = Services.prefs.getBoolPref("geo.wifi.logging.enabled");
@ -79,9 +71,6 @@ function WifiGeoPositionProvider() {
this.timer = null; this.timer = null;
this.hasSeenWiFi = false; this.hasSeenWiFi = false;
this.started = false; this.started = false;
this.lastRequestPrivate = false;
Services.obs.addObserver(privateBrowsingObserver, "last-pb-context-exited", false);
} }
WifiGeoPositionProvider.prototype = { WifiGeoPositionProvider.prototype = {
@ -107,18 +96,16 @@ WifiGeoPositionProvider.prototype = {
this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK); this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK);
}, },
watch: function(c, requestPrivate) { watch: function(c) {
LOG("watch called"); LOG("watch called");
if (!this.wifiService) { if (!this.wifiService) {
this.wifiService = Cc["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor); this.wifiService = Cc["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor);
this.wifiService.startWatching(this); this.wifiService.startWatching(this);
this.lastRequestPrivate = requestPrivate;
} }
if (this.hasSeenWiFi) { if (this.hasSeenWiFi) {
this.hasSeenWiFi = false; this.hasSeenWiFi = false;
this.wifiService.stopWatching(this); this.wifiService.stopWatching(this);
this.wifiService.startWatching(this); this.wifiService.startWatching(this);
this.lastRequestPrivate = requestPrivate;
} }
}, },
@ -151,20 +138,11 @@ WifiGeoPositionProvider.prototype = {
// check to see if we have an access token: // check to see if we have an access token:
let accessToken = ""; let accessToken = "";
try { try {
if (this.lastRequestPrivate) { let accessTokenPrefName = "geo.wifi.access_token." + url;
accessToken = gPrivateAccessToken; accessToken = Services.prefs.getCharPref(accessTokenPrefName);
} else {
let accessTokenPrefName = "geo.wifi.access_token." + url;
accessToken = Services.prefs.getCharPref(accessTokenPrefName);
}
// check to see if it has expired // check to see if it has expired
let accessTokenDate; let accessTokenDate = Services.prefs.getIntPref(accessTokenPrefName + ".time");
if (this.lastRequestPrivate) {
accessTokenDate = gPrivateAccessTime;
} else {
Services.prefs.getIntPref(accessTokenPrefName + ".time");
}
let accessTokenInterval = 1209600; // seconds in 2 weeks let accessTokenInterval = 1209600; // seconds in 2 weeks
try { try {
@ -274,26 +252,17 @@ WifiGeoPositionProvider.prototype = {
{ {
let accessToken = ""; let accessToken = "";
let accessTokenPrefName = "geo.wifi.access_token." + providerUrlBase; let accessTokenPrefName = "geo.wifi.access_token." + providerUrlBase;
if (this.lastRequestPrivate) { try { accessToken = Services.prefs.getCharPref(accessTokenPrefName); } catch (e) {}
accessTokenPrefName = gPrivateAccessToken;
} else {
try { accessToken = Services.prefs.getCharPref(accessTokenPrefName); } catch (e) {}
}
if (accessToken != newAccessToken) { if (accessToken != newAccessToken) {
// no match, lets cache // no match, lets cache
LOG("New Access Token: " + newAccessToken + "\n" + accessTokenPrefName); LOG("New Access Token: " + newAccessToken + "\n" + accessTokenPrefName);
if (this.lastRequestPrivate) {
gPrivateAccessToken = newAccessToken;
gPrivateAccessTime = nowInSeconds();
} else {
try { try {
Services.prefs.setIntPref(accessTokenPrefName + ".time", nowInSeconds()); Services.prefs.setIntPref(accessTokenPrefName + ".time", nowInSeconds());
Services.prefs.setCharPref(accessTokenPrefName, newAccessToken); Services.prefs.setCharPref(accessTokenPrefName, newAccessToken);
} catch (x) { } catch (x) {
// XXX temporary hack for bug 575346 to allow geolocation to function // XXX temporary hack for bug 575346 to allow geolocation to function
} }
}
} }
} }
}, false); }, false);

View File

@ -585,7 +585,7 @@ GonkGPSGeolocationProvider::Startup()
} }
NS_IMETHODIMP NS_IMETHODIMP
GonkGPSGeolocationProvider::Watch(nsIGeolocationUpdate* aCallback, bool aPrivate) GonkGPSGeolocationProvider::Watch(nsIGeolocationUpdate* aCallback)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());

View File

@ -35,7 +35,7 @@ interface nsIGeolocationUpdate : nsISupports {
* startup is called, any geo location change should call * startup is called, any geo location change should call
* callback.update(). * callback.update().
*/ */
[scriptable, uuid(d32b87b3-fe96-4f42-81ab-2f39f7ec43ff)] [scriptable, uuid(483BE98B-F747-490A-8AF1-53146D2D5373)]
interface nsIGeolocationProvider : nsISupports { interface nsIGeolocationProvider : nsISupports {
/** /**
@ -46,12 +46,9 @@ interface nsIGeolocationProvider : nsISupports {
/** /**
* watch * watch
* When a location change is observed, notify the callback. The privacy * When a location change is observed, notify the callback
* argument informs the provider whether the initiating request came from
* a private context; it is up to the provider to use that information
* in a sensible manner.
*/ */
void watch(in nsIGeolocationUpdate callback, in boolean requestPrivate); void watch(in nsIGeolocationUpdate callback);
/** /**
* shutdown * shutdown