Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome_frame/chrome_tab.cc

Issue 3029007: First step for cleaning registration code for ChromeFrame.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_frame.gyp ('k') | chrome_frame/register_bho.rgs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // chrome_tab.cc : Implementation of DLL Exports. 5 // chrome_tab.cc : Implementation of DLL Exports.
6 6
7 // Include without path to make GYP build see it. 7 // Include without path to make GYP build see it.
8 #include "chrome_tab.h" // NOLINT 8 #include "chrome_tab.h" // NOLINT
9 9
10 #include <atlsecurity.h> 10 #include <atlsecurity.h>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // the objects to a lib. Also reduces magic. 76 // the objects to a lib. Also reduces magic.
77 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho) 77 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho)
78 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) 78 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument)
79 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) 79 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex)
80 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) 80 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol)
81 81
82 82
83 // See comments in DllGetClassObject. 83 // See comments in DllGetClassObject.
84 LPFNGETCLASSOBJECT g_dll_get_class_object_redir_ptr = NULL; 84 LPFNGETCLASSOBJECT g_dll_get_class_object_redir_ptr = NULL;
85 85
86 class ChromeTabModule 86 class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> {
87 : public AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > {
88 public: 87 public:
89 typedef AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > ParentClass; 88 typedef CAtlDllModuleT<ChromeTabModule> ParentClass;
90 89
91 DECLARE_LIBID(LIBID_ChromeTabLib) 90 DECLARE_LIBID(LIBID_ChromeTabLib)
92 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB, 91 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB,
93 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}") 92 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}")
94 93
95 // Override to add our SYSTIME binary value to registry scripts. 94 // Override to add our SYSTIME binary value to registry scripts.
96 // See chrome_frame_activex.rgs for usage. 95 // See chrome_frame_activex.rgs for usage.
97 virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* registrar) throw() { 96 virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* registrar) throw() {
98 HRESULT hr = ParentClass::AddCommonRGSReplacements(registrar); 97 HRESULT hr = ParentClass::AddCommonRGSReplacements(registrar);
99 98
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 234 }
236 235
237 FreeLibrary(ieframe_module); 236 FreeLibrary(ieframe_module);
238 } else { 237 } else {
239 hr = HRESULT_FROM_WIN32(GetLastError()); 238 hr = HRESULT_FROM_WIN32(GetLastError());
240 } 239 }
241 240
242 return hr; 241 return hr;
243 } 242 }
244 243
245 HRESULT RegisterChromeTabBHO() {
246 RegKey ie_bho_key;
247 if (!ie_bho_key.Create(HKEY_LOCAL_MACHINE, kBhoRegistryPath,
248 KEY_CREATE_SUB_KEY)) {
249 DLOG(WARNING) << "Failed to open registry key "
250 << kBhoRegistryPath
251 << " for write";
252 return E_FAIL;
253 }
254
255 wchar_t bho_class_id_as_string[MAX_PATH] = {0};
256 StringFromGUID2(CLSID_ChromeFrameBHO, bho_class_id_as_string,
257 arraysize(bho_class_id_as_string));
258
259 if (!ie_bho_key.CreateKey(bho_class_id_as_string, KEY_READ | KEY_WRITE)) {
260 DLOG(WARNING) << "Failed to create bho registry key under "
261 << kBhoRegistryPath
262 << " for write";
263 return E_FAIL;
264 }
265
266 ie_bho_key.WriteValue(kBhoNoLoadExplorerValue, 1);
267 DLOG(INFO) << "Registered ChromeTab BHO";
268
269 // We now add the chromeframe user agent at runtime.
270 RefreshElevationPolicy();
271 return S_OK;
272 }
273
274 HRESULT UnregisterChromeTabBHO() {
275 RegKey ie_bho_key;
276 if (!ie_bho_key.Open(HKEY_LOCAL_MACHINE, kBhoRegistryPath,
277 KEY_READ | KEY_WRITE)) {
278 DLOG(WARNING) << "Failed to open registry key "
279 << kBhoRegistryPath
280 << " for write.";
281 return E_FAIL;
282 }
283
284 wchar_t bho_class_id_as_string[MAX_PATH] = {0};
285 StringFromGUID2(CLSID_ChromeFrameBHO, bho_class_id_as_string,
286 arraysize(bho_class_id_as_string));
287
288 if (!ie_bho_key.DeleteKey(bho_class_id_as_string)) {
289 DLOG(WARNING) << "Failed to delete bho registry key "
290 << bho_class_id_as_string
291 << " under "
292 << kBhoRegistryPath;
293 return E_FAIL;
294 }
295
296 DLOG(INFO) << "Unregistered ChromeTab BHO";
297 return S_OK;
298 }
299
300 // Experimental boot prefetch optimization for Chrome Frame 244 // Experimental boot prefetch optimization for Chrome Frame
301 // 245 //
302 // If chrome is warmed up during a single reboot, it gets paged 246 // If chrome is warmed up during a single reboot, it gets paged
303 // in for subsequent reboots and the cold startup times essentially 247 // in for subsequent reboots and the cold startup times essentially
304 // look like warm times thereafter! The 'warm up' is done by 248 // look like warm times thereafter! The 'warm up' is done by
305 // setting up a 'RunOnce' key during DLLRegisterServer of 249 // setting up a 'RunOnce' key during DLLRegisterServer of
306 // npchrome_frame.dll. 250 // npchrome_frame.dll.
307 // 251 //
308 // This works because chrome prefetch becomes part of boot 252 // This works because chrome prefetch becomes part of boot
309 // prefetch file ntosboot-b00dfaad.pf and paged in on subsequent 253 // prefetch file ntosboot-b00dfaad.pf and paged in on subsequent
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (g_dll_get_class_object_redir_ptr) { 301 if (g_dll_get_class_object_redir_ptr) {
358 return g_dll_get_class_object_redir_ptr(rclsid, riid, ppv); 302 return g_dll_get_class_object_redir_ptr(rclsid, riid, ppv);
359 } else { 303 } else {
360 g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); 304 g_patch_helper.InitializeAndPatchProtocolsIfNeeded();
361 return _AtlModule.DllGetClassObject(rclsid, riid, ppv); 305 return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
362 } 306 }
363 } 307 }
364 308
365 // DllRegisterServer - Adds entries to the system registry 309 // DllRegisterServer - Adds entries to the system registry
366 STDAPI DllRegisterServer() { 310 STDAPI DllRegisterServer() {
367 // registers object, typelib and all interfaces in typelib 311 // registers objects, typelib and all interfaces in typelib
368 HRESULT hr = _AtlModule.DllRegisterServer(TRUE); 312 HRESULT hr = _AtlModule.DllRegisterServer(TRUE);
369 313
370 if (SUCCEEDED(hr)) { 314 if (SUCCEEDED(hr)) {
371 // Best effort attempt to register the BHO. At this point we silently 315 // Best effort attempt to register the BHO. At this point we silently
372 // ignore any errors during registration. There are some traces emitted 316 // ignore any errors during registration. There are some traces emitted
373 // to the debug log. 317 // to the debug log.
374 RegisterChromeTabBHO(); 318 _AtlModule.UpdateRegistryFromResourceS(IDR_REGISTER_BHO, TRUE);
375 if (!RegisterSecuredMimeHandler(true)) 319 if (!RegisterSecuredMimeHandler(true))
376 hr = E_FAIL; 320 hr = E_FAIL;
377 SetupRunOnce(); 321 SetupRunOnce();
378 } 322 }
379 323
380 if (UtilIsPersistentNPAPIMarkerSet()) { 324 if (UtilIsPersistentNPAPIMarkerSet()) {
381 hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, TRUE); 325 hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, TRUE);
382 } 326 }
383 327
384 return hr; 328 return hr;
385 } 329 }
386 330
387 // DllUnregisterServer - Removes entries from the system registry 331 // DllUnregisterServer - Removes entries from the system registry
388 STDAPI DllUnregisterServer() { 332 STDAPI DllUnregisterServer() {
389 HRESULT hr = _AtlModule.DllUnregisterServer(TRUE); 333 HRESULT hr = _AtlModule.DllUnregisterServer(TRUE);
390 334
391 if (SUCCEEDED(hr)) { 335 if (SUCCEEDED(hr)) {
392 // Best effort attempt to unregister the BHO. At this point we silently 336 // Best effort attempt to unregister the BHO. At this point we silently
393 // ignore any errors during unregistration. There are some traces emitted 337 // ignore any errors during unregistration. There are some traces emitted
394 // to the debug log. 338 // to the debug log.
395 UnregisterChromeTabBHO(); 339 _AtlModule.UpdateRegistryFromResourceS(IDR_REGISTER_BHO, FALSE);
396 if (!RegisterSecuredMimeHandler(false)) 340 if (!RegisterSecuredMimeHandler(false))
397 hr = E_FAIL; 341 hr = E_FAIL;
398 } 342 }
399 343
400 if (UtilIsNPAPIPluginRegistered()) { 344 if (UtilIsNPAPIPluginRegistered()) {
401 hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, FALSE); 345 hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, FALSE);
402 } 346 }
403 347
404 return hr; 348 return hr;
405 } 349 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 sd.GetDacl(&new_dacl); 543 sd.GetDacl(&new_dacl);
600 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ); 544 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ);
601 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) { 545 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) {
602 result = SetOrDeleteMimeHandlerKey(enable); 546 result = SetOrDeleteMimeHandlerKey(enable);
603 } 547 }
604 } 548 }
605 549
606 backup.RestoreSecurity(object_name.c_str()); 550 backup.RestoreSecurity(object_name.c_str());
607 return result; 551 return result;
608 } 552 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame.gyp ('k') | chrome_frame/register_bho.rgs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698