diff --git a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-Net48.baseline.txt b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-Net48.baseline.txt
index 2f11985bd53..3a0b69dab20 100644
--- a/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-Net48.baseline.txt
+++ b/src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-Net48.baseline.txt
@@ -1,14 +1,15 @@
-Compat issues with assembly PresentationFramework:
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.AttachedPropertyBrowsableForChildrenAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ResourceReferenceKeyNotFoundException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.StyleTypedPropertyAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplatePartAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplateVisualStateAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ThemeInfoAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.PrintDialogException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueConversionAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueUnavailableException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Documents.TextElementEditingBehaviorAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
-CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Markup.XamlParseException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
-CannotRemoveAttribute : Attribute 'System.Security.SecurityCriticalAttribute' exists on 'System.Windows.Shell.JumpList' in the contract but not the implementation.
-Total Issues: 12
+Compat issues with assembly PresentationFramework:
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.AttachedPropertyBrowsableForChildrenAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ResourceReferenceKeyNotFoundException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.StyleTypedPropertyAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplatePartAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplateVisualStateAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ThemeInfoAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.PrintDialogException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueConversionAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueUnavailableException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Documents.TextElementEditingBehaviorAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
+TypesMustExist : Type 'System.Windows.Interop.DocObjHost' does not exist in the implementation but it does exist in the contract.
+CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Markup.XamlParseException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
+CannotRemoveAttribute : Attribute 'System.Security.SecurityCriticalAttribute' exists on 'System.Windows.Shell.JumpList' in the contract but not the implementation.
+Total Issues: 13
diff --git a/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/PresentationFramework.cs b/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/PresentationFramework.cs
index 750187c3794..d73b585dd97 100644
--- a/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/PresentationFramework.cs
+++ b/src/Microsoft.DotNet.Wpf/cycle-breakers/PresentationFramework/PresentationFramework.cs
@@ -11217,12 +11217,7 @@ public static partial class BrowserInteropHelper
public static bool IsBrowserHosted { get { throw null; } }
public static System.Uri Source { get { throw null; } }
}
- public sealed partial class DocObjHost : System.MarshalByRefObject, System.IServiceProvider
- {
- public DocObjHost() { }
- public override object InitializeLifetimeService() { throw null; }
- object System.IServiceProvider.GetService(System.Type serviceType) { throw null; }
- }
+
public sealed partial class DynamicScriptObject : System.Dynamic.DynamicObject
{
internal DynamicScriptObject() { }
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Win32KeyboardDevice.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Win32KeyboardDevice.cs
index 3688f15f9e5..16dec0e21fd 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Win32KeyboardDevice.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Win32KeyboardDevice.cs
@@ -47,55 +47,14 @@ protected override KeyStates GetKeyStatesFromSystem(Key key)
{
KeyStates keyStates = KeyStates.None;
- bool getKeyStatesFromSystem = false;
- if(IsActive)
- {
- // Our keyboard device is only active if some WPF window in
- // this AppDomain has focus. It is always safe to return
- // the state of keys.
- getKeyStatesFromSystem = true;
- }
- else if (SecurityHelper.AppDomainGrantedUnrestrictedUIPermission)
- {
- // This is a trusted AppDomain, so we are willing to expose
- // the state of keys regardless of whether or not a WPF
- // window has focus. This is important for child HWND
- // hosting scenarios.
- getKeyStatesFromSystem = true;
- }
- else
- {
- // Security Mitigation:
- // No WPF window has focus in this AppDomain, and this is a
- // partially-trusted AppDomain, so we do not generally want
- // to expose the state of keys. However, we make an exception
- // for modifier keys, as they are considered safe.
- switch (key)
- {
- case Key.LeftAlt:
- case Key.RightAlt:
- case Key.LeftCtrl:
- case Key.RightCtrl:
- case Key.LeftShift:
- case Key.RightShift:
- getKeyStatesFromSystem = true;
- break;
- }
- }
+ int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key);
+ int nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode);
- if (getKeyStatesFromSystem)
- {
- int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key);
- int nativeKeyState;
+ if ((nativeKeyState & 0x00008000) == 0x00008000)
+ keyStates |= KeyStates.Down;
- nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode);
-
- if( (nativeKeyState & 0x00008000) == 0x00008000 )
- keyStates |= KeyStates.Down;
-
- if( (nativeKeyState & 0x00000001) == 0x00000001 )
- keyStates |= KeyStates.Toggled;
- }
+ if ((nativeKeyState & 0x00000001) == 0x00000001)
+ keyStates |= KeyStates.Toggled;
return keyStates;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndKeyboardInputProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndKeyboardInputProvider.cs
index cb50c8a4f62..7314d5b8fbe 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndKeyboardInputProvider.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndKeyboardInputProvider.cs
@@ -103,38 +103,29 @@ bool IKeyboardInputProvider.AcquireFocus(bool checkOnly)
// In either case, the window must be enabled.
if(SafeNativeMethods.IsWindowEnabled(thisWindow))
{
- if (SecurityHelper.AppDomainGrantedUnrestrictedUIPermission)
- {
- // In fully-trusted AppDomains, the only hard requirement
- // is that Win32 keyboard focus be on some window owned
- // by a thread that is attached to our Win32 queue. This
- // presumes that the thread's message pump will cooperate
- // by calling ComponentDispatcher.RaiseThreadMessage.
- // If so, WPF will be able to route the keyboard events to the
- // element with WPF keyboard focus, regardless of which
- // window has Win32 keyboard focus.
- //
- // Menus/ComboBoxes use this feature.
- //
- // Dev11 is moving more towards cross-process designer
- // support. They make sure to call AttachThreadInput so
- // the the two threads share the same Win32 queue. In
- // addition, they repost the keyboard messages to the
- // main UI process/thread for handling.
- //
- // We rely on the behavior of GetFocus to only return a
- // window handle for windows attached to the calling
- // thread's queue.
- //
- result = focus != IntPtr.Zero;
- }
- else
- {
- // In partially-trusted AppDomains, we do not want to expose input
- // intended for other native windows, or for WPF windows in other
- // AppDomains.
- result = IsOurWindow(focus);
- }
+
+ // In fully-trusted AppDomains, the only hard requirement
+ // is that Win32 keyboard focus be on some window owned
+ // by a thread that is attached to our Win32 queue. This
+ // presumes that the thread's message pump will cooperate
+ // by calling ComponentDispatcher.RaiseThreadMessage.
+ // If so, WPF will be able to route the keyboard events to the
+ // element with WPF keyboard focus, regardless of which
+ // window has Win32 keyboard focus.
+ //
+ // Menus/ComboBoxes use this feature.
+ //
+ // Dev11 is moving more towards cross-process designer
+ // support. They make sure to call AttachThreadInput so
+ // the the two threads share the same Win32 queue. In
+ // addition, they repost the keyboard messages to the
+ // main UI process/thread for handling.
+ //
+ // We rely on the behavior of GetFocus to only return a
+ // window handle for windows attached to the calling
+ // thread's queue.
+ //
+ result = focus != IntPtr.Zero;
}
}
else
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs
index ddd035eca27..08b13f63f12 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndSource.cs
@@ -340,13 +340,7 @@ private void Initialize(HwndSourceParameters parameters)
AddSource();
// Register dropable window.
- // The checking CallerHasPermissionWithAppDomainOptimization will call RegisterDropTarget
- // safely without the security exception in case of no unmanaged code permission.
- // So RegisterDropTarget will be called safely in case of having the unmanged code permission.
- // Otherwise, the security exception cause System.Printing to be instatiated which will
- // load system.drawing module.
- if (_hwndWrapper.Handle != IntPtr.Zero &&
- SecurityHelper.CallerHasPermissionWithAppDomainOptimization(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)))
+ if (_hwndWrapper.Handle != IntPtr.Zero)
{
// This call is safe since DragDrop.RegisterDropTarget is checking the unmanged
// code permission.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs
index 9e7cb69ed8f..dc9185fe0b5 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs
@@ -105,29 +105,7 @@ internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri,
MS.Internal.PresentationFramework.SecurityHelper.CallerHasUserInitiatedNavigationPermission()) &&
((fIsTopLevel && isKnownScheme) || fIsMailTo))
{
- if (isKnownScheme)
- {
-#if NETFX
- IBrowserCallbackServices ibcs = ( Application.Current != null ) ? Application.Current.BrowserCallbackServices : null ;
- if (ibcs != null)
- {
- launched = CanNavigateToUrlWithZoneCheck(originatingUri , destinationUri);
- if ( launched == LaunchResult.Launched )
- {
- // resetting launched to NotLaunched here; if the assert succeeds
- // and ibcs.DelegateNavigation does not throw then we will set it to Launched.
- launched = LaunchResult.NotLaunched;
- // Browser app.
- // We need to see if this is the right behavior when clicking on a link in
- // a secondary window in a multi-window browser app
- ibcs.DelegateNavigation( BindUriHelper.UriToString( destinationUri ), targetName, GetHeaders(destinationUri));
-
- launched = LaunchResult.Launched ;
- }
- }
-#endif
- }
- else if (fIsMailTo) // unnecessary if - but being paranoid.
+ if (!isKnownScheme && fIsMailTo) // unnecessary if - but being paranoid.
{
// Shell-Exec the browser to the mailto url.
// assumed safe - because we're only allowing this for mailto urls.
@@ -150,22 +128,6 @@ internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri,
// Whoever is calling this function should do the right demands.
internal static void UnsafeLaunchBrowser(Uri uri, string targetFrame = null)
{
-#if NETFX
- // This'll likely go into SafeLaunchBrowser() function.
- if (Application.Current != null && Application.Current.CheckAccess())
- {
- IBrowserCallbackServices ibcs = Application.Current.BrowserCallbackServices;
- if (ibcs != null)
- {
- // Browser app.
- // TODO: See if this is the right behavior when clicking on a link in
- // a secondary window in a multi-window browser app - PS # 840726
- ibcs.DelegateNavigation(BindUriHelper.UriToString(uri), targetFrame, GetHeaders(uri));
- return;
- }
- }
-#endif
-
ShellExecuteDefaultBrowser(uri);
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserCallbackServices.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserCallbackServices.cs
deleted file mode 100644
index 9b36cd9e0d1..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserCallbackServices.cs
+++ /dev/null
@@ -1,245 +0,0 @@
-// 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:
-// Managed definition for IBrowserCallbackServices & IHostBrowser, used for
-// communicating from managed code back to the native DocObject code and the
-// in-proc handlers in the host browser.
-//
-// ***********************IMPORTANT**************************
-//
-// If you change any of the interface definitions here
-// make sure you also change the interface definitions
-// on the native side (src\host\inc\HostServices.idl & HostSupport.idl).
-// If you are not sure about how to define it
-// here, TEMPORARILY mark the interface as
-// ComVisible in the managed side, use tlbexp to generate
-// a typelibrary from the managed dll and copy the method
-// signatures from there. REMEMBER to remove the ComVisible
-// in the managed code when you are done.
-// Defining the interfaces at both ends prevents us from
-// publicly exposing these interfaces to the outside world.
-// In order for marshaling to work correctly, the vtable
-// and data types should match EXACTLY in both the managed
-// and unmanaged worlds
-//
-
-using System;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.Permissions;
-
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Navigation;
-using System.Windows.Interop;
-using MS.Internal;
-using MS.Utility;
-using MS.Internal.Interop;
-
-namespace MS.Internal.AppModel
-{
- //********************************************************************************************//
- // IMPORTANT: IMPORTANT: IMPORTANT: IMPORTANT: //
- //********************************************************************************************//
- // If you change or update this interface, make sure you update the definitions in
- // wcp\host\inc\hostservices.idl
-
- ///
- /// Internal interface used for Interop in browser hosting scenarios. This
- /// interface is passed in by the Docobj Server hosted in the browser and is
- /// used to communicate from the Windows Client application back to the browser
- /// The master definition is in HostServices.idl.
- ///
- ///
- /// The original (v1) interface has been partly superseded by IHostBrowser.
- ///
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("5FFAD804-61C8-445c-8C31-A2101C64C510")]
- internal interface IBrowserCallbackServices
- {
- void OnBeforeShowNavigationWindow();
-
- ///
- /// Causes the browser host to fire a ReadyState change to Complete to let
- /// shdocvw know that the navigation is complete
- ///
- ///
- void PostReadyStateChange([In, MarshalAs(UnmanagedType.I4)] int readyState);
-
- ///
- /// Allows browser host to navigate to the url. This method is typically called
- /// to delegate navigation back to the browser for mime types we don't handle eg: html
- ///
- ///
- ///
- ///
- ///
- void DelegateNavigation([In, MarshalAs(UnmanagedType.BStr)] string url, [In, MarshalAs(UnmanagedType.BStr)] string targetName, [In, MarshalAs(UnmanagedType.BStr)] string headers);
-
- ///
- /// Notifies the avalon host to update the address bar with the current url
- ///
- ///
- ///
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool UpdateAddressBar([In, MarshalAs(UnmanagedType.BStr)] string url);
-
- ///
- /// When the internal Journal state changes, we need to make sure it is reflected
- /// appropriately in the browser. Adding entries will make this happen automatically
- /// since we explicitly add entries to the browser's TravelLog
- /// We need this callback for the following purposes
- /// 1.. Deleting visible entries will not reflect the change immediately unless
- /// we explicitly notify the browser (think the browser calls CanInvoke but its nice
- /// to update UI immediately)
- /// 2. Back/Forward state needs to be updated automatically when frames are
- /// programmatically removed from the tree. Since frames don't have their own
- /// journal, reparenting a frame to a new tree doesn't affect the new tree.
- /// Its only the tree state where it is being removed from that is affected.
- ///
- [PreserveSig]
- void UpdateBackForwardState();
-
- ///
- /// Add entry to shdocvw's TravelLog. Will fail on downlevel platform.
- ///
- ///
- ///
- ///
- void UpdateTravelLog([In, MarshalAs(UnmanagedType.Bool)]bool addNewEntry);
-
- ///
- /// Change status of progress bar.
- ///
- ///
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool UpdateProgress([In, MarshalAs(UnmanagedType.I8)]long cBytesCompleted, [In, MarshalAs(UnmanagedType.I8)]long cBytesTotal);
-
- ///
- /// Change the download state (spin the globe/wave the flag).
- ///
- ///
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool ChangeDownloadState([In]bool fIsDownloading);
-
- ///
- /// Is this a downlevel platform that is not fully integrated
- ///
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool IsDownlevelPlatform();
-
- ///
- /// Check if browser is shutting us down
- ///
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool IsShuttingDown();
-
- ///
- /// Moves focus out of the application, to the browser frame.
- ///
- [PreserveSig]
- bool TabOut(bool forward);
-
- ///
- /// When an unhandled exception occurs in PresentationHost a stack trace is generated
- /// and passed to native code via this method. Then an html error page is generated
- /// and the browser navigates to it.
- /// NOTE: There's also a DLL-exported function from PresentationHostDll for this purpose.
- /// See DocObjHost.ProcessUnhandledException().
- ///
- [PreserveSig]
- void ProcessUnhandledException([In, MarshalAs(UnmanagedType.BStr)] string pErrorMsg);
-
- ///
- /// Returns the IOleClientSite interface
- ///
- [PreserveSig]
- int GetOleClientSite([Out, MarshalAs(UnmanagedType.IUnknown)] out object oleClientSite);
-
- ///
- /// Asks the browser to re-query for command status
- ///
- [PreserveSig]
- int UpdateCommands();
-
- ///
- /// The return value is declared as an IntPtr, not as a typed IWebBrowser2 interface, to prevent CLR
- /// Remoting from getting involved when the object is passed cross-AppDomain. When making calls on this
- /// interface, there is no point in switching to the default AppDomain, given that that object actually
- /// lives in another process.
- /// The caller must call Release() on the COM interface.
- ///
- IntPtr CreateWebBrowserControlInBrowserProcess();
- }
-
-
- ///
- /// [See master definition in HostSupport.idl.]
- ///
- [ComImport, Guid("AD5D6F02-5F4E-4D77-9FC0-381981317144"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- interface IHostBrowser
- {
- ///
- /// Returns the browser's top-level URL and whether the DocObject is top-level or in a frame.
- /// If querying from a frame in a less secure zone than the top window, NULL may be returned for top-level URL.
- ///
- string DetermineTopLevel(out bool pbIsTopLevel);
-
- ///
- /// Delegates a navigation to the browser. This may cause the Avalon application to be shut down.
- /// targetName is the name of a frame/window or one of the predefined targets: _parent, _blank, etc.
- /// Normally, IBCS.DelegateNavigation() should be used instead. It calls CoAllowSetForegroundWindow()
- /// to let a new browser window become active.
- ///
- void Navigate(string url, string targetName = null, string headers = null);
-
- void GoBack();
- void GoForward();
-
- void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string title);
- [PreserveSig]
- long SetStatusText([MarshalAs(UnmanagedType.LPWStr)] string text);
-
- void SetWidth(uint width);
- void SetHeight(uint height);
- uint GetWidth();
- uint GetHeight();
- int GetLeft();
- int GetTop();
-
- // These methods should not be used directly. They are used in the implementation of the cookie shim in PHDLL.
- // Managed code can use Application.Get/SetCookie().
- string GetCookie_DoNotUse(string url, string cookieName, bool thirdParty);
- void SetCookie_NoNotUse(string url, string cookieName, string cookieData, bool thirdParty, string P3PHeader = null);
-
- [PreserveSig]
- MS.Internal.Interop.HRESULT GetUserAgentString(out string userAgent);
-
- // The implementation of IBCS.CreateWebBrowserControlInBrowserProcess() performs an important security
- // check before calling this method.
- void CreateWebBrowserControl_DoNotUse([Out] out IntPtr ppWebBrowser);
-
- void TabOut_v35SP1QFE(bool forward);
- };
-
- [ComImport, Guid("AD5D6F03-0002-4D77-9FC0-381981317144"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- interface IHostBrowser2
- {
- // Use IBCS.TabOut() instead. The implementation of TabOut is not fully factored out yet.
- void TabOut_DoNotUse(bool forward);
-
- object HostScriptObject { [return: MarshalAs(UnmanagedType.IDispatch)] get; }
-
- string PluginName { get; }
- string PluginVersion { get; }
- };
-}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserHostServices.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserHostServices.cs
index fd506b71a0b..dbd66cb1c0d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserHostServices.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/IBrowserHostServices.cs
@@ -51,113 +51,6 @@ enum HostingFlags
hfInDebugMode = 0x20
};
- //
- // This interface is used to host Windows Client Applications in the browser
- // The unmanaged docobj server communicates with the application through this
- // interface using COM interop.
- //
- [ComImport]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- [Guid("a0aa9153-65b4-3b57-9f2b-126f9c76c9f5")]
- internal interface IBrowserHostServices
- {
- // This method inits and runs the server
- // Int indicating whether the exit code of the application, failure could also
- // mean that the app was not launched successfully
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.I4)]
- int Run([In, MarshalAs(UnmanagedType.LPWStr)] string strUrl,
- [In, MarshalAs(UnmanagedType.LPWStr)] string strFragment,
- MimeType mime,
- [In, MarshalAs(UnmanagedType.LPWStr)] string strDebugSecurityZoneURL,
- [In, MarshalAs(UnmanagedType.LPWStr)] string strApplicationId,
- [In, MarshalAs(UnmanagedType.Interface)] object storageIUnknown,
- [In, MarshalAs(UnmanagedType.Interface)] object loadByteArray,
- HostingFlags hostingFlags,
- INativeProgressPage nativeProgressPage,
- [In, MarshalAs(UnmanagedType.BStr)] string bstrProgressAssemblyName,
- [In, MarshalAs(UnmanagedType.BStr)] string bstrProgressClassName,
- [In, MarshalAs(UnmanagedType.BStr)] string bstrErrorAssemblyName,
- [In, MarshalAs(UnmanagedType.BStr)] string bstrErrorClassName,
- IHostBrowser hostBrowser
- );
-
- // Reparent the viewport
- void SetParent(IntPtr parentHandle);
-
- // Show the viewport
- void Show([MarshalAs(UnmanagedType.Bool)]bool showView);
-
- // Move the viewport
- void Move(int x, int y, int width, int height);
-
- ///
- /// Used by C# hosting code to get back to the native browser hosting code.
- /// (The interface type is IBrowserCallbackServices.)
- ///
- void SetBrowserCallback([In, MarshalAs(UnmanagedType.Interface)]object browserCallback);
-
- // If the Application is loaded we use LoadHistory else create a new app object
- //
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool IsAppLoaded();
-
- // Returns the Environment.ExitCode set by the application object when it Shutdown
- //
- [PreserveSig]
- int GetApplicationExitCode();
-
- // Returns whether a journalEntry at that index is invokable. If the entry is a frame
- // and we are not in the context of its host page, we return failure
- //
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool CanInvokeJournalEntry([In, MarshalAs(UnmanagedType.I4)] int entryId);
-
- // IPersistHistory::SaveHistory implementation called
- //when hosted in the browser
- void SaveHistory([MarshalAs(UnmanagedType.Interface)]object ucomIStream,
- [MarshalAs(UnmanagedType.Bool)]bool persistEntireJournal,
- [Out, MarshalAs(UnmanagedType.I4)] out int entryIndex,
- [Out, MarshalAs(UnmanagedType.LPWStr)]out string url,
- [Out, MarshalAs(UnmanagedType.LPWStr)]out string title);
-
- // IPersistHistory::LoadHistory implementation called
- //when hosted in the browser
- void LoadHistory([MarshalAs(UnmanagedType.Interface)]object ucomIStream);
-
- //
- // IOleCommandTarget::QueryStatus called when hosted in the browser
- //
- [PreserveSig]
- int QueryStatus([MarshalAs(UnmanagedType.LPStruct)]Guid guidCmdGroup, [In] uint command, [Out] out uint flags);
-
- //
- // IOleCommandTarget::Exec called when hosted in the browser
- //
- [PreserveSig]
- int ExecCommand([MarshalAs(UnmanagedType.LPStruct)]Guid guidCmdGroup, uint command, object arg);
-
- /// Shuts down the application.
- ///
- /// The "post" in the method name is legacy. Now all of Application's shutdown work is complete
- /// when this method returns. In particular, the managed Dispatcher is shut down.
- ///
- void PostShutdown();
-
- // Activate or deactivate RootBrowswerWindow
- void Activate([MarshalAs(UnmanagedType.Bool)]bool fActivated);
-
- void TabInto(bool forward);
-
- ///
- /// Returns true is the focused element wants the backspace key
- ///
- [PreserveSig]
- [return: MarshalAs(UnmanagedType.Bool)]
- bool FocusedElementWantsBackspace();
- }
//********************************************************************************************//
// IMPORTANT: IMPORTANT: IMPORTANT: IMPORTANT: //
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourceContainer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourceContainer.cs
index 129c4099cc3..4a6fb8663e6 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourceContainer.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourceContainer.cs
@@ -207,7 +207,7 @@ protected override PackagePart GetPartCore(Uri uri)
// old version dll when a newer one is loaded. So whenever the AssemblyLoad event is fired, we will need to update the cache
// with the newly loaded assembly. This is currently only for designer so not needed for browser hosted apps.
// Attach the event handler before the first time we get the ResourceManagerWrapper.
- if ((!assemblyLoadhandlerAttached) && (!BrowserInteropHelper.IsBrowserHosted))
+ if (!assemblyLoadhandlerAttached)
{
AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoadEventHandler);
assemblyLoadhandlerAttached = true;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/securitymgrsite.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/securitymgrsite.cs
index f8b29d820dd..f73249c2c80 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/securitymgrsite.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/securitymgrsite.cs
@@ -30,11 +30,6 @@ public void GetWindow( /* [out] */ ref IntPtr phwnd)
if (Application.Current != null)
{
Window curWindow = Application.Current.MainWindow;
-
-#if NETFX
- Invariant.Assert( Application.Current.BrowserCallbackServices == null || ( curWindow is RootBrowserWindow ));
-#endif
-
if (curWindow != null)
{
phwnd = curWindow.CriticalHandle;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XamlFilter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XamlFilter.cs
index e7250498241..df0ef286e1f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XamlFilter.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XamlFilter.cs
@@ -96,20 +96,6 @@ internal enum AttributesToIgnore
#region Internal Constructors
- ///
- /// The class constructor initializes trace and event logging.
- ///
- static XamlFilter()
- {
-#if TRACE
-#if NETFX
- EventLog xamlFilterEventLog = new EventLog();
- xamlFilterEventLog.Log = "Application";
- xamlFilterEventLog.Source = "XAML filter";
- Trace.Listeners.Add(new EventLogTraceListener(xamlFilterEventLog));
-#endif
-#endif
- }
///
/// Constructor. Does initialization.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs
index 5f5d29b184d..1255d9c2eb8 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs
@@ -11,9 +11,6 @@
using System;
using System.IO;
-#if NETFX
-using System.Runtime.Remoting;
-#endif
using System.Security; // SecurityCritical attribute
using System.Security.Permissions;
using MS.Internal.AppModel;
@@ -219,20 +216,6 @@ public override void Close()
}
}
-#if NETFX
- ///
- /// Overridden CreateObjRef method
- ///
- ///
- ///
- public override ObjRef CreateObjRef(
- Type requestedType
- )
- {
- return _stream.CreateObjRef(requestedType);
- }
-#endif
-
///
/// Overridden EndRead method
///
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Utility/SponsorHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Utility/SponsorHelper.cs
deleted file mode 100644
index 898a9402434..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Utility/SponsorHelper.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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.
-
-using System;
-using System.Diagnostics;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Lifetime;
-using System.Security;
-using System.Security.Permissions;
-
-namespace MS.Internal.Utility
-{
- #region SponsorHelper Class
- ///
- /// We either mark the Sponsor as MarshalByRef or make it serializable.
- /// If we make it MarshalByRef, then this sponsor which is used to control
- /// the lifetime of a MBR object in turn needs to have another sponsor OR
- /// the sponsor can mark itself to remain alive for the life of the AppDomain
- /// by overriding InitializeLifetimeService and returning null OR the object
- /// can be marked as Serializeable instead of MBR in which case it is marshaled
- /// by value to the client appdomain and will not have the state of the host
- /// appdomain to make renewal decisions. In our case we don't have any state so
- /// its easier and better perf-wise to mark it Serializable.
- ///
- [Serializable]
- internal class SponsorHelper : ISponsor
- {
- #region Private Data
- private ILease _lease;
- private TimeSpan _timespan;
- #endregion Private Data
-
- #region Constructor
- internal SponsorHelper(ILease lease, TimeSpan timespan)
- {
- Debug.Assert(lease != null && timespan != null, "Lease and TimeSpan arguments cannot be null");
- _lease = lease;
- _timespan = timespan;
- }
- #endregion Constructor
-
- #region ISponsor Interface
- TimeSpan ISponsor.Renewal(ILease lease)
- {
- if (lease == null)
- {
- throw new ArgumentNullException("lease");
- }
-
- return _timespan;
- }
- #endregion ISponsor Interface
-
- #region Internal Methods
- internal void Register()
- {
- _lease.Register((ISponsor)this);
- }
-
- internal void Unregister()
- {
- _lease.Unregister((ISponsor)this);
- }
- #endregion Internal Methods
- }
- #endregion SponsorHelper Class
-}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj
index 41a570b7642..f3964390267 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj
@@ -118,7 +118,6 @@
-
@@ -1136,7 +1135,6 @@
-
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs
index 85b8c306d82..a813ca85d47 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs
@@ -29,10 +29,6 @@
using System.Globalization;
using System.IO;
using System.Reflection;
-#if NETFX
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Lifetime;
-#endif
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
@@ -101,10 +97,6 @@ public class Application : DispatcherObject, IHaveResources, IQueryAmbient
static Application()
{
ApplicationInit();
-
-#if NETFX
- NetFxVersionTraceLogger.LogVersionDetails();
-#endif
}
///
@@ -140,12 +132,6 @@ public Application()
}
}
- // Post a work item to start the Dispatcher (if we are browser hosted) so that the Dispatcher
- // will be running before OnStartup is fired. We can't check to see if we are browser-hosted
- // in the app ctor because BrowerInteropHelper.IsBrowserHosted hasn't been set yet.
- Dispatcher.BeginInvoke(
- DispatcherPriority.Send,
- new DispatcherOperationCallback(StartDispatcherInBrowser), null);
//
// (Application not shutting down when calling
@@ -232,35 +218,9 @@ public int Run()
public int Run(Window window)
{
VerifyAccess();
-
- //
- // Browser hosted app should not explictly call App.Run(). We need to filter out those
- // calls here
- //
- if (InBrowserHostedApp())
- {
- throw new InvalidOperationException(SR.Get(SRID.CannotCallRunFromBrowserHostedApp));
- }
- else
- {
- return RunInternal(window);
- }
+ return RunInternal(window);
}
- ///
- /// This will return true IFF this is a browser hosted, and this is the user's deployed
- /// application, not our deployment application. We can't use BrowserCallbackServices for
- /// this test, because it may not be hooked up yet. BrowserInteropHelper.IsBrowserHosted
- /// is set before any of the code in the new AppDomain will be run yet.
- ///
- internal static bool InBrowserHostedApp()
- {
-#if NETFX
- return BrowserInteropHelper.IsBrowserHosted && !(Application.Current is XappLauncherApp);
-#else
- return false;
-#endif
- }
///
///
@@ -877,21 +837,6 @@ public Window MainWindow
{
VerifyAccess();
-#if NETFX
- //
- // Throw if an attempt is made to change RBW.
- // or we are browser hosted, main window is null, and attempt is made to change RBW.
- //
- if ( ( _mainWindow is RootBrowserWindow )
- ||
- ((BrowserCallbackServices != null ) &&
- ( _mainWindow == null ) &&
- ( !( value is RootBrowserWindow ))) )
- {
- throw new InvalidOperationException( SR.Get( SRID.CannotChangeMainWindowInBrowser ) ) ;
- }
-#endif
-
if (value != _mainWindow)
{
_mainWindow = value;
@@ -1532,7 +1477,6 @@ internal virtual void PerformNavigationStateChangeTasks(
switch (state)
{
case NavigationStateChange.Navigating:
- ChangeBrowserDownloadState(true);
if (playNavigatingSound)
{
PlaySound(SOUND_NAVIGATING);
@@ -1540,29 +1484,13 @@ internal virtual void PerformNavigationStateChangeTasks(
break;
case NavigationStateChange.Completed:
PlaySound(SOUND_COMPLETE_NAVIGATION);
- ChangeBrowserDownloadState(false);
- UpdateBrowserCommands();
break;
case NavigationStateChange.Stopped:
- ChangeBrowserDownloadState(false);
break;
}
}
}
- internal void UpdateBrowserCommands()
- {
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_UpdateBrowserCommandsStart);
-
- IBrowserCallbackServices ibcs = (IBrowserCallbackServices)this.GetService(typeof(IBrowserCallbackServices));
- if (ibcs != null)
- {
- // ask the browser to re-query us for toolbar button state
- ibcs.UpdateCommands();
- }
-
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_UpdateBrowserCommandsEnd);
- }
///
/// Application Startup.
@@ -1766,10 +1694,7 @@ internal int RunInternal(Window window)
//Shutdown DispatcherOperationCallback
// Invoke the Dispatcher synchronously if we are not in the browser
- if (!BrowserInteropHelper.IsBrowserHosted)
- {
- RunDispatcher(null);
- }
+ RunDispatcher(null);
return _exitCode;
}
@@ -1788,29 +1713,12 @@ internal void InvalidateResourceReferences(ResourcesChangeInfo info)
// is created before the application.Run is called.
internal NavigationWindow GetAppWindow()
{
- NavigationWindow appWin = null;
- IBrowserCallbackServices ibcs = (IBrowserCallbackServices)this.GetService(typeof(IBrowserCallbackServices));
+ NavigationWindow appWin = new NavigationWindow();
- // standalone case
- if (ibcs == null)
- {
- appWin = new NavigationWindow();
-
- // We don't want to show the window before the content is ready, but for compatibility reasons
- // we do want it to have an HWND available. Not doing this can cause Application's MainWindow
- // to be null when LoadCompleted has happened.
- new WindowInteropHelper(appWin).EnsureHandle();
- }
-#if NETFX
- else // browser hosted case
- {
- IHostService ihs = (IHostService)this.GetService(typeof(IHostService));
- Debug.Assert(ihs != null, "IHostService in RootBrowserWindow cannot be null");
- appWin = ihs.RootBrowserWindowProxy.RootBrowserWindow;
- Debug.Assert(appWin != null, "appWin must be non-null");
- Debug.Assert(appWin is RootBrowserWindow, "appWin must be a RootBrowserWindow");
- }
-#endif
+ // We don't want to show the window before the content is ready, but for compatibility reasons
+ // we do want it to have an HWND available. Not doing this can cause Application's MainWindow
+ // to be null when LoadCompleted has happened.
+ new WindowInteropHelper(appWin).EnsureHandle();
return appWin;
}
@@ -1955,52 +1863,9 @@ private get
{
VerifyAccess();
_serviceProvider = value ;
-#if NETFX
- if (value != null)
- {
- _browserCallbackServices = (IBrowserCallbackServices)(_serviceProvider.GetService(typeof(IBrowserCallbackServices)));
- ILease lease = RemotingServices.GetLifetimeService(_browserCallbackServices as MarshalByRefObject) as ILease;
- if (lease != null)
- {
- //Per the remoting infrastructure, any remote object will get released in 5 mins unless the lease
- //is extended with the lease manager by a sponsor
- _browserCallbackSponsor = new SponsorHelper(lease, new TimeSpan(0, 5, 0));
- _browserCallbackSponsor.Register();
- }
-
- }
- else
- {
- CleanUpBrowserCallBackServices();
- }
-#endif
}
}
-#if NETFX
- private void CleanUpBrowserCallBackServices()
- {
- if (_browserCallbackServices != null)
- {
- if (_browserCallbackSponsor != null)
- {
- _browserCallbackSponsor.Unregister();
- _browserCallbackSponsor = null;
- }
- _browserCallbackServices = null;
- // Marshal.ReleaseComObject(IBHS) is called from ApplicationProxyInternal.
- }
- }
-
- internal IBrowserCallbackServices BrowserCallbackServices
- {
- get
- {
- VerifyAccess();
- return _browserCallbackServices;
- }
- }
-#endif
// is called by NavigationService to detect TopLevel container
// We check there to call this only if NavigationService is on
@@ -2032,17 +1897,6 @@ internal static bool IsShuttingDown
return _isShuttingDown;
}
-#if NETFX
- if (BrowserInteropHelper.IsBrowserHosted)
- {
- Application app = Application.Current;
- if ((app != null) && (app.CheckAccess()))
- {
- IBrowserCallbackServices bcs = app.BrowserCallbackServices;
- return ((bcs != null) && bcs.IsShuttingDown());
- }
- }
-#endif
return false;
}
set
@@ -2202,14 +2056,7 @@ private static Package GetResourcePackage(Uri packageUri)
///
private void EnsureHwndSource()
{
- // We don't support Activate, Deactivate, and SessionEnding
- // events for browser hosted scenarios thus don't create
- // this HwndSource if BrowserCallbackServices is valid
-#if NETFX
- if (BrowserCallbackServices == null && _parkingHwnd == null)
-#else
if (_parkingHwnd == null)
-#endif
{
// _appFilterHook needs to be member variable otherwise
// it is GC'ed and we don't get messages from HwndWrapper
@@ -2432,15 +2279,6 @@ private void ConfigAppWindowAndRootElement(object root, Uri uri)
}
}
- private void ChangeBrowserDownloadState(bool newState)
- {
- IBrowserCallbackServices ibcs = (IBrowserCallbackServices)this.GetService(typeof(IBrowserCallbackServices));
- if (ibcs != null)
- {
- // start or stop waving the flag
- ibcs.ChangeDownloadState(newState);
- }
- }
///
/// Plays a system sound using the PlaySound api. This is a managed equivalent of the
@@ -2570,31 +2408,6 @@ private static bool IsComponentBeingLoadedFromOuterLoadBaml(Uri curComponentUri)
return isRootElement;
}
- [DebuggerNonUserCode] // to treat this method as non-user code even when symbols are available
- private object StartDispatcherInBrowser(object unused)
- {
- if (BrowserInteropHelper.IsBrowserHosted)
- {
- BrowserInteropHelper.InitializeHostFilterInput();
-
- // This seemingly meaningless try-catch-throw is a workaround for a CLR deficiency/bug in
- // exception handling. When an unhandled exception on the main thread crosses
- // the AppDomain boundary, the p/invoke layer catches it and throws another exception. Thus,
- // the original exception is lost before the debugger is notified. The result is no managed
- // callstack whatsoever. The workaround is based on a debugger/CLR feature that notifies of
- // exceptions unhandled in 'user code'. This works only when the Just My Code feature is enabled
- // in VS.
- try
- {
- RunDispatcher(null);
- }
- catch
- {
- throw;
- }
- }
- return null;
- }
private object RunDispatcher(object ignore)
{
@@ -2641,10 +2454,6 @@ private object RunDispatcher(object ignore)
private SecurityCriticalDataForSet _appMimeType;
private IServiceProvider _serviceProvider;
-#if NETFX
- private IBrowserCallbackServices _browserCallbackServices;
- private SponsorHelper _browserCallbackSponsor;
-#endif
private bool _appIsShutdown;
private int _exitCode;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs
index 20e60eaff8d..247a1be5c22 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs
@@ -2950,11 +2950,7 @@ internal bool IsChildPopup
{
if (!_isChildPopupInitialized)
{
- // Force popup to be a child window if it we don't have unmanaged code permission (needed by bitmap effect)
- // This is a tighter restriction than just UIWindowPermission
- _isChildPopup = BrowserInteropHelper.IsBrowserHosted ||
- !SecurityHelper.CheckUnmanagedCodePermission();
-
+ _isChildPopup = false;
_isChildPopupInitialized = true;
}
return (_isChildPopup);
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/TextBoxBase.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/TextBoxBase.cs
index 072043e7631..adb0b7c9564 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/TextBoxBase.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/TextBoxBase.cs
@@ -83,14 +83,6 @@ internal TextBoxBase() : base()
// b) create TextContainer and call InitializeTextContainer
// c) configure TextEditor by setting appropriate properties
CoerceValue(HorizontalScrollBarVisibilityProperty);
-
- // Security team really wants to set AllowDrop property value as "False"
- // not to generate the security exception that can be happened in the
- // partial trust environment.
- if (!SecurityHelper.CallerHasPermissionWithAppDomainOptimization(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)))
- {
- AllowDrop = false;
- }
}
#endregion Constructors
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs
index 3455dd624c1..307728b1157 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs
@@ -81,49 +81,8 @@ public sealed class WebBrowser : ActiveXHost
static WebBrowser()
{
-#if NETFX
- if (IsWebOCPermissionRestricted)
- {
- // Breaking change for v4, intended to be backported to v3.x: We block PT hosting of the WebOC:
- // - In non-IE browser (intended for Firefox presently) for Internet-zone XBAPs, in order
- // not to expose IE's attack surface;
- // - In PT standalone ClickOnce application. WPF does not support this in general, but a WebBrowser
- // can be instantiated and navigated, and script in it will run, which could be harmful.
- if (BrowserInteropHelper.IsBrowserHosted)
- {
- if ((BrowserInteropHelper.HostingFlags & HostingFlags.hfHostedInIEorWebOC) == 0)
- {
- // Explicitly trust only these zones...
- int sourceZone = AppSecurityManager.MapUrlToZone(BrowserInteropHelper.Source);
- if (sourceZone != NativeMethods.URLZONE_INTRANET && sourceZone != NativeMethods.URLZONE_TRUSTED &&
- sourceZone != NativeMethods.URLZONE_LOCAL_MACHINE)
- {
- // Enable explicit opt-out of this blocking.
- if (RegistryKeys.ReadLocalMachineBool(RegistryKeys.WPF_Hosting, RegistryKeys.value_UnblockWebBrowserControl) != true)
- {
- //[Using a resource string for another issue that's close enough in meaning.]
- throw new SecurityException(SR.Get(SRID.AffectedByMsCtfIssue, "http://go.microsoft.com/fwlink/?LinkID=168882"));
- }
- }
- }
- }
- else
- {
- // ClickOnce uses AppLaunch.exe to host partial-trust applications.
- string hostProcessName = Path.GetFileName(UnsafeNativeMethods.GetModuleFileName(new HandleRef()));
- if (string.Compare(hostProcessName, "AppLaunch.exe", StringComparison.OrdinalIgnoreCase) == 0)
- {
- // No explanation message is warranted in this case since it's not supported anyway.
- SecurityHelperPF.DemandWebBrowserPermission();
- }
- }
-
- RegisterWithRBW();
- }
-#endif
TurnOnFeatureControlKeys();
-
ControlsTraceLogger.AddControl(TelemetryControls.WebBrowser);
}
@@ -142,17 +101,7 @@ public WebBrowser()
(new WebBrowserPermission(WebBrowserPermissionLevel.Safe)).Demand();
}
-#if NETFX
- // If the webbrowser permission is restricted, we don't allow webbrowser to be inside Popup.
- if (IsWebOCPermissionRestricted)
- {
- Loaded += new RoutedEventHandler(LoadedHandler);
- }
- _hostingAdaptor = IsWebOCHostedInBrowserProcess ?
- new WebOCHostedInBrowserAdaptor(this) : new WebOCHostingAdaptor(this);
-#else
_hostingAdaptor = new WebOCHostingAdaptor(this);
-#endif
}
#endregion Constructor
@@ -527,11 +476,8 @@ public object ObjectForScripting
if (value != null)
{
Type t = value.GetType();
-#if NETFX
- if (!System.Runtime.InteropServices.Marshal.IsTypeVisibleFromCom(t))
-#else
+
if (!System.Runtime.InteropServices.MarshalLocal.IsTypeVisibleFromCom(t))
-#endif
{
throw new ArgumentException(SR.Get(SRID.NeedToBeComVisible));
}
@@ -823,27 +769,6 @@ internal Guid LastNavigation
}
}
- internal static bool IsWebOCHostedInBrowserProcess
- {
- get
- {
-#if NETFX
- if(!IsWebOCPermissionRestricted)
- return false;
- HostingFlags hf = BrowserInteropHelper.HostingFlags;
- return (hf & HostingFlags.hfHostedInIE) != 0
- || // Backup condition in case the low-integrity IE process is compromised.
- // The hfHostedInIE flag cannot be trusted, because it's derived by talking to code
- // in the IE process. (Theretically, one could pretend to be our Mozilla plugin by
- // creating a similar hosting envrionment within IE! Then no IWebBrowser...)
- // But hfIsBrowserLowIntegrityProcess is reliable because it's determined externally.
- (hf & HostingFlags.hfIsBrowserLowIntegrityProcess) != 0;
-#else
- return false;
-#endif
- }
- }
-
#endregion Internal Properties
//----------------------------------------------
@@ -884,17 +809,6 @@ private void LoadedHandler(object sender, RoutedEventArgs args)
}
}
- private static void RegisterWithRBW()
- {
-#if NETFX
- // if we are browser hosted, rbw should have been created here.
- // what if RootBrowserWindow is null.
- if (RootBrowserWindow != null)
- {
- RootBrowserWindow.AddLayoutUpdatedHandler();
- }
-#endif
- }
// Turn on all the WebOC Feature Control Keys implementing various security mitigations.
// Whenever possible, we do it programmatically instead of adding reg-keys so that these are on on all WPF apps.
@@ -980,19 +894,6 @@ private static void TurnOnFeatureControlKeys()
UnsafeNativeMethods.CoInternetSetFeatureEnabled( NativeMethods.FEATURE_DISABLE_LEGACY_COMPRESSION, NativeMethods.SET_FEATURE_ON_PROCESS, true ) ;
UnsafeNativeMethods.CoInternetSetFeatureEnabled( NativeMethods.FEATURE_DISABLE_TELNET_PROTOCOL, NativeMethods.SET_FEATURE_ON_PROCESS, true ) ;
-#if NETFX
- // For use of the WebOC in stand-alone applications and full-trust XBAPs, we don't want to
- // impact existing behavior causing potential different layout due to the appearance of
- // address bar and status bar. We therefore only apply the following flag where the spoofing
- // threat is the most relevant, when restricted permissions apply.
- if (IsWebOCPermissionRestricted)
- {
- UnsafeNativeMethods.CoInternetSetFeatureEnabled( NativeMethods.FEATURE_FORCE_ADDR_AND_STATUS, NativeMethods.SET_FEATURE_ON_PROCESS, true ) ;
- }
-#endif
-
- // The relevant IE 8 FCKs are applied only in the registry because they don't work through the API.
- // We are trying to change this unfortunate trend. .
}
private void DoNavigate(Uri source, ref object targetFrameName, ref object postData, ref object headers, bool ignoreEscaping = false)
@@ -1156,33 +1057,6 @@ protected override bool TabIntoCore(TraversalRequest request)
#endregion Private Methods
- //----------------------------------------------
- //
- // Private Properties
- //
- //----------------------------------------------
-
- #region Private Properties
-
-#if NETFX
- private static RootBrowserWindow RootBrowserWindow
- {
- get
- {
- if (_rbw.Value == null)
- {
- if (Application.Current != null)
- {
- _rbw.Value = Application.Current.MainWindow as RootBrowserWindow;
- }
- }
-
- return _rbw.Value;
- }
- }
-#endif
-
- #endregion Private Properties
//----------------------------------------------
//
@@ -1192,10 +1066,6 @@ private static RootBrowserWindow RootBrowserWindow
#region Private Fields
-#if NETFX
- private static readonly bool IsWebOCPermissionRestricted =
- !SecurityHelperPF.CallerAndAppDomainHaveUnrestrictedWebBrowserPermission();
-#endif
// Reference to the native ActiveX control's IWebBrowser2
// Do not reference this directly. Use the AxIWebBrowser2 property instead since that
@@ -1206,11 +1076,6 @@ private static RootBrowserWindow RootBrowserWindow
// To hook up events from the native WebBrowser
private ConnectionPointCookie _cookie;
-
-#if NETFX
- private static SecurityCriticalDataForSet _rbw;
-#endif
-
private object _objectForScripting;
private Stream _documentStream;
@@ -1240,6 +1105,9 @@ private static RootBrowserWindow RootBrowserWindow
/// the WebOC either in-process or in the browser process (when IsWebOCHostedInBrowserProcess==true).
/// This base class handles the in-process hosting.
///
+ ///
+ /// IsWebOCHostedInBrowserProcess property no longer exists since .NET Core 3.0
+ ///
internal class WebOCHostingAdaptor
{
internal WebOCHostingAdaptor(WebBrowser webBrowser)
@@ -1274,63 +1142,6 @@ internal virtual object CreateEventSink()
protected WebBrowser _webBrowser;
};
-#if NETFX
- ///
- /// Used when WebBrowser.IsWebOCHostedInBrowserProcess.
- ///
- private class WebOCHostedInBrowserAdaptor : WebOCHostingAdaptor
- {
- internal WebOCHostedInBrowserAdaptor(WebBrowser webBrowser) : base(webBrowser) { }
-
- static WebOCHostedInBrowserAdaptor()
- {
- // IDocHostUIHandler is not marshalable ... probably because no one has needed to use it
- // cross-thread. PresentationHostProxy.dll is compiled with a clone of it and contains
- // proxy-stub code for it. Registering the proxy-stub this way rather than in the registry
- // is cleaner because it applies only to our scenarios.
- // The same thing is done in the browser process, by our in-proc handler.
- Guid iidDHUIH = typeof(UnsafeNativeMethods.IDocHostUIHandler).GUID;
- Guid clsidPresHostProxy = new Guid("e302cb55-5f9d-41a3-9ef3-61827fb8b46d");
- int hr = UnsafeNativeMethods.CoRegisterPSClsid(ref iidDHUIH, ref clsidPresHostProxy);
- if (hr != NativeMethods.S_OK)
- {
- Marshal.ThrowExceptionForHR(hr);
- }
- }
-
- internal override object ObjectForScripting
- {
- get
- {
- return _threadBoundObjectForScripting;
- }
-
- set
- {
- _threadBoundObjectForScripting =
- value == null ? null : ActiveXHelper.CreateIDispatchSTAForwarder(value);
- }
- }
-
- internal override object CreateWebOC()
- {
- IntPtr pWebOC = Application.Current.BrowserCallbackServices.CreateWebBrowserControlInBrowserProcess();
- object webOC = Marshal.GetTypedObjectForIUnknown(pWebOC, typeof(UnsafeNativeMethods.IWebBrowser2));
- Marshal.Release(pWebOC);
- return webOC;
- }
-
- internal override object CreateEventSink()
- {
- return ActiveXHelper.CreateIDispatchSTAForwarder(
- (UnsafeNativeMethods.DWebBrowserEvents2)base.CreateEventSink());
- }
-
- // This is a native object that wraps the ObjectForScripting provided by the application
- // in order to ensure calls arrive on WebBrowser's thread.
- object _threadBoundObjectForScripting;
- };
-#endif
#endregion Private Class
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs
index 9d952bda465..b8bea5c7c05 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/BrowserInteropHelper.cs
@@ -33,7 +33,6 @@ public static class BrowserInteropHelper
{
static BrowserInteropHelper()
{
- SetBrowserHosted(false);
IsInitialViewerNavigation = true;
}
@@ -51,48 +50,20 @@ public static object ClientSite
object oleClientSite = null;
-#if NETFX
- if (IsBrowserHosted)
- {
- Application.Current.BrowserCallbackServices.GetOleClientSite(out oleClientSite);
- }
-#endif
return oleClientSite;
}
}
- public static dynamic HostScript
- {
- get
- {
- // Allows to disable script interop through the registry in partial trust code.
- EnsureScriptInteropAllowed();
-
- // IE's marshaling proxy for the HTMLWindow object doesn't work in MTA.
- Verify.IsApartmentState(ApartmentState.STA);
-
- IHostBrowser2 hb2 = HostBrowser as IHostBrowser2;
- if (hb2 == null)
- return null; // One possibility is we are running under NPWPF v3.5.
- try
- {
- var hostScriptObject = (UnsafeNativeMethods.IDispatch)hb2.HostScriptObject;
- if (hostScriptObject == null)
- return null;
-
- var scriptObject = new DynamicScriptObject(hostScriptObject);
-
- InitializeHostHtmlDocumentServiceProvider(scriptObject);
-
- return scriptObject;
- }
- catch (UnauthorizedAccessException)
- {
- return null;
- }
- }
- }
+ ///
+ /// Gets a script object that provides access to the HTML window object,
+ /// custom script functions, and global variables for the HTML page, if the XAML browser application (XBAP)
+ /// is hosted in a frame.
+ ///
+ ///
+ /// Starting .NET Core 3.0, XBAP's are not supported - will always return null
+ ///
+ public static dynamic HostScript => null;
///
/// Returns true if the app is a browser hosted app.
@@ -101,21 +72,7 @@ public static dynamic HostScript
/// Note that HostingFlags may not be set at the time this property is queried first.
/// That's why they are still separate. Also, this one is public.
///
- public static bool IsBrowserHosted
- {
- get
- {
- return _isBrowserHosted.Value;
- }
- }
-
- ///
- /// HostingFlags is set after this property.
- ///
- internal static void SetBrowserHosted(bool value)
- {
- _isBrowserHosted.Value = value;
- }
+ public static bool IsBrowserHosted => false;
internal static HostingFlags HostingFlags
{
@@ -147,19 +104,6 @@ internal static bool IsViewer
}
}
- ///
- /// Returns true if avalon it top level.
- /// Also returns true if not browser-hosted.
- ///
- internal static bool IsAvalonTopLevel
- {
- get
- {
- if (!IsBrowserHosted)
- return true;
- return (HostingFlags & HostingFlags.hfHostedInFrame) == 0;
- }
- }
///
/// Returns true if the host browser is IE or the WebOC hosted in a standalone application.
@@ -190,23 +134,6 @@ internal static bool IsInitialViewerNavigation
}
}
- internal static IHostBrowser HostBrowser;
-
- internal static void ReleaseBrowserInterfaces()
- {
- if (HostBrowser != null)
- {
- Marshal.ReleaseComObject(HostBrowser);
- HostBrowser = null;
- }
-
- if (_hostHtmlDocumentServiceProvider.Value != null)
- {
- Marshal.ReleaseComObject(_hostHtmlDocumentServiceProvider.Value);
- _hostHtmlDocumentServiceProvider.Value = null;
- }
- }
-
///
/// Retrieves the IServiceProvider object for the browser we're hosted in.
/// This is used for IDispatchEx operations in the script interop feature.
@@ -327,7 +254,6 @@ private static void EnsureScriptInteropAllowed()
}
}
- private static SecurityCriticalDataForSet _isBrowserHosted;
private static SecurityCriticalDataForSet _hostingFlags;
private static SecurityCriticalDataForSet _isInitialViewerNavigation;
private static SecurityCriticalDataForSet _isScriptInteropDisabled;
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DocobjHost.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DocobjHost.cs
deleted file mode 100644
index 3d138c01c93..00000000000
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DocobjHost.cs
+++ /dev/null
@@ -1,1329 +0,0 @@
-// 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:
-// Implements the type used for COM interop by the browser host
-//
-
-using System;
-
-#if NETFX
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.IO.Packaging;
-using System.Threading;
-using System.Net;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Runtime.Remoting;
-using System.Runtime.Remoting.Lifetime;
-using System.Security;
-using System.Security.Permissions;
-using System.Security.Policy;
-using System.Windows.Threading;
-using System.Windows.Navigation;
-using System.Xml;
-using Microsoft.Win32.SafeHandles;
-using MS.Internal.AppModel;
-using MS.Internal.IO.Packaging;
-using MS.Internal.Progressivity;
-using MS.Internal.Utility;
-using MS.Utility;
-using MS.Win32;
-using MS.Internal;
-using System.Text;
-using System.Windows.Input;
-using Microsoft.Win32;
-#endif
-
-//In order to avoid generating warnings about unknown message numbers and
-//unknown pragmas when compiling your C# source code with the actual C# compiler,
-//you need to disable warnings 1634 and 1691. (Presharp Documentation)
-#pragma warning disable 1634, 1691
-
-namespace System.Windows.Interop
-{
-#if NETFX
- ///
- /// Interop class used for implementing the managed part of a DocObj Server for browser hosting
- ///
- public sealed class DocObjHost : MarshalByRefObject, IServiceProvider, IHostService,
- IBrowserHostServices, IByteRangeDownloaderService
- {
- ///
- /// This is only exposed publically for interop with the browser.
- /// This is not secure for partial trust.
- ///
- ///
- /// Callers must have UnmanagedCode permission to call this API.
- ///
- public DocObjHost()
- {
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_DocObjHostCreated);
-
- SecurityHelper.DemandUnmanagedCode();
-
- _mainThread = Thread.CurrentThread;
- _initData.Value.ServiceProvider = this;
-
- // Thread.ApartmentState is [Obsolete]
- #pragma warning disable 0618
-
- Debug.Assert(_mainThread.ApartmentState == ApartmentState.STA);
-
- #pragma warning restore 0618
- }
-
- #region Private Data
-
- private Thread _mainThread;
- private ApplicationProxyInternal _appProxyInternal;
- private SecurityCriticalDataForSet _initData =
- new SecurityCriticalDataForSet(new ApplicationProxyInternal.InitData());
- private IntPtr _parent;
- private IBrowserCallbackServices _browserCallbackServices;
- private Object _downloader; // byte range downloader
-
- #endregion Private Data
-
- //******************************************************************************
- //
- // MarshalByRef override
- //
- //******************************************************************************
-
- ///
- /// Return the ILease object, specifying that the lease should never expire
- ///
- /// A new ILease object
- public override object InitializeLifetimeService()
- {
- ILease lease = (ILease)base.InitializeLifetimeService();
- Debug.Assert(lease.CurrentState == LeaseState.Initial);
-
- (new SecurityPermission(PermissionState.Unrestricted)).Assert(); //BlessedAssert
- try
- {
- lease.InitialLeaseTime = TimeSpan.Zero; // infinite -- never expire
- }
- finally
- {
- CodeAccessPermission.RevertAssert();
- }
-
- return lease;
- }
-
- #region IServiceProvider
- //******************************************************************************
- //
- // IServiceProvider interface implementation
- //
- //******************************************************************************
-
- ///
- /// Provides IHostService, IBrowserHostService
- ///
- object IServiceProvider.GetService(Type serviceType)
- {
- if (serviceType == typeof(IHostService))
- {
- return this;
- }
- else if (serviceType == typeof(IBrowserCallbackServices))
- {
- return _browserCallbackServices;
- }
- return null;
- }
- #endregion IServiceProvider
-
- #region IHostService
- //******************************************************************************
- //
- // IHostService interface implementation
- //
- //******************************************************************************
-
- //
- // Get the proxy for the RootBrowserWindow.
- // CAUTION: This forces the RBW to be created.
- //
- [DebuggerBrowsable(DebuggerBrowsableState.Never)]
- RootBrowserWindowProxy IHostService.RootBrowserWindowProxy
- {
- get
- {
- return (_appProxyInternal == null) ? null : _appProxyInternal.RootBrowserWindowProxy;
- }
- }
-
- //
- // ParentHandle of the host window
- //
- IntPtr IHostService.HostWindowHandle
- {
- get { return _parent; }
- }
- #endregion IHostService
-
- #region IBrowserHostServices
- //******************************************************************************
- //
- // IBrowserHostServices interface implementation
- //
- //******************************************************************************
-
- ///
- /// Loads and runs the application or document based on the parameters passed in
- ///
- /// Path to XBAP deployment manifest, XPS document, or loose XAML file
- /// any URL #fragment (passed separately by the browser)
- /// Mime type of the content we are trying to load
- /// "fake" site-of-origin URL for debugging
- /// ClickOnce application id (for XBAPs)
- /// Marshaled IStream representing the current bind that we want to reuse
- /// PersistHistory load stream
- ///
- /// assembly name from which to load a custom deployment progress page
- /// class implementing IProgressPage
- /// assembly name from which to load a custom deployment error page
- ///
- /// Int indicating whether the exit code of the application, failure could also
- /// mean that the app was not lauched successfully
- int IBrowserHostServices.Run(
- String path,
- String fragment,
- MimeType mime,
- String debugSecurityZoneURL,
- String applicationId,
- object streamContainer,
- object ucomLoadIStream,
- HostingFlags hostingFlags,
- INativeProgressPage nativeProgressPage,
- string progressAssemblyName,
- string progressClassName,
- string errorAssemblyName,
- string errorClassName,
- IHostBrowser hostBrowser
- )
- {
- Invariant.Assert(String.IsNullOrEmpty(path) == false, "path string should not be null or empty when Run method is called.");
- Invariant.Assert(mime != MimeType.Unknown, "Unknown mime type");
-
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_IBHSRunStart, "\""+path+"\"", "\""+applicationId+"\"");
-
- int exitCode = 0;
-
- try
- {
- ApplicationProxyInternal.InitData initData = _initData.Value;
- initData.HostBrowser = hostBrowser;
- initData.Fragment = fragment;
- initData.UcomLoadIStream = ucomLoadIStream;
- initData.HandleHistoryLoad = true;
- initData.MimeType.Value = mime;
-
- // Installing .NET 4.0 adds two parts to the user agent string, i.e.
- // .NET4.0C and .NET4.0E, potentially causing the user agent string to overflow its
- // documented maximum length of MAX_PATH. While the right place to fix this is in
- // HostBrowserIE::GetUserAgentString in PresentationHostProxy, shared components
- // turn out hard to patch after the fact, so we do a spot-fix here in case we're
- // running in IE.
- string userAgent = null;
- MS.Internal.Interop.HRESULT hr = hostBrowser.GetUserAgentString(out userAgent); // get it only once for both AppDomains
- if (hr == MS.Internal.Interop.HRESULT.E_OUTOFMEMORY && (hostingFlags & HostingFlags.hfHostedInIEorWebOC) != 0)
- {
- userAgent = MS.Win32.UnsafeNativeMethods.ObtainUserAgentString();
- hr = MS.Internal.Interop.HRESULT.S_OK;
- }
- hr.ThrowIfFailed();
-
- initData.UserAgentString = userAgent;
- initData.HostingFlags = hostingFlags;
-
- Uri activationUri = new UriBuilder(path).Uri;
- initData.ActivationUri.Value = activationUri;
- PresentationAppDomainManager.ActivationUri = activationUri;
-
- // We do this here so that it will be set correctly when our deployment application
- // launches. This matters because if it isn't set when the app ctor is run, then
- // we will call Dispatcher.Run synchronously, which will make the browser
- // unresponsive.
- BrowserInteropHelper.SetBrowserHosted(true);
-
- if ((hostingFlags & HostingFlags.hfInDebugMode) != 0)
- {
- _browserCallbackServices.ChangeDownloadState(false); // stop waving the flag
- _browserCallbackServices.UpdateProgress(-1, 0); // make the progress bar go away
- EnableErrorPage();
- _appProxyInternal = new ApplicationLauncherXappDebug(path, debugSecurityZoneURL).Initialize();
- }
- else
- {
- switch (mime)
- {
- case MimeType.Document:
-
- _appProxyInternal = CreateAppDomainForXpsDocument();
- if (_appProxyInternal == null)
- {
- exitCode = -1;
- }
- else
- {
- if (streamContainer != null)
- {
- IntPtr punk = Marshal.GetIUnknownForObject(streamContainer);
- _appProxyInternal.StreamContainer = punk;
- Marshal.Release(punk);
- }
- }
- // Free objects (after the _appProxyInternal.Run(initData) call below).
- // For the other MIME types, this is done in RunApplication().
- _initData.Value = null;
- break;
-
- case MimeType.Markup:
- _appProxyInternal = CreateAppDomainForLooseXaml(activationUri);
- _initData.Value = null; // Not needed anymore.
- break;
-
- case MimeType.Application:
- // This is a browser hosted express app scenario.
- // Setup XappLauncherApp with default values, and instantiate
- // ApplicationProxyInternal for this AppDomain.
- XappLauncherApp application = new XappLauncherApp(activationUri, applicationId,
- _browserCallbackServices, new ApplicationRunnerCallback(RunApplication),
- nativeProgressPage,
- progressAssemblyName, progressClassName, errorAssemblyName, errorClassName);
-
- // No need to handle history for progress app. Remember
- // it for the real app.
- initData.HandleHistoryLoad = false;
-
- _appProxyInternal = new ApplicationProxyInternal();
- break;
-
- default:
- exitCode = -1;
- break;
- }
- }
- if (exitCode != -1)
- {
- if (mime == MimeType.Document || mime == MimeType.Markup)
- {
- //[ChangoV, 7/27/07]
- // Unfortunately, XPSViewer relies on the unhandled exception page to report bad XAML.
- // Ideally, only exceptions from the XamlReader should be caught and shown this way,
- // in order not to hide platform bugs. But it's more than one place where XAML is
- // loaded from the XPS package, and in more than one way. A little too much to change
- // in SP1.
- // For loose XAML viewing, most exceptions likely to occur from this point on should be
- // due to bad XAML.
- EnableErrorPage();
- }
-
- //
- // This mitigates failures in XBAP deployment and XPSViewer caused by msctf.dll
- // by showing an actionable message instead of crashing
- // deep inside the Input code where MSCTF gets loaded and fails to do so. More info on the
- // conditions leading to this bug and how we detect those can be found in the method used
- // for the check below and in the TFS bug database.
- // See KB article http://support.microsoft.com/kb/954494 (linked in the displayed message).
- if (IsAffectedByCtfIssue())
- {
- exitCode = -1;
- _browserCallbackServices.ProcessUnhandledException(
- String.Format(
- CultureInfo.CurrentCulture,
- SR.Get(SRID.AffectedByMsCtfIssue),
- "http://support.microsoft.com/kb/954494"
- )
- );
- }
- else
- {
- exitCode = _appProxyInternal.Run(initData);
- }
- }
- }
- catch (Exception ex)
- {
- exitCode = -1;
- // The exception is re-thrown here, but it will get translated to an HRESULT by
- // COM Interop. That's why ProcessUnhandledException() is called directly.
- // In most cases it runs a modal loop around the error page and never returns.
- _browserCallbackServices.ProcessUnhandledException(ex.ToString());
- throw;
- }
- catch
- {
- // This catches non-CLS compliant exceptions.
- // Not having this clause triggers an FxCop violation.
- exitCode = -1;
- _browserCallbackServices.ProcessUnhandledException(SR.Get(SRID.NonClsActivationException));
- throw;
- }
- finally
- {
- Cleanup(exitCode);
- }
-
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_IBHSRunEnd, exitCode);
-
- return exitCode;
- }
-
- ///
- /// Checks for the conditions in which bug 451830 affects browser-hosted applications.
- ///
- /// true if the configuration is affected; false if not.
- private bool IsAffectedByCtfIssue()
- {
- // There's an issue in MSCTF.dll (Language Bar supporting DLL) that affects Windows XP users
- // when the language bar is enabled and a security policy known as "Security objects: Default
- // owner for objects created by members of the Administrators group" is set to (the non-default)
- // value of "Administrators group". Because PresentationHost.exe emulates Vista's UAC feature
- // on XP it strips down the process token, removing the Administrators group from it. This
- // causes calls within MSCTF.dll to fail when acquiring access to shared memory and mutexes
- // required for the operation of the language bar (see windows\advcore\ctf\inc\cicmutex.h),
- // which causes DllMain to fail, turning XBAPs that use Input features useless.
- //
- // Note: We tried detouring the affected function CreateFileMapping but it turned out other
- // calls to CreateMutex were involved to create mutexes to protect the shared memory.
- // Unfortunately the resulting language bar was not in a usable state due to broken
- // input switching. This would be even more obscure than the original behavior so we
- // opt for detection logic instead, pointing at the KB article.
-
- OperatingSystem os = Environment.OSVersion;
- if (os.Version.Major == 5 && os.Version.Minor == 1)
- {
- //
- // MSCTF.dll gets loaded by the WPF Text stack in two cases (which reflect the presence
- // of the language bar):
- // * TextServicesLoader.ServicesInstalled (special IME present)
- // * InputLanguageManager.IsMultipleKeyboardLayout (multiple keyboard layouts available)
- //
- if (TextServicesLoader.ServicesInstalled ||
- InputLanguageManager.IsMultipleKeyboardLayout)
- {
- //
- // The registry value queried below is the one set by the aformentioned policy setting.
- // This value can be controlled through group policy and requires a reboot or logoff/
- // logon cycle in order to become effective. Therefore just changing this value will
- // make the following check pass while still causing the application to crash because
- // the objects used by MSCTF.dll will have been created at the time the policy was in
- // effect, causing the owner of the created objects to be set to the Administrators
- // group.
- //
- using (RegistryKey lsaKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Lsa"))
- {
- if ((int)lsaKey.GetValue("NoDefaultAdminOwner", 1) == 0)
- {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- internal delegate bool ApplicationRunner();
- internal delegate void ApplicationRunnerCallback(ApplicationRunner runner);
-
- //
- // This method is invoked by the callback that occurs when the download of the app is complete, so that
- // running the main application happens on the correct thread.
- //
- internal void RunApplication(ApplicationRunner runner)
- {
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_DocObjHostRunApplicationStart);
-
- // Run the App in the new AppDomain and ask the AppDomainManager
- // to save it.
- PresentationAppDomainManager.SaveAppDomain = true;
-
- EnableErrorPage();
-
- if (runner())
- {
- Invariant.Assert(PresentationAppDomainManager.NewAppDomain != null, "Failed to start the application in a new AppDomain");
-
- Invariant.Assert(ApplicationProxyInternal.Current != null, "Unexpected reentrant PostShutdown?");
-
- // Create an ApplicationProxyInternal in the new domain.
- PresentationAppDomainManager appDomainMgrProxy =
- PresentationAppDomainManager.NewAppDomain.DomainManager as PresentationAppDomainManager;
-
- // And replace _appProxyInternal.
- Invariant.Assert(ApplicationProxyInternal.Current == _appProxyInternal,
- "AppProxyInternal has shut down unexpectedly.");
- _appProxyInternal = appDomainMgrProxy.CreateApplicationProxyInternal();
-
- PresentationAppDomainManager.SaveAppDomain = false;
-
- // Run the app.
- ApplicationProxyInternal.InitData initData = _initData.Value;
- initData.HandleHistoryLoad = true;
- _appProxyInternal.Run(initData);
- _initData.Value = null; // free objects
- }
- else
- {
- // Cached application activation failed
- // we will give the app launcher a chance to retry with Uri activation
- PresentationAppDomainManager.SaveAppDomain = false;
- }
-
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_DocObjHostRunApplicationEnd);
- }
-
- //
- // Sets up the interface that the Windows Client host can use to talk back to the browser
- //
- //
- void IBrowserHostServices.SetBrowserCallback(object browserCallbackServices)
- {
- Invariant.Assert(browserCallbackServices != null, "Browser interop interface passed in should not be null");
- _browserCallbackServices = (IBrowserCallbackServices)browserCallbackServices;
- }
-
- //
- // Set the parent window of the host window
- //
- //
- ///
- void IBrowserHostServices.SetParent(IntPtr hParent)
- {
- _parent = hParent;
- // This is not a top-level window to be a proper owner, but at this time it may not be attached yet,
- // so we'll look for the root window later on.
- PresentationHostSecurityManager.ElevationPromptOwnerWindow = hParent;
- }
-
- //
- // Show or hide view
- //
- //
- //
- void IBrowserHostServices.Show(bool show)
- {
- if (_initData.Value != null)
- {
- _initData.Value.ShowWindow = show;
- }
-
- if (_appProxyInternal != null)
- {
- _appProxyInternal.Show(show);
- }
- }
-
- //
- // For shdocvw LoadHistory support
- //
- //
- bool IBrowserHostServices.IsAppLoaded()
- {
- return (_appProxyInternal == null) ? false : _appProxyInternal.IsAppLoaded();
- }
-
- //
- // The application sets the Environment.ExitCode to the applications exit code set by
- // calling Shutdown(exitCode) or in the ShutdownEventArgs
- //
- // Environment.ExitCode set by the application object when it Shutdown
- int IBrowserHostServices.GetApplicationExitCode()
- {
- return Environment.ExitCode;
- }
-
- bool IBrowserHostServices.CanInvokeJournalEntry(int entryId)
- {
- bool canInvoke = false;
-
- if ((this as IBrowserHostServices).IsAppLoaded() == false)
- {
- canInvoke = false;
- }
- else
- {
- canInvoke = _appProxyInternal.CanInvokeJournalEntry(entryId);
- }
-
- return canInvoke;
- }
-
- //
- // IPersistHistory.SaveHistory implementation called
- // when hosted in the browser
- //
- // The native stream to save the journal information
- // GCHandle to the saved byte array
-
- void IBrowserHostServices.SaveHistory(object comIStream,
- bool persistEntireJournal,
- out int entryIndex,
- out string uri,
- out string title)
- {
- if (_appProxyInternal != null)
- {
- SaveHistoryHelper(comIStream, persistEntireJournal, out entryIndex, out uri, out title);
- }
- else
- {
- entryIndex = -1;
- uri = null;
- title = null;
- }
- }
-
- //
- // IPersistHistory::LoadHistory implementation called
- // when hosted in the browser
- //
- //
- void IBrowserHostServices.LoadHistory(object ucomIStream)
- {
- if (_appProxyInternal != null)
- {
- LoadHistoryHelper(ucomIStream, /*firstHistoryLoad=*/false);
- }
- }
-
- //
- // IOleCommandTarget::QueryStatus called when hosted in the browser
- //
- ///
- /// OleCmdHelper reports errors by throwing ComException. The interop layer takes the
- /// associated HRESULT and returns it to the native caller. However, to avoid throwing exceptions
- /// on startup, while _appProxyInternal is not set up yet, this method is marked as [PreserveSig]
- /// and directly returns an error HRESULT.
- ///
- int IBrowserHostServices.QueryStatus(Guid guidCmdGroup, uint command, out uint flags)
- {
- flags = 0;
- if (_appProxyInternal != null)
- {
- OleCmdHelper cmdHelper = _appProxyInternal.OleCmdHelper;
- if (cmdHelper != null)
- {
- cmdHelper.QueryStatus(guidCmdGroup, command, ref flags);
- return NativeMethods.S_OK;
- }
- }
- return OleCmdHelper.OLECMDERR_E_UNKNOWNGROUP;
- }
-
- //
- // IOleCommandTarget::Exec called when hosted in the browser
- //
- ///
- /// OleCmdHelper reports errors by throwing ComException. The interop layer takes the
- /// associated HRESULT and returns it to the native caller. However, to avoid throwing exceptions
- /// on startup, while _appProxyInternal is not set up yet, this method is marked as [PreserveSig]
- /// and directly returns an error HRESULT.
- ///
- int IBrowserHostServices.ExecCommand(Guid guidCommandGroup, uint command, object arg)
- {
- // When the native progress page is active, there is no RootBrowserWindow to handle the Refresh
- // and Stop commands. That's why they are dispatched directly here. Of course, this will also
- // handle some cases when the RBW is shown, for example Refresh (coming from the browser) when the
- // deployment failed/canceled page is shown.
- XappLauncherApp launcherApp = Application.Current as XappLauncherApp;
- if (launcherApp != null && guidCommandGroup == Guid.Empty)
- {
- switch ((UnsafeNativeMethods.OLECMDID)command)
- {
- case UnsafeNativeMethods.OLECMDID.OLECMDID_REFRESH:
- launcherApp.HandleRefresh();
- return NativeMethods.S_OK;
- case UnsafeNativeMethods.OLECMDID.OLECMDID_STOP:
- launcherApp.UserStop();
- return NativeMethods.S_OK;
- }
- }
-
- if (_appProxyInternal != null)
- {
- OleCmdHelper cmdHelper = _appProxyInternal.OleCmdHelper;
- if (cmdHelper != null)
- {
- cmdHelper.ExecCommand(guidCommandGroup, command, arg);
- return NativeMethods.S_OK;
- }
- }
- return OleCmdHelper.OLECMDERR_E_UNKNOWNGROUP;
- }
-
- //
- // Move -- standard args
- //
- //
- //
- //
- //
- void IBrowserHostServices.Move(int x, int y, int width, int height)
- {
- Rect windowRect = new Rect(x, y, width, height);
-
- // Remember the size and position of the browser window. We'll need
- // to use this in the case of .deploy app where we need to size it
- // after creating it. Otherwise the window won't render till we resize.
- // i. _initData is null after the application is started.
- if (_initData.Value != null)
- {
- _initData.Value.WindowRect = windowRect;
- }
-
- if (_appProxyInternal != null)
- {
- _appProxyInternal.Move(windowRect);
- }
- }
-
- void IBrowserHostServices.PostShutdown()
- {
- EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_PostShutdown);
-
- if (_appProxyInternal != null)
- {
- _appProxyInternal.PostShutdown();
- }
-
- // AppProxyInternal does this, but we need to make sure the one in the default AppDomain gets
- // released too.
- BrowserInteropHelper.ReleaseBrowserInterfaces();
- }
-
- //
- // Tell the app to activate/deactivate root browser window
- //
- // Activate or Deactivate browser window
- void IBrowserHostServices.Activate(bool fActivate)
- {
- if (_appProxyInternal != null)
- {
- _appProxyInternal.Activate(fActivate);
- }
- }
-
- void IBrowserHostServices.TabInto(bool forward)
- {
- // Don't let the RBW be created while the native progress page is shown. Doing so would shut down
- // the progress page prematurely.
- if (!_appProxyInternal.RootBrowserWindowCreated)
- return;
-
- _appProxyInternal.RootBrowserWindowProxy.TabInto(forward);
- }
-
- bool IBrowserHostServices.FocusedElementWantsBackspace()
- {
- return _appProxyInternal != null ? _appProxyInternal.FocusedElementWantsBackspace() : false;
- }
- #endregion IBrowserHostServices
-
- #region ByteRangeDownloader
-
- ///
- /// Initialize the downloader for byte range request
- ///
- /// url to be downloaded
- /// temporary file where the downloaded bytes should be saved
- /// event handle to be raised when a byte range request is done
- void IByteRangeDownloaderService.InitializeByteRangeDownloader(
- String url,
- String tempFile,
- SafeWaitHandle eventHandle)
- {
- if (url == null)
- {
- throw new ArgumentNullException("url");
- }
-
- if(tempFile == null)
- {
- throw new ArgumentNullException("tempFile");
- }
-
- if(eventHandle == null)
- {
- throw new ArgumentNullException("eventHandle");
- }
-
- if (eventHandle.IsInvalid || eventHandle.IsClosed)
- {
- throw new ArgumentException(SR.Get(SRID.InvalidEventHandle), "eventHandle");
- }
-
- Uri requestedUri = new Uri(url, UriKind.Absolute);
-
- if(tempFile.Length <= 0)
- {
- throw new ArgumentException(SR.Get(SRID.InvalidTempFileName), "tempFile");
- }
-
- ByteRangeDownloader loader = new ByteRangeDownloader(requestedUri, tempFile, eventHandle);
-
- // We defined _downloader as Object for performance reasons. If we define it as ByteRangeDownloader the whole
- // class will be loaded although it might not be used at all. By declaring it as Object we can prevent it
- // from being loaded. This technique is used in other areas.
- _downloader = (Object) loader;
- }
-
- ///
- /// Make HTTP byte range web request
- ///
- /// byte ranges to be downloaded; byteRanges is one dimensional
- /// array consisting pairs of offset and length
- /// number of elements in byteRanges
- void IByteRangeDownloaderService.RequestDownloadByteRanges (int[] byteRanges, int size)
- {
- //
- // Because of COM Interop Marshalling, we use made byte ranges as one dimensional array
- // However, since they are pairs of offset and length, it makes more sense to convert
- // them into two dimensional array in Managed code
- //
- if (byteRanges == null)
- {
- throw new ArgumentNullException("byteRanges");
- }
-
- if (byteRanges.Length <= 0 || (byteRanges.Length % 2) != 0)
- {
- throw new ArgumentException(SR.Get(SRID.InvalidByteRanges, "byteRanges"));
- }
-
- if (_downloader == null)
- {
- throw new InvalidOperationException(SR.Get(SRID.ByteRangeDownloaderNotInitialized));
- }
-
- ((ByteRangeDownloader) _downloader).RequestByteRanges(ByteRangeDownloader.ConvertByteRanges(byteRanges));
- }
-
- ///
- /// Get the byte ranges that are downloaded
- ///
- /// byte ranges that are downloaded; byteRanges is one dimensional
- /// array consisting pairs of offset and length
- /// size of byteRanges
- void IByteRangeDownloaderService.GetDownloadedByteRanges (out int[] byteRanges, out int size)
- {
- //
- // Because of COM Interop Marshalling, we use made byte ranges as one dimensional array
- // However, since they are pairs of offset and length, it makes more sense to convert
- // them into two dimensional array in Managed code
- //
-
- size = 0;
- byteRanges = null;
-
- if (_downloader == null)
- {
- throw new InvalidOperationException(SR.Get(SRID.ByteRangeDownloaderNotInitialized));
- }
-
- int[,] ranges = ((ByteRangeDownloader) _downloader).GetDownloadedByteRanges();
- byteRanges = ByteRangeDownloader.ConvertByteRanges(ranges);
- size = byteRanges.Length;
- }
-
- ///
- /// Release the byte range downloader
- ///
- void IByteRangeDownloaderService.ReleaseByteRangeDownloader ()
- {
- if (_downloader == null)
- {
- throw new InvalidOperationException(SR.Get(SRID.ByteRangeDownloaderNotInitialized));
- }
-
- ((IDisposable) _downloader).Dispose();
- _downloader = null;
- }
-
- #endregion ByteRangeDownloader
-
- #region Private Helper Methods
-
- #region Security Helpers
-
- private ApplicationProxyInternal CreateAppDomainForXpsDocument()
- {
- // Create the app domain using a restricted set of permissions, which are a subset of the
- // typical "Internet Zone" permissions.
- // (Explicitly, we leave out Web Browser permissions, and we only support SafeImages)
- PermissionSet permissionSet = new PermissionSet(null);
- permissionSet.AddPermission(new FileDialogPermission(FileDialogPermissionAccess.Open));
- permissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
- permissionSet.AddPermission(new UIPermission(UIPermissionWindow.SafeTopLevelWindows));
- permissionSet.AddPermission(new UIPermission(UIPermissionClipboard.OwnClipboard));
- permissionSet.AddPermission(new MediaPermission(MediaPermissionImage.SafeImage));
-
- // Set up IsolatedStorage permissions:
- // We allow 20mb of storage space and we isloate the storage on a per domain basis, by user.
- IsolatedStorageFilePermission storagePermission = new IsolatedStorageFilePermission(PermissionState.Unrestricted);
- storagePermission.UsageAllowed = IsolatedStorageContainment.DomainIsolationByUser;
- storagePermission.UserQuota = GetXpsViewerIsolatedStorageUserQuota();
- permissionSet.AddPermission(storagePermission);
-
- return CreateAppDomainAndAppProxy("WCP_Hosted_Application", GetXPSViewerPath(), permissionSet);
- }
-
- private ApplicationProxyInternal CreateAppDomainForLooseXaml(Uri uri)
- {
- /*
- The permission set for the XamlViewer AppDomain is similar to the default for the "Internet"
- security zone. Differences:
- - No IsolatedStorageFilePermission.
- - A site-of-origin permission is added so that the document and any other resources referenced
- by it can be loaded.
-
- FileDialogPermission and UIPermissionWindow.SafeTopLevelWindows shouldn't be needed for loose XAML
- viewing, but they are included for compatibility with the old XamlViewer.xbap.
- */
- PermissionSet permissionSet = new PermissionSet(null);
- permissionSet.AddPermission(new FileDialogPermission(FileDialogPermissionAccess.Open));
- permissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
- permissionSet.AddPermission(new UIPermission(UIPermissionWindow.SafeTopLevelWindows));
- permissionSet.AddPermission(new UIPermission(UIPermissionClipboard.OwnClipboard));
- permissionSet.AddPermission(SystemDrawingHelper.NewSafePrintingPermission());
- permissionSet.AddPermission(new MediaPermission(MediaPermissionAudio.SafeAudio, MediaPermissionVideo.SafeVideo, MediaPermissionImage.SafeImage));
- permissionSet.AddPermission(new WebBrowserPermission(WebBrowserPermissionLevel.Safe));
-
- permissionSet = PresentationHostSecurityManager.AddPermissionForUri(permissionSet, uri);
-
- // Setting AppDomain.ApplicationBase to some safe location is important. That's where assembly
- // lookup is done. We don't want to allow loading arbitrary assemblies in partial trust.
- // XamlViewer.xbap is defunct, but we still construct a path to where it used to be, just because
- // we need some path.
- string xamlViewer = "XamlViewer";
- // This GetModuleFileName() throws on error.
- string PHDLLPath = UnsafeNativeMethods.GetModuleFileName(new HandleRef(null, UnsafeNativeMethods.GetModuleHandle(ExternDll.PresentationHostDll)));
- string appBase = Path.GetDirectoryName(PHDLLPath) + "\\" + xamlViewer;
-
- return CreateAppDomainAndAppProxy(xamlViewer, appBase, permissionSet);
- }
-
- private ApplicationProxyInternal CreateAppDomainAndAppProxy(string domainName, string appBasePath, PermissionSet grantSet)
- {
- AppDomainSetup domainSetup = new AppDomainSetup();
- Invariant.Assert(!string.IsNullOrEmpty(appBasePath));
- domainSetup.ApplicationBase = appBasePath;
- AppDomain appDomain = AppDomain.CreateDomain(domainName, null, domainSetup, grantSet, null);
- return ((PresentationAppDomainManager)appDomain.DomainManager).CreateApplicationProxyInternal();
- }
-
-
- #endregion Security Helpers
-
- private void Cleanup(int exitCode)
- {
- //No error => don't cleanup
- if (exitCode == 0)
- return;
-
- // You need to explicitly release the COM object. The RCW doesn't
- // seem to get garbage collected automatically.
- //
- // We don't want to call release multiple times. So call either
- // on the App or on the Docobj since the ServiceProvider setter
- // release the _browserCallbackServices com object
- if (_appProxyInternal != null)
- {
- _appProxyInternal.Cleanup();
- }
- else if (_browserCallbackServices != null)
- {
- Marshal.ReleaseComObject(_browserCallbackServices);
- _browserCallbackServices = null;
- }
- }
-
- // IPersistHistory::SaveHistory implementation called
- // when hosted in the browser
- // GCHandle to the saved byte array
-
- private void SaveHistoryHelper(object comIStream,
- bool persistEntireJournal,
- out int entryIndex,
- out string uri,
- out string title)
- {
- //out params need to be initialized before control leaves this method (CS0177)
- uri = title = null;
- entryIndex = -1;
-
- // If the ApplicationProxyInternal object is in the default AppDomain, we are not yet
- // running the real applicaiton, so there is no journal to persist.
- if (_appProxyInternal == null || !RemotingServices.IsTransparentProxy(_appProxyInternal))
- {
- return;
- }
-
- SecuritySuppressedIStream historyStream = comIStream as SecuritySuppressedIStream;
- //CONSIDER: Should throw an exception instead?
- if (historyStream == null)
- return;
-
- byte [] saveByteArray = _appProxyInternal.GetSaveHistoryBytes( persistEntireJournal,
- out entryIndex,
- out uri,
- out title);
-
- if (saveByteArray == null)
- return;
-
- int len = saveByteArray.Length;
- int bytesWritten = 0;
- historyStream.Write(saveByteArray, len, out bytesWritten);
- Invariant.Assert(bytesWritten == len, "Error saving journal stream to native IStream");
- }
-
- // IPersistHistory::LoadHistory implementation called
- // when hosted in the browser
- //
- private void LoadHistoryHelper(object comIStream, bool firstLoadFromHistory)
- {
- if (_appProxyInternal == null)
- {
- return;
- }
-
- _appProxyInternal.LoadHistoryStream(ExtractComStream(comIStream), firstLoadFromHistory);
- }
-
- internal static MemoryStream ExtractComStream(object comIStream)
- {
- SecuritySuppressedIStream historyStream = comIStream as SecuritySuppressedIStream;
- if (historyStream == null)
- {
- throw new ArgumentNullException("comIStream");
- }
-
- MemoryStream loadStream = new MemoryStream();
- byte[] loadByteArray = new byte[1024];
- int bytesRead = 0;
-
- do
- {
- bytesRead = 0;
- historyStream.Read(loadByteArray, 1024, out bytesRead);
- loadStream.Write(loadByteArray, 0, bytesRead);
- }
- while (bytesRead > 0);
-
- Invariant.Assert(loadStream.Length > 0, "Error reading journal stream from native IStream");
-
- return loadStream;
- }
-
- private bool IsXbapErrorPageDisabled()
- {
- object errorPageSetting = Microsoft.Win32.Registry.GetValue(
- "HKEY_CURRENT_USER\\" + RegistryKeys.WPF_Hosting, RegistryKeys.value_DisableXbapErrorPage, null);
- if(errorPageSetting == null)
- {
- errorPageSetting = Microsoft.Win32.Registry.GetValue(
- "HKEY_LOCAL_MACHINE\\" + RegistryKeys.WPF_Hosting, RegistryKeys.value_DisableXbapErrorPage, null);
- }
- return errorPageSetting is int && (int)errorPageSetting != 0;
- }
-
- ///
- /// Sets up an AppDomain.UnhandledException handler intended to show exceptions from the hosted
- /// application in the HTML error page. This handler should be activated as late as possible,
- /// just before the Main() method of the hosted application is called, in order to allow unhandled
- /// exceptions in the hosting code and ClickOnce to go to Watson.
- /// In a future release we'll add a Send Error Report button to the error page. Exceptions due to
- /// platform bugs are currently "swallowed" by it.
- ///
- private void EnableErrorPage()
- {
- if (!IsXbapErrorPageDisabled())
- {
- AppDomain.CurrentDomain.UnhandledException += this.ProcessUnhandledException;
- }
- // Caveats:
- // -- Debuggers affect exception handling. In particular, doing mixed-mode or
- // native-only debugging seems to disable this event. Debugging the unmanaged
- // unhandled-exception handling code is easier when it is called before an exception
- // occurs. (Add a temporary call somewhere.)
- // -- AppDomain.add_UnhandledException() requires the given handler to follow the
- // CLR Constrained Execution Region rules. (It calls RuntimeHelpers.PrepareDelegate().)
- // See http://blogs.msdn.com/bclteam/archive/2005/06/14/429181.aspx for a discussion.
- }
-
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
- private void ProcessUnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- // In CLR v2 unhandled exceptions on background threads also terminate the process. That's why
- // e.IsTerminating appears to be always 'true' here.
-
- try
- {
- // Exception.ToString() contains the exception type, stack trace, and information about
- // inner exceptions. If the exception object is not derived from Exception (the CLR
- // allows throwing anything), we should get at least its type.
- string errorMessage = e.ExceptionObject.ToString();
- errorMessage = errorMessage.Replace(" --->", "\n--->"); // Make nested exceptions more readable.
-
- Invariant.Assert(_browserCallbackServices != null);
-
- // Immediately returning from here makes sure the debugger always gets notified on
- // unhandled exception.
- if (Debugger.IsAttached)
- return;
-
- // Issue: If the exception arrives on a thread other than the main one, we can't call
- // _browserCallbackServices.ProcessUnhandledException(), because COM marshaling for
- // COleDocument is not available (no typelib or proxy/stub CLSID registered).
- // The workaround is to make the call via a DLL-exported function.
- // (This is actually better in a way because proper marshaling would depend on the main
- // thread actively pumping messages [STA apartment], and we can't be sure where it is
- // and what it is doing at this point.)
- //
- // In the current implementation, the native ProcessUnhandledException() may or may not
- // return, depending on whether the browser is currently blocked on a call into our
- // DocObject.
- if (Thread.CurrentThread == _mainThread)
- {
- _browserCallbackServices.ProcessUnhandledException(errorMessage);
- }
- else
- {
- MS.Win32.UnsafeNativeMethods.ProcessUnhandledException_DLL(errorMessage);
- }
- }
- catch(Exception ex)
- {
- Debug.Fail(ex.ToString());
- throw;
- }
- }
-
- ///
- /// Returns the path for the XPSViewer application.
- ///
- ///
- private string GetXPSViewerPath()
- {
- // Get the path to the XPSViewer executable from the registry:
- string xpsViewerPath = Microsoft.Win32.Registry.GetValue(
- RegistryKeys.HKLM_XpsViewerLocalServer32,
- null,
- null) as string;
-
- // If the registry value is not found, we consider this a fatal error and will not continue.
- if( xpsViewerPath == null )
- {
- throw new InvalidOperationException(
- String.Format(
- CultureInfo.CurrentCulture,
- SR.Get(SRID.DocumentApplicationRegistryKeyNotFound),
- RegistryKeys.HKLM_XpsViewerLocalServer32));
- }
-
- // The path we get back from the registry contains the name of the XPSViewer
- // executable -- we only want the path to the viewer, so we strip that off.
- xpsViewerPath = System.IO.Path.GetDirectoryName(xpsViewerPath);
-
- return xpsViewerPath;
- }
-
- ///
- /// Returns the amount of IsolatedStorage to allot the XPSViewer instance.
- /// This queries the registry for a DWORD value named "IsolatedStorageUserQuota" in
- /// HKCU\Software\Microsoft\XPSViewer. If it exists then the value there is used as
- /// the isolated storage quota; otherwise the default value of 20mb is used.
- ///
- ///
- private int GetXpsViewerIsolatedStorageUserQuota()
- {
- int isolatedStorageUserQuota = _defaultXpsIsolatedStorageUserQuota;
-
- object isolatedStorageRegistryValue = Microsoft.Win32.Registry.GetValue(
- RegistryKeys.HKCU_XpsViewer,
- RegistryKeys.value_IsolatedStorageUserQuota,
- null);
-
- if (isolatedStorageRegistryValue is int)
- {
- isolatedStorageUserQuota = (int)isolatedStorageRegistryValue;
- }
-
- return isolatedStorageUserQuota;
- }
-
- #endregion Private Helper Methods
-
- //------------------------------------------------------
- //
- // Private Unmanaged Interfaces
- //
- //------------------------------------------------------
- #region Private Unmanaged Interface imports
-
- [Guid("0000000c-0000-0000-C000-000000000046")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [ComImport]
- private interface SecuritySuppressedIStream
- {
- // ISequentialStream portion
- void Read([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] Byte[] pv, int cb, out int pcbRead);
-
- void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Byte[] pv, int cb, out int pcbWritten);
-
- // IStream portion
- void Seek(long dlibMove, int dwOrigin, out long plibNewPosition);
- void SetSize(long libNewSize);
- void CopyTo(SecuritySuppressedIStream pstm, long cb, out long pcbRead, out long pcbWritten);
- void Commit(int grfCommitFlags);
- void Revert();
- void LockRegion(long libOffset, long cb, int dwLockType);
- void UnlockRegion(long libOffset, long cb, int dwLockType);
- void Stat(out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg, int grfStatFlag);
- void Clone(out SecuritySuppressedIStream ppstm);
- }
- #endregion Private Unmanaged Interface imports
-
- // The amount of User Quota to allow for XPSViewer's Isolated Storage (approx 512mb)
- private const int _defaultXpsIsolatedStorageUserQuota = 512000000;
- }
-
- internal class ApplicationLauncherXappDebug
- {
- public ApplicationLauncherXappDebug(string path, string debugSecurityZoneURL)
- {
- _deploymentManifestPath = path; // assumed to be .xapp
- _deploymentManifest = new Uri(path);
- if (!string.IsNullOrEmpty(debugSecurityZoneURL))
- {
- _debugSecurityZoneURL.Value = new Uri(debugSecurityZoneURL);
- }
- _applicationManifestPath = Path.ChangeExtension(path, ".exe.manifest");
- _exePath = Path.ChangeExtension(path, ".exe");
- }
-
- public ApplicationProxyInternal Initialize()
- {
- SecurityHelper.DemandUIWindowPermission();
-
- _context = ActivationContext.CreatePartialActivationContext(GetApplicationIdentity(), new string[] {_deploymentManifestPath, _applicationManifestPath});
-
- // remove cached trust decision
- ApplicationTrust at = new ApplicationTrust(GetApplicationIdentity());
- System.Security.Policy.ApplicationSecurityManager.UserApplicationTrusts.Remove(at);
-
- PresentationAppDomainManager.IsDebug = true;
- PresentationAppDomainManager.DebugSecurityZoneURL = _debugSecurityZoneURL.Value;
- PresentationAppDomainManager.SaveAppDomain = true;
- ObjectHandle oh = Activator.CreateInstance(_context);
- if (PresentationAppDomainManager.SaveAppDomain)
- {
- AppDomain newDomain = oh.Unwrap() as AppDomain;
- PresentationAppDomainManager.NewAppDomain = newDomain;
- }
-
- // Create an ApplicationProxyInternal in the new domain.
- PresentationAppDomainManager appDomainMgrProxy = PresentationAppDomainManager.NewAppDomain.DomainManager as PresentationAppDomainManager;
- ApplicationProxyInternal proxy = appDomainMgrProxy.CreateApplicationProxyInternal();
-
- proxy.SetDebugSecurityZoneURL(_debugSecurityZoneURL.Value);
-
- PresentationAppDomainManager.SaveAppDomain = false;
-
- return proxy;
- }
-
- private ApplicationIdentity GetApplicationIdentity()
- {
- return new ApplicationIdentity(
- _deploymentManifest.ToString() + "#"
- + GetIdFromManifest(_deploymentManifestPath) + "/"
- + GetIdFromManifest(_applicationManifestPath));
- }
-
- private string GetIdFromManifest(string manifestName)
- {
- FileStream fileStream = new FileStream(manifestName, FileMode.Open, FileAccess.Read);
- try
- {
- using (XmlTextReader reader = new XmlTextReader(fileStream))
- {
- reader.WhitespaceHandling = WhitespaceHandling.None;
- while (reader.Read())
- {
- if (reader.NodeType == XmlNodeType.Element)
- {
- if (reader.NamespaceURI != "urn:schemas-microsoft-com:asm.v1")
- {
- continue;
- }
- if (reader.LocalName == "assemblyIdentity")
- {
- string id = string.Empty;
- while (reader.MoveToNextAttribute())
- {
- if (reader.Name == "name")
- {
- id = reader.Value + id;
- }
- else if (reader.Name == "xmlns")
- {
- // do nothing
- }
- else
- {
- id = id + ", " + reader.Name + "=" + reader.Value;
- }
- }
- return id;
- }
- }
- }
- }
- }
- finally
- {
- fileStream.Close();
- }
-
- return string.Empty;
- }
-
- string _deploymentManifestPath;
- Uri _deploymentManifest;
- string _applicationManifestPath;
- string _exePath;
- SecurityCriticalDataForSet _debugSecurityZoneURL = new SecurityCriticalDataForSet(null);
- ActivationContext _context;
- }
-#else
-
- public sealed class DocObjHost : MarshalByRefObject, IServiceProvider
- {
- public DocObjHost()
- {
- throw new PlatformNotSupportedException(SR.Get(SRID.BrowserHostingNotSupported));
- }
- public override object InitializeLifetimeService()
- {
- throw new PlatformNotSupportedException(SR.Get(SRID.BrowserHostingNotSupported));
- }
- object System.IServiceProvider.GetService(Type serviceType)
- {
- throw new PlatformNotSupportedException(SR.Get(SRID.BrowserHostingNotSupported));
- }
- }
-#endif
-}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs
index 12996e8c757..86b13f1382f 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs
@@ -385,13 +385,8 @@ internal unsafe bool TryFindMemberAndInvokeNonWrapped(string memberName, int fla
// by the CLR. Therefore we also check for the IsCOMObject property. It also seems
// COM interop special-cases DateTime as it's not revealed to be visible by any
// of the first two checks below.
- if (
-#if NETFX
- !Marshal.IsTypeVisibleFromCom(argType)
-#else
- !MarshalLocal.IsTypeVisibleFromCom(argType)
-#endif
- && !argType.IsCOMObject && argType != typeof(DateTime))
+ if (!MarshalLocal.IsTypeVisibleFromCom(argType) &&
+ !argType.IsCOMObject && argType != typeof(DateTime))
{
throw new ArgumentException(SR.Get(SRID.NeedToBeComVisible));
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs
index a412b00355c..16b6b7200bb 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs
@@ -205,28 +205,7 @@ private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
}
else
{
-#if NETFX
- if (Application.InBrowserHostedApp())
- {
- LaunchResult launched = LaunchResult.NotLaunched;
-
- if (SecurityHelper.AreStringTypesEqual(bpu.Scheme, BaseUriHelper.PackAppBaseUri.Scheme))
- {
- bpu = BaseUriHelper.ConvertPackUriToAbsoluteExternallyVisibleUri(bpu);
- }
-
- launched = AppSecurityManager.SafeLaunchBrowserOnlyIfPossible(CurrentSource, bpu, target, true /*IsTopLevelContainer*/);
-
- if (launched == LaunchResult.NotLaunched)
- {
- throw new System.Exception(SR.Get(SRID.FailToNavigateUsingHyperlinkTarget));
- }
- }
- else
-#endif
- {
- throw new System.ArgumentException(SR.Get(SRID.HyperLinkTargetNotFound));
- }
+ throw new System.ArgumentException(SR.Get(SRID.HyperLinkTargetNotFound));
}
}
@@ -451,35 +430,6 @@ private JournalNavigationScope EnsureJournal()
return _journalScope;
}
- private bool IsParentedByBrowserWindow()
- {
- // We want to update browser related state only if
- //
- // 1. There's no window associated with this NavigationService (meaning that this NavigationService)
- // was created by Application) and if we're hosted in the Browser i.e BCBS is not null
- //
- // or
- //
- // 2. The window associated with this NavigationService is a RootBrowserWindow (meaning that we're
- // hosted in the browser and RBW is navigated
- // and
- // we are not in a Frame with its own Journal.
- //
-#if NETFX
- if (this.Application != null &&
- this.Application.CheckAccess())
- {
- if ((JournalScope != null && JournalScope.NavigatorHost is RootBrowserWindow) ||
- (JournalScope == null &&
- this.Application.BrowserCallbackServices != null))
- {
- return true;
- }
- }
-#endif
- return false;
- }
-
bool IsConsistent(NavigateInfo navInfo)
{
return navInfo == null
@@ -523,58 +473,6 @@ private bool RestoreRootViewerState(CustomJournalStateInternal rvs)
return true;
}
-#if NETFX
- ///
- /// When it is top level navigation away from loose XAML (not the intial navigation to the loose xaml,
- /// nor a refresh), we want to delegate to the browser right away. There is no need to go through our
- /// navigation process, because no matter what content type (xaml, html...) it is trying to navigate to,
- /// we always let the browser handle it when it is top-level navigation from inside XamlViewer.
- ///
- /// V3 SP1 Optimization:
- /// We can avoid the cost of recycling the host process when:
- /// 1) The new content is from the same site-of-origin. This way there is no danger of cross-domain
- /// attacks made possible by poor cleanup. See SecurityNote below.
- /// 2) We can update the address bar with the new URL, or there is no address bar, which is when
- /// XamlViewer is hosted in an HTML frame.
- ///
- ///
- /// This function may return false and we still end up delegating to the browser. This will be the
- /// case when the top-level navigation is to something other than XAML. GetObjectFromResponse()
- /// handles this case.
- ///
- private bool ShouldDelegateXamlViewerNavigationToBrowser(NavigateInfo navigateInfo, Uri resolvedUri)
- {
- bool shouldDelegate = false;
- if (BrowserInteropHelper.IsViewer)
- {
- Invariant.Assert(resolvedUri != null && resolvedUri.IsAbsoluteUri);
- shouldDelegate = !BrowserInteropHelper.IsInitialViewerNavigation &&
- (navigateInfo == null || navigateInfo.NavigationMode != NavigationMode.Refresh) &&
- IsTopLevelContainer &&
- // except when we can update the address bar or we are in a frame:
- !(!BrowserInteropHelper.IsAvalonTopLevel || HasTravelLogIntegration);
- }
- return shouldDelegate;
- }
-
-
- void UpdateAddressBarForLooseXaml()
- {
- if (BrowserInteropHelper.IsViewer && !BrowserInteropHelper.IsInitialViewerNavigation &&
- IsTopLevelContainer)
- {
- Uri source = _currentSource;
- if (PackUriHelper.IsPackUri(source))
- {
- source = BaseUriHelper.ConvertPackUriToAbsoluteExternallyVisibleUri(source);
- }
- Invariant.Assert(_navigatorHost != null && _navigatorHost == Application.MainWindow &&
- source.IsAbsoluteUri && !PackUriHelper.IsPackUri(source));
- SecurityHelper.DemandWebPermission(source);
- this.Application.BrowserCallbackServices.UpdateAddressBar(source.ToString());
- }
- }
-#endif
#endregion Private Methods
@@ -1132,22 +1030,6 @@ private bool OnBeforeSwitchContent(Object newBP, NavigateInfo navInfo, Uri newUr
Debug.Assert(_navigateQueueItem == null);
-#if NETFX
- // Workaround for the reentrance problem from browser (bug 128689).
- // Call into browser before we update journal. If there is another navigation waiting, e.g,
- // user starts a new navigation using the browser back/forward button, it will
- // re-enter with this call. We can detect whether a new navigation has started by checking
- // _navigateQueueItem. The goal is to check for reentrance before we update journal. It should
- // be safe to cancel the current navigation at this point (before any journal changes).
- if (HasTravelLogIntegration)
- {
- DispatchPendingCallFromBrowser();
- if (_navigateQueueItem != null)
- {
- return false;
- }
- }
-#endif
if (navInfo == null)
{
@@ -1158,8 +1040,6 @@ private bool OnBeforeSwitchContent(Object newBP, NavigateInfo navInfo, Uri newUr
UpdateJournal(navInfo.NavigationMode, JournalReason.NewContentNavigation, navInfo.JournalEntry);
}
- // Check for reentrance again before we proceed. UpdateJournal calls CallUpdateTravelLog which calls
- // into browser that can cause a new navigation to reenter.
// Future:
// The journal entry of the new page that is navigated to might be lost because the navigation is
// cancelled after the current page being added to jounral. E.g, The journal looks like:
@@ -1199,14 +1079,6 @@ private bool OnBeforeSwitchContent(Object newBP, NavigateInfo navInfo, Uri newUr
return true;
}
-#if NETFX
- // Allow new navigations from browser to re-enter with this call.
- private void DispatchPendingCallFromBrowser()
- {
- BrowserInteropHelper.HostBrowser.GetTop();
- }
-#endif
-
///
/// Called when style is actually applied.
///
@@ -1748,24 +1620,8 @@ internal bool Navigate(Uri source, Object navigationState, bool sandboxExternalC
return true;
}
-#if NETFX
- if (ShouldDelegateXamlViewerNavigationToBrowser(navInfo, resolvedSource))
- {
- try
- {
- DelegateToBrowser(newRequest is PackWebRequest, resolvedSource);
- }
- finally
- {
- ResetPendingNavigationState(NavigationStatus.Idle);
- }
- }
- else
-#endif
- {
- // Post the navigate Dispatcher operation
- _navigateQueueItem.PostNavigation();
- }
+ // Post the navigate Dispatcher operation
+ _navigateQueueItem.PostNavigation();
return true;
}
@@ -2408,9 +2264,6 @@ private void FireNavigated(object navState)
private void HandleNavigated(object navState, bool navigatedToNewContent)
{
Debug.Assert(_navStatus == NavigationStatus.Navigated);
-#if NETFX
- UpdateAddressBarForLooseXaml();
-#endif
BrowserInteropHelper.IsInitialViewerNavigation = false;
NavigateInfo navInfo = navState as NavigateInfo;
@@ -3090,13 +2943,6 @@ private void HandleWebResponse(IAsyncResult ar)
}
}
- private bool CanUseTopLevelBrowserForHTMLRendering()
- {
- return (IsTopLevelContainer
- && IsParentedByBrowserWindow()
- );
- }
-
// Create Object from the return of WebResponse stream
private void GetObjectFromResponse(WebRequest request, WebResponse response, Uri destinationUri, Object navState)
{
@@ -3134,14 +2980,12 @@ private void GetObjectFromResponse(WebRequest request, WebResponse response, Uri
_webResponse = response;
_asyncObjectConverter = null;
-#if NETFX
- Invariant.Assert(!ShouldDelegateXamlViewerNavigationToBrowser(navigateInfo, destinationUri),
- "TopLevel navigation away from loose xaml is already delageted to browser. It should never reach here.");
-#endif
- // CanUseTopLevelBrowserForHTMLRendering() will be true for TopLevel navigation away from browser hosted app. If that is the case
+ // canUseTopLevelBrowserForHTMLRendering will be true for TopLevel navigation away from browser hosted app. If that is the case
// o will be null.
- Object o = MimeObjectFactory.GetObjectAndCloseStream(bindStream, contentType, destinationUri, CanUseTopLevelBrowserForHTMLRendering(), sandBoxContent, true /*allowAsync*/, IsJournalNavigation(navigateInfo), out _asyncObjectConverter);
+ // We don't support browser hosting since .NET Core 3.0, so therefore canUseTopLevelBrowserForHTMLRendering = false
+ bool canUseTopLevelBrowserForHTMLRendering = false;
+ Object o = MimeObjectFactory.GetObjectAndCloseStream(bindStream, contentType, destinationUri, canUseTopLevelBrowserForHTMLRendering, sandBoxContent, true /*allowAsync*/, IsJournalNavigation(navigateInfo), out _asyncObjectConverter);
if (o != null)
{
@@ -3366,10 +3210,6 @@ private JournalEntry UpdateJournal(
journalScope.Journal.UpdateCurrentEntry(journalEntry);
- if (journalEntry.IsNavigable())
- {
- CallUpdateTravelLog(navigationMode == NavigationMode.New);
- }
if (navigationMode == NavigationMode.New)
{
@@ -3601,22 +3441,6 @@ internal void RequestCustomContentStateOnAppShutdown()
FireNavigating(null, null, null, null); // sets _customContentStateToSave
}
- internal void CallUpdateTravelLog(bool addNewEntry)
- {
-#if NETFX
- // Not explicitly checking IsSerializable here because we will be called back
- // immediately via SaveHistory which will throw the serialization exception which
- // will give us the same effect and without the overhead of an explicit
- // GetType + type.IsSerializable check. But if the subclass has data members
- // that are not serializable we will still throw an exception inspite of
- // IsSerializable == true for the subclass.
-
- if (HasTravelLogIntegration)
- {
- this.Application.BrowserCallbackServices.UpdateTravelLog(addNewEntry);
- }
-#endif
- }
///
/// Returns the current Application
@@ -3703,18 +3527,6 @@ private FinishEventHandler FinishHandler
}
}
-#if NETFX
- private bool HasTravelLogIntegration
- {
- get
- {
- return IsParentedByBrowserWindow() &&
- ApplicationProxyInternal.Current.RootBrowserWindow.HasTravelLogIntegration;
- return false;
- }
- }
-#endif
-
private bool IsTopLevelContainer
{
get
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StartUpEventArgs.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StartUpEventArgs.cs
index 9b483f8e5a9..c708171ee45 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StartUpEventArgs.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StartUpEventArgs.cs
@@ -59,51 +59,23 @@ internal bool PerformDefaultAction
private string[] GetCmdLineArgs()
{
- string[] retValue = null;
+ string[] args = Environment.GetCommandLineArgs();
+ Invariant.Assert(args.Length >= 1);
- if (!BrowserInteropHelper.IsBrowserHosted &&
- ( ( Application.Current.MimeType != MimeType.Application )
- || ! IsOnNetworkShareForDeployedApps() ))
- {
- string[] args = Environment.GetCommandLineArgs();
- Invariant.Assert(args.Length >= 1);
+ int newLength = args.Length - 1;
+ newLength = (newLength >= 0 ? newLength : 0);
- int newLength = args.Length - 1;
- newLength = (newLength >=0 ? newLength : 0);
-
- retValue = new string[newLength];
-
- for (int i = 1; i < args.Length; i++)
- {
- retValue[i-1] = args[i];
- }
- }
- else
+ string[] retValue = new string[newLength];
+
+ for (int i = 1; i < args.Length; i++)
{
- retValue = new string[0];
+ retValue[i - 1] = args[i];
}
return retValue;
}
- //
- // Put this into a separate Method to avoid loading of this code at JIT time.
- //
- //
- // Explicitly tell the compiler that we don't want to be inlined.
- // This will prevent loading of system.deployment unless we are a click-once app.
- //
- [MethodImplAttribute (MethodImplOptions.NoInlining )]
- private bool IsOnNetworkShareForDeployedApps()
- {
-#if NETFX
- return System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed ;
-#else
- return false;
-#endif
- }
-
private String[] _args;
private bool _performDefaultAction;
}
diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs
index 7d678a4b616..7a63174909c 100644
--- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs
@@ -170,26 +170,6 @@ internal static WebBrowserPermission CachedWebBrowserPermission
}
static WebBrowserPermission _webBrowserPermission;
- ///
- /// Check whether the call stack has the permissions needed for WebBrowser.
- /// Optimization: false is returned if the AppDomain's permission grant does not include the
- /// WebBrowserPermission. This preliminary check will defeat an Assert on the callstack, but it
- /// avoids the SecurityException in PT when the full WB permission is not granted.
- ///
- internal static bool CallerAndAppDomainHaveUnrestrictedWebBrowserPermission()
- {
- if (!MS.Internal.SecurityHelper.AppDomainHasPermission(CachedWebBrowserPermission))
- return false;
- try
- {
- SecurityHelper.DemandWebBrowserPermission();
- }
- catch (SecurityException)
- {
- return false;
- }
- return true;
- }
///
/// Check to see if we have User initiated navigation permission.
@@ -288,49 +268,6 @@ internal static bool IsFullTrustCaller()
}
static PermissionSet _fullTrustPermissionSet = null;
- ///
- /// Return true if the caller has the correct permission set to get a folder
- /// path.
- ///
- ///
- /// This function exists solely as a an optimazation for the debugger scenario
- ///
- internal static bool CallerHasPermissionWithAppDomainOptimization(params IPermission[] permissionsToCheck)
- {
-#if NETFX
- // in case of passing null return true
- if (permissionsToCheck == null)
- return true;
- PermissionSet psToCheck = new PermissionSet(PermissionState.None);
- for ( int i = 0 ; i < permissionsToCheck.Length ; i++ )
- {
- psToCheck.AddPermission(permissionsToCheck[i]);
- }
- PermissionSet permissionSetAppDomain = AppDomain.CurrentDomain.PermissionSet;
- if (psToCheck.IsSubsetOf(permissionSetAppDomain))
- {
- return true;
- }
- return false;
-#else
- return true;
-#endif
- }
-
- /// Enables an efficient check for a specific permisison in the AppDomain's permission grant
- /// without having to catch a SecurityException in the case the permission is not granted.
- ///
- internal static bool AppDomainHasPermission(IPermission permissionToCheck)
- {
-#if NETFX
- Invariant.Assert(permissionToCheck != null);
- PermissionSet psToCheck = new PermissionSet(PermissionState.None);
- psToCheck.AddPermission(permissionToCheck);
- return psToCheck.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
-#else
- return true;
-#endif
- }
internal static Uri GetBaseDirectory(AppDomain domain)
{
@@ -453,11 +390,7 @@ internal static void DemandFilePathDiscoveryWriteRead()
internal static PermissionSet ExtractAppDomainPermissionSetMinusSiteOfOrigin()
{
-#if NETFX
- PermissionSet permissionSetAppDomain = AppDomain.CurrentDomain.PermissionSet;
-#else
PermissionSet permissionSetAppDomain = new PermissionSet(PermissionState.Unrestricted);
-#endif
// Ensure we remove the FileIO read permission to site of origin.
// We choose to use unrestricted here because it does not matter
@@ -853,23 +786,6 @@ internal static void DemandUnrestrictedUIPermission()
static UIPermission _unrestrictedUIPermission = null;
#endif
-#if PRESENTATION_CORE
- internal static bool AppDomainGrantedUnrestrictedUIPermission
- {
- get
- {
- if(!_appDomainGrantedUnrestrictedUIPermission.HasValue)
- {
- _appDomainGrantedUnrestrictedUIPermission = AppDomainHasPermission(new UIPermission(PermissionState.Unrestricted));
- }
-
- return _appDomainGrantedUnrestrictedUIPermission.Value;
- }
- }
- private static bool? _appDomainGrantedUnrestrictedUIPermission;
-
-#endif
-
#if PRESENTATION_CORE
internal static void DemandFileIOReadPermission(string fileName)
{