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