diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-17 04:48:37 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-17 04:48:37 +0000 |
commit | 3f55e8712f88d8477d9e58f68958e83c92664389 (patch) | |
tree | 21f9eeeda041fd570c31d8b0f266f780b767418f /chrome_frame/vtable_patch_manager.cc | |
parent | cd1c89e833b7e67b7a7ca8799122e07b65999771 (diff) | |
download | chromium_src-3f55e8712f88d8477d9e58f68958e83c92664389.zip chromium_src-3f55e8712f88d8477d9e58f68958e83c92664389.tar.gz chromium_src-3f55e8712f88d8477d9e58f68958e83c92664389.tar.bz2 |
Add the chromeframe tag to the user agent header at runtime instead of statically in the registry.TEST=Try disabling GCF and see if the chromeframe tag in the user agent is still set. It should not be. Also make sure you don't have an older version installed... the chromeframe tag should not be in the registry - if it is, you've got an older version still registered. This should fix the issue with going to wave.google.com after disabling chrome frame and seeing the white page of death.R=amitBUG=22760
Review URL: http://codereview.chromium.org/259025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/vtable_patch_manager.cc')
-rw-r--r-- | chrome_frame/vtable_patch_manager.cc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/chrome_frame/vtable_patch_manager.cc b/chrome_frame/vtable_patch_manager.cc index 0b9f79aa..c070211 100644 --- a/chrome_frame/vtable_patch_manager.cc +++ b/chrome_frame/vtable_patch_manager.cc @@ -4,7 +4,10 @@ #include "chrome_frame/vtable_patch_manager.h" +#include <algorithm> + #include "base/logging.h" +#include "base/scoped_ptr.h" #include "chrome_frame/function_stub.h" @@ -88,4 +91,72 @@ HRESULT UnpatchInterfaceMethods(MethodPatchInfo* patches) { return S_OK; } +// Disabled for now as we're not using it atm. +#if 0 + +DynamicPatchManager::DynamicPatchManager(const MethodPatchInfo* patch_prototype) + : patch_prototype_(patch_prototype) { + DCHECK(patch_prototype_); + DCHECK(patch_prototype_->stub_ == NULL); +} + +DynamicPatchManager::~DynamicPatchManager() { + UnpatchAll(); +} + +HRESULT DynamicPatchManager::PatchObject(void* unknown) { + int patched_methods = 0; + for (; patch_prototype_[patched_methods].index_ != -1; patched_methods++) { + // If you hit this, then you are likely using the prototype instance for + // patching in _addition_ to this class. This is not a good idea :) + DCHECK(patch_prototype_[patched_methods].stub_ == NULL); + } + + // Prepare a new patch object using the patch info from the prototype. + int mem_size = sizeof(PatchedObject) + + sizeof(MethodPatchInfo) * patched_methods; + PatchedObject* entry = reinterpret_cast<PatchedObject*>(new char[mem_size]); + entry->vtable_ = GetIFVTable(unknown); + memcpy(entry->patch_info_, patch_prototype_, + sizeof(MethodPatchInfo) * (patched_methods + 1)); + + patch_list_lock_.Acquire(); + + // See if we've already patched this vtable before. + // The search is done via the == operator of the PatchedObject class. + PatchList::const_iterator it = std::find(patch_list_.begin(), + patch_list_.end(), entry); + HRESULT hr; + if (it == patch_list_.end()) { + hr = PatchInterfaceMethods(unknown, entry->patch_info_); + if (SUCCEEDED(hr)) { + patch_list_.push_back(entry); + entry = NULL; // Ownership transferred to the array. + } + } else { + hr = S_FALSE; + } + + patch_list_lock_.Release(); + + delete entry; + + return hr; +} + +bool DynamicPatchManager::UnpatchAll() { + patch_list_lock_.Acquire(); + PatchList::iterator it; + for (it = patch_list_.begin(); it != patch_list_.end(); it++) { + UnpatchInterfaceMethods((*it)->patch_info_); + delete (*it); + } + patch_list_.clear(); + patch_list_lock_.Release(); + + return true; +} + +#endif // disabled DynamicPatchManager + } // namespace vtable_patch |