[Tizen] Add BuildTools 2.1.0-rc1-02804-05
[platform/upstream/coreclr.git] / Tools / dotnetcli / sdk / NuGetFallbackFolder / microsoft.identitymodel.clients.activedirectory / 3.14.1 / src / src / ADAL.PCL.Desktop / WebBrowserInterfaces.cs
1 //----------------------------------------------------------------------
2 //
3 // Copyright (c) Microsoft Corporation.
4 // All rights reserved.
5 //
6 // This code is licensed under the MIT License.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files(the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions :
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 // THE SOFTWARE.
25 //
26 //------------------------------------------------------------------------------
27
28 using System;
29 using System.Drawing;
30 using System.Runtime.InteropServices;
31
32 namespace Microsoft.IdentityModel.Clients.ActiveDirectory.Internal
33 {
34     internal class NativeWrapper
35     {
36         [StructLayout(LayoutKind.Sequential)]
37         public class POINT
38         {
39             public int x;
40             public int y;
41
42             public POINT()
43             {
44             }
45
46             public POINT(int x, int y)
47             {
48                 this.x = x;
49                 this.y = y;
50             }
51         }
52
53         [StructLayout(LayoutKind.Sequential)]
54         public class OLECMD
55         {
56             [MarshalAs(UnmanagedType.U4)]
57             public int cmdID;
58             [MarshalAs(UnmanagedType.U4)]
59             public int cmdf;
60         }
61
62         [ComImport, ComVisible(true), Guid("B722BCCB-4E68-101B-A2BC-00AA00404770"),
63          InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
64         public interface IOleCommandTarget
65         {
66             [return: MarshalAs(UnmanagedType.I4)]
67             [PreserveSig]
68             int QueryStatus(ref Guid pguidCmdGroup, int cCmds, [In, Out] OLECMD prgCmds, [In, Out] IntPtr pCmdText);
69
70             [return: MarshalAs(UnmanagedType.I4)]
71             [PreserveSig]
72             int Exec(IntPtr guid, int nCmdID, int nCmdexecopt,
73                      [In, MarshalAs(UnmanagedType.LPArray)] object[] pvaIn, IntPtr pvaOut);
74         }
75
76         [StructLayout(LayoutKind.Sequential), ComVisible(true)]
77         public class DOCHOSTUIINFO
78         {
79             [MarshalAs(UnmanagedType.U4)]
80             public int cbSize = Marshal.SizeOf(typeof(DOCHOSTUIINFO));
81             [MarshalAs(UnmanagedType.I4)]
82             public int dwFlags;
83             [MarshalAs(UnmanagedType.I4)]
84             public int dwDoubleClick;
85             [MarshalAs(UnmanagedType.I4)]
86             public int dwReserved1;
87             [MarshalAs(UnmanagedType.I4)]
88             public int dwReserved2;
89         }
90
91         [Serializable, StructLayout(LayoutKind.Sequential)]
92         public struct MSG
93         {
94             public IntPtr hwnd;
95             public int message;
96             public IntPtr wParam;
97             public IntPtr lParam;
98             public int time;
99             public int pt_x;
100             public int pt_y;
101         }
102
103         [StructLayout(LayoutKind.Sequential)]
104         public class COMRECT
105         {
106             public int left;
107             public int top;
108             public int right;
109             public int bottom;
110
111             public override string ToString()
112             {
113                 return
114                     string.Concat(new object[] { "Left = ", this.left, " Top ", this.top, " Right = ", this.right, " Bottom = ", this.bottom });
115             }
116
117             public COMRECT()
118             {
119             }
120
121             public COMRECT(Rectangle r)
122             {
123                 this.left = r.X;
124                 this.top = r.Y;
125                 this.right = r.Right;
126                 this.bottom = r.Bottom;
127             }
128
129             public COMRECT(int left, int top, int right, int bottom)
130             {
131                 this.left = left;
132                 this.top = top;
133                 this.right = right;
134                 this.bottom = bottom;
135             }
136
137             public static COMRECT FromXYWH(int x, int y, int width, int height)
138             {
139                 return new COMRECT(x, y, x + width, y + height);
140             }
141         }
142
143         [ComImport, Guid("00000115-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
144         public interface IOleInPlaceUIWindow
145         {
146             IntPtr GetWindow();
147
148             [PreserveSig]
149             int ContextSensitiveHelp(int fEnterMode);
150
151             [PreserveSig]
152             int GetBorder([Out] COMRECT lprectBorder);
153
154             [PreserveSig]
155             int RequestBorderSpace([In] COMRECT pborderwidths);
156
157             [PreserveSig]
158             int SetBorderSpace([In] COMRECT pborderwidths);
159
160             void SetActiveObject([In, MarshalAs(UnmanagedType.Interface)] IOleInPlaceActiveObject pActiveObject,
161                                  [In, MarshalAs(UnmanagedType.LPWStr)] string pszObjName);
162         }
163
164         [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00000117-0000-0000-C000-000000000046")]
165         public interface IOleInPlaceActiveObject
166         {
167             [PreserveSig]
168             int GetWindow(out IntPtr hwnd);
169
170             void ContextSensitiveHelp(int fEnterMode);
171
172             [PreserveSig]
173             int TranslateAccelerator([In] ref MSG lpmsg);
174
175             void OnFrameWindowActivate(bool fActivate);
176             void OnDocWindowActivate(int fActivate);
177             void ResizeBorder([In] COMRECT prcBorder, [In] IOleInPlaceUIWindow pUIWindow, bool fFrameWindow);
178             void EnableModeless(int fEnable);
179         }
180
181         [StructLayout(LayoutKind.Sequential)]
182         public sealed class tagOleMenuGroupWidths
183         {
184             [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
185             public int[] widths = new int[6];
186         }
187
188         [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00000116-0000-0000-C000-000000000046")]
189         public interface IOleInPlaceFrame
190         {
191             IntPtr GetWindow();
192
193             [PreserveSig]
194             int ContextSensitiveHelp(int fEnterMode);
195
196             [PreserveSig]
197             int GetBorder([Out] COMRECT lprectBorder);
198
199             [PreserveSig]
200             int RequestBorderSpace([In] COMRECT pborderwidths);
201
202             [PreserveSig]
203             int SetBorderSpace([In] COMRECT pborderwidths);
204
205             [PreserveSig]
206             int SetActiveObject([In, MarshalAs(UnmanagedType.Interface)] IOleInPlaceActiveObject pActiveObject,
207                                 [In, MarshalAs(UnmanagedType.LPWStr)] string pszObjName);
208
209             [PreserveSig]
210             int InsertMenus([In] IntPtr hmenuShared, [In, Out] tagOleMenuGroupWidths lpMenuWidths);
211
212             [PreserveSig]
213             int SetMenu([In] IntPtr hmenuShared, [In] IntPtr holemenu, [In] IntPtr hwndActiveObject);
214
215             [PreserveSig]
216             int RemoveMenus([In] IntPtr hmenuShared);
217
218             [PreserveSig]
219             int SetStatusText([In, MarshalAs(UnmanagedType.LPWStr)] string pszStatusText);
220
221             [PreserveSig]
222             int EnableModeless(bool fEnable);
223
224             [PreserveSig]
225             int TranslateAccelerator([In] ref MSG lpmsg, [In, MarshalAs(UnmanagedType.U2)] short wID);
226         }
227
228         [ComImport, Guid("00000122-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
229         public interface IOleDropTarget
230         {
231             [PreserveSig]
232             int OleDragEnter([In, MarshalAs(UnmanagedType.Interface)] object pDataObj,
233                              [In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In] POINT pt,
234                              [In, Out] ref int pdwEffect);
235
236             [PreserveSig]
237             int OleDragOver([In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In] POINT pt,
238                             [In, Out] ref int pdwEffect);
239
240             [PreserveSig]
241             int OleDragLeave();
242
243             [PreserveSig]
244             int OleDrop([In, MarshalAs(UnmanagedType.Interface)] object pDataObj,
245                         [In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In] POINT pt, [In, Out] ref int pdwEffect);
246         }
247
248         [ComImport, ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
249          Guid("BD3F23C0-D43E-11CF-893B-00AA00BDCE1A")]
250         public interface IDocHostUIHandler
251         {
252             [return: MarshalAs(UnmanagedType.I4)]
253             [PreserveSig]
254             int ShowContextMenu([In, MarshalAs(UnmanagedType.U4)] int dwID, [In] POINT pt,
255                                 [In, MarshalAs(UnmanagedType.Interface)] object pcmdtReserved,
256                                 [In, MarshalAs(UnmanagedType.Interface)] object pdispReserved);
257
258             [return: MarshalAs(UnmanagedType.I4)]
259             [PreserveSig]
260             int GetHostInfo([In, Out] DOCHOSTUIINFO info);
261
262             [return: MarshalAs(UnmanagedType.I4)]
263             [PreserveSig]
264             int ShowUI([In, MarshalAs(UnmanagedType.I4)] int dwID, [In] IOleInPlaceActiveObject activeObject,
265                        [In] IOleCommandTarget commandTarget, [In] IOleInPlaceFrame frame, [In] IOleInPlaceUIWindow doc);
266
267             [return: MarshalAs(UnmanagedType.I4)]
268             [PreserveSig]
269             int HideUI();
270
271             [return: MarshalAs(UnmanagedType.I4)]
272             [PreserveSig]
273             int UpdateUI();
274
275             [return: MarshalAs(UnmanagedType.I4)]
276             [PreserveSig]
277             int EnableModeless([In, MarshalAs(UnmanagedType.Bool)] bool fEnable);
278
279             [return: MarshalAs(UnmanagedType.I4)]
280             [PreserveSig]
281             int OnDocWindowActivate([In, MarshalAs(UnmanagedType.Bool)] bool fActivate);
282
283             [return: MarshalAs(UnmanagedType.I4)]
284             [PreserveSig]
285             int OnFrameWindowActivate([In, MarshalAs(UnmanagedType.Bool)] bool fActivate);
286
287             [return: MarshalAs(UnmanagedType.I4)]
288             [PreserveSig]
289             int ResizeBorder([In] COMRECT rect, [In] IOleInPlaceUIWindow doc, bool fFrameWindow);
290
291             [return: MarshalAs(UnmanagedType.I4)]
292             [PreserveSig]
293             int TranslateAccelerator([In] ref MSG msg, [In] ref Guid group, [In, MarshalAs(UnmanagedType.I4)] int nCmdID);
294
295             [return: MarshalAs(UnmanagedType.I4)]
296             [PreserveSig]
297             int GetOptionKeyPath([Out, MarshalAs(UnmanagedType.LPArray)] string[] pbstrKey,
298                                  [In, MarshalAs(UnmanagedType.U4)] int dw);
299
300             [return: MarshalAs(UnmanagedType.I4)]
301             [PreserveSig]
302             int GetDropTarget([In, MarshalAs(UnmanagedType.Interface)] IOleDropTarget pDropTarget,
303                               [MarshalAs(UnmanagedType.Interface)] out IOleDropTarget ppDropTarget);
304
305             [return: MarshalAs(UnmanagedType.I4)]
306             [PreserveSig]
307             int GetExternal([MarshalAs(UnmanagedType.Interface)] out object ppDispatch);
308
309             [return: MarshalAs(UnmanagedType.I4)]
310             [PreserveSig]
311             int TranslateUrl([In, MarshalAs(UnmanagedType.U4)] int dwTranslate,
312                              [In, MarshalAs(UnmanagedType.LPWStr)] string strURLIn,
313                              [MarshalAs(UnmanagedType.LPWStr)] out string pstrURLOut);
314
315             [return: MarshalAs(UnmanagedType.I4)]
316             [PreserveSig]
317             // Please, don't use System.Windows.Forms.IDataObject it is wrong one.
318             int FilterDataObject(System.Runtime.InteropServices.ComTypes.IDataObject pDO, out System.Runtime.InteropServices.ComTypes.IDataObject ppDORet);
319         }
320
321         [ComImport]
322         [Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E")]
323         [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
324         public interface IWebBrowser2
325         {
326             [DispId(0xcb)]
327             object Document { [return: MarshalAs(UnmanagedType.IDispatch)] [DispId(0xcb)] get; }
328
329             [DispId(0x227)]
330             bool Silent { [param: MarshalAs(UnmanagedType.Bool)] [DispId(0x227)]set; }
331         }
332
333         [ComImport, Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D"), TypeLibType(TypeLibTypeFlags.FHidden), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
334         public interface DWebBrowserEvents2
335         {
336             [DispId(0x66)]
337             void StatusTextChange([In] string text);
338             [DispId(0x6c)]
339             void ProgressChange([In] int progress, [In] int progressMax);
340             [DispId(0x69)]
341             void CommandStateChange([In] long command, [In] bool enable);
342             [DispId(0x6a)]
343             void DownloadBegin();
344             [DispId(0x68)]
345             void DownloadComplete();
346             [DispId(0x71)]
347             void TitleChange([In] string text);
348             [DispId(0x70)]
349             void PropertyChange([In] string szProperty);
350             [DispId(250)]
351             void BeforeNavigate2([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp, [In] ref object URL, [In] ref object flags, [In] ref object targetFrameName, [In] ref object postData, [In] ref object headers, [In, Out] ref bool cancel);
352             [DispId(0xfb)]
353             void NewWindow2([In, Out, MarshalAs(UnmanagedType.IDispatch)] ref object pDisp, [In, Out] ref bool cancel);
354             [DispId(0xfc)]
355             void NavigateComplete2([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp, [In] ref object URL);
356             [DispId(0x103)]
357             void DocumentComplete([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp, [In] ref object URL);
358             [DispId(0xfd)]
359             void OnQuit();
360             [DispId(0xfe)]
361             void OnVisible([In] bool visible);
362             [DispId(0xff)]
363             void OnToolBar([In] bool toolBar);
364             [DispId(0x100)]
365             void OnMenuBar([In] bool menuBar);
366             [DispId(0x101)]
367             void OnStatusBar([In] bool statusBar);
368             [DispId(0x102)]
369             void OnFullScreen([In] bool fullScreen);
370             [DispId(260)]
371             void OnTheaterMode([In] bool theaterMode);
372             [DispId(0x106)]
373             void WindowSetResizable([In] bool resizable);
374             [DispId(0x108)]
375             void WindowSetLeft([In] int left);
376             [DispId(0x109)]
377             void WindowSetTop([In] int top);
378             [DispId(0x10a)]
379             void WindowSetWidth([In] int width);
380             [DispId(0x10b)]
381             void WindowSetHeight([In] int height);
382             [DispId(0x107)]
383             void WindowClosing([In] bool isChildWindow, [In, Out] ref bool cancel);
384             [DispId(0x10c)]
385             void ClientToHostWindow([In, Out] ref long cx, [In, Out] ref long cy);
386             [DispId(0x10d)]
387             void SetSecureLockIcon([In] int secureLockIcon);
388             [DispId(270)]
389             void FileDownload([In, Out] ref bool cancel);
390             [DispId(0x10f)]
391             void NavigateError([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp, [In] ref object URL, [In] ref object frame, [In] ref object statusCode, [In, Out] ref bool cancel);
392             [DispId(0xe1)]
393             void PrintTemplateInstantiation([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp);
394             [DispId(0xe2)]
395             void PrintTemplateTeardown([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp);
396             [DispId(0xe3)]
397             void UpdatePageStatus([In, MarshalAs(UnmanagedType.IDispatch)] object pDisp, [In] ref object nPage, [In] ref object fDone);
398             [DispId(0x110)]
399             void PrivacyImpactedStateChange([In] bool bImpacted);
400         }
401
402         internal static class NativeMethods
403         {
404             [DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
405             internal static extern IntPtr GetDC(IntPtr hWnd);
406
407             [DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
408             internal static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
409
410             [DllImport("Gdi32.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
411             internal static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
412
413             [DllImport("User32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
414             internal static extern bool IsProcessDPIAware();
415         }
416     }
417 }