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

Side by Side Diff: chrome_frame/chrome_active_document.cc

Issue 3053008: Second attempt at trying to land buggy bho avoidance: http://codereview.chrom... (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/buggy_bho_handling.cc ('k') | chrome_frame/chrome_frame.gyp » ('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 // Implementation of ChromeActiveDocument 5 // Implementation of ChromeActiveDocument
6 #include "chrome_frame/chrome_active_document.h" 6 #include "chrome_frame/chrome_active_document.h"
7 7
8 #include <hlink.h> 8 #include <hlink.h>
9 #include <htiface.h> 9 #include <htiface.h>
10 #include <initguid.h> 10 #include <initguid.h>
11 #include <mshtmcid.h> 11 #include <mshtmcid.h>
12 #include <shdeprecated.h> 12 #include <shdeprecated.h>
13 #include <shlguid.h> 13 #include <shlguid.h>
14 #include <shobjidl.h> 14 #include <shobjidl.h>
15 #include <tlogstg.h> 15 #include <tlogstg.h>
16 #include <urlmon.h> 16 #include <urlmon.h>
17 #include <wininet.h> 17 #include <wininet.h>
18 18
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "base/file_version_info.h"
22 #include "base/logging.h" 21 #include "base/logging.h"
23 #include "base/path_service.h" 22 #include "base/path_service.h"
24 #include "base/process_util.h" 23 #include "base/process_util.h"
25 #include "base/registry.h" 24 #include "base/registry.h"
26 #include "base/scoped_variant_win.h" 25 #include "base/scoped_variant_win.h"
27 #include "base/string_tokenizer.h" 26 #include "base/string_tokenizer.h"
28 #include "base/string_util.h" 27 #include "base/string_util.h"
29 #include "base/thread.h" 28 #include "base/thread.h"
30 #include "base/thread_local.h" 29 #include "base/thread_local.h"
31 #include "base/trace_event.h" 30 #include "base/trace_event.h"
32 31
33 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
34 #include "chrome/app/chrome_dll_resource.h" 33 #include "chrome/app/chrome_dll_resource.h"
35 #include "chrome/browser/tab_contents/tab_contents.h" 34 #include "chrome/browser/tab_contents/tab_contents.h"
36 #include "chrome/common/chrome_constants.h" 35 #include "chrome/common/chrome_constants.h"
37 #include "chrome/common/navigation_types.h" 36 #include "chrome/common/navigation_types.h"
38 #include "chrome/test/automation/browser_proxy.h" 37 #include "chrome/test/automation/browser_proxy.h"
39 #include "chrome/test/automation/tab_proxy.h" 38 #include "chrome/test/automation/tab_proxy.h"
40 #include "chrome_frame/bho.h" 39 #include "chrome_frame/bho.h"
41 #include "chrome_frame/bind_context_info.h" 40 #include "chrome_frame/bind_context_info.h"
41 #include "chrome_frame/buggy_bho_handling.h"
42 #include "chrome_frame/crash_reporting/crash_metrics.h" 42 #include "chrome_frame/crash_reporting/crash_metrics.h"
43 #include "chrome_frame/utils.h" 43 #include "chrome_frame/utils.h"
44 44
45 const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab"; 45 const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab";
46 46
47 static const wchar_t kUseChromeNetworking[] = L"UseChromeNetworking"; 47 static const wchar_t kUseChromeNetworking[] = L"UseChromeNetworking";
48 static const wchar_t kHandleTopLevelRequests[] = L"HandleTopLevelRequests"; 48 static const wchar_t kHandleTopLevelRequests[] = L"HandleTopLevelRequests";
49 49
50 DEFINE_GUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 50 DEFINE_GUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0,
51 0x46); 51 0x46);
52 52
53
54 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; 53 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache;
55 54
56 bool g_first_launch_by_process_ = true; 55 bool g_first_launch_by_process_ = true;
57 56
58 const DWORD kIEEncodingIdArray[] = { 57 const DWORD kIEEncodingIdArray[] = {
59 #define DEFINE_ENCODING_ID_ARRAY(encoding_name, id, chrome_name) encoding_name, 58 #define DEFINE_ENCODING_ID_ARRAY(encoding_name, id, chrome_name) encoding_name,
60 INTERNAL_IE_ENCODINGMENU_IDS(DEFINE_ENCODING_ID_ARRAY) 59 INTERNAL_IE_ENCODINGMENU_IDS(DEFINE_ENCODING_ID_ARRAY)
61 #undef DEFINE_ENCODING_ID_ARRAY 60 #undef DEFINE_ENCODING_ID_ARRAY
62 0 // The Last data must be 0 to indicate the end of the encoding id array. 61 0 // The Last data must be 0 to indicate the end of the encoding id array.
63 }; 62 };
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 StartsWith(static_cast<BSTR>(url_), kChromeAttachExternalTabPrefix, 716 StartsWith(static_cast<BSTR>(url_), kChromeAttachExternalTabPrefix,
718 false); 717 false);
719 718
720 if (new_navigation_info.url.is_valid()) 719 if (new_navigation_info.url.is_valid())
721 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); 720 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str());
722 721
723 if (is_internal_navigation) { 722 if (is_internal_navigation) {
724 ScopedComPtr<IDocObjectService> doc_object_svc; 723 ScopedComPtr<IDocObjectService> doc_object_svc;
725 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; 724 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc;
726 725
726 buggy_bho::BuggyBhoTls bad_bho_tls;
727 if (GetConfigBool(true, kEnableBuggyBhoIntercept)) {
728 ScopedComPtr<IWebBrowser2> wb2;
729 DoQueryService(SID_SWebBrowserApp, m_spClientSite, wb2.Receive());
730 if (wb2) {
731 buggy_bho::BuggyBhoTls::PatchBuggyBHOs(wb2);
732 }
733 }
734
727 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, 735 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite,
728 web_browser_events_svc.Receive()); 736 web_browser_events_svc.Receive());
729 737
730 if (!web_browser_events_svc.get()) { 738 if (!web_browser_events_svc.get()) {
731 DoQueryService(SID_SShellBrowser, m_spClientSite, 739 DoQueryService(SID_SShellBrowser, m_spClientSite,
732 doc_object_svc.Receive()); 740 doc_object_svc.Receive());
733 } 741 }
734 742
735 // web_browser_events_svc can be NULL on IE6. 743 // web_browser_events_svc can be NULL on IE6.
736 if (web_browser_events_svc) { 744 if (web_browser_events_svc) {
(...skipping 20 matching lines...) Expand all
757 internal_navigation.AsInput(), NULL); 765 internal_navigation.AsInput(), NULL);
758 766
759 // We no longer need to lie to IE. If we lie persistently to IE, then 767 // We no longer need to lie to IE. If we lie persistently to IE, then
760 // IE reuses us for new navigations. 768 // IE reuses us for new navigations.
761 IEExec(&CGID_DocHostCmdPriv, DOCHOST_DOCCANNAVIGATE, 0, NULL, NULL); 769 IEExec(&CGID_DocHostCmdPriv, DOCHOST_DOCCANNAVIGATE, 0, NULL, NULL);
762 770
763 if (doc_object_svc) { 771 if (doc_object_svc) {
764 // Now call the FireNavigateCompleteEvent which makes IE update the text 772 // Now call the FireNavigateCompleteEvent which makes IE update the text
765 // in the address-bar. 773 // in the address-bar.
766 doc_object_svc->FireNavigateComplete2(this, 0); 774 doc_object_svc->FireNavigateComplete2(this, 0);
767 if (ShouldFireDocumentComplete()) 775 doc_object_svc->FireDocumentComplete(this, 0);
768 doc_object_svc->FireDocumentComplete(this, 0);
769 } else if (web_browser_events_svc) { 776 } else if (web_browser_events_svc) {
770 web_browser_events_svc->FireNavigateComplete2Event(); 777 web_browser_events_svc->FireNavigateComplete2Event();
771 if (ShouldFireDocumentComplete()) 778 web_browser_events_svc->FireDocumentCompleteEvent();
772 web_browser_events_svc->FireDocumentCompleteEvent();
773 } 779 }
774 } 780 }
775 781
776 if (is_title_changed) { 782 if (is_title_changed) {
777 ScopedVariant title(new_navigation_info.title.c_str()); 783 ScopedVariant title(new_navigation_info.title.c_str());
778 IEExec(NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER, 784 IEExec(NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER,
779 title.AsInput(), NULL); 785 title.AsInput(), NULL);
780 } 786 }
781 787
782 // It is important that we only update the navigation_info_ after we have 788 // It is important that we only update the navigation_info_ after we have
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 SetFocus(); 1277 SetFocus();
1272 return 0; 1278 return 0;
1273 } 1279 }
1274 1280
1275 LRESULT ChromeActiveDocument::OnSetFocus(UINT message, WPARAM wparam, 1281 LRESULT ChromeActiveDocument::OnSetFocus(UINT message, WPARAM wparam,
1276 LPARAM lparam, 1282 LPARAM lparam,
1277 BOOL& handled) { // NO_LINT 1283 BOOL& handled) { // NO_LINT
1278 GiveFocusToChrome(false); 1284 GiveFocusToChrome(false);
1279 return 0; 1285 return 0;
1280 } 1286 }
1281
1282 namespace {
1283 struct ModuleAndVersion {
1284 const char* module_name_;
1285 const uint32 major_version_;
1286 const uint32 minor_version_;
1287 };
1288 } // end namespace
1289
1290 // static
1291 bool ChromeActiveDocument::ShouldFireDocumentComplete() {
1292 typedef enum ModuleCheckResult {
1293 CHECK_NOT_DONE,
1294 DOCUMENT_COMPLETE_OK,
1295 DOCUMENT_COMPLETE_NOT_OK
1296 };
1297
1298 static ModuleCheckResult results = CHECK_NOT_DONE;
1299
1300 if (results == CHECK_NOT_DONE) {
1301 // These modules are missing some checks in their DocumentComplete
1302 // implementation that causes a crash.
1303 static const ModuleAndVersion buggy_modules[] = {
1304 { "askbar.dll", 4, 1 }, // biggest troublemaker: 4.1.0.5.
1305 { "gbieh.dll", 3, 8 }, // biggest troublemaker: 3.8.14.12
1306 { "gbiehcef.dll", 3, 8 }, // biggest troublemaker: 3.8.11.23
1307 { "gbiehUni.dll", 3, 8 }, // Another Banco DLL.
1308 };
1309
1310 for (size_t i = 0; results == CHECK_NOT_DONE &&
1311 i < arraysize(buggy_modules); ++i) {
1312 const ModuleAndVersion& module = buggy_modules[i];
1313 HMODULE mod = ::GetModuleHandleA(module.module_name_);
1314 if (mod) {
1315 wchar_t path[MAX_PATH * 2] = {0};
1316 ::GetModuleFileNameW(mod, path, arraysize(path));
1317 scoped_ptr<FileVersionInfo> version_info(
1318 FileVersionInfo::CreateFileVersionInfo(FilePath(path)));
1319 DCHECK(version_info.get());
1320 if (version_info.get()) {
1321 uint32 major = 0, minor = 0;
1322 if (!ParseVersion(version_info->file_version(), &major, &minor))
1323 ParseVersion(version_info->product_version(), &major, &minor);
1324 if (major < module.major_version_ ||
1325 (major == module.major_version_ &&
1326 minor <= module.minor_version_)) {
1327 DLOG(WARNING) << "Buggy module found: " << module.module_name_;
1328 results = DOCUMENT_COMPLETE_NOT_OK;
1329 }
1330 }
1331 }
1332 }
1333
1334 if (results == CHECK_NOT_DONE)
1335 results = DOCUMENT_COMPLETE_OK;
1336 }
1337
1338 return results == DOCUMENT_COMPLETE_OK;
1339 }
1340
OLDNEW
« no previous file with comments | « chrome_frame/buggy_bho_handling.cc ('k') | chrome_frame/chrome_frame.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698