1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
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>
11#include <htiframe.h>
12#include <mshtmcid.h>
13#include <perhist.h>
14
15#include <map>
16#include <string>
17
18#include "base/memory/scoped_ptr.h"
19#include "base/threading/thread.h"
20#include "base/win/scoped_comptr.h"
21
22#include "chrome_frame/chrome_frame_activex_base.h"
23#include "chrome_frame/com_type_info_holder.h"
24#include "chrome_frame/extra_system_apis.h"
25#include "chrome_frame/find_dialog.h"
26#include "chrome_frame/html_private_window_impl.h"
27#include "chrome_frame/html_window_impl.h"
28#include "chrome_frame/resource.h"
29#include "chrome_frame/utils.h"
30#include "third_party/active_doc/in_place_menu.h"
31#include "third_party/active_doc/ole_document_impl.h"
32
33class TabProxy;
34class 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
51#define INTERNAL_CMDID_REPLACE_CURRENT_TRAVEL_LOG_ENTRY_URL (40)
52
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
109extern const DWORD kIEEncodingIdArray[];
110
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
118
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
130#define DOCHOST_DISPLAY_PRIVACY                      (75)
131
132// This macro should be defined in the public section of the class.
133#define BEGIN_EXEC_COMMAND_MAP(theClass) \
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 {
140
141#define EXEC_COMMAND_HANDLER(group, id, handler)                              \
142  if ((id == command_id) && ((group != NULL && cmd_group_guid != NULL && \
143       IsEqualGUID(*reinterpret_cast<const GUID*>(group), *cmd_group_guid)) || \
144       (group == NULL && cmd_group_guid == NULL))) {  \
145    hr = S_OK;  \
146    handler(cmd_group_guid, command_id, cmd_exec_opt, in_args, out_args);  \
147    break;  \
148  }
149
150#define EXEC_COMMAND_HANDLER_NO_ARGS(group, id, handler) \
151  if ((id == command_id) && ((group != NULL && cmd_group_guid != NULL && \
152       IsEqualGUID(*reinterpret_cast<const GUID*>(group), *cmd_group_guid)) || \
153       (group == NULL && cmd_group_guid == NULL))) {  \
154    hr = S_OK;  \
155    handler();  \
156    break;  \
157  }
158
159#define EXEC_COMMAND_HANDLER_GENERIC(group, id, code) \
160  if ((id == command_id) && ((group != NULL && cmd_group_guid != NULL && \
161       IsEqualGUID(*reinterpret_cast<const GUID*>(group), *cmd_group_guid)) || \
162       (group == NULL && cmd_group_guid == NULL))) {  \
163    hr = S_OK;  \
164    code;  \
165    break;  \
166  }
167
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 && \
180        IsEqualGUID(*reinterpret_cast<const GUID*>(group), \
181                    *cmd_group_guid)) || \
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
189#define END_EXEC_COMMAND_MAP()  \
190  } while (0); \
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
198class ATL_NO_VTABLE ChromeActiveDocument
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,
208      public IEnumPrivacyRecords,
209      public HTMLWindowImpl<IHTMLWindow2>,
210      public HTMLPrivateWindowImpl<IHTMLPrivateWindow> {
211 public:
212  typedef ChromeFrameActivexBase<ChromeActiveDocument,
213      CLSID_ChromeActiveDocument> BaseActiveX;
214
215  ChromeActiveDocument();
216  ~ChromeActiveDocument();
217
218  DECLARE_REGISTRY_RESOURCEID(IDR_CHROMEACTIVEDOCUMENT)
219
220BEGIN_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)
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)
231  COM_INTERFACE_ENTRY(IEnumPrivacyRecords)
232  COM_INTERFACE_ENTRY_CHAIN(BaseActiveX)
233END_COM_MAP()
234
235BEGIN_MSG_MAP(ChromeActiveDocument)
236  MESSAGE_HANDLER(WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, OnFirePrivacyChange)
237  COMMAND_ID_HANDLER(IDC_CHROMEFRAME_FORWARD, OnForward)
238  COMMAND_ID_HANDLER(IDC_CHROMEFRAME_BACK, OnBack)
239  MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow)
240  MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
241  CHAIN_MSG_MAP(BaseActiveX)
242END_MSG_MAP()
243
244  HRESULT FinalConstruct();
245
246#define FORWARD_TAB_COMMAND(group, id, command) \
247  EXEC_COMMAND_HANDLER_GENERIC(group, id, GetTabProxy() ? \
248    GetTabProxy()->command() : 1)
249
250BEGIN_EXEC_COMMAND_MAP(ChromeActiveDocument)
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)
260  FORWARD_TAB_COMMAND(NULL, OLECMDID_STOP, StopAsync)
261  FORWARD_TAB_COMMAND(NULL, OLECMDID_SAVEAS, SaveAsAsync)
262  EXEC_COMMAND_HANDLER(NULL, OLECMDID_REFRESH, OnRefreshPage)
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)
270
271  EXEC_GROUP_COMMANDS_HANDLER(&CGID_MSHTML, kIEEncodingIdArray,
272                              OnEncodingChange)
273
274  EXEC_COMMAND_HANDLER_NO_ARGS(&CGID_ShellDocView, DOCHOST_DISPLAY_PRIVACY,
275                               OnDisplayPrivacyInfo)
276  EXEC_COMMAND_HANDLER(NULL, OLECMDID_OPTICAL_GETZOOMRANGE, OnGetZoomRange)
277  EXEC_COMMAND_HANDLER(NULL, OLECMDID_OPTICAL_ZOOM, OnSetZoomRange)
278  EXEC_COMMAND_HANDLER(NULL, OLECMDID_ONUNLOAD, OnUnload)
279END_EXEC_COMMAND_MAP()
280
281  // IPCs from automation server.
282  virtual void OnNavigationStateChanged(
283      int flags, const NavigationInfo& nav_info);
284  virtual void OnUpdateTargetUrl(const std::wstring& new_target_url);
285  virtual void OnAcceleratorPressed(const MSG& accel_message);
286  virtual void OnTabbedOut(bool reverse);
287  virtual void OnDidNavigate(const NavigationInfo& nav_info);
288  virtual void OnCloseTab();
289  // Override DoVerb
290  STDMETHOD(DoVerb)(LONG verb,
291                    LPMSG msg,
292                    IOleClientSite* active_site,
293                    LONG index,
294                    HWND parent_window,
295                    LPCRECT pos);
296
297  // Override IOleInPlaceActiveObjectImpl::OnDocWindowActivate
298  STDMETHOD(OnDocWindowActivate)(BOOL activate);
299  STDMETHOD(TranslateAccelerator)(MSG* msg);
300
301  // IPersistMoniker methods
302  STDMETHOD(GetClassID)(CLSID* class_id);
303  STDMETHOD(IsDirty)();
304  STDMETHOD(GetCurMoniker)(IMoniker** moniker_name);
305  STDMETHOD(Load)(BOOL fully_avalable,
306                  IMoniker* moniker_name,
307                  LPBC bind_context,
308                  DWORD mode);
309  STDMETHOD(Save)(IMoniker* moniker_name,
310                  LPBC bind_context,
311                  BOOL remember);
312  STDMETHOD(SaveCompleted)(IMoniker* moniker_name,
313                  LPBC bind_context);
314
315  // IOleCommandTarget methods
316  STDMETHOD(QueryStatus)(const GUID* cmd_group_guid,
317                         ULONG number_of_commands,
318                         OLECMD commands[],
319                         OLECMDTEXT* command_text);
320  STDMETHOD(Exec)(const GUID* cmd_group_guid, DWORD command_id,
321                  DWORD cmd_exec_opt,
322                  VARIANT* in_args,
323                  VARIANT* out_args);
324
325  // IPersistHistory
326  STDMETHOD(LoadHistory)(IStream* stream, IBindCtx* bind_context);
327  STDMETHOD(SaveHistory)(IStream* stream);
328  STDMETHOD(SetPositionCookie)(DWORD position_cookie);
329  STDMETHOD(GetPositionCookie)(DWORD* position_cookie);
330
331  // IWebBrowserEventsUrlService methods
332  STDMETHOD(GetUrlForEvents)(BSTR* url);
333
334  // IHTMLPrivateWindow methods
335  STDMETHOD(GetAddressBarUrl)(BSTR* url);
336
337  // ChromeFrameActivexBase overrides
338  HRESULT IOleObject_SetClientSite(IOleClientSite* client_site);
339
340  HRESULT ActiveXDocActivate(LONG verb);
341
342  // Callbacks from ChromeFramePlugin<T>
343  bool PreProcessContextMenu(HMENU menu);
344  bool HandleContextMenuCommand(UINT cmd, const MiniContextMenuParams& params);
345
346  // ChromeFramePlugin overrides.
347  virtual void OnAutomationServerReady();
348
349  // IEnumPrivacyRecords
350  STDMETHOD(Reset)();
351  STDMETHOD(GetSize)(ULONG* size);
352  STDMETHOD(GetPrivacyImpacted)(BOOL* privacy_impacted);
353  STDMETHOD(Next)(BSTR* url, BSTR* policy, LONG* reserved, DWORD* flags);
354
355  // NavigationConstraints overrides.
356  bool IsSchemeAllowed(const GURL& url);
357
358  // Accessor for InPlaceMenu.  Returns S_OK if set, S_FALSE if NULL.
359  HRESULT GetInPlaceFrame(IOleInPlaceFrame** in_place_frame);
360
361 protected:
362  // ChromeFrameActivexBase overrides
363  virtual void OnAttachExternalTab(const AttachExternalTabParams& params);
364  virtual void OnGoToHistoryEntryOffset(int offset);
365  virtual void OnMoveWindow(const gfx::Rect& dimensions);
366
367  // A helper method that updates our internal navigation state
368  // as well as IE's navigation state (viz Title and current URL).
369  // The navigation_flags is a TabContents::InvalidateTypes enum
370  void UpdateNavigationState(const NavigationInfo& nav_info, int flags);
371
372  TabProxy* GetTabProxy() const {
373    if (automation_client_.get())
374      return automation_client_->tab();
375    return NULL;
376  }
377
378  // Exec command handlers
379  void OnFindInPage();
380  void OnViewSource();
381  void OnDetermineSecurityZone(const GUID* cmd_group_guid, DWORD command_id,
382                               DWORD cmd_exec_opt, VARIANT* in_args,
383                               VARIANT* out_args);
384  void OnDisplayPrivacyInfo();
385
386  void OnGetZoomRange(const GUID* cmd_group_guid, DWORD command_id,
387                      DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args);
388
389  void OnSetZoomRange(const GUID* cmd_group_guid, DWORD command_id,
390                      DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args);
391
392  // This function handles the OLECMDID_ONUNLOAD command. It enables Chrome to
393  // invoke before unload and unload handlers on the page if any, thereby
394  // enabling a webpage to potentially cancel the operation.
395  void OnUnload(const GUID* cmd_group_guid, DWORD command_id,
396                DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args);
397
398  // Call exec on our site's command target
399  HRESULT IEExec(const GUID* cmd_group_guid, DWORD command_id,
400                 DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args);
401
402  // Initiates navigation to the URL passed in.
403  // Returns true on success.
404  bool LaunchUrl(const ChromeFrameUrl& cf_url, const std::string& referrer);
405
406  // Handler to set the page font size in Chrome.
407  HRESULT SetPageFontSize(const GUID* cmd_group_guid,
408                          DWORD command_id,
409                          DWORD cmd_exec_opt,
410                          VARIANT* in_args,
411                          VARIANT* out_args);
412
413  // IOleCommandTarget handler for page refresh command
414  HRESULT OnRefreshPage(const GUID* cmd_group_guid, DWORD command_id,
415      DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args);
416
417  // Handler to set the page encoding info in Chrome.
418  HRESULT OnEncodingChange(const GUID* cmd_group_guid, DWORD command_id,
419                           DWORD cmd_exec_opt, VARIANT* in_args,
420                           VARIANT* out_args);
421
422  // Get the travel log from the client site
423  HRESULT GetBrowserServiceAndTravelLog(IBrowserService** browser_service,
424                                        ITravelLog** travel_log);
425  LRESULT OnForward(WORD notify_code, WORD id, HWND control_window,
426                    BOOL& bHandled);
427  LRESULT OnBack(WORD notify_code, WORD id, HWND control_window,
428                 BOOL& bHandled);
429
430  LRESULT OnFirePrivacyChange(UINT message, WPARAM wparam, LPARAM lparam,
431                              BOOL& handled);
432  LRESULT OnShowWindow(UINT message, WPARAM wparam, LPARAM lparam,
433                       BOOL& handled);
434  LRESULT OnSetFocus(UINT message, WPARAM wparam, LPARAM lparam,
435                     BOOL& handled);
436
437  // Returns true if the NavigationInfo object passed in represents a new
438  // navigation initiated by the renderer.
439  bool IsNewNavigation(const NavigationInfo& new_navigation_info,
440                       int flags) const;
441
442  // Returns true if the NavigationInfo object passed in represents a first
443  // page navigation initiated as this active document was being created.
444  bool IsFirstNavigation(const NavigationInfo& new_navigation_info) const;
445
446 protected:
447  typedef std::map<int, OLECMDF> CommandStatusMap;
448
449  scoped_ptr<NavigationInfo> navigation_info_;
450  bool is_doc_object_;
451
452  // This indicates whether this is the first navigation in this
453  // active document. It is initalize to true and it is set to false
454  // after we get a navigation notification from Chrome
455  bool first_navigation_;
456
457  // Our find dialog
458  CFFindDialog find_dialog_;
459
460  // These members contain the status of the commands we support.
461  CommandStatusMap null_group_commands_map_;
462  CommandStatusMap mshtml_group_commands_map_;
463  CommandStatusMap explorer_group_commands_map_;
464  CommandStatusMap shdoc_view_group_commands_map_;
465
466  // Set to true if the automation_client_ member is initialized from
467  // an existing ChromeActiveDocument instance which is going away and
468  // a new ChromeActiveDocument instance is taking its place.
469  bool is_automation_client_reused_;
470
471  base::win::ScopedComPtr<INewWindowManager> popup_manager_;
472  bool popup_allowed_;
473  HACCEL accelerator_table_;
474
475  // Contains privacy data retrieved from the UrlmonUrlRequestManager. This
476  // is used to return privacy data in response to the View->Privacy policy
477  // command.
478  UrlmonUrlRequestManager::PrivacyInfo privacy_info_;
479  UrlmonUrlRequestManager::PrivacyInfo::PrivacyRecords::iterator
480      next_privacy_record_;
481
482 public:
483  OLEINPLACEFRAMEINFO frame_info_;
484};
485
486#endif  // CHROME_FRAME_CHROME_ACTIVE_DOCUMENT_H_
487