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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 // 0x80020101 == SCRIPT_E_REPORTED. | 907 // 0x80020101 == SCRIPT_E_REPORTED. |
908 // When the script we're invoking has an error, we get this error back. | 908 // When the script we're invoking has an error, we get this error back. |
909 DLOG_IF(ERROR, FAILED(hr) && hr != 0x80020101) << "Failed to invoke script"; | 909 DLOG_IF(ERROR, FAILED(hr) && hr != 0x80020101) << "Failed to invoke script"; |
910 return hr; | 910 return hr; |
911 } | 911 } |
912 | 912 |
913 // Gives the browser a chance to handle an accelerator that was | 913 // Gives the browser a chance to handle an accelerator that was |
914 // sent to the out of proc chromium instance. | 914 // sent to the out of proc chromium instance. |
915 // Returns S_OK iff the accelerator was handled by the browser. | 915 // Returns S_OK iff the accelerator was handled by the browser. |
916 HRESULT AllowFrameToTranslateAccelerator(const MSG& msg) { | 916 HRESULT AllowFrameToTranslateAccelerator(const MSG& msg) { |
| 917 static const int kMayTranslateAcceleratorOffset = 0x170; |
917 // Although IBrowserService2 is officially deprecated, it's still alive | 918 // Although IBrowserService2 is officially deprecated, it's still alive |
918 // and well in IE7 and earlier. We have to use it here to correctly give | 919 // and well in IE7 and earlier. We have to use it here to correctly give |
919 // the browser a chance to handle keyboard shortcuts. | 920 // the browser a chance to handle keyboard shortcuts. |
920 // This happens automatically for activex components that have windows that | 921 // This happens automatically for activex components that have windows that |
921 // belong to the current thread. In that circumstance IE owns the message | 922 // belong to the current thread. In that circumstance IE owns the message |
922 // loop and can walk the line of components allowing each participant the | 923 // loop and can walk the line of components allowing each participant the |
923 // chance to handle the keystroke and eventually falls back to | 924 // chance to handle the keystroke and eventually falls back to |
924 // v_MayTranslateAccelerator. However in our case, the message loop is | 925 // v_MayTranslateAccelerator. However in our case, the message loop is |
925 // owned by the out-of-proc chromium instance so IE doesn't have a chance to | 926 // owned by the out-of-proc chromium instance so IE doesn't have a chance to |
926 // fall back on its default behavior. Instead we give IE a chance to | 927 // fall back on its default behavior. Instead we give IE a chance to |
927 // handle the shortcut here. | 928 // handle the shortcut here. |
928 | |
929 MSG accel_message = msg; | 929 MSG accel_message = msg; |
930 accel_message.hwnd = ::GetParent(m_hWnd); | 930 accel_message.hwnd = ::GetParent(m_hWnd); |
931 | |
932 HRESULT hr = S_FALSE; | 931 HRESULT hr = S_FALSE; |
933 ScopedComPtr<IBrowserService2> bs2; | 932 ScopedComPtr<IBrowserService2> bs2; |
| 933 // The code below explicitly checks for whether the |
| 934 // IBrowserService2::v_MayTranslateAccelerator function is valid. On IE8 |
| 935 // there is one vtable ieframe!c_ImpostorBrowserService2Vtbl where this |
| 936 // function entry is NULL which leads to a crash. We don't know under what |
| 937 // circumstances this vtable is actually used though. |
934 if (S_OK == DoQueryService(SID_STopLevelBrowser, m_spInPlaceSite, | 938 if (S_OK == DoQueryService(SID_STopLevelBrowser, m_spInPlaceSite, |
935 bs2.Receive()) && bs2.get()) { | 939 bs2.Receive()) && bs2.get() && |
| 940 (bs2 + kMayTranslateAcceleratorOffset)) { |
936 hr = bs2->v_MayTranslateAccelerator(&accel_message); | 941 hr = bs2->v_MayTranslateAccelerator(&accel_message); |
937 } else { | 942 } else { |
938 // IE8 doesn't support IBrowserService2 unless you enable a special, | 943 // IE8 doesn't support IBrowserService2 unless you enable a special, |
939 // undocumented flag with CoInternetSetFeatureEnabled and even then, | 944 // undocumented flag with CoInternetSetFeatureEnabled and even then, |
940 // the object you get back implements only a couple of methods of | 945 // the object you get back implements only a couple of methods of |
941 // that interface... all the other entries in the vtable are NULL. | 946 // that interface... all the other entries in the vtable are NULL. |
942 // In addition, the class that implements it is called | 947 // In addition, the class that implements it is called |
943 // ImpostorBrowserService2 :) | 948 // ImpostorBrowserService2 :) |
944 // IE8 does have a new interface though, presumably called | 949 // IE8 does have a new interface though, presumably called |
945 // ITabBrowserService or something that can be abbreviated to TBS. | 950 // ITabBrowserService or something that can be abbreviated to TBS. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 EventHandlers onreadystatechanged_; | 1125 EventHandlers onreadystatechanged_; |
1121 EventHandlers onprivatemessage_; | 1126 EventHandlers onprivatemessage_; |
1122 EventHandlers onextensionready_; | 1127 EventHandlers onextensionready_; |
1123 | 1128 |
1124 // Handle network requests when host network stack is used. Passed to the | 1129 // Handle network requests when host network stack is used. Passed to the |
1125 // automation client on initialization. | 1130 // automation client on initialization. |
1126 UrlmonUrlRequestManager url_fetcher_; | 1131 UrlmonUrlRequestManager url_fetcher_; |
1127 }; | 1132 }; |
1128 | 1133 |
1129 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 1134 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
OLD | NEW |