OLD | NEW |
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 #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 11 matching lines...) Expand all Loading... |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "base/win/scoped_bstr.h" | 23 #include "base/win/scoped_bstr.h" |
24 #include "base/win/scoped_comptr.h" | 24 #include "base/win/scoped_comptr.h" |
25 #include "base/win/scoped_variant.h" | 25 #include "base/win/scoped_variant.h" |
26 #include "grit/chrome_frame_resources.h" | 26 #include "grit/chrome_frame_resources.h" |
27 #include "ceee/ie/common/ceee_util.h" | 27 #include "ceee/ie/common/ceee_util.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "chrome_frame/chrome_frame_plugin.h" | 29 #include "chrome_frame/chrome_frame_plugin.h" |
30 #include "chrome_frame/com_message_event.h" | 30 #include "chrome_frame/com_message_event.h" |
31 #include "chrome_frame/com_type_info_holder.h" | 31 #include "chrome_frame/com_type_info_holder.h" |
32 #include "chrome_frame/navigation_constraints.h" | |
33 #include "chrome_frame/simple_resource_loader.h" | 32 #include "chrome_frame/simple_resource_loader.h" |
34 #include "chrome_frame/urlmon_url_request.h" | 33 #include "chrome_frame/urlmon_url_request.h" |
35 #include "chrome_frame/urlmon_url_request_private.h" | 34 #include "chrome_frame/urlmon_url_request_private.h" |
36 #include "chrome_frame/utils.h" | 35 #include "chrome_frame/utils.h" |
37 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
38 #include "net/base/cookie_monster.h" | 37 #include "net/base/cookie_monster.h" |
39 | 38 |
40 // Include without path to make GYP build see it. | 39 // Include without path to make GYP build see it. |
41 #include "chrome_tab.h" // NOLINT | 40 #include "chrome_tab.h" // NOLINT |
42 | 41 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 public IQuickActivateImpl<T>, | 162 public IQuickActivateImpl<T>, |
164 public com_util::IProvideClassInfo2Impl<class_id, | 163 public com_util::IProvideClassInfo2Impl<class_id, |
165 DIID_DIChromeFrameEvents>, | 164 DIID_DIChromeFrameEvents>, |
166 public com_util::IDispatchImpl<IChromeFrame>, | 165 public com_util::IDispatchImpl<IChromeFrame>, |
167 public IChromeFrameInternal, | 166 public IChromeFrameInternal, |
168 public IConnectionPointContainerImpl<T>, | 167 public IConnectionPointContainerImpl<T>, |
169 public ProxyDIChromeFrameEvents<T>, | 168 public ProxyDIChromeFrameEvents<T>, |
170 public IPropertyNotifySinkCP<T>, | 169 public IPropertyNotifySinkCP<T>, |
171 public CComCoClass<T, &class_id>, | 170 public CComCoClass<T, &class_id>, |
172 public CComControl<T>, | 171 public CComControl<T>, |
173 public ChromeFramePlugin<T>, | 172 public ChromeFramePlugin<T> { |
174 public NavigationConstraintsImpl { | |
175 protected: | 173 protected: |
176 typedef std::set<base::win::ScopedComPtr<IDispatch> > EventHandlers; | 174 typedef std::set<base::win::ScopedComPtr<IDispatch> > EventHandlers; |
177 typedef ChromeFrameActivexBase<T, class_id> BasePlugin; | 175 typedef ChromeFrameActivexBase<T, class_id> BasePlugin; |
178 | 176 |
179 public: | 177 public: |
180 ChromeFrameActivexBase() | 178 ChromeFrameActivexBase() |
181 : ready_state_(READYSTATE_UNINITIALIZED), | 179 : ready_state_(READYSTATE_UNINITIALIZED), |
182 url_fetcher_(new UrlmonUrlRequestManager()), | 180 url_fetcher_(new UrlmonUrlRequestManager()), |
183 failed_to_fetch_in_place_frame_(false), | 181 failed_to_fetch_in_place_frame_(false), |
184 draw_sad_tab_(false), | 182 draw_sad_tab_(false), |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // ActiveX controls genereally will want to do this, | 379 // ActiveX controls genereally will want to do this, |
382 // returning true, while true top-level documents | 380 // returning true, while true top-level documents |
383 // (ActiveDocument servers) will not. Your specialization | 381 // (ActiveDocument servers) will not. Your specialization |
384 // of this template should implement this method based on how | 382 // of this template should implement this method based on how |
385 // it "feels" from a security perspective. If it's hosted in another | 383 // it "feels" from a security perspective. If it's hosted in another |
386 // scriptable document, return true, else false. | 384 // scriptable document, return true, else false. |
387 // | 385 // |
388 // The base implementation returns true unless we are in privileged | 386 // The base implementation returns true unless we are in privileged |
389 // mode, in which case we always trust our container so we return false. | 387 // mode, in which case we always trust our container so we return false. |
390 bool is_frame_busting_enabled() const { | 388 bool is_frame_busting_enabled() const { |
391 return !is_privileged_; | 389 return !is_privileged(); |
392 } | 390 } |
393 | 391 |
394 // Needed to support PostTask. | 392 // Needed to support PostTask. |
395 static bool ImplementsThreadSafeReferenceCounting() { | 393 static bool ImplementsThreadSafeReferenceCounting() { |
396 return true; | 394 return true; |
397 } | 395 } |
398 | 396 |
399 protected: | 397 protected: |
400 virtual void GetProfilePath(const std::wstring& profile_name, | 398 virtual void GetProfilePath(const std::wstring& profile_name, |
401 FilePath* profile_path) { | 399 FilePath* profile_path) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 std::wstring wide_url = url_; | 485 std::wstring wide_url = url_; |
488 GURL parsed_url(WideToUTF8(wide_url)); | 486 GURL parsed_url(WideToUTF8(wide_url)); |
489 | 487 |
490 // If Chrome-Frame is presently navigated to an extension page, navigating | 488 // If Chrome-Frame is presently navigated to an extension page, navigating |
491 // the host to a url with scheme chrome-extension will fail, so we | 489 // the host to a url with scheme chrome-extension will fail, so we |
492 // point the host at http:local_host. Note that this is NOT the URL | 490 // point the host at http:local_host. Note that this is NOT the URL |
493 // to which the host is directed. It is only used as a temporary message | 491 // to which the host is directed. It is only used as a temporary message |
494 // passing mechanism between this CF instance, and the BHO that will | 492 // passing mechanism between this CF instance, and the BHO that will |
495 // be constructed in the new IE tab. | 493 // be constructed in the new IE tab. |
496 if (parsed_url.SchemeIs("chrome-extension") && | 494 if (parsed_url.SchemeIs("chrome-extension") && |
497 is_privileged_) { | 495 is_privileged()) { |
498 const char kScheme[] = "http"; | 496 const char kScheme[] = "http"; |
499 const char kHost[] = "local_host"; | 497 const char kHost[] = "local_host"; |
500 | 498 |
501 GURL::Replacements r; | 499 GURL::Replacements r; |
502 r.SetScheme(kScheme, url_parse::Component(0, sizeof(kScheme) -1)); | 500 r.SetScheme(kScheme, url_parse::Component(0, sizeof(kScheme) -1)); |
503 r.SetHost(kHost, url_parse::Component(0, sizeof(kHost) - 1)); | 501 r.SetHost(kHost, url_parse::Component(0, sizeof(kHost) - 1)); |
504 parsed_url = parsed_url.ReplaceComponents(r); | 502 parsed_url = parsed_url.ReplaceComponents(r); |
505 } | 503 } |
506 | 504 |
507 std::string url = base::StringPrintf( | 505 std::string url = base::StringPrintf( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 draw_sad_tab_ = true; | 564 draw_sad_tab_ = true; |
567 | 565 |
568 ready_state_ = READYSTATE_UNINITIALIZED; | 566 ready_state_ = READYSTATE_UNINITIALIZED; |
569 FireOnChanged(DISPID_READYSTATE); | 567 FireOnChanged(DISPID_READYSTATE); |
570 } | 568 } |
571 | 569 |
572 virtual void OnCloseTab(int tab_handle) { | 570 virtual void OnCloseTab(int tab_handle) { |
573 Fire_onclose(); | 571 Fire_onclose(); |
574 } | 572 } |
575 | 573 |
576 // NavigationConstraints overrides. | |
577 virtual bool IsSchemeAllowed(const GURL& url) { | |
578 bool allowed = NavigationConstraintsImpl::IsSchemeAllowed(url); | |
579 if (allowed) | |
580 return true; | |
581 | |
582 if (is_privileged_ && | |
583 (url.SchemeIs(chrome::kDataScheme) || | |
584 url.SchemeIs(chrome::kExtensionScheme))) { | |
585 return true; | |
586 } | |
587 return false; | |
588 } | |
589 | |
590 // Overridden to take advantage of readystate prop changes and send those | 574 // Overridden to take advantage of readystate prop changes and send those |
591 // to potential listeners. | 575 // to potential listeners. |
592 HRESULT FireOnChanged(DISPID dispid) { | 576 HRESULT FireOnChanged(DISPID dispid) { |
593 if (dispid == DISPID_READYSTATE) { | 577 if (dispid == DISPID_READYSTATE) { |
594 Fire_onreadystatechanged(ready_state_); | 578 Fire_onreadystatechanged(ready_state_); |
595 } | 579 } |
596 return __super::FireOnChanged(dispid); | 580 return __super::FireOnChanged(dispid); |
597 } | 581 } |
598 | 582 |
599 // IChromeFrame | 583 // IChromeFrame |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 STDMETHOD(get_useChromeNetwork)(VARIANT_BOOL* use_chrome_network) { | 710 STDMETHOD(get_useChromeNetwork)(VARIANT_BOOL* use_chrome_network) { |
727 if (!use_chrome_network) | 711 if (!use_chrome_network) |
728 return E_INVALIDARG; | 712 return E_INVALIDARG; |
729 | 713 |
730 *use_chrome_network = | 714 *use_chrome_network = |
731 automation_client_->use_chrome_network() ? VARIANT_TRUE : VARIANT_FALSE; | 715 automation_client_->use_chrome_network() ? VARIANT_TRUE : VARIANT_FALSE; |
732 return S_OK; | 716 return S_OK; |
733 } | 717 } |
734 | 718 |
735 STDMETHOD(put_useChromeNetwork)(VARIANT_BOOL use_chrome_network) { | 719 STDMETHOD(put_useChromeNetwork)(VARIANT_BOOL use_chrome_network) { |
736 if (!is_privileged_) { | 720 if (!is_privileged()) { |
737 DLOG(ERROR) << "Attempt to set useChromeNetwork in non-privileged mode"; | 721 DLOG(ERROR) << "Attempt to set useChromeNetwork in non-privileged mode"; |
738 return E_ACCESSDENIED; | 722 return E_ACCESSDENIED; |
739 } | 723 } |
740 | 724 |
741 automation_client_->set_use_chrome_network( | 725 automation_client_->set_use_chrome_network( |
742 (VARIANT_FALSE != use_chrome_network)); | 726 (VARIANT_FALSE != use_chrome_network)); |
743 return S_OK; | 727 return S_OK; |
744 } | 728 } |
745 | 729 |
746 // Posts a message to the chrome frame. | 730 // Posts a message to the chrome frame. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 } | 807 } |
824 | 808 |
825 *version = SysAllocString(automation_client_->GetVersion().c_str()); | 809 *version = SysAllocString(automation_client_->GetVersion().c_str()); |
826 return S_OK; | 810 return S_OK; |
827 } | 811 } |
828 | 812 |
829 STDMETHOD(postPrivateMessage)(BSTR message, BSTR origin, BSTR target) { | 813 STDMETHOD(postPrivateMessage)(BSTR message, BSTR origin, BSTR target) { |
830 if (NULL == message) | 814 if (NULL == message) |
831 return E_INVALIDARG; | 815 return E_INVALIDARG; |
832 | 816 |
833 if (!is_privileged_) { | 817 if (!is_privileged()) { |
834 DLOG(ERROR) << "Attempt to postPrivateMessage in non-privileged mode"; | 818 DLOG(ERROR) << "Attempt to postPrivateMessage in non-privileged mode"; |
835 return E_ACCESSDENIED; | 819 return E_ACCESSDENIED; |
836 } | 820 } |
837 | 821 |
838 DCHECK(automation_client_.get()); | 822 DCHECK(automation_client_.get()); |
839 std::string utf8_message, utf8_origin, utf8_target; | 823 std::string utf8_message, utf8_origin, utf8_target; |
840 WideToUTF8(message, ::SysStringLen(message), &utf8_message); | 824 WideToUTF8(message, ::SysStringLen(message), &utf8_message); |
841 WideToUTF8(origin, ::SysStringLen(origin), &utf8_origin); | 825 WideToUTF8(origin, ::SysStringLen(origin), &utf8_origin); |
842 WideToUTF8(target, ::SysStringLen(target), &utf8_target); | 826 WideToUTF8(target, ::SysStringLen(target), &utf8_target); |
843 | 827 |
844 if (!automation_client_->ForwardMessageFromExternalHost(utf8_message, | 828 if (!automation_client_->ForwardMessageFromExternalHost(utf8_message, |
845 utf8_origin, | 829 utf8_origin, |
846 utf8_target)) { | 830 utf8_target)) { |
847 Error(L"Failed to post message to chrome frame"); | 831 Error(L"Failed to post message to chrome frame"); |
848 return E_FAIL; | 832 return E_FAIL; |
849 } | 833 } |
850 | 834 |
851 return S_OK; | 835 return S_OK; |
852 } | 836 } |
853 | 837 |
854 STDMETHOD(installExtension)(BSTR crx_path) { | 838 STDMETHOD(installExtension)(BSTR crx_path) { |
855 DCHECK(automation_client_.get()); | 839 DCHECK(automation_client_.get()); |
856 | 840 |
857 if (NULL == crx_path) { | 841 if (NULL == crx_path) { |
858 NOTREACHED(); | 842 NOTREACHED(); |
859 return E_INVALIDARG; | 843 return E_INVALIDARG; |
860 } | 844 } |
861 | 845 |
862 if (!is_privileged_) { | 846 if (!is_privileged()) { |
863 DLOG(ERROR) << "Attempt to installExtension in non-privileged mode"; | 847 DLOG(ERROR) << "Attempt to installExtension in non-privileged mode"; |
864 return E_ACCESSDENIED; | 848 return E_ACCESSDENIED; |
865 } | 849 } |
866 | 850 |
867 FilePath::StringType crx_path_str(crx_path); | 851 FilePath::StringType crx_path_str(crx_path); |
868 FilePath crx_file_path(crx_path_str); | 852 FilePath crx_file_path(crx_path_str); |
869 | 853 |
870 automation_client_->InstallExtension(crx_file_path, NULL); | 854 automation_client_->InstallExtension(crx_file_path, NULL); |
871 return S_OK; | 855 return S_OK; |
872 } | 856 } |
873 | 857 |
874 STDMETHOD(loadExtension)(BSTR path) { | 858 STDMETHOD(loadExtension)(BSTR path) { |
875 DCHECK(automation_client_.get()); | 859 DCHECK(automation_client_.get()); |
876 | 860 |
877 if (NULL == path) { | 861 if (NULL == path) { |
878 NOTREACHED(); | 862 NOTREACHED(); |
879 return E_INVALIDARG; | 863 return E_INVALIDARG; |
880 } | 864 } |
881 | 865 |
882 if (!is_privileged_) { | 866 if (!is_privileged()) { |
883 DLOG(ERROR) << "Attempt to loadExtension in non-privileged mode"; | 867 DLOG(ERROR) << "Attempt to loadExtension in non-privileged mode"; |
884 return E_ACCESSDENIED; | 868 return E_ACCESSDENIED; |
885 } | 869 } |
886 | 870 |
887 FilePath::StringType path_str(path); | 871 FilePath::StringType path_str(path); |
888 FilePath file_path(path_str); | 872 FilePath file_path(path_str); |
889 | 873 |
890 automation_client_->LoadExpandedExtension(file_path, NULL); | 874 automation_client_->LoadExpandedExtension(file_path, NULL); |
891 return S_OK; | 875 return S_OK; |
892 } | 876 } |
893 | 877 |
894 STDMETHOD(getEnabledExtensions)() { | 878 STDMETHOD(getEnabledExtensions)() { |
895 DCHECK(automation_client_.get()); | 879 DCHECK(automation_client_.get()); |
896 | 880 |
897 if (!is_privileged_) { | 881 if (!is_privileged()) { |
898 DLOG(ERROR) << "Attempt to getEnabledExtensions in non-privileged mode"; | 882 DLOG(ERROR) << "Attempt to getEnabledExtensions in non-privileged mode"; |
899 return E_ACCESSDENIED; | 883 return E_ACCESSDENIED; |
900 } | 884 } |
901 | 885 |
902 automation_client_->GetEnabledExtensions(NULL); | 886 automation_client_->GetEnabledExtensions(NULL); |
903 return S_OK; | 887 return S_OK; |
904 } | 888 } |
905 | 889 |
906 STDMETHOD(getSessionId)(int* session_id) { | 890 STDMETHOD(getSessionId)(int* session_id) { |
907 DCHECK(automation_client_.get()); | 891 DCHECK(automation_client_.get()); |
908 DCHECK(session_id); | 892 DCHECK(session_id); |
909 | 893 |
910 if (!is_privileged_) { | 894 if (!is_privileged()) { |
911 DLOG(ERROR) << "Attempt to getSessionId in non-privileged mode"; | 895 DLOG(ERROR) << "Attempt to getSessionId in non-privileged mode"; |
912 return E_ACCESSDENIED; | 896 return E_ACCESSDENIED; |
913 } | 897 } |
914 | 898 |
915 *session_id = automation_client_->GetSessionId(); | 899 *session_id = automation_client_->GetSessionId(); |
916 return (*session_id) == -1 ? S_FALSE : S_OK; | 900 return (*session_id) == -1 ? S_FALSE : S_OK; |
917 } | 901 } |
918 | 902 |
919 STDMETHOD(registerBhoIfNeeded)() { | 903 STDMETHOD(registerBhoIfNeeded)() { |
920 return E_NOTIMPL; | 904 return E_NOTIMPL; |
(...skipping 13 matching lines...) Expand all Loading... |
934 } else if (LowerCaseEqualsASCII(event_type, event_type_end, "load")) { | 918 } else if (LowerCaseEqualsASCII(event_type, event_type_end, "load")) { |
935 *handlers = &onload_; | 919 *handlers = &onload_; |
936 } else if (LowerCaseEqualsASCII(event_type, event_type_end, "loaderror")) { | 920 } else if (LowerCaseEqualsASCII(event_type, event_type_end, "loaderror")) { |
937 *handlers = &onloaderror_; | 921 *handlers = &onloaderror_; |
938 } else if (LowerCaseEqualsASCII(event_type, event_type_end, | 922 } else if (LowerCaseEqualsASCII(event_type, event_type_end, |
939 "readystatechanged")) { | 923 "readystatechanged")) { |
940 *handlers = &onreadystatechanged_; | 924 *handlers = &onreadystatechanged_; |
941 } else if (LowerCaseEqualsASCII(event_type, event_type_end, | 925 } else if (LowerCaseEqualsASCII(event_type, event_type_end, |
942 "privatemessage")) { | 926 "privatemessage")) { |
943 // This event handler is only available in privileged mode. | 927 // This event handler is only available in privileged mode. |
944 if (is_privileged_) { | 928 if (is_privileged()) { |
945 *handlers = &onprivatemessage_; | 929 *handlers = &onprivatemessage_; |
946 } else { | 930 } else { |
947 Error("Event type 'privatemessage' is privileged"); | 931 Error("Event type 'privatemessage' is privileged"); |
948 hr = E_ACCESSDENIED; | 932 hr = E_ACCESSDENIED; |
949 } | 933 } |
950 } else if (LowerCaseEqualsASCII(event_type, event_type_end, | 934 } else if (LowerCaseEqualsASCII(event_type, event_type_end, |
951 "extensionready")) { | 935 "extensionready")) { |
952 // This event handler is only available in privileged mode. | 936 // This event handler is only available in privileged mode. |
953 if (is_privileged_) { | 937 if (is_privileged()) { |
954 *handlers = &onextensionready_; | 938 *handlers = &onextensionready_; |
955 } else { | 939 } else { |
956 Error("Event type 'extensionready' is privileged"); | 940 Error("Event type 'extensionready' is privileged"); |
957 hr = E_ACCESSDENIED; | 941 hr = E_ACCESSDENIED; |
958 } | 942 } |
959 } else { | 943 } else { |
960 Error(base::StringPrintf( | 944 Error(base::StringPrintf( |
961 "Event type '%ls' not found", event_type).c_str()); | 945 "Event type '%ls' not found", event_type).c_str()); |
962 hr = E_INVALIDARG; | 946 hr = E_INVALIDARG; |
963 } | 947 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 EventHandlers onextensionready_; | 1271 EventHandlers onextensionready_; |
1288 | 1272 |
1289 // Handle network requests when host network stack is used. Passed to the | 1273 // Handle network requests when host network stack is used. Passed to the |
1290 // automation client on initialization. | 1274 // automation client on initialization. |
1291 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; | 1275 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; |
1292 | 1276 |
1293 HINSTANCE prev_resource_instance_; | 1277 HINSTANCE prev_resource_instance_; |
1294 }; | 1278 }; |
1295 | 1279 |
1296 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 1280 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
OLD | NEW |