Bug 519086 - Remove embedding/wrappers/ (DotNETEmbed), r=bsmedberg

This commit is contained in:
Phil Ringnalda 2009-10-02 20:15:20 -07:00
parent b84b733803
commit 7f6e5a23bf
24 changed files with 0 additions and 2866 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,89 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* ***** END LICENSE BLOCK ***** */
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View file

@ -1,116 +0,0 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{796A3EA3-D33E-46C8-AE6C-B6E40027BF36}"
>
<Build>
<Settings
ApplicationIcon = "App.ico"
AssemblyKeyContainerName = ""
AssemblyName = "MSDotNETCSEmbed"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "WinExe"
RootNamespace = "MSDotNETCSEmbed"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
Optimize = "false"
OutputPath = "..\..\..\dist\bin\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
/>
<Reference
Name = "System.Drawing"
AssemblyName = "System.Drawing"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Drawing.dll"
/>
<Reference
Name = "System.Windows.Forms"
AssemblyName = "System.Windows.Forms"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Windows.Forms.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
/>
<Reference
Name = "DotNETEmbed"
AssemblyName = "DotNETEmbed"
HintPath = "..\..\..\dist\bin\DotNETEmbed.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "App.ico"
BuildAction = "Content"
/>
<File
RelPath = "AssemblyInfo.cs"
BuildAction = "Compile"
/>
<File
RelPath = "MSDotNETCSEmbedForm.cs"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "MSDotNETCSEmbedForm.resx"
DependentUpon = "MSDotNETCSEmbedForm.cs"
BuildAction = "EmbeddedResource"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View file

@ -1,48 +0,0 @@
<VisualStudioProject>
<CSHARP>
<Build>
<Settings ReferencePath = "D:\seamonkey\mozilla\dist\bin\" >
<Config
Name = "Debug"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "false"
/>
<Config
Name = "Release"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "true"
/>
</Settings>
</Build>
<OtherProjectSettings
CopyProjectDestinationFolder = ""
CopyProjectUncPath = ""
CopyProjectOption = "0"
ProjectView = "ProjectFiles"
ProjectTrust = "0"
/>
</CSHARP>
</VisualStudioProject>

View file

@ -1,21 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSDotNETCSEmbed", "MSDotNETCSEmbed.csproj", "{796A3EA3-D33E-46C8-AE6C-B6E40027BF36}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{796A3EA3-D33E-46C8-AE6C-B6E40027BF36}.Debug.ActiveCfg = Debug|.NET
{796A3EA3-D33E-46C8-AE6C-B6E40027BF36}.Debug.Build.0 = Debug|.NET
{796A3EA3-D33E-46C8-AE6C-B6E40027BF36}.Release.ActiveCfg = Release|.NET
{796A3EA3-D33E-46C8-AE6C-B6E40027BF36}.Release.Build.0 = Release|.NET
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -1,180 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* ***** END LICENSE BLOCK ***** */
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
// Gecko namespace
using Mozilla.Embedding;
namespace MSDotNETCSEmbed
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MSDotNETCSEmbedForm : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private Mozilla.Embedding.Gecko gecko1;
private System.Windows.Forms.Button goButton;
private System.Windows.Forms.TextBox urlBar;
public MSDotNETCSEmbedForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.gecko1 = new Mozilla.Embedding.Gecko();
this.goButton = new System.Windows.Forms.Button();
this.urlBar = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// gecko1
//
this.gecko1.Location = new System.Drawing.Point(0, 40);
this.gecko1.Name = "gecko1";
this.gecko1.Size = new System.Drawing.Size(664, 392);
this.gecko1.TabIndex = 0;
//
// goButton
//
this.goButton.Location = new System.Drawing.Point(600, 8);
this.goButton.Name = "goButton";
this.goButton.Size = new System.Drawing.Size(56, 24);
this.goButton.TabIndex = 1;
this.goButton.Text = "Go";
this.goButton.Click += new System.EventHandler(this.goButton_Click);
//
// urlBar
//
this.urlBar.Location = new System.Drawing.Point(8, 10);
this.urlBar.Name = "urlBar";
this.urlBar.Size = new System.Drawing.Size(576, 20);
this.urlBar.TabIndex = 2;
this.urlBar.Text = "";
this.urlBar.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.urlBar_KeyPress);
//
// MSDotNETCSEmbedForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(664, 429);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.urlBar,
this.goButton,
this.gecko1});
this.Name = "MSDotNETCSEmbedForm";
this.Text = "MSDotNETCSEmbed [UNSUPPORTED]";
this.Resize += new System.EventHandler(this.MSDotNETCSEmbedForm_Resize);
this.Load += new System.EventHandler(this.MSDotNETCSEmbedForm_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MSDotNETCSEmbedForm());
// terminate gecko
Gecko.TermEmbedding();
}
private void MSDotNETCSEmbedForm_Load(object sender, System.EventArgs e)
{
urlBar.Text = "http://www.mozilla.org";
gecko1.OpenURL(urlBar.Text);
this.Text = "MSDotNETCSEmbed [UNSUPPORTED] - " + urlBar.Text;
}
private void MSDotNETCSEmbedForm_Resize(object sender, System.EventArgs e)
{
gecko1.Size =
new Size(ClientSize.Width,
ClientSize.Height - gecko1.Location.Y);
}
private void urlBar_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case '\r':
gecko1.OpenURL(urlBar.Text);
e.Handled = true;
break;
}
}
private void goButton_Click(object sender, System.EventArgs e)
{
gecko1.OpenURL(urlBar.Text);
}
}
}

View file

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="$this.Name">
<value>MSDotNETCSEmbedForm</value>
</data>
</root>

View file

@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#using <mscorlib.dll>
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("DotNETEmbed")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("mozilla.org")];
[assembly:AssemblyProductAttribute("Gecko")];
[assembly:AssemblyCopyrightAttribute("")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project directory.
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly:AssemblyDelaySignAttribute(false)];
[assembly:AssemblyKeyFileAttribute("DotNETEmbed.snk")];
[assembly:AssemblyKeyNameAttribute("")];

View file

