-
Notifications
You must be signed in to change notification settings - Fork 10
/
Opera.cs
executable file
·83 lines (64 loc) · 2.36 KB
/
Opera.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;
namespace FreenetTray.Browsers
{
class Opera: Browser
{
private static string OperaRegistryKey = @"Software\Opera Software\Last Stable Install Path";
private static string RegistryPathForView(RegistryView view) {
RegistryKey hive = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, view);
RegistryKey key = hive.OpenSubKey(OperaRegistryKey);
if (key == null) {
return null;
}
string value = key.GetValue("opera.exe") as string;
return value;
}
// find the path to opera, preferring 64-bit if available
private static string RegistryPath {
get {
if (Environment.Is64BitOperatingSystem) {
var path64 = RegistryPathForView(RegistryView.Registry64);
if (path64 != null) {
return path64;
}
var path32 = RegistryPathForView(RegistryView.Registry32);
if (path32 != null) {
return path32;
}
return null;
}
else {
var path32 = RegistryPathForView(RegistryView.Registry32);
if (path32 != null) {
return path32;
}
return null;
}
}
}
public Opera()
{
/*
* TODO: Opera 26 adds launcher.exe and does not support -newprivatetab. Documentation
* on what it supports in its place, if anything, has not been forthcoming.
*/
// Key present with Opera 21.
var possiblePath = RegistryPath;
_isInstalled = File.Exists(possiblePath);
if (_isInstalled)
{
_path = possiblePath;
}
// we don't know at the moment, but might need to add support to properly
// handle the private browsing argument when it works
_version = new System.Version(0, 0);
_isUsable = true;
// See http://www.opera.com/docs/switches
_args = "-newprivatetab ";
_name = "Opera";
}
}
}