merge backout

This commit is contained in:
Marco Bonardo 2008-11-27 16:12:20 +01:00
commit dba989ee2b
5 changed files with 22 additions and 83 deletions

View File

@ -1107,11 +1107,7 @@ function prepareForStartup() {
gBrowser.browsers[0].removeAttribute("disablehistory"); gBrowser.browsers[0].removeAttribute("disablehistory");
// enable global history // enable global history
try { gBrowser.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).useGlobalHistory = true;
gBrowser.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).useGlobalHistory = true;
} catch(ex) {
Components.utils.reportError("Places database may be locked: " + ex);
}
// hook up UI through progress listener // hook up UI through progress listener
gBrowser.addProgressListener(window.XULBrowserWindow, Components.interfaces.nsIWebProgress.NOTIFY_ALL); gBrowser.addProgressListener(window.XULBrowserWindow, Components.interfaces.nsIWebProgress.NOTIFY_ALL);

View File

@ -74,26 +74,12 @@ function BrowserGlue() {
} }
BrowserGlue.prototype = { BrowserGlue.prototype = {
__prefs: null,
get _prefs() { get _prefs() {
var prefs = Cc["@mozilla.org/preferences-service;1"]. if (!this.__prefs)
getService(Ci.nsIPrefBranch); this.__prefs = Cc["@mozilla.org/preferences-service;1"].
this.__defineGetter__("_prefs", function() prefs); getService(Ci.nsIPrefBranch);
return this._prefs; return this.__prefs;
},
get _placesBundle() {
var strings = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle("chrome://browser/locale/places/places.properties");
this.__defineGetter__("_placesBundle", function() strings);
return this._placesBundle;
},
get _idleService() {
var idleSvc = Cc["@mozilla.org/widget/idleservice;1"].
getService(Ci.nsIIdleService);
this.__defineGetter__("_idleService", function() idleSvc);
return this._idleService;
}, },
_saveSession: false, _saveSession: false,
@ -146,7 +132,7 @@ BrowserGlue.prototype = {
this._initPlaces(); this._initPlaces();
break; break;
case "idle": case "idle":
if (this._idleService.idleTime > BOOKMARKS_ARCHIVE_IDLE_TIME * 1000) { if (this.idleService.idleTime > BOOKMARKS_ARCHIVE_IDLE_TIME * 1000) {
// Back up bookmarks. // Back up bookmarks.
this._archiveBookmarks(); this._archiveBookmarks();
} }
@ -229,7 +215,7 @@ BrowserGlue.prototype = {
_onProfileShutdown: function() _onProfileShutdown: function()
{ {
this._shutdownPlaces(); this._shutdownPlaces();
this._idleService.removeIdleObserver(this, BOOKMARKS_ARCHIVE_IDLE_TIME); this.idleService.removeIdleObserver(this, BOOKMARKS_ARCHIVE_IDLE_TIME);
this.Sanitizer.onShutdown(); this.Sanitizer.onShutdown();
}, },
@ -259,17 +245,6 @@ BrowserGlue.prototype = {
ww.openWindow(null, EMURL, "_blank", EMFEATURES, args); ww.openWindow(null, EMURL, "_blank", EMFEATURES, args);
this._prefs.clearUserPref(PREF_EM_NEW_ADDONS_LIST); this._prefs.clearUserPref(PREF_EM_NEW_ADDONS_LIST);
} }
// Load the "more info" page for a locked places.sqlite
if (this._showPlacesLockedPage) {
var helpTopic = "places-locked";
var url = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Components.interfaces.nsIURLFormatter).
formatURLPref("app.support.baseURL");
url += helpTopic;
var browser = this.getMostRecentBrowserWindow().gBrowser;
browser.selectedTab = browser.addTab(url);
}
}, },
_onQuitRequest: function(aCancelQuit, aQuitType) _onQuitRequest: function(aCancelQuit, aQuitType)
@ -473,6 +448,14 @@ BrowserGlue.prototype = {
return Sanitizer; return Sanitizer;
}, },
_idleService: null,
get idleService() {
if (!this._idleService)
this._idleService = Cc["@mozilla.org/widget/idleservice;1"].
getService(Ci.nsIIdleService);
return this._idleService;
},
/** /**
* Initialize Places * Initialize Places
* - imports the bookmarks html file if bookmarks database is empty, try to * - imports the bookmarks html file if bookmarks database is empty, try to
@ -501,15 +484,9 @@ BrowserGlue.prototype = {
getService(Ci.nsINavHistoryService); getService(Ci.nsINavHistoryService);
var databaseStatus = histsvc.databaseStatus; var databaseStatus = histsvc.databaseStatus;
if (databaseStatus == histsvc.DATABASE_STATUS_LOCKED) {
this._showPlacesLockedAlert();
return;
}
// If the database is corrupt or has been newly created we should // If the database is corrupt or has been newly created we should
// import bookmarks. // import bookmarks.
var importBookmarks = databaseStatus == histsvc.DATABASE_STATUS_CREATE || var importBookmarks = databaseStatus != histsvc.DATABASE_STATUS_OK;
histsvc.DATABASE_STATUS_CORRUPT;
// Check if user or an extension has required to import bookmarks.html // Check if user or an extension has required to import bookmarks.html
var importBookmarksHTML = false; var importBookmarksHTML = false;
@ -600,7 +577,7 @@ BrowserGlue.prototype = {
// Initialize bookmark archiving on idle. // Initialize bookmark archiving on idle.
// Once a day, either on idle or shutdown, bookmarks are backed up. // Once a day, either on idle or shutdown, bookmarks are backed up.
this._idleService.addIdleObserver(this, BOOKMARKS_ARCHIVE_IDLE_TIME); this.idleService.addIdleObserver(this, BOOKMARKS_ARCHIVE_IDLE_TIME);
}, },
/** /**
@ -652,29 +629,6 @@ BrowserGlue.prototype = {
} }
}, },
/**
* Show the alert for a locked places database.
*/
_showPlacesLockedAlert: function nsBrowserGlue__showPlacesLockedAlert() {
// notify the user
var title = this._placesBundle.GetStringFromName("lockPromptTitle");
var text = this._placesBundle.GetStringFromName("lockPromptText");
var buttonText = this._placesBundle.GetStringFromName("lockPromptInfoButtonText");
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
var flags = promptService.BUTTON_POS_0 * promptService.BUTTON_TITLE_IS_STRING +
promptService.BUTTON_POS_1 * promptService.BUTTON_TITLE_CANCEL;
var buttonChoice = promptService.confirmEx(null, title, text, flags,
buttonText, null , null, null,
{value:false});
// Show "more info" page once the browser has loaded
if (buttonChoice == 0)
this._showPlacesLockedPage = true;
},
_migrateUI: function bg__migrateUI() { _migrateUI: function bg__migrateUI() {
var migration = 0; var migration = 0;
try { try {
@ -783,10 +737,11 @@ BrowserGlue.prototype = {
getService(Ci.nsINavBookmarksService); getService(Ci.nsINavBookmarksService);
var annosvc = Cc["@mozilla.org/browser/annotation-service;1"]. var annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService); getService(Ci.nsIAnnotationService);
var strings = this._placesBundle;
var callback = { var callback = {
_placesBundle: strings, _placesBundle: Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle("chrome://browser/locale/places/places.properties"),
_uri: function(aSpec) { _uri: function(aSpec) {
return Cc["@mozilla.org/network/io-service;1"]. return Cc["@mozilla.org/network/io-service;1"].

View File

@ -118,7 +118,3 @@ tagResultLabel=Tag
# for url bar autocomplete results of type "bookmark" # for url bar autocomplete results of type "bookmark"
# See createResultLabel() in urlbarBindings.xml # See createResultLabel() in urlbarBindings.xml
bookmarkResultLabel=Bookmark bookmarkResultLabel=Bookmark
lockPromptTitle=Browser Startup Error
lockPromptText=The bookmarks and history system will not be functional because one of Firefox's files is in use by another application. Some security software can cause this problem.
lockPromptInfoButtonText=Learn More

View File

@ -1118,11 +1118,6 @@ interface nsINavHistoryService : nsISupports
*/ */
const unsigned short DATABASE_STATUS_CORRUPT = 2; const unsigned short DATABASE_STATUS_CORRUPT = 2;
/**
* Set when database is locked
*/
const unsigned short DATABASE_STATUS_LOCKED = 3;
/** /**
* Returns the current database status * Returns the current database status
*/ */

View File

@ -626,11 +626,8 @@ nsNavHistory::InitDBFile(PRBool aForceInit)
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = mDBService->OpenUnsharedDatabase(mDBFile, getter_AddRefs(mDBConn)); rv = mDBService->OpenUnsharedDatabase(mDBFile, getter_AddRefs(mDBConn));
} }
else if (rv == NS_ERROR_FILE_IS_LOCKED) {
mDatabaseStatus = DATABASE_STATUS_LOCKED;
}
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;
} }