@ -1,421 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <vcclr.h>
#include "nsCOMPtr.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserChrome.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIBaseWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWindowWatcher.h"
#include "nsIInputStream.h"
#include "nsEmbedAPI.h"
#include "DotNETEmbed.h"
#include "umWebChrome.h"
using namespace Mozilla::Embedding;
// Silly class for holding on to a static UTF8Encoding so that we
// don't need to create a new one in every call to CopyString()...
public __gc class UTF8EncodingHolder
{
public:
static Text::UTF8Encoding *sUTF8Encoding = new Text::UTF8Encoding();
};
String *
Mozilla::Embedding::CopyString(const nsAFlatCString& aStr)
{
return new String(aStr.get(), 0, aStr.Length(),
UTF8EncodingHolder::sUTF8Encoding);
}
// In stead of copying String's to nsAString's we could write a class
// that wraps a String object and exposes its underlying
// buffer. Doable, if we pin the String object, and so on, but this'll
// do for now.
nsAFlatString&
Mozilla::Embedding::CopyString(String *aSrc, nsAFlatString& aDest)
{
const wchar_t __pin * strbuf = PtrToStringChars(aSrc);
aDest.Assign(strbuf, aSrc->Length);
return aDest;
}
nsAFlatCString&
Mozilla::Embedding::CopyString(String *aSrc, nsAFlatCString& aDest)
{
const wchar_t __pin * strbuf = PtrToStringChars(aSrc);
CopyUTF16toUTF8(nsDependentString(strbuf, aSrc->Length), aDest);
return aDest;
}
void
Mozilla::Embedding::ThrowIfFailed(nsresult rv)
{
if (NS_FAILED(rv)) {
// XXX: Throw some useful exception here!
throw "rv is an error code!";
}
}
#pragma unmanaged
#define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
//*****************************************************************************
// WebBrowserChrome::nsISupports
//*****************************************************************************
NS_IMPL_ADDREF(WebBrowserChrome)
NS_IMPL_RELEASE(WebBrowserChrome)
NS_INTERFACE_MAP_BEGIN(WebBrowserChrome)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_END
WebBrowserChrome::WebBrowserChrome()
{
mNativeWindow = nsnull;
}
WebBrowserChrome::~WebBrowserChrome()
{
}
/* attribute nativeSiteWindow siteWindow */
NS_IMETHODIMP
WebBrowserChrome::GetSiteWindow(void * *aSiteWindow)
{
*aSiteWindow = mNativeWindow;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::GetTitle(PRUnichar * *aTitle)
{
NS_ENSURE_ARG_POINTER(aTitle);
*aTitle = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
WebBrowserChrome::SetTitle(const PRUnichar * aTitle)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute boolean visibility; */
NS_IMETHODIMP
WebBrowserChrome::GetVisibility(PRBool * aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
*aVisibility = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::SetVisibility(PRBool aVisibility)
{
return NS_OK;
}
/* void setFocus (); */
NS_IMETHODIMP
WebBrowserChrome::SetFocus()
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy)
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y,
PRInt32 *cx, PRInt32 *cy)
{
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
{
*x = 0;
*y = 0;
}
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
{
*cx = 0;
*cy = 0;
}
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::ExitModalEventLoop(nsresult aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::ShowAsModal(void)
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::IsWindowModal(PRBool *_retval)
{
*_retval = PR_FALSE;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = mWebBrowser;
NS_IF_ADDREF(*aWebBrowser);
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
{
mWebBrowser = aWebBrowser;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::GetChromeFlags(PRUint32* aChromeMask)
{
*aChromeMask = mChromeFlags;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask)
{
mChromeFlags = aChromeMask;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::DestroyBrowserWindow(void)
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight)
{
::MoveWindow((HWND)mNativeWindow, 0, 0, aWidth, aHeight, TRUE);
return NS_OK;
}
nsresult
WebBrowserChrome::CreateBrowser(HWND hWnd, PRInt32 aX, PRInt32 aY, PRInt32 aCX,
PRInt32 aCY, nsIWebBrowser **aBrowser)
{
NS_ENSURE_ARG_POINTER(aBrowser);
*aBrowser = nsnull;
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
if (!mWebBrowser)
return NS_ERROR_FAILURE;
mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(this));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser);
dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
nsCOMPtr<nsIBaseWindow> browserBaseWindow = do_QueryInterface(mWebBrowser);
mNativeWindow = hWnd;
if (!mNativeWindow)
return NS_ERROR_FAILURE;
browserBaseWindow->InitWindow(mNativeWindow, nsnull, aX, aY, aCX, aCY);
browserBaseWindow->Create();
if (mWebBrowser)
{
*aBrowser = mWebBrowser;
NS_ADDREF(*aBrowser);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
#pragma managed
Gecko::Gecko()
: mChrome(nsnull)
{
}
void
Gecko::TermEmbedding()
{
if (!sIsInitialized) {
return;
}
sIsInitialized = false;
nsresult rv = NS_TermEmbedding();
ThrowIfFailed(rv);
}
void
Gecko::OpenURL(String *aUrl)
{
if (!sIsInitialized) {
nsresult rv = NS_InitEmbedding(nsnull, nsnull);
ThrowIfFailed(rv);
sIsInitialized = true;
}
const wchar_t __pin * url = PtrToStringChars(aUrl);
nsresult rv;
HWND hWnd = (HWND)Handle.ToPointer();
if (!mChrome) {
CreateBrowserWindow(nsIWebBrowserChrome::CHROME_ALL, nsnull);
}
// Start loading a page
nsCOMPtr<nsIWebBrowser> newBrowser;
mChrome->GetWebBrowser(getter_AddRefs(newBrowser));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(newBrowser));
rv = webNav->LoadURI(url, nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull,
nsnull);
ThrowIfFailed(rv);
}
void
Gecko::OnResize(EventArgs *e)
{
if (mChrome) {
nsCOMPtr<nsIEmbeddingSiteWindow> embeddingSite =
do_QueryInterface(mChrome);
RECT rect;
GetClientRect((HWND)Handle.ToPointer(), &rect);
// Make sure the browser is visible and sized
nsCOMPtr<nsIWebBrowser> webBrowser;
mChrome->GetWebBrowser(getter_AddRefs(webBrowser));
nsCOMPtr<nsIBaseWindow> webBrowserAsWin = do_QueryInterface(webBrowser);
if (webBrowserAsWin) {
webBrowserAsWin->SetPositionAndSize(rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
PR_TRUE);
webBrowserAsWin->SetVisibility(PR_TRUE);
}
}
UserControl::OnResize(e);
}
void
Gecko::CreateBrowserWindow(PRUint32 aChromeFlags, nsIWebBrowserChrome *aParent)
{
WebBrowserChrome * chrome = new WebBrowserChrome();
if (!chrome) {
throw new OutOfMemoryException();
}
mChrome = chrome;
NS_ADDREF(mChrome);
// XXX: Is this really needed?
// now an extra addref; the window owns itself (to be released by
// WebBrowserChromeUI::Destroy)
NS_ADDREF(mChrome);
chrome->SetChromeFlags(aChromeFlags);
HWND hWnd = (HWND)Handle.ToPointer();
// Insert the browser
nsCOMPtr<nsIWebBrowser> newBrowser;
chrome->CreateBrowser(hWnd, -1, -1, -1, -1, getter_AddRefs(newBrowser));
if (!newBrowser) {
ThrowIfFailed(NS_ERROR_FAILURE);
}
// Place it where we want it.
OnResize(0);
// if opened as chrome, it'll be made visible after the chrome has loaded.
// otherwise, go ahead and show it now.
if (!(aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME))
::ShowWindow(hWnd, SW_RESTORE);
}

View file

@ -1,102 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsString.h"
#using <mscorlib.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>
using namespace System;
using namespace System::Windows::Forms;
class nsIWebBrowserChrome;
namespace Mozilla
{
namespace Embedding
{
// .NET UI control class that can be placed in a Windows Form
// using DevStudio.NET's GUI.
public __gc class Gecko : public System::Windows::Forms::UserControl
{
public:
Gecko();
static void TermEmbedding();
void OpenURL(String *url);
protected:
// Overriden System::Windows::Forms::Control methods
void OnResize(EventArgs *e);
private:
void CreateBrowserWindow(PRUint32 aChromeFlags,
nsIWebBrowserChrome *aParent);
nsIWebBrowserChrome *mChrome;
static bool sIsInitialized = false;
}; // class Gecko
// Throw an exception if NS_FAILED(rv)
void ThrowIfFailed(nsresult rv);
// Helper for copying an UCS2 Mozilla nsAFlatString to a managed
// String.
inline String * CopyString(const nsAFlatString& aStr)
{
return new String(aStr.get(), 0, aStr.Length());
}
// Helper for copying an UTF8 Mozilla nsAFlatCString to a managed
// String.
String * CopyString(const nsAFlatCString& aStr);
// Helper for copying a managed String into a Mozilla UCS2
// nsAFlatString.
nsAFlatString& CopyString(String *aSrc, nsAFlatString& aDest);
// Helper for copying a managed String into a Mozilla UTF8
// nsAFlatCString.
nsAFlatCString& CopyString(String *aSrc, nsAFlatCString& aDest);
} // namespace Embedding
}

View file

@ -1,355 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
* Johnny Stenback <jst@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#using <mscorlib.dll>
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "DotNETNetworking.h"
using namespace Mozilla::Embedding::Networking;
URI::URI(nsIURI *aURI)
: mURI(aURI)
{
NS_IF_ADDREF(mURI);
}
URI::URI(String *aSpec)
: mURI(nsnull)
{
nsCAutoString spec;
CopyString(aSpec, spec);
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), spec.get());
ThrowIfFailed(rv);
mURI = uri.get();
NS_IF_ADDREF(mURI);
}
URI::~URI()
{
NS_IF_RELEASE(mURI);
}
Object *
URI::Clone()
{
nsCOMPtr<nsIURI> uriClone;
if (mURI) {
nsresult rv = mURI->Clone(getter_AddRefs(uriClone));
ThrowIfFailed(rv);
}
return new URI(uriClone);
}
void
URI::Dispose()
{
NS_IF_RELEASE(mURI);
GC::SuppressFinalize(this);
}
String *
URI::get_Spec()
{
nsCAutoString spec;
nsresult rv = mURI->GetSpec(spec);
ThrowIfFailed(rv);
return CopyString(spec);
}
void
URI::set_Spec(String *aSpec)
{
nsCAutoString spec;
CopyString(aSpec, spec);
nsresult rv = mURI->SetSpec(spec);
ThrowIfFailed(rv);
}
String *
URI::get_PrePath()
{
nsCAutoString prePath;
nsresult rv = mURI->GetPrePath(prePath);
ThrowIfFailed(rv);
return CopyString(prePath);
}
String *
URI::get_Scheme()
{
nsCAutoString scheme;
nsresult rv = mURI->GetScheme(scheme);
ThrowIfFailed(rv);
return CopyString(scheme);
}
void
URI::set_Scheme(String *aScheme)
{
nsCAutoString scheme;
CopyString(aScheme, scheme);
nsresult rv = mURI->SetScheme(scheme);
ThrowIfFailed(rv);
}
String *
URI::get_UserPass()
{
nsCAutoString userPass;
nsresult rv = mURI->GetUserPass(userPass);
ThrowIfFailed(rv);
return CopyString(userPass);
}
void
URI::set_UserPass(String *aUserPass)
{
nsCAutoString userPass;
CopyString(aUserPass, userPass);
nsresult rv = mURI->SetUserPass(userPass);
ThrowIfFailed(rv);
}
String *
URI::get_Username()
{
nsCAutoString username;
nsresult rv = mURI->GetUsername(username);
ThrowIfFailed(rv);
return CopyString(username);
}
void
URI::set_Username(String *aUsername)
{
nsCAutoString username;
CopyString(aUsername, username);
nsresult rv = mURI->SetUsername(username);
ThrowIfFailed(rv);
}
String *
URI::get_Password()
{
nsCAutoString password;
nsresult rv = mURI->GetPassword(password);
ThrowIfFailed(rv);
return CopyString(password);
}
void
URI::set_Password(String *aPassword)
{
nsCAutoString password;
CopyString(aPassword, password);
nsresult rv = mURI->SetPassword(password);
ThrowIfFailed(rv);
}
String *
URI::get_HostPort()
{
nsCAutoString hostPort;
nsresult rv = mURI->GetHostPort(hostPort);
ThrowIfFailed(rv);
return CopyString(hostPort);
}
void
URI::set_HostPort(String *aHostPort)
{
nsCAutoString hostPort;
CopyString(aHostPort, hostPort);
nsresult rv = mURI->SetHostPort(hostPort);
ThrowIfFailed(rv);
}
String *
URI::get_Host()
{
nsCAutoString host;
nsresult rv = mURI->GetHost(host);
ThrowIfFailed(rv);
return CopyString(host);
}
void
URI::set_Host(String *aHost)
{
nsCAutoString host;
CopyString(aHost, host);
nsresult rv = mURI->SetHost(host);
ThrowIfFailed(rv);
}
Int32
URI::get_Port()
{
PRInt32 port;
nsresult rv = mURI->GetPort(&port);
ThrowIfFailed(rv);
return port;
}
void
URI::set_Port(Int32 aPort)
{
nsresult rv = mURI->SetPort(aPort);
ThrowIfFailed(rv);
}
String *
URI::get_Path()
{
nsCAutoString path;
nsresult rv = mURI->GetPath(path);
ThrowIfFailed(rv);
return CopyString(path);
}
void
URI::set_Path(String *aPath)
{
nsCAutoString path;
CopyString(aPath, path);
nsresult rv = mURI->SetPath(path);
ThrowIfFailed(rv);
}
bool
URI::Equals(URI *aOther)
{
if (!mURI) {
if (!aOther || !aOther->mURI) {
return true;
}
return false;
}
PRBool equals;
nsresult rv = mURI->Equals(aOther->mURI, &equals);
ThrowIfFailed(rv);
return equals;
}
bool
URI::SchemeIs(String *aScheme)
{
nsCAutoString scheme;
CopyString(aScheme, scheme);
PRBool isScheme = PR_FALSE;
nsresult rv = mURI->SchemeIs(scheme.get(), &isScheme);
ThrowIfFailed(rv);
return isScheme;
}
String *
URI::Resolve(String *aRelativePath)
{
nsCAutoString relativePath, resolvedPath;
CopyString(aRelativePath, relativePath);
nsresult rv = mURI->Resolve(relativePath, resolvedPath);
ThrowIfFailed(rv);
return CopyString(resolvedPath);
}
String *
URI::get_AsciiSpec()
{
nsCAutoString asciiSpec;
nsresult rv = mURI->GetAsciiSpec(asciiSpec);
ThrowIfFailed(rv);
return CopyString(asciiSpec);
}
String *
URI::get_AsciiHost()
{
nsCAutoString asciiHost;
nsresult rv = mURI->GetAsciiHost(asciiHost);
ThrowIfFailed(rv);
return CopyString(asciiHost);
}
String *
URI::get_OriginCharset()
{
nsCAutoString originalCharset;
nsresult rv = mURI->GetOriginCharset(originalCharset);
ThrowIfFailed(rv);
return CopyString(originalCharset);
}

View file

@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#pragma once
#include "DotNETEmbed.h"
// Forward declarations, Mozilla classes/interfaces.
class nsIURI;
namespace Mozilla
{
namespace Embedding
{
namespace Networking
{
public __gc class URI : public ICloneable,
public IDisposable
{
public:
URI(String *aSpec);
URI(nsIURI *aURI);
~URI();
// ICloneable
Object *Clone();
// IDisposable
void Dispose();
__property String* get_Spec();
__property void set_Spec(String *aSpec);
__property String* get_PrePath();
__property String* get_Scheme();
__property void set_Scheme(String *aScheme);
__property String* get_UserPass();
__property void set_UserPass(String *aUserPass);
__property String* get_Username();
__property void set_Username(String *aUsername);
__property String* get_Password();
__property void set_Password(String *aPassword);
__property String* get_HostPort();
__property void set_HostPort(String *aHostPort);
__property String* get_Host();
__property void set_Host(String *aHost);
__property Int32 get_Port();
__property void set_Port(Int32 aPort);
__property String* get_Path();
__property void set_Path(String *aPath);
bool Equals(URI *aOther);
bool SchemeIs(String *aScheme);
// No need for URI *Clone() since we implement ICloneable
String* Resolve(String *aRelativePath);
__property String* get_AsciiSpec();
__property String* get_AsciiHost();
__property String* get_OriginCharset();
private:
nsIURI *mURI; // [OWNER]
}; // class URI
}; // namespace Networking
} // namespace Embedding
}

View file

@ -1,205 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#using <mscorlib.dll>
#include "cstringt.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIProfile.h"
#include "DotNetProfileManager.h"
using namespace Mozilla::Embedding;
// static
void
ProfileManager::EnsureProfileService()
{
if (sProfileService) {
return;
}
nsresult rv;
nsCOMPtr<nsIProfile> profileService =
do_GetService(NS_PROFILE_CONTRACTID, &rv);
ThrowIfFailed(rv);
sProfileService = profileService.get();
NS_ADDREF(sProfileService);
}
// static
Int32
ProfileManager::get_ProfileCount()
{
EnsureProfileService();
PRInt32 count;
nsresult rv = sProfileService->GetProfileCount(&count);
ThrowIfFailed(rv);
return count;
}
// static
String *
ProfileManager::GetProfileList()[]
{
EnsureProfileService();
PRUint32 profileCount;
PRUnichar **profiles;
nsresult rv = sProfileService->GetProfileList(&profileCount, &profiles);
ThrowIfFailed(rv);
String *list[] = new String *[profileCount];
for (PRUint32 i = 0; i < profileCount; ++i) {
list[i] = CopyString(nsDependentString(profiles[i]));
}
return list;
}
// static
bool
ProfileManager::ProfileExists(String *aProfileName)
{
EnsureProfileService();
PRBool exists;
const wchar_t __pin * profileName = PtrToStringChars(aProfileName);
nsresult rv = sProfileService->ProfileExists(profileName, &exists);
ThrowIfFailed(rv);
return exists;
}
// static
String*
ProfileManager::get_CurrentProfile()
{
EnsureProfileService();
nsXPIDLString currentProfile;
nsresult rv =
sProfileService->GetCurrentProfile(getter_Copies(currentProfile));
ThrowIfFailed(rv);
return CopyString(currentProfile);
}
// static
void
ProfileManager::set_CurrentProfile(String* aCurrentProfile)
{
EnsureProfileService();
const wchar_t __pin * currentProfile = PtrToStringChars(aCurrentProfile);
nsresult rv = sProfileService->SetCurrentProfile(currentProfile);
ThrowIfFailed(rv);
}
// static
void
ProfileManager::ShutDownCurrentProfile(UInt32 shutDownType)
{
EnsureProfileService();
nsresult rv = sProfileService->ShutDownCurrentProfile(shutDownType);
ThrowIfFailed(rv);
}
// static
void
ProfileManager::CreateNewProfile(String* aProfileName,
String *aNativeProfileDir, String* aLangcode,
bool useExistingDir)
{
EnsureProfileService();
const wchar_t __pin * profileName = PtrToStringChars(aProfileName);
const wchar_t __pin * nativeProfileDir = PtrToStringChars(aNativeProfileDir);
const wchar_t __pin * langCode = PtrToStringChars(aLangcode);
nsresult rv = sProfileService->CreateNewProfile(profileName,
nativeProfileDir, langCode,
useExistingDir);
ThrowIfFailed(rv);
}
// static
void
ProfileManager::RenameProfile(String* aOldName, String* aNewName)
{
EnsureProfileService();
const wchar_t __pin * oldName = PtrToStringChars(aOldName);
const wchar_t __pin * newName = PtrToStringChars(aNewName);
nsresult rv = sProfileService->RenameProfile(oldName, newName);
ThrowIfFailed(rv);
}
// static
void
ProfileManager::DeleteProfile(String* aName, bool aCanDeleteFiles)
{
EnsureProfileService();
const wchar_t __pin * name = PtrToStringChars(aName);
nsresult rv = sProfileService->DeleteProfile(name, aCanDeleteFiles);
ThrowIfFailed(rv);
}
// static
void
ProfileManager::CloneProfile(String* aProfileName)
{
EnsureProfileService();
const wchar_t __pin * profileName = PtrToStringChars(aProfileName);
nsresult rv = sProfileService->CloneProfile(profileName);
ThrowIfFailed(rv);
}

View file

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#pragma once
#include "DotNETEmbed.h"
using namespace System;
namespace Mozilla
{
namespace Embedding
{
// Static
public __gc class ProfileManager
{
public:
// XXX: These should be in an enum!
static UInt32 SHUTDOWN_PERSIST = 1;
static UInt32 SHUTDOWN_CLEANSE = 2;
__property static Int32 get_ProfileCount();
static String *GetProfileList()[];
static bool ProfileExists(String *aProfileName);
__property static String* get_CurrentProfile();
__property static void set_CurrentProfile(String* aCurrentProfile);
static void ShutDownCurrentProfile(UInt32 shutDownType);
static void CreateNewProfile(String* aProfileName,
String *aNativeProfileDir,
String* aLangcode, bool useExistingDir);
static void RenameProfile(String* aOldName, String* aNewName);
static void DeleteProfile(String* aName, bool aCanDeleteFiles);
static void CloneProfile(String* aProfileName);
private:
static nsIProfile *sProfileService = 0; // [OWNER]
static void EnsureProfileService();
}; // class ProfileManager
} // namespace Embedding
}

View file

@ -1,150 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#pragma once
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserChrome.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIBaseWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWindowWatcher.h"
#include "nsIInputStream.h"
#include "nsIURI.h"
#include "nsEmbedAPI.h"
#include "DotNetNetworking.h"
#include "DotNetXPCOM_IO.h"
using namespace System;
using namespace Mozilla::Embedding::Networking;
using namespace Mozilla::Embedding::XPCOM_IO;
namespace Mozilla
{
namespace Embedding
{
namespace WebBrowser
{
public __gc class EmbeddingSiteWindow
{
private:
Boolean mVisibility;
String* mTitle;
public:
static const UInt32 DIM_FLAGS_POSITION = 1;
static const UInt32 DIM_FLAGS_SIZE_INNER = 2;
static const UInt32 DIM_FLAGS_SIZE_OUTER = 4;
__property Boolean get_Visibility() { return visibility; };
__property void set_Visibility(Boolean v) { visibility = v; };
__property String* get_Title() { return title; };
__property void set_Title(String * t) { title = t; };
void setDimensions(UInt32 aFlags, Int32 x, Int32 y, Int32 cx, Int32 cy) {};
void getDimensions(UInt32 aFlags, Int32 *x, Int32 *y, Int32 *cx, Int32 *cy) {};
void setFocus() {};
}; // class EmbeddingSiteWindow
public __gc class WebBrowserChrome
{
public:
bool setStatus() { return true; };
bool destroyBrowserWindow() { return true; };
bool sizeBrowserTo() { return true; };
bool showAsModal() { return true; };
bool isWindowModal() { return true; };
bool exitModalEventLoop() { return true; };
}; // class WebBrowserChrome
public __gc class WebNavigation
{
public:
static const UInt32 LOAD_FLAGS_MASK = 65535;
static const UInt32 LOAD_FLAGS_NONE = 0;
static const UInt32 LOAD_FLAGS_IS_REFRESH = 16;
static const UInt32 LOAD_FLAGS_IS_LINK = 32;
static const UInt32 LOAD_FLAGS_BYPASS_HISTORY = 64;
static const UInt32 LOAD_FLAGS_REPLACE_HISTORY = 128;
static const UInt32 LOAD_FLAGS_BYPASS_CACHE = 256;
static const UInt32 LOAD_FLAGS_BYPASS_PROXY = 512;
static const UInt32 LOAD_FLAGS_CHARSET_CHANGE = 1024;
static const UInt32 STOP_NETWORK = 1;
static const UInt32 STOP_CONTENT = 2;
static const UInt32 STOP_ALL = 3;
void goBack() {};
void goForward() {};
void gotoIndex(Int32 arg0) {};
void loadURI(String *arg0, UInt32 arg1, URI *arg2, InputStream *arg3, InputStream *arg4) {};
void reload(UInt32 arg0) {};
void stop(UInt32 arg0) {};
}; // class WebNavigation
public __gc class WebBrowser
{
public:
bool addWebBrowserListener() { return true; };
bool removeWebBrowserListener() { return true; };
bool SetContainerWindow(WebBrowserChrome *aChrome) { return true; };
}; // class WebBrowser
public __gc class WindowWatcher
{
public:
bool openWindow() { return true; };
bool registerNotification() { return true; };
bool unregisterNotification() { return true; };
bool getWindowEnumerator() { return true; };
bool getNewPrompter() { return true; };
bool getNewAuthPrompter() { return true; };
bool setWindowCreator() { return true; };
}; //class WindowWatcher
public __gc class WindowCreator
{
public:
bool createChromeWindow() { return true; };
}; //class WindowCreator
} // namespace WebBrowser
} // namespace Embedding
}

View file

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#pragma once
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserChrome.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIBaseWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWindowWatcher.h"
#include "nsIInputStream.h"
#include "nsIURI.h"
#include "nsEmbedAPI.h"
using namespace System;
namespace Mozilla
{
namespace Embedding
{
namespace XPCOM_IO
{
public __gc class InputStream
{
bool Close(void) { return true; };
bool Available(int *_retval) { return true; };
bool Read(String * aBuf, int aCount, int *_retval) { return true; };
bool IsNonBlocking(bool *_retval) { return true; };
}; // class InputStream
}; // namespace XPCOM_IO
} // namespace Embedding
}

View file

@ -1,112 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla 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/MPL/
#
# 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 the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Christopher Blizzard.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
ifndef MOZ_OBJ_DIR
MOZ_OBJ_DIR = ${MOZ_SRC}/mozilla
endif
# Compiler variables (implicit rules are used to compile .cpp files)
CC = cl
CFLAGS = -nologo -Zi
CXX = cl
CXXFLAGS = -nologo -CLR -TP -Zi -wd4005 -we4700 -we4701 -c -DDEBUG -DXP_WIN -DXP_WIN32 ${INCLUDES}
OUTPUT_OPTION = -Fo$@
# Linker variables (implicit rules can't use link.exe, so we do that manually)
LDFLAGS = -nologo -dll -debug -libpath:${MOZ_OBJ_DIR}/dist/lib/ -NODEFAULTLIB:MSVCRTD
INCLUDES = \
-I${MOZ_OBJ_DIR}/dist/include \
-I${MOZ_OBJ_DIR}/dist/include/profile \
-I${MOZ_OBJ_DIR}/dist/include/webbrwsr \
-I${MOZ_OBJ_DIR}/dist/include/widget \
-I${MOZ_OBJ_DIR}/dist/include/xpcom \
-I${MOZ_OBJ_DIR}/dist/include/nspr \
-I${MOZ_OBJ_DIR}/dist/include/necko \
-I${MOZ_OBJ_DIR}/dist/include/docshell \
-I${MOZ_OBJ_DIR}/dist/include/dom \
-I${MOZ_OBJ_DIR}/dist/include/string \
-I${MOZ_OBJ_DIR}/dist/include/embed_base \
-I${MOZ_OBJ_DIR}/dist/include/windowwatcher \
-I${MOZ_OBJ_DIR}/dist/include/xpconnect
DEPS = DotNETEmbed.h Makefile
CPP_FILES = \
DotNETEmbed.cpp \
DotNETProfileManager.cpp \
DotNETNetworking.cpp \
AssemblyInfo.cpp
OBJ_FILES = $(CPP_FILES:%.cpp=%.obj)
LIBS = user32.lib xpcom.lib embed_base_s.lib
# Default target.
DotNETEmbed.dll: ${OBJ_FILES} DotNETEmbed.snk ${DEPS}
link ${LDFLAGS} ${LIBS} ${OBJ_FILES} -out:DotNETEmbed.dll
@echo
cp DotNETEmbed.dll ${MOZ_OBJ_DIR}/dist/bin
cp DotNETEmbed.pdb ${MOZ_OBJ_DIR}/dist/bin
regasm DotNETEmbed.dll
@echo
gacutil.exe -i DotNETEmbed.dll
@echo
DotNETEmbed.obj: DotNETEmbed.cpp umWebChrome.h ${DEPS}
${CXX} ${CXXFLAGS} ${OUTPUT_OPTION} DotNETEmbed.cpp
DotNETProfileManager.obj: DotNETProfileManager.cpp ${DEPS}
${CXX} ${CXXFLAGS} ${OUTPUT_OPTION} DotNETProfileManager.cpp
DotNETNetworking.obj: DotNETNetworking.cpp DotNETNetworking.h ${DEPS}
${CXX} ${CXXFLAGS} ${OUTPUT_OPTION} DotNETNetworking.cpp
AssemblyInfo.obj: AssemblyInfo.cpp ${DEPS}
${CXX} ${CXXFLAGS} ${OUTPUT_OPTION} AssemblyInfo.cpp
extdlls:
cp ${MOZ_OBJ_DIR}/dist/bin/nspr4.dll .
cp ${MOZ_OBJ_DIR}/dist/bin/plc4.dll .
cp ${MOZ_OBJ_DIR}/dist/bin/plds4.dll .
cp ${MOZ_OBJ_DIR}/dist/bin/xpcom.dll .
clean:
rm -f *.obj DotNETEmbed.dll
rm -f *.pdb *.ilk
realclean: clean
rm -f *~

View file

@ -1,270 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<title>Convert Gecko from unmanged to managed code in .Net</title>
</head>
<body>
<h1 style="margin-left: 40px; text-align: center;">Wrapping Gecko APIs
using Microsoft Visual Studio .NET Managed Extensions for C++<big><big><big><br
style="color: rgb(255, 0, 0);">
</big></big></big> </h1>
<div style="text-align: center;"> <big><big><big><span
style="color: rgb(255, 0, 0);">**DRAFT**</span></big></big></big><br>
</div>
<br>
<h2>Intended Audience:</h2>
This paper is intended for a C++ programmer who would like to know how
to wrap Gecko engine from unmanaged C++ to managed C++ .&nbsp; Author
assumes the reader is familiar with Gecko and MS Visual Studio.NET with
Managed Extensions for C++.&nbsp; <br>
<br>
<h2>Background:</h2>
<ol>
<li> Why do we go all this trouble?&nbsp; </li>
<li>When we have Gecko as ActiveX control, then why don't we use the
Runtime-Callable Wrapper (RCW) and COM-Callable Wrapper (CCW)?&nbsp; </li>
</ol>
<br>
<h2 class="dtH1">How do we do this?</h2>
There are few ways to convert the existing unmanaged code to managed
code:
<ol type="1">
<li>You can use the built-in .NET runtime interop facilities (such as
PInvoke or COM Interop)<br>
</li>
<li>You can wrap the unmanaged code using the managed extensions to
C++.</li>
<li>You can rewrite the entire code in a .NET language.</li>
</ol>
<h2 class="dtH1">What do we need?</h2>
We need <br>
<ol>
<li>.NET Framework (1.1) <br>
</li>
<li>Microsoft Visual Studio .NET (preferably 2003)</li>
<li>mozilla development environment
(http://www.mozilla.org/build/win32.html)<br>
</li>
</ol>
<h2>Terminology:</h2>
Following terms are used throughout out this document and it is
important to understand what each term means.&nbsp; <br>
<ul>
<li><span style="font-weight: bold;">Assembly</span><br>
</li>
</ul>
<div style="margin-left: 80px;">Assembly is a building block of the
.Net Framework.&nbsp; It is the fundamental unit of deployment, version
control, reuse, activation, scoping, and security permissions.&nbsp; It
provides the Common Language Runtime (CLR) with the information it needs
to be aware of type implementations.&nbsp; It is a collection of types
and resources that are built to work together and form a logical unit of
functionality.&nbsp; <br>
</div>
<ul style="font-weight: bold;">
<li>Global Assembly Cache</li>
</ul>
<div style="margin-left: 80px;">Global Assembly Cache is a machine wide
code cache that is installed whereever the CLR is installed.&nbsp; In
most cases, if you intend to share an assembly with multiple
applications, you should deploy it into the global assembly cache.<br>
</div>
<ul>
<li><span style="font-weight: bold;">Managed code vs Unmanaged code</span><br>
</li>
</ul>
<div style="margin-left: 80px;"><span style="font-style: italic;">Manged
code</span> requires the execution environment of the CLR.&nbsp;
Compilers emit managed code as MSIL, the intermidate language.&nbsp; The
reason for the name is that code is managed by the CLR and objects are
allocated from heaps managed by the CLR.<br>
</div>
<div style="margin-left: 80px;"><span style="font-style: italic;">Unmanaged
code</span> does not use nor require the execution environment of the
Common Language Runtime (CLR).&nbsp; Unmanaged code is outside the
reach of the CLR's security system, garbage collector and other
services.</div>
<ul>
<li style="font-weight: bold;">CLR</li>
<li style="font-weight: bold;">Runtime-Callable Wrapper (RCW)</li>
<li style="font-weight: bold;">COM-Callable Wrapper (CCW)</li>
<li style="font-weight: bold;">Boxing</li>
</ul>
<div style="margin-left: 80px;">Boxing is a technique to convert a
value type to a __gc object by using the __box<br>
<div style="margin-left: 40px;">Int32 i = 42;<br>
__box Int32* b = __box(i);<br>
</div>
</div>
<ul>
<li style="font-weight: bold;">UnBoxing</li>
</ul>
<div style="margin-left: 80px;">UnBoxing (dereferencing) is a technique
to convert a boxed object to value type by casting.<br>
<div style="margin-left: 40px;">Color red;<br>
Object* obj = Enum::Parse(__typeof(Color), S"red");<br>
red = *static_cast&lt;__box Color*&gt;(obj);<br>
</div>
</div>
<br>
<ul>
<li style="font-weight: bold;">Managed Objects</li>
</ul>
<div style="margin-left: 80px;">Managed Object is an instance of a
class which is created in the heap and managed by the garbage collector
by using the <span style="font-style: italic;">__gc</span>
modifier.&nbsp; <br>
<div style="margin-left: 40px;"><span style="font-style: italic;">__gc</span>
class Point<br>
{<br>
</div>
<div style="margin-left: 80px;">public:<br>
</div>
<div style="margin-left: 120px;"> int x;<br>
int y;<br>
</div>
<div style="margin-left: 40px;"> };<br>
</div>
</div>
<ul style="font-weight: bold;">
<li>Value Types</li>
</ul>
<div style="margin-left: 80px;">Value Types ar typically small, short
lived objects and they are usually created on the stack. In managed C++,
the value types are defined by using <span style="font-style: italic;">__value</span>
modifier.&nbsp; <br>
<div style="margin-left: 40px;"><span style="font-style: italic;">__value</span>
class Point<br>
{<br>
</div>
<div style="margin-left: 80px;">public:<br>
</div>
<div style="margin-left: 120px;"> int x;<br>
int y;<br>
</div>
<div style="margin-left: 40px;"> };<br>
</div>
</div>
<br>
<h2>Necessary Steps:</h2>
<ul>
</ul>
<br>
<h2>Gecko APIs</h2>
We will be exposing list of Gecko APIs<br>
<ul>
<li>nsresult NS_InitEmbedding(nsILocalFile *aMozBinDirectory,
nsIDirectoryServiceProvider *aAppFileLocProvider);<br>
</li>
<li>nsresult NS_TermEmbedding();</li>
<li>...<br>
</li>
</ul>
<br>
<h2>Coding Techniques:</h2>
<ul>
<li>
<h3>Using managed object in unmanaged code</h3>
</li>
</ul>
<div style="margin-left: 40px;">Managed pointers are managed by the
garbage collector so that when copies are made, the gc knows that
references are created.&nbsp; When a pointer is passed to native code,
the gc cannot track its usage and so cannot determine any change in
object reference.&nbsp;&nbsp; Furthermore, if a garbage collection
occures, the object can be moved in memory, so the gc changes all
managed pointers so that they point to the new location.&nbsp; Because
the gc doesn't have access to the pointers passed to native code
(unmanaged code), potentially a pointer used in native code could
suddenly become invalid.&nbsp; Use a pinned pointer which tells gc not
to move the memory.<br>
<div style="margin-left: 80px;">
<table cellpadding="2" cellspacing="2" border="1"
style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style="vertical-align: top;">//Using pinning<br>
#progma unmanaged<br>
void print(int *p)<br>
{<br>
&nbsp;&nbsp;&nbsp; printf("%ld\n", *p);<br>
}<br>
<br>
#progma managed<br>
_gc struct Test {<br>
&nbsp;&nbsp;&nbsp; int i;<br>
};<br>
<br>
void main()<br>
{<br>
&nbsp;&nbsp;&nbsp; Test * t = new Test;<br>
&nbsp;&nbsp;&nbsp; int __pin* p = &amp;t-&gt;i;<br>
&nbsp;&nbsp;&nbsp; print(p);<br>
}<br>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div style="margin-left: 40px;"><br>
</div>
<ul>
<li>
<h3>Using unmanaged object in managed code</h3>
</li>
</ul>
<div style="margin-left: 120px;">
<table cellpadding="2" cellspacing="2" border="1"
style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style="vertical-align: top;"><span class="clsCap">//Using
GCHandle</span> <br>
<pre>#using &lt;mscorlib.dll&gt;<br><br>using namespace System;<br>using namespace System::Runtime::InteropServices;<br><br>#pragma managed<br>class AppDomainWrapper<br>{<br>private:<br> int m_handle;<br>public:<br> AppDomainWrapper() {<br> AppDomain* d = AppDomain::Current;<br> m_handle = (GCHandle::op_Explicit(GCHandle::Alloc(d))).ToInt32();<br> }<br> ~AppDomainWrapper() {<br> (GCHandle::op_Explicit(m_handle)).Free();<br> }<br> // more functions here...<br> void PrintBaseDir() {<br> AppDomain* domain = __try_cast&lt;AppDomain*&gt;(<br> (GCHandle::op_Explicit(m_handle)).Target);<br> Console::WriteLine ( S"AppDomain Base Directory: {0}",<br> domain-&gt;BaseDirectory );<br> }<br>};<br><br>#pragma unmanaged<br>int main() {<br> AppDomainWrapper w; <br> w.PrintBaseDir();<br> return 0; <br>}</pre>
</td>
<td style="vertical-align: top;"><span class="clsCap">//Using
gcroot</span> <br>
<pre>#using &lt;mscorlib.dll&gt;<br>#include &lt;gcroot.h&gt;<br><br>using namespace System;<br>using namespace System::Runtime::InteropServices;<br><br>#pragma managed<br>class AppDomainWrapper<br>{<br>private:<br> gcroot&lt;AppDomain*&gt; m_domain;<br>public:<br> AppDomainWrapper() {<br> m_domain = AppDomain::CurrentDomain;<br> }<br> ~AppDomainWrapper() {<br> }<br> // more functions here...<br> void PrintBaseDir() {<br> Console::WriteLine ( S"AppDomain Base Directory: {0}",<br> m_domain-&gt;BaseDirectory );<br> }<br>};<br><br>#pragma unmanaged<br>int main() {<br> AppDomainWrapper w; <br> w.PrintBaseDir();<br> return 0; <br><br><br><br>}</pre>
</td>
</tr>
</tbody>
</table>
<span class="clsFigure"></span><span class="clsCap"></span> </div>
<h2>Useful Tools:</h2>
<ul>
<li>Viewing Assembly Contents</li>
<ul>
<li>MSIL Disassembler (ildasm.exe)<br>
</li>
</ul>
</ul>
<ul>
<li>TLBIMP.exe</li>
<li>TLBEXP.exe</li>
<li>REGASM.exe</li>
<li>AXIMP.exe</li>
<li>REGSVCS.exe</li>
</ul>
<br>
<h2 class="dtH1">References<br>
</h2>
<ul>
<li>Visual Studio .NET
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vsstartpage.asp)<br>
</li>
<li>Managed Extensions for C++ programming (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcconmcoverview.asp)</li>
<li>Managed Extensions for C++ specifications
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcManagedExtensionsSpec_Start.asp)<br>
</li>
</ul>
<h2><br>
</h2>
<h2>History:</h2>
Draft 0.1 : April 9 2003&nbsp; Roy Yokoyama<br>
<br>
<br>
</body>
</html>

View file

@ -1,230 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#using <mscorlib.dll>
#include "DotNETEmbed.h"
#include "WebChrome.h"
#define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
#pragma unmanaged
//*****************************************************************************
// WebBrowserChrome::nsISupports
//*****************************************************************************
NS_IMPL_ADDREF(WebBrowserChrome)
NS_IMPL_RELEASE(WebBrowserChrome)
NS_INTERFACE_MAP_BEGIN(WebBrowserChrome)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_END
WebBrowserChrome::WebBrowserChrome()
{
mNativeWindow = nsnull;
}
WebBrowserChrome::~WebBrowserChrome()
{
}
/* attribute nativeSiteWindow siteWindow */
NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void * *aSiteWindow)
{
*aSiteWindow = mNativeWindow;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::GetTitle(PRUnichar * *aTitle)
{
NS_ENSURE_ARG_POINTER(aTitle);
*aTitle = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetTitle(const PRUnichar * aTitle)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute boolean visibility; */
NS_IMETHODIMP WebBrowserChrome::GetVisibility(PRBool * aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
*aVisibility = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetVisibility(PRBool aVisibility)
{
return NS_OK;
}
/* void setFocus (); */
NS_IMETHODIMP WebBrowserChrome::SetFocus()
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
{
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
{
*x = 0;
*y = 0;
}
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
{
*cx = 0;
*cy = 0;
}
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::ExitModalEventLoop(nsresult aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::ShowAsModal(void)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::IsWindowModal(PRBool *_retval)
{
*_retval = PR_FALSE;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = mWebBrowser;
NS_IF_ADDREF(*aWebBrowser);
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
{
mWebBrowser = aWebBrowser;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::GetChromeFlags(PRUint32* aChromeMask)
{
*aChromeMask = mChromeFlags;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask)
{
mChromeFlags = aChromeMask;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight)
{
::MoveWindow((HWND)mNativeWindow, 0, 0, aWidth, aHeight, TRUE);
return NS_OK;
}
nsresult WebBrowserChrome::CreateBrowser(HWND hWnd, PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY,
nsIWebBrowser **aBrowser)
{
NS_ENSURE_ARG_POINTER(aBrowser);
*aBrowser = nsnull;
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
if (!mWebBrowser)
return NS_ERROR_FAILURE;
(void)mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(this));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser);
dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
nsCOMPtr<nsIBaseWindow> browserBaseWindow = do_QueryInterface(mWebBrowser);
mNativeWindow = hWnd;
if (!mNativeWindow)
return NS_ERROR_FAILURE;
browserBaseWindow->InitWindow( mNativeWindow,
nsnull,
aX, aY, aCX, aCY);
browserBaseWindow->Create();
if (mWebBrowser)
{
*aBrowser = mWebBrowser;
NS_ADDREF(*aBrowser);
return NS_OK;
}
return NS_ERROR_FAILURE;
}

View file

@ -1,72 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roy Yokoyama <yokoyama@netscape.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIGenericFactory.h"
#include "nsString.h"
#include "nsIWebBrowserChrome.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWebBrowser.h"
#include "nsIDocShellTreeItem.h"
#include "nsIBaseWindow.h"
#include "nsIWindowCreator.h"
class WebBrowserChrome : public nsIWebBrowserChrome,
public nsIEmbeddingSiteWindow
{
public:
WebBrowserChrome();
virtual ~WebBrowserChrome();
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIEMBEDDINGSITEWINDOW
nsresult CreateBrowser(HWND hWnd, PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY,
nsIWebBrowser **aBrowser);
protected:
nativeWindow mNativeWindow;
PRUint32 mChromeFlags;
nsCOMPtr<nsIWebBrowser> mWebBrowser;
};

View file

@ -1,48 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla 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/MPL/
#
# 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 the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Netscape Communications, Inc.
# Portions created by the Initial Developer are Copyright (C) 1999
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Adam Lock <adamlock@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=
include $(topsrcdir)/config/rules.mk

View file

@ -1,5 +0,0 @@
This folder is for components, widgets and frameworks that enable Gecko
to be embedded with 3rd party development tools.
activex/
gtk/