| 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 // 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> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 << cached_document; | 78 << cached_document; |
| 79 DCHECK(automation_client_.get() != NULL); | 79 DCHECK(automation_client_.get() != NULL); |
| 80 automation_client_->Reinitialize(this, &url_fetcher_); | 80 automation_client_->Reinitialize(this, &url_fetcher_); |
| 81 is_automation_client_reused_ = true; | 81 is_automation_client_reused_ = true; |
| 82 } else { | 82 } else { |
| 83 // The FinalConstruct implementation in the ChromeFrameActivexBase class | 83 // The FinalConstruct implementation in the ChromeFrameActivexBase class |
| 84 // i.e. Base creates an instance of the ChromeFrameAutomationClient class | 84 // i.e. Base creates an instance of the ChromeFrameAutomationClient class |
| 85 // and initializes it, which would spawn a new Chrome process, etc. | 85 // and initializes it, which would spawn a new Chrome process, etc. |
| 86 // We don't want to be doing this if we have a cached document, whose | 86 // We don't want to be doing this if we have a cached document, whose |
| 87 // automation client instance can be reused. | 87 // automation client instance can be reused. |
| 88 HRESULT hr = Base::FinalConstruct(); | 88 HRESULT hr = BaseActiveX::FinalConstruct(); |
| 89 if (FAILED(hr)) | 89 if (FAILED(hr)) |
| 90 return hr; | 90 return hr; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool chrome_network = GetConfigBool(false, kUseChromeNetworking); | 93 bool chrome_network = GetConfigBool(false, kUseChromeNetworking); |
| 94 bool top_level_requests = GetConfigBool(true, kHandleTopLevelRequests); | 94 bool top_level_requests = GetConfigBool(true, kHandleTopLevelRequests); |
| 95 automation_client_->set_use_chrome_network(chrome_network); | 95 automation_client_->set_use_chrome_network(chrome_network); |
| 96 automation_client_->set_handle_top_level_requests(top_level_requests); | 96 automation_client_->set_handle_top_level_requests(top_level_requests); |
| 97 | 97 |
| 98 find_dialog_.Init(automation_client_.get()); | 98 find_dialog_.Init(automation_client_.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 112 DCHECK(accelerator_table_ != NULL); | 112 DCHECK(accelerator_table_ != NULL); |
| 113 return S_OK; | 113 return S_OK; |
| 114 } | 114 } |
| 115 | 115 |
| 116 ChromeActiveDocument::~ChromeActiveDocument() { | 116 ChromeActiveDocument::~ChromeActiveDocument() { |
| 117 DLOG(INFO) << __FUNCTION__; | 117 DLOG(INFO) << __FUNCTION__; |
| 118 if (find_dialog_.IsWindow()) { | 118 if (find_dialog_.IsWindow()) { |
| 119 find_dialog_.DestroyWindow(); | 119 find_dialog_.DestroyWindow(); |
| 120 } | 120 } |
| 121 // ChromeFramePlugin | 121 // ChromeFramePlugin |
| 122 Base::Uninitialize(); | 122 BaseActiveX::Uninitialize(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Override DoVerb | 125 // Override DoVerb |
| 126 STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb, | 126 STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb, |
| 127 LPMSG msg, | 127 LPMSG msg, |
| 128 IOleClientSite* active_site, | 128 IOleClientSite* active_site, |
| 129 LONG index, | 129 LONG index, |
| 130 HWND parent_window, | 130 HWND parent_window, |
| 131 LPCRECT pos) { | 131 LPCRECT pos) { |
| 132 // IE will try and in-place activate us in some cases. This happens when | 132 // IE will try and in-place activate us in some cases. This happens when |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 return S_FALSE; | 187 return S_FALSE; |
| 188 } | 188 } |
| 189 // Override IPersistStorageImpl::IsDirty | 189 // Override IPersistStorageImpl::IsDirty |
| 190 STDMETHODIMP ChromeActiveDocument::IsDirty() { | 190 STDMETHODIMP ChromeActiveDocument::IsDirty() { |
| 191 DLOG(INFO) << __FUNCTION__; | 191 DLOG(INFO) << __FUNCTION__; |
| 192 return S_FALSE; | 192 return S_FALSE; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void ChromeActiveDocument::OnAutomationServerReady() { | 195 void ChromeActiveDocument::OnAutomationServerReady() { |
| 196 Base::OnAutomationServerReady(); | 196 BaseActiveX::OnAutomationServerReady(); |
| 197 Base::GiveFocusToChrome(); | 197 BaseActiveX::GiveFocusToChrome(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, | 200 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, |
| 201 IMoniker* moniker_name, | 201 IMoniker* moniker_name, |
| 202 LPBC bind_context, | 202 LPBC bind_context, |
| 203 DWORD mode) { | 203 DWORD mode) { |
| 204 if (NULL == moniker_name) { | 204 if (NULL == moniker_name) { |
| 205 return E_INVALIDARG; | 205 return E_INVALIDARG; |
| 206 } | 206 } |
| 207 | 207 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 233 NavigationManager* mgr = NavigationManager::GetThreadInstance(); | 233 NavigationManager* mgr = NavigationManager::GetThreadInstance(); |
| 234 DCHECK(mgr); | 234 DCHECK(mgr); |
| 235 | 235 |
| 236 // If the original URL contains an anchor, then the URL queried | 236 // If the original URL contains an anchor, then the URL queried |
| 237 // from the moniker does not contain the anchor. To workaround | 237 // from the moniker does not contain the anchor. To workaround |
| 238 // this we retrieve the URL from our BHO. | 238 // this we retrieve the URL from our BHO. |
| 239 std::wstring url(GetActualUrlFromMoniker( | 239 std::wstring url(GetActualUrlFromMoniker( |
| 240 moniker_name, bind_context, | 240 moniker_name, bind_context, |
| 241 mgr ? mgr->original_url_with_fragment() : std::wstring())); | 241 mgr ? mgr->original_url_with_fragment() : std::wstring())); |
| 242 | 242 |
| 243 scoped_refptr<RequestData> data; | |
| 244 if (mgr) { | 243 if (mgr) { |
| 244 mgr->set_url(L""); |
| 245 mgr->set_original_url_with_fragment(L""); | 245 mgr->set_original_url_with_fragment(L""); |
| 246 data = mgr->GetActiveRequestData(url.c_str()); | |
| 247 } | 246 } |
| 248 | 247 |
| 249 DLOG_IF(INFO, data) << "Got active request data"; | |
| 250 DLOG_IF(WARNING, data.get() == NULL) << "NO active request data"; | |
| 251 | |
| 252 // The is_new_navigation variable indicates if this a navigation initiated | 248 // The is_new_navigation variable indicates if this a navigation initiated |
| 253 // by typing in a URL for e.g. in the IE address bar, or from Chrome by | 249 // by typing in a URL for e.g. in the IE address bar, or from Chrome by |
| 254 // a window.open call from javascript, in which case the current IE tab | 250 // a window.open call from javascript, in which case the current IE tab |
| 255 // will attach to an existing ExternalTabContainer instance. | 251 // will attach to an existing ExternalTabContainer instance. |
| 256 bool is_new_navigation = true; | 252 bool is_new_navigation = true; |
| 257 bool is_chrome_protocol = false; | 253 bool is_chrome_protocol = false; |
| 258 | 254 |
| 259 if (!ParseUrl(url, &is_new_navigation, &is_chrome_protocol, &url)) { | 255 if (!ParseUrl(url, &is_new_navigation, &is_chrome_protocol, &url)) { |
| 260 DLOG(WARNING) << __FUNCTION__ << " Failed to parse url:" << url; | 256 DLOG(WARNING) << __FUNCTION__ << " Failed to parse url:" << url; |
| 261 return E_INVALIDARG; | 257 return E_INVALIDARG; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 456 |
| 461 if (doc_host_handler.get()) { | 457 if (doc_host_handler.get()) { |
| 462 doc_host_handler->HideUI(); | 458 doc_host_handler->HideUI(); |
| 463 } | 459 } |
| 464 | 460 |
| 465 doc_site_.Release(); | 461 doc_site_.Release(); |
| 466 in_place_frame_.Release(); | 462 in_place_frame_.Release(); |
| 467 } | 463 } |
| 468 | 464 |
| 469 if (client_site != m_spClientSite) { | 465 if (client_site != m_spClientSite) { |
| 470 return Base::IOleObject_SetClientSite(client_site); | 466 return BaseActiveX::IOleObject_SetClientSite(client_site); |
| 471 } | 467 } |
| 472 | 468 |
| 473 return S_OK; | 469 return S_OK; |
| 474 } | 470 } |
| 475 | 471 |
| 476 HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { | 472 HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { |
| 477 HRESULT hr = S_OK; | 473 HRESULT hr = S_OK; |
| 478 m_bNegotiatedWnd = TRUE; | 474 m_bNegotiatedWnd = TRUE; |
| 479 if (!m_bInPlaceActive) { | 475 if (!m_bInPlaceActive) { |
| 480 hr = m_spInPlaceSite->CanInPlaceActivate(); | 476 hr = m_spInPlaceSite->CanInPlaceActivate(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 if (in_place_frame_ != NULL) { | 567 if (in_place_frame_ != NULL) { |
| 572 handled_accel = (S_OK == in_place_frame_->TranslateAcceleratorW( | 568 handled_accel = (S_OK == in_place_frame_->TranslateAcceleratorW( |
| 573 const_cast<MSG*>(&accel_message), 0)); | 569 const_cast<MSG*>(&accel_message), 0)); |
| 574 } | 570 } |
| 575 | 571 |
| 576 if (!handled_accel) { | 572 if (!handled_accel) { |
| 577 if (IsFindAccelerator(accel_message)) { | 573 if (IsFindAccelerator(accel_message)) { |
| 578 // Handle the showing of the find dialog explicitly. | 574 // Handle the showing of the find dialog explicitly. |
| 579 OnFindInPage(); | 575 OnFindInPage(); |
| 580 } else { | 576 } else { |
| 581 Base::OnAcceleratorPressed(tab_handle, accel_message); | 577 BaseActiveX::OnAcceleratorPressed(tab_handle, accel_message); |
| 582 } | 578 } |
| 583 } else { | 579 } else { |
| 584 DLOG(INFO) << "IE handled accel key " << accel_message.wParam; | 580 DLOG(INFO) << "IE handled accel key " << accel_message.wParam; |
| 585 } | 581 } |
| 586 } | 582 } |
| 587 | 583 |
| 588 void ChromeActiveDocument::OnTabbedOut(int tab_handle, bool reverse) { | 584 void ChromeActiveDocument::OnTabbedOut(int tab_handle, bool reverse) { |
| 589 DLOG(INFO) << __FUNCTION__; | 585 DLOG(INFO) << __FUNCTION__; |
| 590 if (in_place_frame_) { | 586 if (in_place_frame_) { |
| 591 MSG msg = { NULL, WM_KEYDOWN, VK_TAB }; | 587 MSG msg = { NULL, WM_KEYDOWN, VK_TAB }; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 navigation_info_.navigation_index)) || | 654 navigation_info_.navigation_index)) || |
| 659 StartsWith(static_cast<BSTR>(url_), kChromeAttachExternalTabPrefix, | 655 StartsWith(static_cast<BSTR>(url_), kChromeAttachExternalTabPrefix, |
| 660 false); | 656 false); |
| 661 | 657 |
| 662 if (new_navigation_info.url.is_valid()) { | 658 if (new_navigation_info.url.is_valid()) { |
| 663 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); | 659 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); |
| 664 NavigationManager* mgr = NavigationManager::GetThreadInstance(); | 660 NavigationManager* mgr = NavigationManager::GetThreadInstance(); |
| 665 DCHECK(mgr); | 661 DCHECK(mgr); |
| 666 if (mgr) { | 662 if (mgr) { |
| 667 mgr->set_url(url_); | 663 mgr->set_url(url_); |
| 668 mgr->ReleaseRequestData(); | |
| 669 } | 664 } |
| 670 } | 665 } |
| 671 | 666 |
| 672 if (is_internal_navigation) { | 667 if (is_internal_navigation) { |
| 673 ScopedComPtr<IDocObjectService> doc_object_svc; | 668 ScopedComPtr<IDocObjectService> doc_object_svc; |
| 674 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; | 669 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; |
| 675 | 670 |
| 676 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, | 671 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, |
| 677 web_browser_events_svc.Receive()); | 672 web_browser_events_svc.Receive()); |
| 678 | 673 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 // current tab, then we can reuse the ChromeFrameAutomationClient instance | 777 // current tab, then we can reuse the ChromeFrameAutomationClient instance |
| 783 // maintained by the current ChromeActiveDocument instance. We cache this | 778 // maintained by the current ChromeActiveDocument instance. We cache this |
| 784 // instance so that it can be used by the new ChromeActiveDocument instance | 779 // instance so that it can be used by the new ChromeActiveDocument instance |
| 785 // which may be instantiated for handling the new URL. | 780 // which may be instantiated for handling the new URL. |
| 786 if (open_disposition == CURRENT_TAB) { | 781 if (open_disposition == CURRENT_TAB) { |
| 787 // Grab a reference to ensure that the document remains valid. | 782 // Grab a reference to ensure that the document remains valid. |
| 788 AddRef(); | 783 AddRef(); |
| 789 g_active_doc_cache.Set(this); | 784 g_active_doc_cache.Set(this); |
| 790 } | 785 } |
| 791 | 786 |
| 792 Base::OnOpenURL(tab_handle, url_to_open, referrer, open_disposition); | 787 BaseActiveX::OnOpenURL(tab_handle, url_to_open, referrer, open_disposition); |
| 793 } | 788 } |
| 794 | 789 |
| 795 void ChromeActiveDocument::OnAttachExternalTab(int tab_handle, | 790 void ChromeActiveDocument::OnAttachExternalTab(int tab_handle, |
| 796 const IPC::AttachExternalTabParams& params) { | 791 const IPC::AttachExternalTabParams& params) { |
| 797 DWORD flags = 0; | 792 DWORD flags = 0; |
| 798 if (params.user_gesture) | 793 if (params.user_gesture) |
| 799 flags = NWMF_USERREQUESTED; | 794 flags = NWMF_USERREQUESTED; |
| 800 else if (popup_allowed_) | 795 else if (popup_allowed_) |
| 801 flags = NWMF_USERALLOWED; | 796 flags = NWMF_USERALLOWED; |
| 802 | 797 |
| 803 HRESULT hr = S_OK; | 798 HRESULT hr = S_OK; |
| 804 if (popup_manager_) { | 799 if (popup_manager_) { |
| 805 LPCWSTR popup_wnd_url = UTF8ToWide(params.url.spec()).c_str(); | 800 LPCWSTR popup_wnd_url = UTF8ToWide(params.url.spec()).c_str(); |
| 806 hr = popup_manager_->EvaluateNewWindow(popup_wnd_url, NULL, url_, | 801 hr = popup_manager_->EvaluateNewWindow(popup_wnd_url, NULL, url_, |
| 807 NULL, FALSE, flags, 0); | 802 NULL, FALSE, flags, 0); |
| 808 } | 803 } |
| 809 // Allow popup | 804 // Allow popup |
| 810 if (hr == S_OK) { | 805 if (hr == S_OK) { |
| 811 Base::OnAttachExternalTab(tab_handle, params); | 806 BaseActiveX::OnAttachExternalTab(tab_handle, params); |
| 812 return; | 807 return; |
| 813 } | 808 } |
| 814 | 809 |
| 815 automation_client_->BlockExternalTab(params.cookie); | 810 automation_client_->BlockExternalTab(params.cookie); |
| 816 } | 811 } |
| 817 | 812 |
| 818 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { | 813 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { |
| 819 ScopedComPtr<IBrowserService> browser_service; | 814 ScopedComPtr<IBrowserService> browser_service; |
| 820 ScopedComPtr<ITravelLog> travel_log; | 815 ScopedComPtr<ITravelLog> travel_log; |
| 821 GetBrowserServiceAndTravelLog(browser_service.Receive(), | 816 GetBrowserServiceAndTravelLog(browser_service.Receive(), |
| 822 travel_log.Receive()); | 817 travel_log.Receive()); |
| 823 if (!browser_service || !travel_log) | 818 if (!browser_service || !travel_log) |
| 824 return true; | 819 return true; |
| 825 | 820 |
| 826 if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, NULL))) { | 821 if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, NULL))) { |
| 827 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MF_ENABLED); | 822 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MF_ENABLED); |
| 828 } else { | 823 } else { |
| 829 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MFS_DISABLED); | 824 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MFS_DISABLED); |
| 830 } | 825 } |
| 831 | 826 |
| 832 if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, NULL))) { | 827 if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, NULL))) { |
| 833 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, | 828 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, |
| 834 MF_BYCOMMAND | MF_ENABLED); | 829 MF_BYCOMMAND | MF_ENABLED); |
| 835 } else { | 830 } else { |
| 836 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, | 831 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, |
| 837 MF_BYCOMMAND | MFS_DISABLED); | 832 MF_BYCOMMAND | MFS_DISABLED); |
| 838 } | 833 } |
| 839 | 834 |
| 840 // Call base class (adds 'About' item) | 835 // Call base class (adds 'About' item) |
| 841 return Base::PreProcessContextMenu(menu); | 836 return BaseActiveX::PreProcessContextMenu(menu); |
| 842 } | 837 } |
| 843 | 838 |
| 844 bool ChromeActiveDocument::HandleContextMenuCommand(UINT cmd, | 839 bool ChromeActiveDocument::HandleContextMenuCommand(UINT cmd, |
| 845 const IPC::ContextMenuParams& params) { | 840 const IPC::ContextMenuParams& params) { |
| 846 ScopedComPtr<IWebBrowser2> web_browser2; | 841 ScopedComPtr<IWebBrowser2> web_browser2; |
| 847 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 842 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
| 848 | 843 |
| 849 switch (cmd) { | 844 switch (cmd) { |
| 850 case IDS_CONTENT_CONTEXT_BACK: | 845 case IDS_CONTENT_CONTEXT_BACK: |
| 851 web_browser2->GoBack(); | 846 web_browser2->GoBack(); |
| 852 break; | 847 break; |
| 853 | 848 |
| 854 case IDS_CONTENT_CONTEXT_FORWARD: | 849 case IDS_CONTENT_CONTEXT_FORWARD: |
| 855 web_browser2->GoForward(); | 850 web_browser2->GoForward(); |
| 856 break; | 851 break; |
| 857 | 852 |
| 858 case IDS_CONTENT_CONTEXT_RELOAD: | 853 case IDS_CONTENT_CONTEXT_RELOAD: |
| 859 web_browser2->Refresh(); | 854 web_browser2->Refresh(); |
| 860 break; | 855 break; |
| 861 | 856 |
| 862 default: | 857 default: |
| 863 return Base::HandleContextMenuCommand(cmd, params); | 858 return BaseActiveX::HandleContextMenuCommand(cmd, params); |
| 864 } | 859 } |
| 865 | 860 |
| 866 return true; | 861 return true; |
| 867 } | 862 } |
| 868 | 863 |
| 869 HRESULT ChromeActiveDocument::IEExec(const GUID* cmd_group_guid, | 864 HRESULT ChromeActiveDocument::IEExec(const GUID* cmd_group_guid, |
| 870 DWORD command_id, DWORD cmd_exec_opt, | 865 DWORD command_id, DWORD cmd_exec_opt, |
| 871 VARIANT* in_args, VARIANT* out_args) { | 866 VARIANT* in_args, VARIANT* out_args) { |
| 872 HRESULT hr = E_FAIL; | 867 HRESULT hr = E_FAIL; |
| 873 | 868 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 ScopedComPtr<ITridentService2> trident_services; | 1219 ScopedComPtr<ITridentService2> trident_services; |
| 1225 trident_services.QueryFrom(shell_browser); | 1220 trident_services.QueryFrom(shell_browser); |
| 1226 if (trident_services) { | 1221 if (trident_services) { |
| 1227 trident_services->FirePrivacyImpactedStateChange(wparam); | 1222 trident_services->FirePrivacyImpactedStateChange(wparam); |
| 1228 } else { | 1223 } else { |
| 1229 NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; | 1224 NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; |
| 1230 } | 1225 } |
| 1231 return 0; | 1226 return 0; |
| 1232 } | 1227 } |
| 1233 | 1228 |
| OLD | NEW |