[email protected] | 074283a | 2010-05-28 23:47:59 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_FRAME_CHROME_ACTIVE_DOCUMENT_H_ |
| 6 | #define CHROME_FRAME_CHROME_ACTIVE_DOCUMENT_H_ |
| 7 | |
| 8 | #include <atlbase.h> |
| 9 | #include <atlcom.h> |
| 10 | #include <atlctl.h> |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 11 | #include <htiframe.h> |
[email protected] | c4e45b3 | 2010-07-28 21:15:15 | [diff] [blame] | 12 | #include <map> |
[email protected] | 1bb5f89 | 2009-10-06 01:44:57 | [diff] [blame] | 13 | #include <mshtmcid.h> |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 14 | #include <perhist.h> |
[email protected] | c4e45b3 | 2010-07-28 21:15:15 | [diff] [blame] | 15 | #include <string> |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 16 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 17 | #include "base/scoped_ptr.h" |
| 18 | #include "base/scoped_comptr_win.h" |
| 19 | #include "base/thread.h" |
| 20 | |
| 21 | #include "chrome_frame/chrome_frame_activex_base.h" |
| 22 | #include "chrome_frame/com_type_info_holder.h" |
| 23 | #include "chrome_frame/find_dialog.h" |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 24 | #include "chrome_frame/html_private_window_impl.h" |
| 25 | #include "chrome_frame/html_window_impl.h" |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 26 | #include "chrome_frame/in_place_menu.h" |
| 27 | #include "chrome_frame/ole_document_impl.h" |
| 28 | #include "chrome_frame/resource.h" |
| 29 | #include "chrome_frame/extra_system_apis.h" |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 30 | #include "chrome_frame/utils.h" |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 31 | |
| 32 | class Thread; |
| 33 | class TabProxy; |
| 34 | class ChromeActiveDocument; |
| 35 | |
| 36 | // A call to IOleCommandTarget::Exec on the webbrowser with this command id |
| 37 | // and a command group of CGID_EXPLORER causes IE to finalize the current |
| 38 | // travel log entry and move to a new location (pruning any forward entries |
| 39 | // if needed) |
| 40 | #define INTERNAL_CMDID_FINALIZE_TRAVEL_LOG (38) |
| 41 | |
| 42 | // To set the lock icon status call IOleCommandTarget::Exec on site with |
| 43 | // this command id and a command group of CGID_EXPLORER The in arg is one of |
| 44 | // the values: SECURELOCK_SET_UNSECURE, SECURELOCK_SET_MIXED, |
| 45 | // SECURELOCK_SET_SECURE128BIT etc declared in shdeprecated.h |
| 46 | #define INTERNAL_CMDID_SET_SSL_LOCK (37) |
| 47 | |
| 48 | // A call to IOleCommandTarget::Exec on the webbrowser with this command id |
| 49 | // and a command group of CGID_EXPLORER causes IE to replace the URL in the |
| 50 | // current travel log entry |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 51 | #define INTERNAL_CMDID_REPLACE_CURRENT_TRAVEL_LOG_ENTRY_URL (40) |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 52 | |
[email protected] | 2f2afba | 2010-04-01 01:53:19 | [diff] [blame] | 53 | // The following macro is to define the mapping of IE encoding menu item to |
| 54 | // corresponding available encoding name in Chrome. For each encoding |
| 55 | // definition, there are three fields. |
| 56 | // The first one is the definition name of encoding menu item in IE. |
| 57 | // The second one is execution id of the encoding menu item in IE, starting |
| 58 | // from 3609(IDM_MIMECSET__FIRST__) to 3699(IDM_MIMECSET__LAST__) end. For |
| 59 | // the details, please refer to mshtmcid.h. |
| 60 | // The last one is the available encoding name of the IE encoding menu item |
| 61 | // in Chrome. If the encoding menu item does not have corresponding encoding |
| 62 | // in Chrome, it will be "unknown". |
| 63 | // So far we don't support the encoding auto detect since we can not control |
| 64 | // the status of encoding menu, such as toggle status of encoding auto detect |
| 65 | // item on the encoding menu. |
| 66 | #define INTERNAL_IE_ENCODINGMENU_IDS(V) \ |
| 67 | V(INTERNAL_IE_ENCODINGMENU_ARABIC_ASMO708, 3609, "unknown") \ |
| 68 | V(INTERNAL_IE_ENCODINGMENU_ARABIC_DOS, 3610, "unknown") \ |
| 69 | V(INTERNAL_IE_ENCODINGMENU_ARABIC_ISO, 3611, "ISO-8859-6") \ |
| 70 | V(INTERNAL_IE_ENCODINGMENU_ARABIC_WINDOWS, 3612, "windows-1256") \ |
| 71 | V(INTERNAL_IE_ENCODINGMENU_BALTIC_ISO, 3614, "ISO-8859-4") \ |
| 72 | V(INTERNAL_IE_ENCODINGMENU_BALTIC_WINDOWS, 3615, "windows-1257") \ |
| 73 | V(INTERNAL_IE_ENCODINGMENU_CENTRAL_EUROPEAN_DOS, 3616, "unknown") \ |
| 74 | V(INTERNAL_IE_ENCODINGMENU_CENTRAL_EUROPEAN_ISO, 3617, "ISO-8859-2") \ |
| 75 | V(INTERNAL_IE_ENCODINGMENU_CENTRAL_EUROPEAN_WINDOWS, 3618, "windows-1250") \ |
| 76 | V(INTERNAL_IE_ENCODINGMENU_CHINESE_SIMP_GB18030, 3619, "gb18030") \ |
| 77 | V(INTERNAL_IE_ENCODINGMENU_CHINESE_SIMP_GB2312, 3620, "GBK") \ |
| 78 | V(INTERNAL_IE_ENCODINGMENU_CHINESE_SIMP_HZ, 3621, "unknown") \ |
| 79 | V(INTERNAL_IE_ENCODINGMENU_CHINESE_TRAD_BIG5, 3622, "Big5") \ |
| 80 | V(INTERNAL_IE_ENCODINGMENU_CYRILLIC_DOS, 3623, "unknown") \ |
| 81 | V(INTERNAL_IE_ENCODINGMENU_CYRILLIC_ISO, 3624, "ISO-8859-5") \ |
| 82 | V(INTERNAL_IE_ENCODINGMENU_CYRILLIC_KOI8R, 3625, "KOI8-R") \ |
| 83 | V(INTERNAL_IE_ENCODINGMENU_CYRILLIC_KOI8U, 3626, "KOI8-U") \ |
| 84 | V(INTERNAL_IE_ENCODINGMENU_CYRILLIC_WINDOWS, 3627, "windows-1251") \ |
| 85 | V(INTERNAL_IE_ENCODINGMENU_GREEK_ISO, 3628, "ISO-8859-7") \ |
| 86 | V(INTERNAL_IE_ENCODINGMENU_GREEK_WINDOWS, 3629, "windows-1253") \ |
| 87 | V(INTERNAL_IE_ENCODINGMENU_HEBREW_DOS, 3630, "unknown") \ |
| 88 | V(INTERNAL_IE_ENCODINGMENU_HEBREW_ISO_LOGICAL, 3631, "ISO-8859-8-I") \ |
| 89 | V(INTERNAL_IE_ENCODINGMENU_HEBREW_ISO_VISUAL, 3632, "ISO-8859-8") \ |
| 90 | V(INTERNAL_IE_ENCODINGMENU_HEBREW_WINDOWS, 3633, "windows-1255") \ |
| 91 | V(INTERNAL_IE_ENCODINGMENU_JAPAN_AUTOSELECT, 3634, "ISO-2022-JP") \ |
| 92 | V(INTERNAL_IE_ENCODINGMENU_JAPAN_EUC, 3635, "EUC-JP") \ |
| 93 | V(INTERNAL_IE_ENCODINGMENU_JAPAN_SHIFT_JIS, 3636, "Shift_JIS") \ |
| 94 | V(INTERNAL_IE_ENCODINGMENU_KOREA, 3637, "windows-949") \ |
| 95 | V(INTERNAL_IE_ENCODINGMENU_THAI, 3638, "windows-874") \ |
| 96 | V(INTERNAL_IE_ENCODINGMENU_TURKISH_ISO, 3639, "windows-1254") \ |
| 97 | V(INTERNAL_IE_ENCODINGMENU_TURKISH_WINDOWS, 3640, "windows-1254") \ |
| 98 | V(INTERNAL_IE_ENCODINGMENU_UTF8, 3641, "UTF-8") \ |
| 99 | V(INTERNAL_IE_ENCODINGMENU_USERDEFINED, 3642, "windows-1252") \ |
| 100 | V(INTERNAL_IE_ENCODINGMENU_VIETNAMESE, 3643, "windows-1258") \ |
| 101 | V(INTERNAL_IE_ENCODINGMENU_WEST_EUROPEAN_ISO8859_1, 3644, "ISO-8859-1") \ |
| 102 | V(INTERNAL_IE_ENCODINGMENU_WEST_EUROPEAN_WINDOWS, 3645, "windows-1252") \ |
| 103 | V(INTERNAL_IE_ENCODINGMENU_AUTODETECT, 3699, "unknown") |
| 104 | |
| 105 | #define DEFINE_ENCODING_ID(encoding_name, id, chrome_name) \ |
| 106 | const DWORD encoding_name = id; |
| 107 | INTERNAL_IE_ENCODINGMENU_IDS(DEFINE_ENCODING_ID) |
| 108 | #undef DEFINE_ENCODING_ID |
| 109 | extern const DWORD kIEEncodingIdArray[]; |
| 110 | |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 111 | #ifndef SBCMDID_MIXEDZONE |
| 112 | // This command is sent by the frame to allow the document to return the URL |
| 113 | // security zone for display. |
| 114 | // Please refer to http://msdn.microsoft.com/en-us/library/aa770042(VS.85).aspx |
| 115 | // for more information. |
| 116 | #define SBCMDID_MIXEDZONE 39 |
| 117 | #endif // SBCMDID_MIXEDZONE |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 118 | |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 119 | // From MSDN: |
| 120 | // Controlling Navigation: The fact that a document can navigate on its own |
| 121 | // implies that it will also take care of updating the navigation history. |
| 122 | // In Internet Explorer 6 and later, the DocObject can indicate to the client |
| 123 | // site that it can navigate using CGID_DocHostCmdPriv (a privately defined |
| 124 | // command group GUID) and the DOCHOST_DOCCANNAVIGATE command. A pointer to |
| 125 | // the object that implements the IHTMLWindow2 interface is passed with the |
| 126 | // command in the VARIANTARG* parameter pvaIn. (Set pvaIn to NULL if the |
| 127 | // document cannot perform its own navigation.) |
| 128 | #define DOCHOST_DOCCANNAVIGATE (0) |
| 129 | |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 130 | #define DOCHOST_DISPLAY_PRIVACY (75) |
| 131 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 132 | // This macro should be defined in the public section of the class. |
| 133 | #define BEGIN_EXEC_COMMAND_MAP(theClass) \ |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 134 | public: \ |
| 135 | HRESULT ProcessExecCommand(const GUID* cmd_group_guid, DWORD command_id, \ |
| 136 | DWORD cmd_exec_opt, VARIANT* in_args, \ |
| 137 | VARIANT* out_args) { \ |
| 138 | HRESULT hr = OLECMDERR_E_NOTSUPPORTED; \ |
| 139 | do { |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 140 | |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 141 | #define EXEC_COMMAND_HANDLER(group, id, handler) \ |
| 142 | if ((id == command_id) && ((group != NULL && cmd_group_guid != NULL && \ |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 143 | IsEqualGUID(*reinterpret_cast<const GUID*>(group), *cmd_group_guid)) || \ |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 144 | (group == NULL && cmd_group_guid == NULL))) { \ |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 145 | hr = S_OK; \ |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 146 | handler(cmd_group_guid, command_id, cmd_exec_opt, in_args, out_args); \ |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 147 | break; \ |
| 148 | } |
| 149 | |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 150 | #define EXEC_COMMAND_HANDLER_NO_ARGS(group, id, handler) \ |
| 151 | if ((id == command_id) && ((group != NULL && cmd_group_guid != NULL && \ |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 152 | IsEqualGUID(*reinterpret_cast<const GUID*>(group), *cmd_group_guid)) || \ |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 153 | (group == NULL && cmd_group_guid == NULL))) { \ |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 154 | hr = S_OK; \ |
| 155 | handler(); \ |
| 156 | break; \ |
| 157 | } |
| 158 | |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 159 | #define EXEC_COMMAND_HANDLER_GENERIC(group, id, code) \ |
| 160 | if ((id == command_id) && ((group != NULL && cmd_group_guid != NULL && \ |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 161 | IsEqualGUID(*reinterpret_cast<const GUID*>(group), *cmd_group_guid)) || \ |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 162 | (group == NULL && cmd_group_guid == NULL))) { \ |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 163 | hr = S_OK; \ |
| 164 | code; \ |
| 165 | break; \ |
| 166 | } |
| 167 | |
[email protected] | 2f2afba | 2010-04-01 01:53:19 | [diff] [blame] | 168 | #define EXEC_GROUP_COMMANDS_HANDLER(group, group_commands, handler) \ |
| 169 | do { \ |
| 170 | const DWORD* commands = group_commands; \ |
| 171 | bool id_in_group_commands = false; \ |
| 172 | while (*commands) { \ |
| 173 | if (*commands == command_id) { \ |
| 174 | id_in_group_commands = true; \ |
| 175 | break; \ |
| 176 | } \ |
| 177 | commands++; \ |
| 178 | } \ |
| 179 | if (id_in_group_commands && ((group != NULL && cmd_group_guid != NULL && \ |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 180 | IsEqualGUID(*reinterpret_cast<const GUID*>(group), \ |
| 181 | *cmd_group_guid)) || \ |
[email protected] | 2f2afba | 2010-04-01 01:53:19 | [diff] [blame] | 182 | (group == NULL && cmd_group_guid == NULL))) { \ |
| 183 | hr = S_OK; \ |
| 184 | handler(cmd_group_guid, command_id, cmd_exec_opt, in_args, out_args); \ |
| 185 | break; \ |
| 186 | } \ |
| 187 | } while (0); |
| 188 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 189 | #define END_EXEC_COMMAND_MAP() \ |
[email protected] | 2f2afba | 2010-04-01 01:53:19 | [diff] [blame] | 190 | } while (0); \ |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 191 | return hr; \ |
| 192 | } |
| 193 | |
| 194 | // ChromeActiveDocument: Implementation of the Active Document object that is |
| 195 | // responsible for rendering pages in Chrome. This object delegates to |
| 196 | // Chrome.exe (via the Chrome IPC-based automation mechanism) for the actual |
| 197 | // rendering |
| 198 | class ATL_NO_VTABLE ChromeActiveDocument |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 199 | : public ChromeFrameActivexBase<ChromeActiveDocument, |
| 200 | CLSID_ChromeActiveDocument>, |
| 201 | public IOleDocumentImpl<ChromeActiveDocument>, |
| 202 | public IOleDocumentViewImpl<ChromeActiveDocument>, |
| 203 | public IPersistMoniker, |
| 204 | public IOleCommandTarget, |
| 205 | public InPlaceMenu<ChromeActiveDocument>, |
| 206 | public IWebBrowserEventsUrlService, |
| 207 | public IPersistHistory, |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 208 | public IEnumPrivacyRecords, |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 209 | public HTMLWindowImpl<IHTMLWindow2>, |
| 210 | public HTMLPrivateWindowImpl<IHTMLPrivateWindow> { |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 211 | public: |
| 212 | typedef ChromeFrameActivexBase<ChromeActiveDocument, |
[email protected] | 97965e1 | 2010-04-09 00:51:10 | [diff] [blame] | 213 | CLSID_ChromeActiveDocument> BaseActiveX; |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 214 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 215 | ChromeActiveDocument(); |
| 216 | ~ChromeActiveDocument(); |
| 217 | |
| 218 | DECLARE_REGISTRY_RESOURCEID(IDR_CHROMEACTIVEDOCUMENT) |
| 219 | |
| 220 | BEGIN_COM_MAP(ChromeActiveDocument) |
| 221 | COM_INTERFACE_ENTRY(IOleDocument) |
| 222 | COM_INTERFACE_ENTRY(IOleDocumentView) |
| 223 | COM_INTERFACE_ENTRY(IPersistMoniker) |
| 224 | COM_INTERFACE_ENTRY(IOleCommandTarget) |
| 225 | COM_INTERFACE_ENTRY(IWebBrowserEventsUrlService) |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 226 | COM_INTERFACE_ENTRY(IPersist) |
| 227 | COM_INTERFACE_ENTRY(IPersistHistory) |
| 228 | COM_INTERFACE_ENTRY(IHTMLFramesCollection2) |
| 229 | COM_INTERFACE_ENTRY(IHTMLWindow2) |
| 230 | COM_INTERFACE_ENTRY(IHTMLPrivateWindow) |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 231 | COM_INTERFACE_ENTRY(IEnumPrivacyRecords) |
[email protected] | 97965e1 | 2010-04-09 00:51:10 | [diff] [blame] | 232 | COM_INTERFACE_ENTRY_CHAIN(BaseActiveX) |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 233 | END_COM_MAP() |
| 234 | |
| 235 | BEGIN_MSG_MAP(ChromeActiveDocument) |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 236 | MESSAGE_HANDLER(WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, OnFirePrivacyChange) |
[email protected] | 074283a | 2010-05-28 23:47:59 | [diff] [blame] | 237 | COMMAND_ID_HANDLER(IDC_CHROMEFRAME_FORWARD, OnForward) |
| 238 | COMMAND_ID_HANDLER(IDC_CHROMEFRAME_BACK, OnBack) |
[email protected] | 723e544 | 2010-07-21 17:36:05 | [diff] [blame] | 239 | MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow) |
| 240 | MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) |
[email protected] | 97965e1 | 2010-04-09 00:51:10 | [diff] [blame] | 241 | CHAIN_MSG_MAP(BaseActiveX) |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 242 | END_MSG_MAP() |
| 243 | |
| 244 | HRESULT FinalConstruct(); |
| 245 | |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 246 | #define FORWARD_TAB_COMMAND(group, id, command) \ |
| 247 | EXEC_COMMAND_HANDLER_GENERIC(group, id, GetTabProxy() ? \ |
| 248 | GetTabProxy()->command() : 1) |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 249 | |
| 250 | BEGIN_EXEC_COMMAND_MAP(ChromeActiveDocument) |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 251 | EXEC_COMMAND_HANDLER_GENERIC(NULL, OLECMDID_PRINT, |
| 252 | automation_client_->PrintTab()) |
| 253 | EXEC_COMMAND_HANDLER_NO_ARGS(NULL, OLECMDID_FIND, OnFindInPage) |
| 254 | EXEC_COMMAND_HANDLER_NO_ARGS(&CGID_MSHTML, IDM_FIND, OnFindInPage) |
| 255 | EXEC_COMMAND_HANDLER_NO_ARGS(&CGID_MSHTML, IDM_VIEWSOURCE, OnViewSource) |
| 256 | FORWARD_TAB_COMMAND(NULL, OLECMDID_SELECTALL, SelectAll) |
| 257 | FORWARD_TAB_COMMAND(NULL, OLECMDID_CUT, Cut) |
| 258 | FORWARD_TAB_COMMAND(NULL, OLECMDID_COPY, Copy) |
| 259 | FORWARD_TAB_COMMAND(NULL, OLECMDID_PASTE, Paste) |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 260 | FORWARD_TAB_COMMAND(NULL, OLECMDID_STOP, StopAsync) |
| 261 | FORWARD_TAB_COMMAND(NULL, OLECMDID_SAVEAS, SaveAsAsync) |
[email protected] | 355309e | 2010-03-15 17:01:34 | [diff] [blame] | 262 | EXEC_COMMAND_HANDLER(NULL, OLECMDID_REFRESH, OnRefreshPage) |
[email protected] | b45b76e2 | 2010-02-11 00:07:34 | [diff] [blame] | 263 | EXEC_COMMAND_HANDLER(&CGID_Explorer, SBCMDID_MIXEDZONE, |
| 264 | OnDetermineSecurityZone) |
| 265 | EXEC_COMMAND_HANDLER(&CGID_MSHTML, IDM_BASELINEFONT1, SetPageFontSize) |
| 266 | EXEC_COMMAND_HANDLER(&CGID_MSHTML, IDM_BASELINEFONT2, SetPageFontSize) |
| 267 | EXEC_COMMAND_HANDLER(&CGID_MSHTML, IDM_BASELINEFONT3, SetPageFontSize) |
| 268 | EXEC_COMMAND_HANDLER(&CGID_MSHTML, IDM_BASELINEFONT4, SetPageFontSize) |
| 269 | EXEC_COMMAND_HANDLER(&CGID_MSHTML, IDM_BASELINEFONT5, SetPageFontSize) |
[email protected] | 2f2afba | 2010-04-01 01:53:19 | [diff] [blame] | 270 | |
| 271 | EXEC_GROUP_COMMANDS_HANDLER(&CGID_MSHTML, kIEEncodingIdArray, |
| 272 | OnEncodingChange) |
| 273 | |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 274 | EXEC_COMMAND_HANDLER_NO_ARGS(&CGID_ShellDocView, DOCHOST_DISPLAY_PRIVACY, |
| 275 | OnDisplayPrivacyInfo) |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 276 | END_EXEC_COMMAND_MAP() |
| 277 | |
| 278 | // IPCs from automation server. |
| 279 | virtual void OnNavigationStateChanged(int tab_handle, int flags, |
| 280 | const IPC::NavigationInfo& nav_info); |
| 281 | virtual void OnUpdateTargetUrl(int tab_handle, |
| 282 | const std::wstring& new_target_url); |
| 283 | virtual void OnAcceleratorPressed(int tab_handle, const MSG& accel_message); |
| 284 | virtual void OnTabbedOut(int tab_handle, bool reverse); |
| 285 | virtual void OnDidNavigate(int tab_handle, |
| 286 | const IPC::NavigationInfo& nav_info); |
[email protected] | e16dd167 | 2010-06-07 21:40:29 | [diff] [blame] | 287 | virtual void OnCloseTab(int tab_handle); |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 288 | // Override DoVerb |
| 289 | STDMETHOD(DoVerb)(LONG verb, |
| 290 | LPMSG msg, |
| 291 | IOleClientSite* active_site, |
| 292 | LONG index, |
| 293 | HWND parent_window, |
| 294 | LPCRECT pos); |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 295 | |
| 296 | // Override IOleInPlaceActiveObjectImpl::OnDocWindowActivate |
| 297 | STDMETHOD(OnDocWindowActivate)(BOOL activate); |
| 298 | STDMETHOD(TranslateAccelerator)(MSG* msg); |
| 299 | |
| 300 | // IPersistMoniker methods |
| 301 | STDMETHOD(GetClassID)(CLSID* class_id); |
| 302 | STDMETHOD(IsDirty)(); |
| 303 | STDMETHOD(GetCurMoniker)(IMoniker** moniker_name); |
| 304 | STDMETHOD(Load)(BOOL fully_avalable, |
| 305 | IMoniker* moniker_name, |
| 306 | LPBC bind_context, |
| 307 | DWORD mode); |
| 308 | STDMETHOD(Save)(IMoniker* moniker_name, |
| 309 | LPBC bind_context, |
| 310 | BOOL remember); |
| 311 | STDMETHOD(SaveCompleted)(IMoniker* moniker_name, |
| 312 | LPBC bind_context); |
| 313 | |
| 314 | // IOleCommandTarget methods |
| 315 | STDMETHOD(QueryStatus)(const GUID* cmd_group_guid, |
| 316 | ULONG number_of_commands, |
| 317 | OLECMD commands[], |
| 318 | OLECMDTEXT* command_text); |
| 319 | STDMETHOD(Exec)(const GUID* cmd_group_guid, DWORD command_id, |
| 320 | DWORD cmd_exec_opt, |
| 321 | VARIANT* in_args, |
| 322 | VARIANT* out_args); |
| 323 | |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 324 | // IPersistHistory |
| 325 | STDMETHOD(LoadHistory)(IStream* stream, IBindCtx* bind_context); |
| 326 | STDMETHOD(SaveHistory)(IStream* stream); |
| 327 | STDMETHOD(SetPositionCookie)(DWORD position_cookie); |
| 328 | STDMETHOD(GetPositionCookie)(DWORD* position_cookie); |
| 329 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 330 | // IWebBrowserEventsUrlService methods |
| 331 | STDMETHOD(GetUrlForEvents)(BSTR* url); |
| 332 | |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 333 | // IHTMLPrivateWindow methods |
| 334 | STDMETHOD(GetAddressBarUrl)(BSTR* url); |
| 335 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 336 | // ChromeFrameActivexBase overrides |
| 337 | HRESULT IOleObject_SetClientSite(IOleClientSite* client_site); |
| 338 | |
| 339 | HRESULT ActiveXDocActivate(LONG verb); |
| 340 | |
| 341 | // Callbacks from ChromeFramePlugin<T> |
| 342 | bool PreProcessContextMenu(HMENU menu); |
[email protected] | 35f13ab | 2009-12-16 23:59:17 | [diff] [blame] | 343 | bool HandleContextMenuCommand(UINT cmd, const IPC::ContextMenuParams& params); |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 344 | |
[email protected] | 723e544 | 2010-07-21 17:36:05 | [diff] [blame] | 345 | // ChromeFramePlugin overrides. |
[email protected] | b95f550f | 2009-11-19 05:35:22 | [diff] [blame] | 346 | virtual void OnAutomationServerReady(); |
| 347 | |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 348 | // IEnumPrivacyRecords |
| 349 | STDMETHOD(Reset)(); |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 350 | STDMETHOD(GetSize)(ULONG* size); |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 351 | STDMETHOD(GetPrivacyImpacted)(BOOL* privacy_impacted); |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 352 | STDMETHOD(Next)(BSTR* url, BSTR* policy, LONG* reserved, DWORD* flags); |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 353 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 354 | protected: |
| 355 | // ChromeFrameActivexBase overrides |
| 356 | virtual void OnOpenURL(int tab_handle, const GURL& url_to_open, |
[email protected] | b36a9f9 | 2009-10-19 17:34:57 | [diff] [blame] | 357 | const GURL& referrer, int open_disposition); |
[email protected] | b1c5563861 | 2010-03-08 16:26:11 | [diff] [blame] | 358 | virtual void OnAttachExternalTab(int tab_handle, |
| 359 | const IPC::AttachExternalTabParams& params); |
[email protected] | f9cc4c45 | 2009-10-13 14:56:38 | [diff] [blame] | 360 | virtual void OnGoToHistoryEntryOffset(int tab_handle, int offset); |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 361 | |
| 362 | // A helper method that updates our internal navigation state |
| 363 | // as well as IE's navigation state (viz Title and current URL). |
| 364 | // The navigation_flags is a TabContents::InvalidateTypes enum |
| 365 | void UpdateNavigationState(const IPC::NavigationInfo& nav_info); |
| 366 | |
| 367 | TabProxy* GetTabProxy() const { |
| 368 | if (automation_client_.get()) |
| 369 | return automation_client_->tab(); |
| 370 | return NULL; |
| 371 | } |
| 372 | |
| 373 | // Exec command handlers |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 374 | void OnFindInPage(); |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 375 | void OnViewSource(); |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 376 | void OnDetermineSecurityZone(const GUID* cmd_group_guid, DWORD command_id, |
| 377 | DWORD cmd_exec_opt, VARIANT* in_args, |
| 378 | VARIANT* out_args); |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 379 | void OnDisplayPrivacyInfo(); |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 380 | |
| 381 | // Call exec on our site's command target |
| 382 | HRESULT IEExec(const GUID* cmd_group_guid, DWORD command_id, |
| 383 | DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args); |
| 384 | |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 385 | // Initiates navigation to the URL passed in. |
| 386 | // Returns true on success. |
[email protected] | c4e45b3 | 2010-07-28 21:15:15 | [diff] [blame] | 387 | bool LaunchUrl(const ChromeFrameUrl& cf_url, const std::string& referrer); |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 388 | |
[email protected] | 1bb5f89 | 2009-10-06 01:44:57 | [diff] [blame] | 389 | // Handler to set the page font size in Chrome. |
| 390 | HRESULT SetPageFontSize(const GUID* cmd_group_guid, |
| 391 | DWORD command_id, |
| 392 | DWORD cmd_exec_opt, |
| 393 | VARIANT* in_args, |
| 394 | VARIANT* out_args); |
| 395 | |
[email protected] | 355309e | 2010-03-15 17:01:34 | [diff] [blame] | 396 | // IOleCommandTarget handler for page refresh command |
| 397 | HRESULT OnRefreshPage(const GUID* cmd_group_guid, DWORD command_id, |
| 398 | DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args); |
| 399 | |
[email protected] | 2f2afba | 2010-04-01 01:53:19 | [diff] [blame] | 400 | // Handler to set the page encoding info in Chrome. |
| 401 | HRESULT OnEncodingChange(const GUID* cmd_group_guid, DWORD command_id, |
| 402 | DWORD cmd_exec_opt, VARIANT* in_args, |
| 403 | VARIANT* out_args); |
[email protected] | 355309e | 2010-03-15 17:01:34 | [diff] [blame] | 404 | |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 405 | // Get the travel log from the client site |
| 406 | HRESULT GetBrowserServiceAndTravelLog(IBrowserService** browser_service, |
| 407 | ITravelLog** travel_log); |
[email protected] | a15d4a4 | 2010-02-17 08:21:35 | [diff] [blame] | 408 | LRESULT OnForward(WORD notify_code, WORD id, HWND control_window, |
| 409 | BOOL& bHandled); |
| 410 | LRESULT OnBack(WORD notify_code, WORD id, HWND control_window, |
| 411 | BOOL& bHandled); |
[email protected] | a1800e8 | 2009-11-19 00:53:23 | [diff] [blame] | 412 | |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 413 | LRESULT OnFirePrivacyChange(UINT message, WPARAM wparam, LPARAM lparam, |
| 414 | BOOL& handled); |
[email protected] | 723e544 | 2010-07-21 17:36:05 | [diff] [blame] | 415 | LRESULT OnShowWindow(UINT message, WPARAM wparam, LPARAM lparam, |
| 416 | BOOL& handled); |
| 417 | LRESULT OnSetFocus(UINT message, WPARAM wparam, LPARAM lparam, |
| 418 | BOOL& handled); |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 419 | |
[email protected] | 00aebd7 | 2010-07-16 14:44:32 | [diff] [blame] | 420 | // Checks for the presence of known-to-be-buggy BHOs. If we find any |
| 421 | // we do not fire the DocumentComplete event to avoid a crash. |
| 422 | static bool ShouldFireDocumentComplete(); |
| 423 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 424 | protected: |
[email protected] | 6fd1a7a | 2010-07-26 22:09:46 | [diff] [blame] | 425 | typedef std::map<int, OLECMDF> CommandStatusMap; |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 426 | |
| 427 | IPC::NavigationInfo navigation_info_; |
| 428 | bool is_doc_object_; |
| 429 | |
| 430 | // This indicates whether this is the first navigation in this |
| 431 | // active document. It is initalize to true and it is set to false |
| 432 | // after we get a navigation notification from Chrome |
| 433 | bool first_navigation_; |
| 434 | |
| 435 | // Our find dialog |
| 436 | CFFindDialog find_dialog_; |
| 437 | |
[email protected] | 6fd1a7a | 2010-07-26 22:09:46 | [diff] [blame] | 438 | // These members contain the status of the commands we support. |
| 439 | CommandStatusMap null_group_commands_map_; |
| 440 | CommandStatusMap mshtml_group_commands_map_; |
| 441 | CommandStatusMap explorer_group_commands_map_; |
| 442 | CommandStatusMap shdoc_view_group_commands_map_; |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 443 | |
| 444 | // Set to true if the automation_client_ member is initialized from |
| 445 | // an existing ChromeActiveDocument instance which is going away and |
| 446 | // a new ChromeActiveDocument instance is taking its place. |
| 447 | bool is_automation_client_reused_; |
| 448 | |
[email protected] | 37346bc | 2009-09-25 22:54:33 | [diff] [blame] | 449 | ScopedComPtr<IInternetSecurityManager> security_manager_; |
[email protected] | b1c5563861 | 2010-03-08 16:26:11 | [diff] [blame] | 450 | ScopedComPtr<INewWindowManager> popup_manager_; |
[email protected] | 355309e | 2010-03-15 17:01:34 | [diff] [blame] | 451 | bool popup_allowed_; |
[email protected] | a15d4a4 | 2010-02-17 08:21:35 | [diff] [blame] | 452 | HACCEL accelerator_table_; |
| 453 | |
[email protected] | 80b5a8d | 2010-03-19 16:50:43 | [diff] [blame] | 454 | // Contains privacy data retrieved from the UrlmonUrlRequestManager. This |
| 455 | // is used to return privacy data in response to the View->Privacy policy |
| 456 | // command. |
| 457 | UrlmonUrlRequestManager::PrivacyInfo privacy_info_; |
| 458 | UrlmonUrlRequestManager::PrivacyInfo::PrivacyRecords::iterator |
| 459 | next_privacy_record_; |
| 460 | |
[email protected] | e3a91e7 | 2010-06-17 01:19:04 | [diff] [blame] | 461 | // Dimensions of the window. Used only when opening popups. |
| 462 | gfx::Rect dimensions_; |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 463 | public: |
| 464 | ScopedComPtr<IOleInPlaceFrame> in_place_frame_; |
| 465 | OLEINPLACEFRAMEINFO frame_info_; |
| 466 | }; |
| 467 | |
[email protected] | f781782 | 2009-09-24 05:11:58 | [diff] [blame] | 468 | #endif // CHROME_FRAME_CHROME_ACTIVE_DOCUMENT_H_ |