OLD | NEW |
| (Empty) |
1 // Copyright 2008-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 // One-click support for Omaha returning users. | |
17 | |
18 #ifndef OMAHA_PLUGINS_UPDATE_ACTIVEX_ONECLICK_CONTROL_H_ | |
19 #define OMAHA_PLUGINS_UPDATE_ACTIVEX_ONECLICK_CONTROL_H_ | |
20 | |
21 // TODO(omaha): We may want to move sitelock.h to be the "standard" sitelock.h | |
22 // file from Microsoft (and move that file to omaha/external) and then have our | |
23 // modifications to sitelock be in a derived class within the plugins | |
24 // directory. | |
25 | |
26 #include <objsafe.h> | |
27 #include <shellapi.h> | |
28 #include <winhttp.h> | |
29 #include <atlbase.h> | |
30 #include <atlcom.h> | |
31 #include <atlctl.h> | |
32 #include "base/scoped_ptr.h" | |
33 #include "omaha/base/ATLRegMapEx.h" | |
34 #include "omaha/base/const_addresses.h" | |
35 #include "omaha/base/constants.h" | |
36 #include "omaha/base/logging.h" | |
37 #include "omaha/base/debug.h" | |
38 #include "omaha/common/goopdate_utils.h" | |
39 #include "omaha/plugins/update/config.h" | |
40 #include "omaha/plugins/update/resource.h" | |
41 #include "omaha/plugins/update/site_lock.h" | |
42 #include "plugins/update/activex/update_control_idl.h" | |
43 | |
44 namespace omaha { | |
45 | |
46 class OneClickControl; | |
47 | |
48 typedef IObjectSafetyImpl<OneClickControl, INTERFACESAFE_FOR_UNTRUSTED_CALLER> | |
49 OneClickControlSafety; | |
50 | |
51 // Using 0xffff for the major/minor versions in the IDispatchImpl template will | |
52 // make ATL load the typelib directly from the DLL instead of looking up typelib | |
53 // registration in registry. The big benefit is that we do not need to register | |
54 // the typelib. Also, this is needed for Vista SP1 with UAC off, in which | |
55 // oleaut32 does not read typelib information from HKCU, because of a bug. | |
56 class ATL_NO_VTABLE OneClickControl | |
57 : public CComObjectRootEx<CComObjectThreadModel>, | |
58 public CComCoClass<OneClickControl, | |
59 &__uuidof(GoogleUpdateOneClickControlCoClass)>, | |
60 public IDispatchImpl<IGoogleUpdateOneClick, | |
61 &__uuidof(IGoogleUpdateOneClick), | |
62 &LIBID_GoogleUpdateControlLib, 0xffff, 0xffff>, | |
63 public OneClickControlSafety, | |
64 public IObjectWithSiteImpl<OneClickControl> { | |
65 public: | |
66 OneClickControl(); | |
67 virtual ~OneClickControl(); | |
68 | |
69 DECLARE_REGISTRY_RESOURCEID_EX(IDR_ONECLICK_RGS) | |
70 | |
71 #pragma warning(push) | |
72 // C4640: construction of local static object is not thread-safe | |
73 #pragma warning(disable : 4640) | |
74 BEGIN_REGISTRY_MAP() | |
75 REGMAP_ENTRY(_T("CLSID"), GetObjectCLSID()) | |
76 REGMAP_ENTRY(_T("PROGID"), kOneclickControlProgId) | |
77 REGMAP_ENTRY(_T("HKROOT"), goopdate_utils::GetHKRoot()) | |
78 REGMAP_ENTRY(_T("SHELLNAME"), kOmahaShellFileName) | |
79 // Not fatal if "SHELLPATH" is empty because the side-effect would be that | |
80 // on Vista, the user will get prompted on invoking one-click. | |
81 REGMAP_ENTRY(_T("SHELLPATH"), GetGoopdateShellPathForRegMap()) | |
82 | |
83 // The following entries are actually for the NPAPI plugin | |
84 REGMAP_ENTRY(_T("PLUGINDESCRIPTION"), kAppName) | |
85 REGMAP_ENTRY(_T("PLUGINDOMAIN"), kGoopdateServer) | |
86 REGMAP_ENTRY(_T("PLUGINVENDOR"), kFullCompanyName) | |
87 REGMAP_ENTRY(_T("PLUGINVERSION"), kOneclickPluginVersion) | |
88 REGMAP_ENTRY(_T("PLUGINPRODUCT"), kAppName) | |
89 REGMAP_ENTRY(_T("PLUGINMIMETYPE"), ONECLICK_MIME_TYPE) | |
90 END_REGISTRY_MAP() | |
91 #pragma warning(pop) | |
92 | |
93 BEGIN_COM_MAP(OneClickControl) | |
94 COM_INTERFACE_ENTRY(IDispatch) | |
95 COM_INTERFACE_ENTRY(IObjectWithSite) | |
96 COM_INTERFACE_ENTRY(IObjectSafety) | |
97 END_COM_MAP() | |
98 | |
99 DECLARE_NOT_AGGREGATABLE(OneClickControl) | |
100 DECLARE_PROTECT_FINAL_CONSTRUCT(); | |
101 | |
102 // Installs the application that the passed-in manifest corresponds to. | |
103 STDMETHOD(Install)(BSTR cmd_line_args, | |
104 VARIANT* success_callback, | |
105 VARIANT* failure_callback); | |
106 | |
107 STDMETHOD(Install2)(BSTR extra_args); | |
108 | |
109 // Gets the version of the passed in application guid. If the application is | |
110 // not installed, returns an empty string. | |
111 STDMETHOD(GetInstalledVersion)(BSTR guid_string, | |
112 VARIANT_BOOL is_machine, | |
113 BSTR* version_string); | |
114 | |
115 // Gets the version of the plugin. The value is ONECLICK_PLUGIN_VERSION_ANSI. | |
116 // TODO(omaha3): If possible without causing incompatibilities, change version | |
117 // to a preferred type here and in OneClickWorker. | |
118 STDMETHOD(GetOneClickVersion)(long* version); // NOLINT | |
119 | |
120 // Launches a command defined by an installed application. Fails if the | |
121 // command is not successfully started, succeeds otherwise. Returns without | |
122 // waiting for the command to complete. | |
123 STDMETHOD(LaunchAppCommand)(BSTR app_guid, | |
124 VARIANT_BOOL is_machine, | |
125 BSTR cmd_id); | |
126 | |
127 private: | |
128 HRESULT DoGetInstalledVersion(const TCHAR* guid_string, | |
129 bool is_machine, | |
130 CString* version_string); | |
131 | |
132 HRESULT DoInstall(const TCHAR* cmd_line_args); | |
133 | |
134 static bool VariantIsValidCallback(const VARIANT* callback); | |
135 static HRESULT InvokeJavascriptCallback(VARIANT* callback, | |
136 const HRESULT* opt_param); | |
137 | |
138 SiteLock site_lock_; | |
139 | |
140 // If Admin, returns the path for Machine Goopdate. Else returns path for User | |
141 // Goopdate. | |
142 static CString GetGoopdateShellPathForRegMap(); | |
143 }; | |
144 | |
145 } // namespace omaha | |
146 | |
147 #endif // OMAHA_PLUGINS_UPDATE_ACTIVEX_ONECLICK_CONTROL_H_ | |
148 | |
OLD | NEW |