OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <atlctl.h> | 10 #include <atlctl.h> |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 *src = SysAllocString(url_); | 423 *src = SysAllocString(url_); |
424 return S_OK; | 424 return S_OK; |
425 } | 425 } |
426 | 426 |
427 STDMETHOD(put_src)(BSTR src) { | 427 STDMETHOD(put_src)(BSTR src) { |
428 if (src == NULL) | 428 if (src == NULL) |
429 return E_INVALIDARG; | 429 return E_INVALIDARG; |
430 | 430 |
431 // Switch the src to UTF8 and try to expand to full URL | 431 // Switch the src to UTF8 and try to expand to full URL |
432 std::string src_utf8; | 432 std::string src_utf8; |
433 WideToUTF8(src, SysStringLen(src), &src_utf8); | 433 base::WideToUTF8(src, SysStringLen(src), &src_utf8); |
434 std::string full_url = ResolveURL(GetDocumentUrl(), src_utf8); | 434 std::string full_url = ResolveURL(GetDocumentUrl(), src_utf8); |
435 | 435 |
436 // We can initiate navigation here even if ready_state is not complete. | 436 // We can initiate navigation here even if ready_state is not complete. |
437 // We do not have to set proxy, and AutomationClient will take care | 437 // We do not have to set proxy, and AutomationClient will take care |
438 // of navigation just after CreateExternalTab is done. | 438 // of navigation just after CreateExternalTab is done. |
439 if (!automation_client_->InitiateNavigation(full_url, | 439 if (!automation_client_->InitiateNavigation(full_url, |
440 GetDocumentUrl(), | 440 GetDocumentUrl(), |
441 this)) { | 441 this)) { |
442 // TODO(robertshield): Make InitiateNavigation return more useful | 442 // TODO(robertshield): Make InitiateNavigation return more useful |
443 // error information. | 443 // error information. |
444 return E_INVALIDARG; | 444 return E_INVALIDARG; |
445 } | 445 } |
446 | 446 |
447 // Save full URL in BSTR member | 447 // Save full URL in BSTR member |
448 url_.Reset(::SysAllocString(UTF8ToWide(full_url).c_str())); | 448 url_.Reset(::SysAllocString(base::UTF8ToWide(full_url).c_str())); |
449 | 449 |
450 return S_OK; | 450 return S_OK; |
451 } | 451 } |
452 | 452 |
453 STDMETHOD(get_onload)(VARIANT* onload_handler) { | 453 STDMETHOD(get_onload)(VARIANT* onload_handler) { |
454 if (NULL == onload_handler) | 454 if (NULL == onload_handler) |
455 return E_INVALIDARG; | 455 return E_INVALIDARG; |
456 | 456 |
457 *onload_handler = onload_handler_.Copy(); | 457 *onload_handler = onload_handler_.Copy(); |
458 | 458 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 hr = E_UNEXPECTED; | 695 hr = E_UNEXPECTED; |
696 } | 696 } |
697 } | 697 } |
698 | 698 |
699 return hr; | 699 return hr; |
700 } | 700 } |
701 | 701 |
702 // Helper function to execute a function on a script IDispatch interface. | 702 // Helper function to execute a function on a script IDispatch interface. |
703 HRESULT InvokeScriptFunction(const VARIANT& script_object, | 703 HRESULT InvokeScriptFunction(const VARIANT& script_object, |
704 const std::string& param) { | 704 const std::string& param) { |
705 base::win::ScopedVariant script_arg(UTF8ToWide(param.c_str()).c_str()); | 705 base::win::ScopedVariant script_arg( |
| 706 base::UTF8ToWide(param.c_str()).c_str()); |
706 return InvokeScriptFunction(script_object, script_arg.AsInput()); | 707 return InvokeScriptFunction(script_object, script_arg.AsInput()); |
707 } | 708 } |
708 | 709 |
709 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* param) { | 710 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* param) { |
710 return InvokeScriptFunction(script_object, param, 1); | 711 return InvokeScriptFunction(script_object, param, 1); |
711 } | 712 } |
712 | 713 |
713 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* params, | 714 HRESULT InvokeScriptFunction(const VARIANT& script_object, VARIANT* params, |
714 int param_count) { | 715 int param_count) { |
715 DCHECK_GE(param_count, 0); | 716 DCHECK_GE(param_count, 0); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 829 } |
829 base::win::ScopedVariant url; | 830 base::win::ScopedVariant url; |
830 // Check to see if the URL uses a "view-source:" prefix, if so, open it | 831 // Check to see if the URL uses a "view-source:" prefix, if so, open it |
831 // using chrome frame full tab mode by using 'cf:' protocol handler. | 832 // using chrome frame full tab mode by using 'cf:' protocol handler. |
832 // Also change the disposition to NEW_WINDOW since IE6 doesn't have tabs. | 833 // Also change the disposition to NEW_WINDOW since IE6 doesn't have tabs. |
833 if (url_to_open.has_scheme() && | 834 if (url_to_open.has_scheme() && |
834 (url_to_open.SchemeIs(content::kViewSourceScheme) || | 835 (url_to_open.SchemeIs(content::kViewSourceScheme) || |
835 url_to_open.SchemeIs(chrome::kAboutScheme))) { | 836 url_to_open.SchemeIs(chrome::kAboutScheme))) { |
836 std::wstring chrome_url; | 837 std::wstring chrome_url; |
837 chrome_url.append(kChromeProtocolPrefix); | 838 chrome_url.append(kChromeProtocolPrefix); |
838 chrome_url.append(UTF8ToWide(url_to_open.spec())); | 839 chrome_url.append(base::UTF8ToWide(url_to_open.spec())); |
839 url.Set(chrome_url.c_str()); | 840 url.Set(chrome_url.c_str()); |
840 open_disposition = NEW_WINDOW; | 841 open_disposition = NEW_WINDOW; |
841 } else { | 842 } else { |
842 url.Set(UTF8ToWide(url_to_open.spec()).c_str()); | 843 url.Set(base::UTF8ToWide(url_to_open.spec()).c_str()); |
843 } | 844 } |
844 | 845 |
845 VARIANT flags = { VT_I4 }; | 846 VARIANT flags = { VT_I4 }; |
846 V_I4(&flags) = 0; | 847 V_I4(&flags) = 0; |
847 | 848 |
848 IEVersion ie_version = GetIEVersion(); | 849 IEVersion ie_version = GetIEVersion(); |
849 DCHECK(ie_version != NON_IE && ie_version != IE_UNSUPPORTED); | 850 DCHECK(ie_version != NON_IE && ie_version != IE_UNSUPPORTED); |
850 // Since IE6 doesn't support tabs, so we just use window instead. | 851 // Since IE6 doesn't support tabs, so we just use window instead. |
851 if (ie_version == IE_6) { | 852 if (ie_version == IE_6) { |
852 if (open_disposition == NEW_FOREGROUND_TAB || | 853 if (open_disposition == NEW_FOREGROUND_TAB || |
(...skipping 26 matching lines...) Expand all Loading... |
879 // "Always open popups in a new window". Otherwise it opens in a new tab. | 880 // "Always open popups in a new window". Otherwise it opens in a new tab. |
880 // We need to investigate more and see if we can force IE to display the | 881 // We need to investigate more and see if we can force IE to display the |
881 // link in a new window. MSHTML uses the below code to force an open in a | 882 // link in a new window. MSHTML uses the below code to force an open in a |
882 // new window. But this logic also fails for us. Perhaps this flag is not | 883 // new window. But this logic also fails for us. Perhaps this flag is not |
883 // honoured if the ActiveDoc is not MSHTML. | 884 // honoured if the ActiveDoc is not MSHTML. |
884 // Even the HLNF_DISABLEWINDOWRESTRICTIONS flag did not work. | 885 // Even the HLNF_DISABLEWINDOWRESTRICTIONS flag did not work. |
885 // Start of MSHTML-like logic. | 886 // Start of MSHTML-like logic. |
886 // CComQIPtr<ITargetFramePriv2> target_frame = web_browser2; | 887 // CComQIPtr<ITargetFramePriv2> target_frame = web_browser2; |
887 // if (target_frame) { | 888 // if (target_frame) { |
888 // CComPtr<IUri> uri; | 889 // CComPtr<IUri> uri; |
889 // CreateUri(UTF8ToWide(open_url_command->url_.spec()).c_str(), | 890 // CreateUri(base::UTF8ToWide(open_url_command->url_.spec()).c_str(), |
890 // Uri_CREATE_IE_SETTINGS, 0, &uri); | 891 // Uri_CREATE_IE_SETTINGS, 0, &uri); |
891 // CComPtr<IBindCtx> bind_ctx; | 892 // CComPtr<IBindCtx> bind_ctx; |
892 // CreateBindCtx(0, &bind_ctx); | 893 // CreateBindCtx(0, &bind_ctx); |
893 // target_frame->AggregatedNavigation2( | 894 // target_frame->AggregatedNavigation2( |
894 // HLNF_TRUSTFIRSTDOWNLOAD|HLNF_OPENINNEWWINDOW, bind_ctx, NULL, | 895 // HLNF_TRUSTFIRSTDOWNLOAD|HLNF_OPENINNEWWINDOW, bind_ctx, NULL, |
895 // L"No_Name", uri, L""); | 896 // L"No_Name", uri, L""); |
896 // } | 897 // } |
897 // End of MSHTML-like logic | 898 // End of MSHTML-like logic |
898 VARIANT empty = base::win::ScopedVariant::kEmptyVariant; | 899 VARIANT empty = base::win::ScopedVariant::kEmptyVariant; |
899 base::win::ScopedVariant http_headers; | 900 base::win::ScopedVariant http_headers; |
900 | 901 |
901 if (referrer.is_valid()) { | 902 if (referrer.is_valid()) { |
902 std::wstring referrer_header = L"Referer: "; | 903 std::wstring referrer_header = L"Referer: "; |
903 referrer_header += UTF8ToWide(referrer.spec()); | 904 referrer_header += base::UTF8ToWide(referrer.spec()); |
904 referrer_header += L"\r\n\r\n"; | 905 referrer_header += L"\r\n\r\n"; |
905 http_headers.Set(referrer_header.c_str()); | 906 http_headers.Set(referrer_header.c_str()); |
906 } | 907 } |
907 | 908 |
908 // IE6 does not support tabs. If Chrome sent us a window open request | 909 // IE6 does not support tabs. If Chrome sent us a window open request |
909 // indicating that the navigation needs to occur in a foreground tab or | 910 // indicating that the navigation needs to occur in a foreground tab or |
910 // a popup window, then we need to ensure that the new window in IE6 is | 911 // a popup window, then we need to ensure that the new window in IE6 is |
911 // brought to the foreground. | 912 // brought to the foreground. |
912 if (ie_version == IE_6) { | 913 if (ie_version == IE_6) { |
913 ChromeFrameUrl cf_url; | 914 ChromeFrameUrl cf_url; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 EventHandlers onreadystatechanged_; | 975 EventHandlers onreadystatechanged_; |
975 EventHandlers onprivatemessage_; | 976 EventHandlers onprivatemessage_; |
976 EventHandlers onextensionready_; | 977 EventHandlers onextensionready_; |
977 | 978 |
978 // Handle network requests when host network stack is used. Passed to the | 979 // Handle network requests when host network stack is used. Passed to the |
979 // automation client on initialization. | 980 // automation client on initialization. |
980 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; | 981 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; |
981 }; | 982 }; |
982 | 983 |
983 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 984 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
OLD | NEW |