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

Side by Side Diff: chrome_frame/chrome_tab.cc

Issue 2038007: Merge 46738 - Change to a simpler upgrade scheme for Chrome Frame whereby we ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/375/src/
Patch Set: Created 10 years, 7 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/module_utils.h » ('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) 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
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
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
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 g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); 347 g_patch_helper.InitializeAndPatchProtocolsIfNeeded();
342 return _AtlModule.DllGetClassObject(rclsid, riid, ppv); 348 return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
343 } 349 }
344 } 350 }
345 351
346 // DllRegisterServer - Adds entries to the system registry 352 // DllRegisterServer - Adds entries to the system registry
347 STDAPI DllRegisterServer() { 353 STDAPI DllRegisterServer() {
348 // registers object, typelib and all interfaces in typelib 354 // registers object, typelib and all interfaces in typelib
349 HRESULT hr = _AtlModule.DllRegisterServer(TRUE); 355 HRESULT hr = _AtlModule.DllRegisterServer(TRUE);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 sd.GetDacl(&new_dacl); 587 sd.GetDacl(&new_dacl);
582 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ); 588 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ);
583 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) { 589 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) {
584 result = SetOrDeleteMimeHandlerKey(enable); 590 result = SetOrDeleteMimeHandlerKey(enable);
585 } 591 }
586 } 592 }
587 593
588 backup.RestoreSecurity(object_name.c_str()); 594 backup.RestoreSecurity(object_name.c_str());
589 return result; 595 return result;
590 } 596 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame.gyp ('k') | chrome_frame/module_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698