Added debugging for new command handler. Localized popup menus. b=48270 a=valeski

This commit is contained in:
locka%iol.ie 2000-08-18 14:44:00 +00:00
Родитель 2783deb7ad
Коммит 81b79072cb
2 изменённых файлов: 105 добавлений и 39 удалений

Просмотреть файл

@ -22,47 +22,74 @@
var appCore = null;
var locationFld = null;
var commandHandler = null;
function nsCommandHandler()
{
}
nsCommandHandler.prototype =
{
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsICommandHandler))
{
return this;
}
throw Components.results.NS_NOINTERFACE;
},
exec : function(command, params)
{
}
query : function(command, params, result)
{
result = "";
}
}
//
function nsXULBrowserWindow()
{
}
nsXULBrowserWindow.prototype =
{
QueryInterface : function(iid)
{
if(iid.equals(Components.interfaces.nsIXULBrowserWindow))
return this;
throw Components.results.NS_NOINTERFACE;
},
setJSStatus : function(status)
{
},
setJSDefaultStatus : function(status)
{
},
setDefaultStatus : function(status)
{
},
setOverLink : function(link)
{
},
QueryInterface : function(iid)
{
if(iid.equals(Components.interfaces.nsIXULBrowserWindow))
return this;
throw Components.results.NS_NOINTERFACE;
},
setJSStatus : function(status)
{
},
setJSDefaultStatus : function(status)
{
},
setDefaultStatus : function(status)
{
},
setOverLink : function(link)
{
},
onProgress : function (channel, current, max)
{
},
onStatusChange : function(channel, status)
{
},
onLocationChange : function(location)
{
if(!locationFld)
locationFld = document.getElementById("urlbar");
{
},
onStatusChange : function(channel, status)
{
},
onLocationChange : function(location)
{
if(!locationFld)
locationFld = document.getElementById("urlbar");
// We should probably not do this if the value has changed since the user
// searched
locationFld.setAttribute("value", location);
}
// We should probably not do this if the value has changed since the user
// searched
locationFld.setAttribute("value", location);
}
}
@ -73,6 +100,7 @@ function Startup()
// Create the browser instance component.
createBrowserInstance();
window._content.appCore= appCore;
if (appCore == null) {
// Give up.
@ -81,6 +109,16 @@ function Startup()
// Initialize browser instance..
appCore.setWebShellWindow(window);
// create the embedding command handler
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var commandHandlerInit = Components
.classes["component://netscape/embedding/browser/nsCommandHandler"]
.createInstance(Components.interfaces.nsICommandHandlerInit);
// Attach it to the window
commandHandlerInit.window = window;
commandHandler = commandHandlerInit.QueryInterface(Components.interfaces.nsICommandHandler);
gURLBar = document.getElementById("urlbar");
}
@ -94,14 +132,28 @@ function Shutdown()
function createBrowserInstance()
{
appCore = Components
.classes[ "component://netscape/appshell/component/browser/instance" ]
.createInstance( Components.interfaces.nsIBrowserInstance );
.classes[ "component://netscape/appshell/component/browser/instance" ]
.createInstance( Components.interfaces.nsIBrowserInstance );
if ( !appCore ) {
alert( "Error creating browser instance\n" );
}
}
function CHExecTest()
{
if (commandHandler != null)
{
commandHandler.exec("hello", "xxx");
}
}
function CHQueryTest()
{
if (commandHandler != null)
{
var result = commandHandler.query("hello", "xxx");
}
}
function InitContextMenu(xulMenu)
{

Просмотреть файл

@ -42,12 +42,26 @@ Contributor(s): ______________________________________. -->
<!-- Context menu -->
<popupset>
<popup id="context"
oncreate="InitContextMenu(this)">
<menuitem id="context-back" value="Back" accesskey="" oncommand="BrowserBack()"/>
<menuitem id="context-forward" value="Forward" accesskey="" oncommand="BrowserForward()"/>
<menuitem id="context-stop" value="Stop" accesskey="" oncommand="BrowserStop()"/>
<menuitem id="context-reload" value="Reload" accesskey="" oncommand="BrowserReload()"/>
<popup id="context" oncreate="InitContextMenu(this)">
<menuitem id="context-back" value="&backCmd.label;"
accesskey="" oncommand="BrowserBack()"/>
<menuitem id="context-forward" value="&forwardCmd.label;"
accesskey="" oncommand="BrowserForward()"/>
<menuitem id="context-stop" value="&stopCmd.label;"
accesskey="" oncommand="BrowserStop()"/>
<menuitem id="context-reload" value="&reloadCmd.label;"
accesskey="" oncommand="BrowserReload()"/>
<!-- The following DEBUG MENU ITEMS can be removed -->
<menuseparator/>
<menu value="Debug">
<menupopup>
<menuitem id="command-handler" value="CommandHandler::Exec" oncommand="CHExecTest()"/>
<menuitem id="command-handler" value="CommandHandler::Query" oncommand="CHQueryTest()"/>
</menupopup>
</menu>
<!-- End DEBUG MENU ITEMS -->
</popup>
</popupset>