| 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 #include "chrome_frame/chrome_frame_activex.h" | 5 #include "chrome_frame/chrome_frame_activex.h" |
| 6 | 6 |
| 7 #include <wininet.h> | 7 #include <wininet.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 if (document_url.SchemeIsSecure()) { | 370 if (document_url.SchemeIsSecure()) { |
| 371 GURL source_url(src); | 371 GURL source_url(src); |
| 372 if (!source_url.SchemeIsSecure()) { | 372 if (!source_url.SchemeIsSecure()) { |
| 373 Base::put_src(ScopedBstr(g_activex_mixed_content_error)); | 373 Base::put_src(ScopedBstr(g_activex_mixed_content_error)); |
| 374 return E_ACCESSDENIED; | 374 return E_ACCESSDENIED; |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 return Base::put_src(src); | 377 return Base::put_src(src); |
| 378 } | 378 } |
| 379 | 379 |
| 380 STDMETHODIMP ChromeFrameActivex::SetSite(IUnknown* site) { | |
| 381 // We need to bootstrap our BHO if IE is running while chrome frame is | |
| 382 // installed. For new tabs and windows the newly registered BHO's are | |
| 383 // loaded. The bootstrapping is only needed for the current tab. | |
| 384 site_ = site; | |
| 385 return IObjectWithSiteImpl<ChromeFrameActivex>::SetSite(site); | |
| 386 } | |
| 387 | |
| 388 HRESULT ChromeFrameActivex::IOleObject_SetClientSite( | 380 HRESULT ChromeFrameActivex::IOleObject_SetClientSite( |
| 389 IOleClientSite* client_site) { | 381 IOleClientSite* client_site) { |
| 390 HRESULT hr = Base::IOleObject_SetClientSite(client_site); | 382 HRESULT hr = Base::IOleObject_SetClientSite(client_site); |
| 391 if (FAILED(hr) || !client_site) { | 383 if (FAILED(hr) || !client_site) { |
| 392 EventHandlers* handlers[] = { | 384 EventHandlers* handlers[] = { |
| 393 &onmessage_, | 385 &onmessage_, |
| 394 &onloaderror_, | 386 &onloaderror_, |
| 395 &onload_, | 387 &onload_, |
| 396 &onreadystatechanged_, | 388 &onreadystatechanged_, |
| 397 &onextensionready_, | 389 &onextensionready_, |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 return hr; | 594 return hr; |
| 603 | 595 |
| 604 HWND top_window = ::GetAncestor(parent_wnd, GA_ROOT); | 596 HWND top_window = ::GetAncestor(parent_wnd, GA_ROOT); |
| 605 chrome_wndproc_hook_ = InstallLocalWindowHook(top_window); | 597 chrome_wndproc_hook_ = InstallLocalWindowHook(top_window); |
| 606 if (chrome_wndproc_hook_) | 598 if (chrome_wndproc_hook_) |
| 607 TopLevelWindowMapping::instance()->AddMapping(top_window, m_hWnd); | 599 TopLevelWindowMapping::instance()->AddMapping(top_window, m_hWnd); |
| 608 | 600 |
| 609 return chrome_wndproc_hook_ ? S_OK : E_FAIL; | 601 return chrome_wndproc_hook_ ? S_OK : E_FAIL; |
| 610 } | 602 } |
| 611 | 603 |
| 612 HRESULT ChromeFrameActivex::RegisterBHOIfNeeded() { | 604 HRESULT ChromeFrameActivex::registerBhoIfNeeded() { |
| 613 if (!site_) { | 605 if (!m_spUnkSite) { |
| 614 NOTREACHED() << "Invalid client site"; | 606 NOTREACHED() << "Invalid client site"; |
| 615 return E_FAIL; | 607 return E_FAIL; |
| 616 } | 608 } |
| 617 | 609 |
| 618 if (NavigationManager::GetThreadInstance() != NULL) { | 610 if (NavigationManager::GetThreadInstance() != NULL) { |
| 619 DLOG(INFO) << "BHO already loaded"; | 611 DLOG(INFO) << "BHO already loaded"; |
| 620 return S_OK; | 612 return S_OK; |
| 621 } | 613 } |
| 622 | 614 |
| 623 ScopedComPtr<IWebBrowser2> web_browser2; | 615 ScopedComPtr<IWebBrowser2> web_browser2; |
| 624 HRESULT hr = DoQueryService(SID_SWebBrowserApp, site_, | 616 HRESULT hr = DoQueryService(SID_SWebBrowserApp, m_spUnkSite, |
| 625 web_browser2.Receive()); | 617 web_browser2.Receive()); |
| 626 if (FAILED(hr) || web_browser2.get() == NULL) { | 618 if (FAILED(hr) || web_browser2.get() == NULL) { |
| 627 DLOG(WARNING) << "Failed to get IWebBrowser2 from client site. Error:" | 619 DLOG(WARNING) << "Failed to get IWebBrowser2 from client site. Error:" |
| 628 << StringPrintf(" 0x%08X", hr); | 620 << StringPrintf(" 0x%08X", hr); |
| 629 return hr; | 621 return hr; |
| 630 } | 622 } |
| 631 | 623 |
| 632 wchar_t bho_class_id_as_string[MAX_PATH] = {0}; | 624 wchar_t bho_class_id_as_string[MAX_PATH] = {0}; |
| 633 StringFromGUID2(CLSID_ChromeFrameBHO, bho_class_id_as_string, | 625 StringFromGUID2(CLSID_ChromeFrameBHO, bho_class_id_as_string, |
| 634 arraysize(bho_class_id_as_string)); | 626 arraysize(bho_class_id_as_string)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 645 if (FAILED(hr)) { | 637 if (FAILED(hr)) { |
| 646 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" | 638 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" |
| 647 << StringPrintf(" 0x%08X", hr); | 639 << StringPrintf(" 0x%08X", hr); |
| 648 return hr; | 640 return hr; |
| 649 } | 641 } |
| 650 | 642 |
| 651 web_browser2->PutProperty(ScopedBstr(bho_class_id_as_string), | 643 web_browser2->PutProperty(ScopedBstr(bho_class_id_as_string), |
| 652 ScopedVariant(bho)); | 644 ScopedVariant(bho)); |
| 653 return S_OK; | 645 return S_OK; |
| 654 } | 646 } |
| OLD | NEW |