Fix bug #395
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / WebBrowser.cs
1 // Permission is hereby granted, free of charge, to any person obtaining\r
2 // a copy of this software and associated documentation files (the\r
3 // "Software"), to deal in the Software without restriction, including\r
4 // without limitation the rights to use, copy, modify, merge, publish,\r
5 // distribute, sublicense, and/or sell copies of the Software, and to\r
6 // permit persons to whom the Software is furnished to do so, subject to\r
7 // the following conditions:\r
8 // \r
9 // The above copyright notice and this permission notice shall be\r
10 // included in all copies or substantial portions of the Software.\r
11 // \r
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
19 //\r
20 // Copyright (c) 2007, 2008 Novell, Inc.\r
21 //\r
22 // Authors:\r
23 //      Andreia Gaita   <avidigal@novell.com>\r
24 \r
25 \r
26 using System;\r
27 using System.ComponentModel;\r
28 using System.Runtime.InteropServices;\r
29 using System.Reflection;\r
30 using System.Windows.Forms;\r
31 using System.IO;\r
32 using System.Drawing;\r
33 \r
34 namespace System.Windows.Forms\r
35 {\r
36         [DefaultProperty ("Url")]\r
37         [DefaultEvent ("DocumentCompleted")]\r
38         [Docking (DockingBehavior.AutoDock)]\r
39         [ClassInterface (ClassInterfaceType.AutoDispatch)]\r
40         [ComVisible(true)]\r
41         [Designer("System.Windows.Forms.Design.WebBrowserDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]\r
42         public class WebBrowser : WebBrowserBase\r
43         {\r
44                 bool allowNavigation; // if this is true, no other navigation is allowed\r
45                 \r
46                 bool allowWebBrowserDrop = true;\r
47                 bool isWebBrowserContextMenuEnabled;\r
48                 object objectForScripting;\r
49                 bool webBrowserShortcutsEnabled;\r
50                 bool scrollbarsEnabled = true;\r
51                 \r
52                 WebBrowserReadyState readyState;\r
53 \r
54                 HtmlDocument document;\r
55                 \r
56                 WebBrowserEncryptionLevel securityLevel;\r
57 \r
58                 Stream data;\r
59                 bool isStreamSet;\r
60 \r
61                 string url;\r
62 \r
63                 #region Public Properties\r
64 \r
65                 [DefaultValue(true)]\r
66                 public bool AllowNavigation {\r
67                         get { return allowNavigation; }\r
68                         set { allowNavigation = value; }\r
69                 }\r
70 \r
71                 [DefaultValue (true)]\r
72                 public bool AllowWebBrowserDrop {\r
73                         get { return allowWebBrowserDrop; }\r
74                         set { allowWebBrowserDrop = value; }\r
75                 }\r
76 \r
77                 [BrowsableAttribute(false)]\r
78                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
79                 public bool CanGoBack {\r
80                         get { return this.WebHost.Navigation.CanGoBack; }\r
81                 }\r
82 \r
83                 [BrowsableAttribute(false)]\r
84                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
85                 public bool CanGoForward {\r
86                         get { return this.WebHost.Navigation.CanGoForward; }\r
87                 }\r
88 \r
89                 [BrowsableAttribute(false)]\r
90                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
91                 public HtmlDocument Document {\r
92                         get {\r
93                                 if (document == null && documentReady)\r
94                                         document = new HtmlDocument (this, this.WebHost);\r
95                                 return document; \r
96                         }\r
97                 }\r
98 \r
99                 [BrowsableAttribute(false)]\r
100                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
101                 public Stream DocumentStream {\r
102                         get {\r
103                                 if (WebHost.Document == null || WebHost.Document.DocumentElement == null)\r
104                                         return null;\r
105 \r
106                                 return null; //WebHost.Document.DocumentElement.ContentStream;\r
107                         }\r
108                         set { \r
109                                 if (this.allowNavigation)\r
110                                         return;\r
111 \r
112                                 this.Url = new Uri ("about:blank");\r
113 \r
114                                 data = value;\r
115                                 isStreamSet = true;\r
116                         }\r
117                 }\r
118 \r
119                 [BrowsableAttribute(false)]\r
120                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
121                 public string DocumentText {\r
122                         get { \r
123                                 if (WebHost.Document == null || WebHost.Document.DocumentElement == null)\r
124                                         return String.Empty;\r
125                                 return WebHost.Document.DocumentElement.OuterHTML;\r
126                         }\r
127                         set {\r
128                                 if (WebHost.Document != null && WebHost.Document.DocumentElement != null)\r
129                                         WebHost.Document.DocumentElement.OuterHTML = value;\r
130                         }\r
131                 }\r
132 \r
133                 [BrowsableAttribute(false)]\r
134                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
135                 public string DocumentTitle {\r
136                         get {\r
137                                 if (document != null)\r
138                                         return document.Title;\r
139                                 return String.Empty;\r
140                         }\r
141                 }\r
142 \r
143                 [BrowsableAttribute(false)]\r
144                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
145                 public string DocumentType {\r
146                         get {\r
147                                 if (document != null)\r
148                                         return document.DocType;\r
149                                 return String.Empty;\r
150                         }\r
151                 }\r
152 \r
153                 [BrowsableAttribute(false)]\r
154                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
155                 public WebBrowserEncryptionLevel EncryptionLevel {\r
156                         get { return securityLevel; }\r
157                 }\r
158 \r
159                 public override bool Focused {\r
160                         get { return base.Focused; }\r
161                 }\r
162 \r
163                 [BrowsableAttribute(false)]\r
164                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
165                 public bool IsBusy {\r
166                         get { return !documentReady; }\r
167                 }\r
168 \r
169                 [BrowsableAttribute(false)]\r
170                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
171                 public bool IsOffline {\r
172                         get { return WebHost.Offline; }\r
173                 }\r
174 \r
175                 [MonoTODO ("Stub, not implemented")]\r
176                 [DefaultValue(true)]\r
177                 public bool IsWebBrowserContextMenuEnabled {\r
178                         get { return isWebBrowserContextMenuEnabled; }\r
179                         set { isWebBrowserContextMenuEnabled = value; }\r
180                 }\r
181 \r
182                 [MonoTODO ("Stub, not implemented")]\r
183                 [BrowsableAttribute(false)]\r
184                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
185                 public object ObjectForScripting {\r
186                         get { return objectForScripting; }\r
187                         set { objectForScripting = value; }\r
188                 }\r
189 \r
190                 [BrowsableAttribute(false)]\r
191                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
192                 public WebBrowserReadyState ReadyState {\r
193                         get { return readyState; }\r
194                 }\r
195 \r
196                 [DefaultValue(false)]\r
197                 public bool ScriptErrorsSuppressed {\r
198                         get { return SuppressDialogs; }\r
199                         set { SuppressDialogs = value; }\r
200                 }\r
201                 \r
202                 [DefaultValue(true)]\r
203                 public bool ScrollBarsEnabled {\r
204                         get { return scrollbarsEnabled; }\r
205                         set {\r
206                                 scrollbarsEnabled = value;\r
207                                 if (document != null)\r
208                                         SetScrollbars ();\r
209                         }\r
210                 }\r
211 \r
212                 [BrowsableAttribute(false)]\r
213                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
214                 public virtual string StatusText {\r
215                         get { return base.status; }\r
216                 }\r
217 \r
218                 [BindableAttribute(true)] \r
219                 [DefaultValue(null)]\r
220                 [TypeConverter(typeof(WebBrowserUriTypeConverter))]\r
221                 public Uri Url {\r
222                         get {\r
223                                 if (url != null)\r
224                                         return new Uri (url);\r
225                                 if (WebHost.Document != null && WebHost.Document.Url != null)\r
226                                         return new Uri (WebHost.Document.Url);\r
227                                 return null;\r
228                         }\r
229                         set {\r
230                                 url = null;\r
231                                 this.Navigate (value); \r
232                         }\r
233                 }\r
234 \r
235                 [BrowsableAttribute(false)]\r
236                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
237                 public Version Version {\r
238                         get { \r
239                                 Assembly ass = WebHost.GetType().Assembly;\r
240                                 return ass.GetName().Version;\r
241                         }\r
242                 }\r
243 \r
244                 [MonoTODO ("Stub, not implemented")]\r
245                 [DefaultValue(true)]\r
246                 public bool WebBrowserShortcutsEnabled {\r
247                         get { return webBrowserShortcutsEnabled; }\r
248                         set { webBrowserShortcutsEnabled = value; }\r
249                 }\r
250                 \r
251                 protected override Size DefaultSize {\r
252                         get { return base.DefaultSize; }\r
253                 }\r
254 \r
255                 [BrowsableAttribute(false)]\r
256                 [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]\r
257                 [EditorBrowsable (EditorBrowsableState.Never)]\r
258                 public new Padding Padding {\r
259                         get { return base.Padding; }\r
260                         set { base.Padding = value; }\r
261                 }\r
262                 \r
263                 #endregion\r
264 \r
265                 [MonoTODO ("WebBrowser control is only supported on Linux/Windows. No support for OSX.")]\r
266                 public WebBrowser ()\r
267                 {\r
268                 }\r
269 \r
270                 #region Public Methods\r
271 \r
272                 public bool GoBack ()\r
273                 {\r
274                         documentReady = false;\r
275                         document = null;\r
276                         return WebHost.Navigation.Back ();\r
277                 }\r
278 \r
279                 public bool GoForward ()\r
280                 {\r
281                         documentReady = false;\r
282                         document = null;\r
283                         return WebHost.Navigation.Forward ();\r
284                 }\r
285 \r
286                 public void GoHome ()\r
287                 {\r
288                         documentReady = false;\r
289                         document = null;\r
290                         WebHost.Navigation.Home ();\r
291                 }\r
292 \r
293                 public void Navigate (string urlString)\r
294                 {\r
295                         documentReady = false;\r
296                         document = null;\r
297                         WebHost.Navigation.Go (urlString);\r
298                 }\r
299 \r
300                 public void Navigate (Uri url)\r
301                 {\r
302                         documentReady = false;\r
303                         document = null;\r
304                         WebHost.Navigation.Go (url.ToString ());\r
305                 }\r
306 \r
307                 public void Navigate (string urlString, bool newWindow)\r
308                 {\r
309                         documentReady = false;\r
310                         document = null;\r
311                         WebHost.Navigation.Go (urlString);\r
312                 }\r
313 \r
314                 public void Navigate (string urlString, string targetFrameName)\r
315                 {\r
316                         documentReady = false;\r
317                         document = null;\r
318                         WebHost.Navigation.Go (urlString);\r
319                 }\r
320 \r
321                 public void Navigate (Uri url, bool newWindow)\r
322                 {\r
323                         documentReady = false;\r
324                         document = null;\r
325                         WebHost.Navigation.Go (url.ToString ());\r
326                 }\r
327 \r
328                 public void Navigate (Uri url, string targetFrameName)\r
329                 {\r
330                         documentReady = false;\r
331                         document = null;\r
332                         WebHost.Navigation.Go (url.ToString ());\r
333                 }\r
334 \r
335                 public void Navigate (string urlString, string targetFrameName, byte[] postData, string additionalHeaders)\r
336                 {\r
337                         documentReady = false;\r
338                         document = null;\r
339                         WebHost.Navigation.Go (urlString);\r
340                 }\r
341 \r
342                 public void Navigate (Uri url, string targetFrameName, byte[] postData, string additionalHeaders)\r
343                 {\r
344                         documentReady = false;\r
345                         document = null;\r
346                         WebHost.Navigation.Go (url.ToString ());\r
347                 }\r
348 \r
349                 public override void Refresh ()\r
350                 {\r
351                         Refresh (WebBrowserRefreshOption.IfExpired);\r
352                 }\r
353 \r
354                 public void Refresh (WebBrowserRefreshOption opt)\r
355                 {\r
356                         documentReady = false;\r
357                         document = null;\r
358                         switch (opt) {\r
359                                 case WebBrowserRefreshOption.Normal:\r
360                                         WebHost.Navigation.Reload (Mono.WebBrowser.ReloadOption.Proxy);\r
361                                         break;\r
362                                 case WebBrowserRefreshOption.IfExpired:\r
363                                         WebHost.Navigation.Reload (Mono.WebBrowser.ReloadOption.None);\r
364                                         break;\r
365                                 case WebBrowserRefreshOption.Completely:\r
366                                         WebHost.Navigation.Reload (Mono.WebBrowser.ReloadOption.Full);\r
367                                         break;\r
368                         }\r
369                 }\r
370 \r
371                 public void Stop ()\r
372                 {\r
373                         WebHost.Navigation.Stop ();\r
374                 }\r
375 \r
376                 public void GoSearch ()\r
377                 {\r
378                         string url = "http://www.google.com";\r
379                         try {\r
380                                 Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey (@"Software\Microsoft\Internet Explorer\Main\Search Page");\r
381                                 if (reg != null) {\r
382                                         object searchUrl = reg.GetValue ("Default_Search_URL");\r
383                                         if (searchUrl != null && searchUrl is string) {\r
384                                                 Uri uri;\r
385                                                 if (System.Uri.TryCreate (searchUrl as string, UriKind.Absolute, out uri))\r
386                                                         url = uri.ToString ();\r
387                                         }\r
388                                 }\r
389                         } catch {\r
390                         }\r
391                         Navigate (url);\r
392                 }\r
393 \r
394                 public void Print ()\r
395                 {\r
396                         throw new NotImplementedException ();\r
397                 }\r
398 \r
399                 public void ShowPageSetupDialog ()\r
400                 {\r
401                         throw new NotImplementedException ();\r
402                 }\r
403 \r
404                 public void ShowPrintDialog()\r
405                 {\r
406                         throw new NotImplementedException ();\r
407                 }\r
408                 \r
409                 public void ShowPrintPreviewDialog()\r
410                 {\r
411                         throw new NotImplementedException ();\r
412                 }\r
413                 \r
414                 public void ShowPropertiesDialog()\r
415                 {\r
416                         throw new NotImplementedException ();\r
417                 }\r
418                 \r
419                 public void ShowSaveAsDialog()\r
420                 {\r
421                         throw new NotImplementedException ();\r
422                 }\r
423 \r
424                 #endregion\r
425 \r
426                 #region Protected Overridden Methods\r
427 \r
428                 [MonoTODO ("Stub, not implemented")]\r
429                 protected override void AttachInterfaces (object nativeActiveXObject)\r
430                 {\r
431                         base.AttachInterfaces (nativeActiveXObject);\r
432                 }\r
433 \r
434                 [MonoTODO ("Stub, not implemented")]\r
435                 protected override void CreateSink ()\r
436                 {\r
437                         base.CreateSink ();\r
438                 }\r
439 \r
440                 [MonoTODO ("Stub, not implemented")]\r
441                 protected override WebBrowserSiteBase CreateWebBrowserSiteBase ()\r
442                 {\r
443                         return base.CreateWebBrowserSiteBase ();\r
444                 }\r
445 \r
446                 [MonoTODO ("Stub, not implemented")]\r
447                 protected override void DetachInterfaces ()\r
448                 {\r
449                         base.DetachInterfaces ();\r
450                 }\r
451 \r
452                 [MonoTODO ("Stub, not implemented")]\r
453                 protected override void DetachSink ()\r
454                 {\r
455                         base.DetachSink ();\r
456                 }\r
457 \r
458                 protected override void Dispose (bool disposing)\r
459                 {\r
460                         base.Dispose (disposing);\r
461                 }\r
462 \r
463                 protected override void WndProc (ref Message m)\r
464                 {\r
465                         base.WndProc (ref m);\r
466                 }\r
467 \r
468                 #endregion\r
469 \r
470                 #region OnXXX methods\r
471 \r
472                 protected virtual void OnCanGoBackChanged(EventArgs e)\r
473                 {\r
474                         if (CanGoBackChanged != null)\r
475                                 CanGoBackChanged (this, e);\r
476                 }\r
477 \r
478                 protected virtual void OnCanGoForwardChanged(EventArgs e)\r
479                 {                       \r
480                         if (CanGoForwardChanged != null)\r
481                                 CanGoForwardChanged (this, e);\r
482                 }\r
483 \r
484                 protected virtual void OnDocumentCompleted(WebBrowserDocumentCompletedEventArgs e)\r
485                 {\r
486                         if (DocumentCompleted != null)\r
487                                 DocumentCompleted (this, e);\r
488                 }\r
489 \r
490                 protected virtual void OnDocumentTitleChanged(EventArgs e)\r
491                 {\r
492                         if (DocumentTitleChanged != null)\r
493                                 DocumentTitleChanged (this, e);\r
494                 }\r
495 \r
496                 protected virtual void OnEncryptionLevelChanged(EventArgs e)\r
497                 {\r
498                         if (EncryptionLevelChanged != null)\r
499                                 EncryptionLevelChanged (this, e);\r
500                 }\r
501 \r
502                 protected virtual void OnFileDownload(EventArgs e)\r
503                 {\r
504                         if (FileDownload != null)\r
505                                 FileDownload (this, e);\r
506                 }\r
507 \r
508                 protected virtual void OnNavigated(WebBrowserNavigatedEventArgs e)\r
509                 {\r
510                         if (Navigated != null)\r
511                                 Navigated (this, e);\r
512                 }\r
513 \r
514                 protected virtual void OnNavigating(WebBrowserNavigatingEventArgs e)\r
515                 {\r
516                         if (Navigating != null)\r
517                                 Navigating (this, e);\r
518                 }\r
519 \r
520                 protected virtual void OnNewWindow(CancelEventArgs e)\r
521                 {\r
522                         if (NewWindow != null)\r
523                                 NewWindow (this, e);\r
524                 }\r
525 \r
526                 protected virtual void OnProgressChanged(WebBrowserProgressChangedEventArgs e)\r
527                 {\r
528                         if (ProgressChanged != null)\r
529                                 ProgressChanged (this, e);\r
530                 }\r
531 \r
532                 protected virtual void OnStatusTextChanged(EventArgs e)\r
533                 {\r
534                         if (StatusTextChanged != null)\r
535                                 StatusTextChanged (this, e);\r
536                 }\r
537 \r
538                 #endregion\r
539 \r
540                 #region Events  \r
541                 [BrowsableAttribute(false)]\r
542                 public event EventHandler CanGoBackChanged;\r
543 \r
544                 [BrowsableAttribute(false)]\r
545                 public event EventHandler CanGoForwardChanged;\r
546 \r
547                 public event WebBrowserDocumentCompletedEventHandler DocumentCompleted;\r
548 \r
549                 [BrowsableAttribute(false)]\r
550                 public event EventHandler DocumentTitleChanged;\r
551 \r
552                 [BrowsableAttribute(false)]\r
553                 public event EventHandler EncryptionLevelChanged;\r
554 \r
555                 public event EventHandler FileDownload;\r
556 \r
557                 public event WebBrowserNavigatedEventHandler Navigated;\r
558 \r
559                 public event WebBrowserNavigatingEventHandler Navigating;\r
560 \r
561                 public event CancelEventHandler NewWindow;\r
562                 \r
563                 public event WebBrowserProgressChangedEventHandler ProgressChanged;\r
564 \r
565                 [BrowsableAttribute(false)]\r
566                 public event EventHandler StatusTextChanged;\r
567 \r
568                 [Browsable (false)]\r
569                 [EditorBrowsable (EditorBrowsableState.Never)]\r
570                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
571                 public new event EventHandler PaddingChanged;\r
572                 #endregion\r
573 \r
574                 #region Internal\r
575 \r
576                 internal override bool OnNewWindowInternal ()\r
577                 {\r
578                         CancelEventArgs c = new CancelEventArgs ();\r
579                         OnNewWindow (c);\r
580                         return c.Cancel;\r
581                 }\r
582                 \r
583                 internal override void OnWebHostLoadStarted (object sender, Mono.WebBrowser.LoadStartedEventArgs e)\r
584                 {\r
585                         documentReady = false;\r
586                         document = null;\r
587                         readyState = WebBrowserReadyState.Loading;\r
588                         WebBrowserNavigatingEventArgs n = new WebBrowserNavigatingEventArgs (new Uri (e.Uri), e.FrameName);\r
589                         OnNavigating (n);\r
590                 }\r
591 \r
592                 internal override void OnWebHostLoadCommited (object sender, Mono.WebBrowser.LoadCommitedEventArgs e)\r
593                 {\r
594                         readyState = WebBrowserReadyState.Loaded;\r
595                         url = e.Uri;\r
596                         SetScrollbars ();\r
597                         WebBrowserNavigatedEventArgs n = new WebBrowserNavigatedEventArgs (new Uri (e.Uri));\r
598                         OnNavigated (n);\r
599                 }\r
600                 internal override void OnWebHostProgressChanged (object sender, Mono.WebBrowser.ProgressChangedEventArgs e)\r
601                 {\r
602                         readyState = WebBrowserReadyState.Interactive;\r
603                         WebBrowserProgressChangedEventArgs n = new WebBrowserProgressChangedEventArgs (e.Progress, e.MaxProgress);\r
604                         OnProgressChanged (n);\r
605                 }\r
606 \r
607                 internal override void OnWebHostLoadFinished (object sender, Mono.WebBrowser.LoadFinishedEventArgs e)\r
608                 {\r
609                         url = null;\r
610                         documentReady = true;\r
611                         readyState = WebBrowserReadyState.Complete;\r
612                         if (isStreamSet) {\r
613                                 byte[] buffer = new byte [data.Length];\r
614                                 long len = data.Length;\r
615                                 int count = 0;\r
616                                 data.Position = 0;\r
617                                 do {\r
618                                         count = data.Read (buffer, (int) data.Position, (int) (len - data.Position));\r
619                                 } while (count > 0);\r
620                                 WebHost.Render (buffer);\r
621                                 data = null;\r
622                                 isStreamSet = false;\r
623                         }\r
624                         SetScrollbars ();\r
625                         WebBrowserDocumentCompletedEventArgs n = new WebBrowserDocumentCompletedEventArgs (new Uri (e.Uri));\r
626                         OnDocumentCompleted (n);\r
627                 }\r
628                 \r
629                 internal override void OnWebHostSecurityChanged (object sender, Mono.WebBrowser.SecurityChangedEventArgs e)\r
630                 {\r
631                         switch (e.State) {\r
632                                 case Mono.WebBrowser.SecurityLevel.Insecure:\r
633                                         securityLevel = WebBrowserEncryptionLevel.Insecure;\r
634                                 break;\r
635                                 case Mono.WebBrowser.SecurityLevel.Mixed:\r
636                                         securityLevel = WebBrowserEncryptionLevel.Mixed;\r
637                                 break;\r
638                                 case Mono.WebBrowser.SecurityLevel.Secure:\r
639                                         securityLevel = WebBrowserEncryptionLevel.Bit56;\r
640                                 break;\r
641                         }\r
642                 }\r
643                 \r
644                 internal override void OnWebHostContextMenuShown (object sender, Mono.WebBrowser.ContextMenuEventArgs e) {\r
645                         if (!isWebBrowserContextMenuEnabled)\r
646                                 return;\r
647                                         \r
648             ContextMenu menu = new ContextMenu();\r
649                         \r
650                         MenuItem item = new MenuItem("Back", delegate { \r
651                                 GoBack(); \r
652                         });\r
653                         item.Enabled = this.CanGoBack;\r
654                         menu.MenuItems.Add (item);\r
655                         \r
656                         item = new MenuItem("Forward", delegate { \r
657                                 GoForward(); \r
658                         });\r
659                         item.Enabled = this.CanGoForward;\r
660                         menu.MenuItems.Add (item);\r
661                         \r
662                         item = new MenuItem("Refresh", delegate { \r
663                                 Refresh (); \r
664                         });\r
665                         menu.MenuItems.Add (item);\r
666             \r
667             menu.MenuItems.Add (new MenuItem ("-"));\r
668             \r
669             menu.Show(this, PointToClient(MousePosition));\r
670                 }\r
671 \r
672                 internal override void OnWebHostStatusChanged (object sender, Mono.WebBrowser.StatusChangedEventArgs e) {\r
673                         base.status = e.Message;\r
674                         OnStatusTextChanged (null);\r
675                 }\r
676                 \r
677                 #endregion\r
678 \r
679 \r
680                 void SetScrollbars () {\r
681                         //if (!scrollbarsEnabled)\r
682                         //        WebHost.ExecuteScript ("document.body.style.overflow='hidden';");\r
683                         //else\r
684                         //        WebHost.ExecuteScript ("document.body.style.overflow='auto';");\r
685                 }\r
686 \r
687                 [MonoTODO ("Stub, not implemented")]\r
688                 [ComVisible (false)]\r
689                 protected class WebBrowserSite : WebBrowserSiteBase\r
690                 {\r
691                         [MonoTODO ("Stub, not implemented")]\r
692                         public WebBrowserSite (WebBrowser host)\r
693                                 : base ()\r
694                         {\r
695                         }\r
696                 }\r
697         }\r
698 \r
699         internal class WebBrowserUriTypeConverter : UriTypeConverter\r
700         {\r
701         }\r
702 }\r