| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // Object entries go here instead of with each object, so that we can move | 69 // Object entries go here instead of with each object, so that we can move |
| 70 // the objects to a lib. Also reduces magic. | 70 // the objects to a lib. Also reduces magic. |
| 71 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho) | 71 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho) |
| 72 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) | 72 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) |
| 73 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) | 73 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) |
| 74 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) | 74 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) |
| 75 | 75 |
| 76 | 76 |
| 77 // See comments in DllGetClassObject. | 77 // See comments in DllGetClassObject. |
| 78 DllRedirector g_dll_redirector; | 78 LPFNGETCLASSOBJECT g_dll_get_class_object_redir_ptr = NULL; |
| 79 Lock g_redirector_lock; | |
| 80 | 79 |
| 81 class ChromeTabModule | 80 class ChromeTabModule |
| 82 : public AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > { | 81 : public AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > { |
| 83 public: | 82 public: |
| 84 typedef AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > ParentClass; | 83 typedef AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > ParentClass; |
| 85 | 84 |
| 86 DECLARE_LIBID(LIBID_ChromeTabLib) | 85 DECLARE_LIBID(LIBID_ChromeTabLib) |
| 87 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB, | 86 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB, |
| 88 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}") | 87 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}") |
| 89 | 88 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 ATL::CTrace::s_trace.ChangeCategory(atlTraceRegistrar, 0, | 165 ATL::CTrace::s_trace.ChangeCategory(atlTraceRegistrar, 0, |
| 167 ATLTRACESTATUS_DISABLED); | 166 ATLTRACESTATUS_DISABLED); |
| 168 #endif | 167 #endif |
| 169 InitGoogleUrl(); | 168 InitGoogleUrl(); |
| 170 | 169 |
| 171 g_exit_manager = new base::AtExitManager(); | 170 g_exit_manager = new base::AtExitManager(); |
| 172 CommandLine::Init(0, NULL); | 171 CommandLine::Init(0, NULL); |
| 173 InitializeCrashReporting(); | 172 InitializeCrashReporting(); |
| 174 logging::InitLogging(NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | 173 logging::InitLogging(NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
| 175 logging::LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE); | 174 logging::LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE); |
| 175 |
| 176 if (!DllRedirector::RegisterAsFirstCFModule()) { |
| 177 // We are not the first ones in, get the module who registered first. |
| 178 HMODULE original_module = DllRedirector::GetFirstCFModule(); |
| 179 DCHECK(original_module != NULL) |
| 180 << "Could not get first CF module handle."; |
| 181 HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase); |
| 182 if (original_module != this_module) { |
| 183 // Someone else was here first, try and get a pointer to their |
| 184 // DllGetClassObject export: |
| 185 g_dll_get_class_object_redir_ptr = |
| 186 DllRedirector::GetDllGetClassObjectPtr(original_module); |
| 187 DCHECK(g_dll_get_class_object_redir_ptr != NULL) |
| 188 << "Found CF module with no DllGetClassObject export."; |
| 189 } |
| 190 } |
| 191 |
| 176 // Enable ETW logging. | 192 // Enable ETW logging. |
| 177 logging::LogEventProvider::Initialize(kChromeFrameProvider); | 193 logging::LogEventProvider::Initialize(kChromeFrameProvider); |
| 178 } else if (reason == DLL_PROCESS_DETACH) { | 194 } else if (reason == DLL_PROCESS_DETACH) { |
| 195 DllRedirector::UnregisterAsFirstCFModule(); |
| 179 g_patch_helper.UnpatchIfNeeded(); | 196 g_patch_helper.UnpatchIfNeeded(); |
| 180 delete g_exit_manager; | 197 delete g_exit_manager; |
| 181 g_exit_manager = NULL; | 198 g_exit_manager = NULL; |
| 182 ShutdownCrashReporting(); | 199 ShutdownCrashReporting(); |
| 183 } | 200 } |
| 184 return _AtlModule.DllMain(reason, reserved); | 201 return _AtlModule.DllMain(reason, reserved); |
| 185 } | 202 } |
| 186 | 203 |
| 187 #ifdef _MANAGED | 204 #ifdef _MANAGED |
| 188 #pragma managed(pop) | 205 #pragma managed(pop) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 return S_OK; | 332 return S_OK; |
| 316 } | 333 } |
| 317 | 334 |
| 318 // Used to determine whether the DLL can be unloaded by OLE | 335 // Used to determine whether the DLL can be unloaded by OLE |
| 319 STDAPI DllCanUnloadNow() { | 336 STDAPI DllCanUnloadNow() { |
| 320 return _AtlModule.DllCanUnloadNow(); | 337 return _AtlModule.DllCanUnloadNow(); |
| 321 } | 338 } |
| 322 | 339 |
| 323 // Returns a class factory to create an object of the requested type | 340 // Returns a class factory to create an object of the requested type |
| 324 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { | 341 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { |
| 325 // On first call, we scan the loaded module list to see if an older version | 342 // If we found another module present when we were loaded, then delegate to |
| 326 // of Chrome Frame is already loaded. If it is, then we delegate all calls | 343 // that: |
| 327 // to DllGetClassObject to it. This is to avoid having instances of | 344 if (g_dll_get_class_object_redir_ptr) { |
| 328 // different versions of e.g. the BHO through an upgrade. It also prevents | 345 return g_dll_get_class_object_redir_ptr(rclsid, riid, ppv); |
| 329 // us from repeatedly patching. | |
| 330 LPFNGETCLASSOBJECT redir_ptr = NULL; | |
| 331 { | |
| 332 AutoLock lock(g_redirector_lock); | |
| 333 g_dll_redirector.EnsureInitialized(L"npchrome_frame.dll", | |
| 334 CLSID_ChromeActiveDocument); | |
| 335 redir_ptr = g_dll_redirector.get_dll_get_class_object_ptr(); | |
| 336 } | |
| 337 | |
| 338 if (redir_ptr) { | |
| 339 return redir_ptr(rclsid, riid, ppv); | |
| 340 } else { | 346 } else { |
| 341 if (g_patch_helper.InitializeAndPatchProtocolsIfNeeded()) { | 347 if (g_patch_helper.InitializeAndPatchProtocolsIfNeeded()) { |
| 342 // We should only get here once. | 348 // We should only get here once. |
| 343 UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, NULL, 0, 0); | 349 UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, NULL, 0, 0); |
| 344 } | 350 } |
| 345 | 351 |
| 346 return _AtlModule.DllGetClassObject(rclsid, riid, ppv); | 352 return _AtlModule.DllGetClassObject(rclsid, riid, ppv); |
| 347 } | 353 } |
| 348 } | 354 } |
| 349 | 355 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 sd.GetDacl(&new_dacl); | 591 sd.GetDacl(&new_dacl); |
| 586 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ); | 592 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ); |
| 587 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) { | 593 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) { |
| 588 result = SetOrDeleteMimeHandlerKey(enable); | 594 result = SetOrDeleteMimeHandlerKey(enable); |
| 589 } | 595 } |
| 590 } | 596 } |
| 591 | 597 |
| 592 backup.RestoreSecurity(object_name.c_str()); | 598 backup.RestoreSecurity(object_name.c_str()); |
| 593 return result; | 599 return result; |
| 594 } | 600 } |
| OLD | NEW |