Fix for feature bug 44427. checking in code on behalf of jce2@po.cwru.edu

r=myself. a=brendan


git-svn-id: svn://10.0.0.236/trunk@73954 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
radha%netscape.com 2000-07-10 22:07:47 +00:00
parent 176282916f
commit ae741cd1bc
5 changed files with 92 additions and 13 deletions

View File

@ -1,4 +1,27 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Jason Eager <jce2@po.cwru.edu>
* (Some other netscape person who forgot to put the NPL header!)
*
*/
const MAX_HISTORY_MENU_ITEMS = 15;
function FillHistoryMenu( aParent, aMenu )
@ -75,8 +98,8 @@ function createUBHistoryMenu( aEvent )
{
var len = ubHistory.count;
var end = (len > MAX_HISTORY_MENU_ITEMS) ? (len - MAX_HISTORY_MENU_ITEMS) : 0;
if (len > 0)
deleteHistoryItems( aEvent ); // Delete old History Menus
// deleteHistoryItems needs to be done even if len = 0!
deleteHistoryItems( aEvent ); // Delete old History Menus
for (var i = len - 1; i >= end; i--)
createMenuItem( aEvent.target, i, ubHistory.getEntryAtIndex(i));
}

View File

@ -34,10 +34,29 @@
<script language="javascript" src="chrome://global/content/strres.js"></script>
<script language="javascript" src="chrome://communicator/content/pref/prefutilities.js"></script>
<script language="javascript" src="chrome://global/content/nsJSComponentManager.js">
</script>
<script language="JavaScript">
<![CDATA[
_elementIDs = ["startupPage", "browserStartupHomepage", "histDay"];
]]>
function Startup()
{
var urlBarHist = nsJSComponentManager.getService("component://netscape/browser/urlbarhistory",
"nsIUrlbarHistory");
if ( urlBarHist )
{
var button = document.getElementById("ClearUrlBarHistoryButton");
if ( urlBarHist.count == 0 )
{
button.setAttribute("disabled","true");
}
else
{
button.removeAttribute("disabled");
}
}
}
</script>
<box class="box-smallheader" title="&lHeader;"/>
@ -96,7 +115,8 @@
<box autostretch="never">
<html flex="1">&clearLocationBar.label;</html>
<box autostretch="never" halign="right">
<button class="dialog" value="&clearLocationBarButton.label;" accesskey="&clearLocationBarButton.accesskey;"/>
<button class="dialog" id="ClearUrlBarHistoryButton" value="&clearLocationBarButton.label;" accesskey="&clearLocationBarButton.accesskey;"
oncommand="prefClearUrlbarHistory();"/>
</box>
</box>
</titledbox>

View File

@ -19,6 +19,7 @@
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
* Jason Eager <jce2@po.cwru.edu>
*/
const nsIFilePicker = Components.interfaces.nsIFilePicker;
@ -91,5 +92,18 @@ function setHomePageToCurrentPage(folderFieldId)
homePageField.value = url;
}
function prefClearUrlbarHistory()
{
var button = document.getElementById("ClearUrlBarHistoryButton");
var urlBarHist = nsJSComponentManager.getService("component://netscape/browser/urlbarhistory",
"nsIUrlbarHistory");
if ( urlBarHist )
{
urlBarHist.clearHistory();
dump("Now history should be empty. \n");
button.setAttribute("disabled","true");
}
}
var bundle = srGetStrBundle("chrome://communicator/locale/pref/prefutilities.properties");

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s): Radha Kulkarni (radha@netscape.com)
* Jason Eager (jce2@po.cwru.edu)
*/
#include "nsISupports.idl"
@ -58,6 +59,11 @@ interface nsIUrlbarHistory: nsISupports
* print the History contents
*/
void printHistory();
/**
* clear the History contents
*/
void clearHistory();
};

View File

@ -55,19 +55,12 @@ nsUrlbarHistory::nsUrlbarHistory():mLength(0)
nsUrlbarHistory::~nsUrlbarHistory()
{
PRInt32 i = mLength;
for (i=0; i<mLength; i++) {
nsString * entry = nsnull;
entry = (nsString *)mArray.ElementAt(i);
delete entry;
mLength--;
}
ClearHistory();
PRInt32 cnt = sizeof(ignoreArray)/sizeof(char *);
for(PRInt32 j=0; j< cnt; j++) {
nsString * ignoreEntry = (nsString *) mIgnoreArray.ElementAt(j);
delete ignoreEntry;
}
mArray.Clear();
mIgnoreArray.Clear();
}
@ -87,6 +80,29 @@ NS_INTERFACE_MAP_END
//*****************************************************************************
// nsUrlbarHistory: nsISHistory
//*****************************************************************************
NS_IMETHODIMP
nsUrlbarHistory::ClearHistory()
{
// This procedure should clear all of the entries out of the structure, but
// not delete the structure itself.
//
// This loop takes each existing entry in the list and replaces it with
// a blank string, decrementing the size of the list by one each time.
// Eventually, we should end up with a zero sized list.
for (PRInt32 i=0; i<=mLength; i++)
{
nsString * entry = nsnull;
entry = (nsString *)mArray.ElementAt(i);
delete entry;
mLength--;
}
mLength = 0; // just to make sure
mArray.Clear();
return NS_OK;
}
/* Add an entry to the History list at mIndex and
* increment the index to point to the new entry