Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IBrowserHostServices/INativeProgressPage and cleanup AppSecurityManager #10220

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

//
//
// Description:
// SiteOfOriginContainer is an implementation of the abstract Package class.
// It contains nontrivial overrides for GetPartCore and Exists.
// Many of the methods on Package are not applicable to loading application
// resources, so the SiteOfOriginContainer implementations of these methods throw
// the NotSupportedException.
//

using System.IO.Packaging;
using System.IO;
using System.IO.Packaging;
using System.Windows.Navigation;

namespace MS.Internal.AppModel
Expand All @@ -25,149 +14,56 @@ namespace MS.Internal.AppModel
/// so the SiteOfOriginContainer implementations of these methods throw
/// the NotSupportedException.
/// </summary>
internal class SiteOfOriginContainer : System.IO.Packaging.Package
internal sealed class SiteOfOriginContainer : Package
{
//------------------------------------------------------
//
// Static Methods
//
//------------------------------------------------------
private static readonly BooleanSwitch s_traceSwitch = new("SiteOfOrigin", "SiteOfOriginContainer and SiteOfOriginPart trace messages");

#region Static Methods
/// <summary>
/// Represents the debug trace <see cref="BooleanSwitch"/> for <see cref="SiteOfOriginContainer"/> and <see cref="SiteOfOriginPart"/>.
/// </summary>
internal static bool TraceSwitchEnabled
{
get => s_traceSwitch.Enabled;
set => s_traceSwitch.Enabled = value;
}

/// <summary>
/// Retrieves the site of origin, derived from <see cref="AppContext.BaseDirectory"/>.
/// </summary>
internal static Uri SiteOfOrigin
{
get
{
// Calling FixFileUri because BaseDirectory will be a c:\\ style path
Uri siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory));
Uri siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(AppContext.BaseDirectory));
#if DEBUG
if (_traceSwitch.Enabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
": SiteOfOriginContainer: returning site of origin " + siteOfOrigin);
if (TraceSwitchEnabled)
{
Trace.TraceInformation($"{DateTime.Now.ToLongTimeString()} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}" +
$": SiteOfOriginContainer: returning site of origin {siteOfOrigin}");
}
#endif

return siteOfOrigin;
}
}

#endregion

//------------------------------------------------------
//
// Public Constructors
//
//------------------------------------------------------

#region Public Constructors

/// <summary>
/// Default Constructor
/// </summary>
internal SiteOfOriginContainer() : base(FileAccess.Read)
{
{
}

#endregion

//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
// None

//------------------------------------------------------
//
// Public Methods
//
//------------------------------------------------------

#region Public Methods

/// <remarks>
/// If this were to be implemented for http site of origin,
/// it will require a server round trip.
/// If this were to be implemented for http site of origin, it will require a server round trip.
/// </remarks>
/// <param name="uri"></param>
/// <returns></returns>
/// <returns>Regardless of <paramref name="uri"/> input, always returns <see langword="true"/>.</returns>
public override bool PartExists(Uri uri)
{
return true;
}

#endregion

//------------------------------------------------------
//
// Public Events
//
//------------------------------------------------------
// None

//------------------------------------------------------
//
// Internal Constructors
//
//------------------------------------------------------
// None

//------------------------------------------------------
//
// Internal Properties
//
//------------------------------------------------------

#region Internal Properties

internal static bool TraceSwitchEnabled
{
get
{
return _traceSwitch.Enabled;
}
set
{
_traceSwitch.Enabled = value;
}
}

internal static System.Diagnostics.BooleanSwitch _traceSwitch =
new System.Diagnostics.BooleanSwitch("SiteOfOrigin", "SiteOfOriginContainer and SiteOfOriginPart trace messages");

#endregion

//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
// None

//------------------------------------------------------
//
// Internal Events
//
//------------------------------------------------------
// None

//------------------------------------------------------
//
// Protected Constructors
//
//------------------------------------------------------
// None

//------------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------

#region Protected Methods

/// <summary>
/// This method creates a SiteOfOriginPart which will create a WebRequest
/// to access files at the site of origin.
Expand All @@ -177,25 +73,15 @@ internal static bool TraceSwitchEnabled
protected override PackagePart GetPartCore(Uri uri)
{
#if DEBUG
if (_traceSwitch.Enabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
": SiteOfOriginContainer: Creating SiteOfOriginPart for Uri " + uri);
if (TraceSwitchEnabled)
{
Trace.TraceInformation($"{DateTime.Now.ToLongTimeString()} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}" +
$": SiteOfOriginContainer: Creating SiteOfOriginPart for Uri {uri}");
}
#endif
return new SiteOfOriginPart(this, uri);
}

#endregion


//------------------------------------------------------
//
// Uninteresting (but required) overrides
//
//------------------------------------------------------
#region Uninteresting (but required) overrides

protected override PackagePart CreatePartCore(Uri uri, string contentType, CompressionOption compressionOption)
{
return null;
Expand All @@ -215,7 +101,5 @@ protected override void FlushCore()
{
throw new NotSupportedException();
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -46,7 +46,7 @@ internal SiteOfOriginPart(Package container, Uri uri) :
protected override Stream GetStreamCore(FileMode mode, FileAccess access)
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -58,7 +58,7 @@ protected override Stream GetStreamCore(FileMode mode, FileAccess access)
protected override string GetContentTypeCore()
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand Down Expand Up @@ -86,7 +86,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
if (onlyNeedContentType && _contentType != MS.Internal.ContentType.Empty)
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -102,7 +102,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
if (_cacheStream != null)
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -116,7 +116,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
if (_absoluteLocation == null)
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -129,7 +129,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
}

#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -155,7 +155,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
private Stream HandleFileSource(bool onlyNeedContentType)
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -179,7 +179,7 @@ private Stream HandleWebSource(bool onlyNeedContentType)
Stream responseStream = response.GetResponseStream();

#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand All @@ -189,7 +189,7 @@ private Stream HandleWebSource(bool onlyNeedContentType)
if (_contentType == MS.Internal.ContentType.Empty)
{
#if DEBUG
if (SiteOfOriginContainer._traceSwitch.Enabled)
if (SiteOfOriginContainer.TraceSwitchEnabled)
System.Diagnostics.Trace.TraceInformation(
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
Environment.CurrentManagedThreadId +
Expand Down
Loading