Upstream version 7.35.139.0
[platform/framework/web/crosswalk.git] / src / content / browser / web_contents / web_contents_impl.h
1 // Copyright (c) 2012 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 CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "base/process/process.h"
17 #include "base/values.h"
18 #include "content/browser/frame_host/frame_tree.h"
19 #include "content/browser/frame_host/navigation_controller_delegate.h"
20 #include "content/browser/frame_host/navigation_controller_impl.h"
21 #include "content/browser/frame_host/navigator_delegate.h"
22 #include "content/browser/frame_host/render_frame_host_delegate.h"
23 #include "content/browser/frame_host/render_frame_host_manager.h"
24 #include "content/browser/renderer_host/render_view_host_delegate.h"
25 #include "content/browser/renderer_host/render_widget_host_delegate.h"
26 #include "content/common/content_export.h"
27 #include "content/public/browser/ax_event_notification_details.h"
28 #include "content/public/browser/notification_observer.h"
29 #include "content/public/browser/notification_registrar.h"
30 #include "content/public/browser/web_contents.h"
31 #include "content/public/common/page_transition_types.h"
32 #include "content/public/common/renderer_preferences.h"
33 #include "content/public/common/three_d_api_types.h"
34 #include "net/base/load_states.h"
35 #include "third_party/WebKit/public/web/WebDragOperation.h"
36 #include "ui/gfx/rect_f.h"
37 #include "ui/gfx/size.h"
38 #include "webkit/common/resource_type.h"
39
40 struct BrowserPluginHostMsg_ResizeGuest_Params;
41 struct ViewHostMsg_DateTimeDialogValue_Params;
42 struct ViewMsg_PostMessage_Params;
43
44 namespace content {
45 class BrowserPluginEmbedder;
46 class BrowserPluginGuest;
47 class BrowserPluginGuestManager;
48 class ColorChooser;
49 class DateTimeChooserAndroid;
50 class DownloadItem;
51 class InterstitialPageImpl;
52 class JavaBridgeDispatcherHostManager;
53 class JavaScriptDialogManager;
54 class PowerSaveBlocker;
55 class RenderViewHost;
56 class RenderViewHostDelegateView;
57 class RenderViewHostImpl;
58 class RenderWidgetHostImpl;
59 class RenderWidgetHostViewPort;
60 class SavePackage;
61 class SessionStorageNamespaceImpl;
62 class SiteInstance;
63 class TestWebContents;
64 class WebContentsDelegate;
65 class WebContentsImpl;
66 class WebContentsObserver;
67 class WebContentsViewPort;
68 class WebContentsViewDelegate;
69 struct AXEventNotificationDetails;
70 struct ColorSuggestion;
71 struct FaviconURL;
72 struct LoadNotificationDetails;
73 struct ResourceRedirectDetails;
74 struct ResourceRequestDetails;
75
76 // Factory function for the implementations that content knows about. Takes
77 // ownership of |delegate|.
78 WebContentsViewPort* CreateWebContentsView(
79     WebContentsImpl* web_contents,
80     WebContentsViewDelegate* delegate,
81     RenderViewHostDelegateView** render_view_host_delegate_view);
82
83 class CONTENT_EXPORT WebContentsImpl
84     : public NON_EXPORTED_BASE(WebContents),
85       public NON_EXPORTED_BASE(RenderFrameHostDelegate),
86       public RenderViewHostDelegate,
87       public RenderWidgetHostDelegate,
88       public RenderFrameHostManager::Delegate,
89       public NotificationObserver,
90       public NON_EXPORTED_BASE(NavigationControllerDelegate),
91       public NON_EXPORTED_BASE(NavigatorDelegate) {
92  public:
93   virtual ~WebContentsImpl();
94
95   static WebContentsImpl* CreateWithOpener(
96       const WebContents::CreateParams& params,
97       WebContentsImpl* opener);
98
99   // Returns the opener WebContentsImpl, if any. This can be set to null if the
100   // opener is closed or the page clears its window.opener.
101   WebContentsImpl* opener() const { return opener_; }
102
103   // Creates a WebContents to be used as a browser plugin guest.
104   static BrowserPluginGuest* CreateGuest(
105       BrowserContext* browser_context,
106       content::SiteInstance* site_instance,
107       int guest_instance_id,
108       scoped_ptr<base::DictionaryValue> extra_params);
109
110   // Creates a swapped out RenderView. This is used by the browser plugin to
111   // create a swapped out RenderView in the embedder render process for the
112   // guest, to expose the guest's window object to the embedder.
113   // This returns the routing ID of the newly created swapped out RenderView.
114   int CreateSwappedOutRenderView(SiteInstance* instance);
115
116   // Complex initialization here. Specifically needed to avoid having
117   // members call back into our virtual functions in the constructor.
118   virtual void Init(const WebContents::CreateParams& params);
119
120   // Returns the SavePackage which manages the page saving job. May be NULL.
121   SavePackage* save_package() const { return save_package_.get(); }
122
123 #if defined(OS_ANDROID)
124   JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
125     return java_bridge_dispatcher_host_manager_.get();
126   }
127
128   // In Android WebView, the RenderView needs created even there is no
129   // navigation entry, this allows Android WebViews to use
130   // javascript: URLs that load into the DOMWindow before the first page
131   // load. This is not safe to do in any context that a web page could get a
132   // reference to the DOMWindow before the first page load.
133   bool CreateRenderViewForInitialEmptyDocument();
134 #endif
135
136   // Expose the render manager for testing.
137   // TODO(creis): Remove this now that we can get to it via FrameTreeNode.
138   RenderFrameHostManager* GetRenderManagerForTesting();
139
140   // Returns guest browser plugin object, or NULL if this WebContents is not a
141   // guest.
142   BrowserPluginGuest* GetBrowserPluginGuest() const;
143
144   // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
145   // has a BrowserPluginGuest then that implies that it is being hosted by
146   // a BrowserPlugin object in an embedder renderer process.
147   void SetBrowserPluginGuest(BrowserPluginGuest* guest);
148
149   // Returns embedder browser plugin object, or NULL if this WebContents is not
150   // an embedder.
151   BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
152
153   // Returns the BrowserPluginGuestManager object, or NULL if this web contents
154   // does not have a BrowserPluginGuestManager.
155   BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
156
157   // Gets the current fullscreen render widget's routing ID. Returns
158   // MSG_ROUTING_NONE when there is no fullscreen render widget.
159   int GetFullscreenWidgetRoutingID() const;
160
161   // Invoked when visible SSL state (as defined by SSLStatus) changes.
162   void DidChangeVisibleSSLState();
163
164   // Informs the render view host and the BrowserPluginEmbedder, if present, of
165   // a Drag Source End.
166   void DragSourceEndedAt(int client_x, int client_y, int screen_x,
167       int screen_y, blink::WebDragOperation operation);
168
169   // Informs the render view host and the BrowserPluginEmbedder, if present, of
170   // a Drag Source Move.
171   void DragSourceMovedTo(int client_x, int client_y,
172                          int screen_x, int screen_y);
173
174   // A response has been received for a resource request.
175   void DidGetResourceResponseStart(
176       const ResourceRequestDetails& details);
177
178   // A redirect was received while requesting a resource.
179   void DidGetRedirectForResourceRequest(
180       RenderViewHost* render_view_host,
181       const ResourceRedirectDetails& details);
182
183   // WebContents ------------------------------------------------------
184   virtual WebContentsDelegate* GetDelegate() OVERRIDE;
185   virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE;
186   virtual NavigationControllerImpl& GetController() OVERRIDE;
187   virtual const NavigationControllerImpl& GetController() const OVERRIDE;
188   virtual BrowserContext* GetBrowserContext() const OVERRIDE;
189   virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
190   virtual RenderFrameHost* GetMainFrame() OVERRIDE;
191   virtual RenderFrameHost* GetFocusedFrame() OVERRIDE;
192   virtual void ForEachFrame(
193       const base::Callback<void(RenderFrameHost*)>& on_frame) OVERRIDE;
194   virtual void SendToAllFrames(IPC::Message* message) OVERRIDE;
195   virtual RenderViewHost* GetRenderViewHost() const OVERRIDE;
196   virtual WebContents* GetEmbedderWebContents() const OVERRIDE;
197   virtual int GetEmbeddedInstanceID() const OVERRIDE;
198   virtual int GetRoutingID() const OVERRIDE;
199   virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE;
200   virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const
201       OVERRIDE;
202   virtual WebContentsView* GetView() const OVERRIDE;
203   virtual WebUI* CreateWebUI(const GURL& url) OVERRIDE;
204   virtual WebUI* GetWebUI() const OVERRIDE;
205   virtual WebUI* GetCommittedWebUI() const OVERRIDE;
206   virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
207   virtual const std::string& GetUserAgentOverride() const OVERRIDE;
208 #if defined(OS_WIN)
209   virtual void SetParentNativeViewAccessible(
210       gfx::NativeViewAccessible accessible_parent) OVERRIDE;
211 #endif
212   virtual const base::string16& GetTitle() const OVERRIDE;
213   virtual int32 GetMaxPageID() OVERRIDE;
214   virtual int32 GetMaxPageIDForSiteInstance(
215       SiteInstance* site_instance) OVERRIDE;
216   virtual SiteInstance* GetSiteInstance() const OVERRIDE;
217   virtual SiteInstance* GetPendingSiteInstance() const OVERRIDE;
218   virtual bool IsLoading() const OVERRIDE;
219   virtual bool IsWaitingForResponse() const OVERRIDE;
220   virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
221   virtual const base::string16& GetLoadStateHost() const OVERRIDE;
222   virtual uint64 GetUploadSize() const OVERRIDE;
223   virtual uint64 GetUploadPosition() const OVERRIDE;
224   virtual std::set<GURL> GetSitesInTab() const OVERRIDE;
225   virtual const std::string& GetEncoding() const OVERRIDE;
226   virtual bool DisplayedInsecureContent() const OVERRIDE;
227   virtual void IncrementCapturerCount(const gfx::Size& capture_size) OVERRIDE;
228   virtual void DecrementCapturerCount() OVERRIDE;
229   virtual int GetCapturerCount() const OVERRIDE;
230   virtual bool IsCrashed() const OVERRIDE;
231   virtual void SetIsCrashed(base::TerminationStatus status,
232                             int error_code) OVERRIDE;
233   virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
234   virtual bool IsBeingDestroyed() const OVERRIDE;
235   virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
236   virtual base::TimeTicks GetLastActiveTime() const OVERRIDE;
237   virtual void WasShown() OVERRIDE;
238   virtual void WasHidden() OVERRIDE;
239   virtual bool NeedToFireBeforeUnload() OVERRIDE;
240   virtual void Stop() OVERRIDE;
241   virtual WebContents* Clone() OVERRIDE;
242   virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
243   virtual bool ShowingInterstitialPage() const OVERRIDE;
244   virtual InterstitialPage* GetInterstitialPage() const OVERRIDE;
245   virtual bool IsSavable() OVERRIDE;
246   virtual void OnSavePage() OVERRIDE;
247   virtual bool SavePage(const base::FilePath& main_file,
248                         const base::FilePath& dir_path,
249                         SavePageType save_type) OVERRIDE;
250   virtual void SaveFrame(const GURL& url,
251                          const Referrer& referrer) OVERRIDE;
252   virtual void GenerateMHTML(
253       const base::FilePath& file,
254       const base::Callback<void(int64)>& callback)
255           OVERRIDE;
256   virtual bool IsActiveEntry(int32 page_id) OVERRIDE;
257
258   virtual const std::string& GetContentsMimeType() const OVERRIDE;
259   virtual bool WillNotifyDisconnection() const OVERRIDE;
260   virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
261   virtual void ResetOverrideEncoding() OVERRIDE;
262   virtual RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
263   virtual void Close() OVERRIDE;
264   virtual void SystemDragEnded() OVERRIDE;
265   virtual void UserGestureDone() OVERRIDE;
266   virtual void SetClosedByUserGesture(bool value) OVERRIDE;
267   virtual bool GetClosedByUserGesture() const OVERRIDE;
268   virtual double GetZoomLevel() const OVERRIDE;
269   virtual int GetZoomPercent(bool* enable_increment,
270                              bool* enable_decrement) const OVERRIDE;
271   virtual void ViewSource() OVERRIDE;
272   virtual void ViewFrameSource(const GURL& url,
273                                const PageState& page_state) OVERRIDE;
274   virtual int GetMinimumZoomPercent() const OVERRIDE;
275   virtual int GetMaximumZoomPercent() const OVERRIDE;
276   virtual gfx::Size GetPreferredSize() const OVERRIDE;
277   virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
278   virtual bool HasOpener() const OVERRIDE;
279   virtual void DidChooseColorInColorChooser(SkColor color) OVERRIDE;
280   virtual void DidEndColorChooser() OVERRIDE;
281   virtual int DownloadImage(const GURL& url,
282                             bool is_favicon,
283                             uint32_t max_bitmap_size,
284                             const ImageDownloadCallback& callback) OVERRIDE;
285   virtual bool IsSubframe() const OVERRIDE;
286   virtual void Find(int request_id,
287                     const base::string16& search_text,
288                     const blink::WebFindOptions& options) OVERRIDE;
289   virtual void SetZoomLevel(double level) OVERRIDE;
290   virtual void StopFinding(StopFindAction action) OVERRIDE;
291 #if defined(OS_ANDROID)
292   virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents()
293       OVERRIDE;
294 #endif
295
296   // Implementation of PageNavigator.
297   virtual WebContents* OpenURL(const OpenURLParams& params) OVERRIDE;
298
299   // Implementation of IPC::Sender.
300   virtual bool Send(IPC::Message* message) OVERRIDE;
301
302   // RenderFrameHostDelegate ---------------------------------------------------
303   virtual bool OnMessageReceived(RenderFrameHost* render_frame_host,
304                                  const IPC::Message& message) OVERRIDE;
305   virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE;
306   virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE;
307   virtual void DidStartLoading(RenderFrameHost* render_frame_host,
308                                bool to_different_document) OVERRIDE;
309   virtual void DidStopLoading(RenderFrameHost* render_frame_host) OVERRIDE;
310   virtual void SwappedOut(RenderFrameHost* render_frame_host) OVERRIDE;
311   virtual void WorkerCrashed(RenderFrameHost* render_frame_host) OVERRIDE;
312   virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
313                                const ContextMenuParams& params) OVERRIDE;
314   virtual WebContents* GetAsWebContents() OVERRIDE;
315
316   // RenderViewHostDelegate ----------------------------------------------------
317   virtual RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
318   virtual bool OnMessageReceived(RenderViewHost* render_view_host,
319                                  const IPC::Message& message) OVERRIDE;
320   virtual const GURL& GetURL() const OVERRIDE;
321   virtual const GURL& GetVisibleURL() const OVERRIDE;
322   virtual const GURL& GetLastCommittedURL() const OVERRIDE;
323   // RenderFrameHostDelegate has the same method, so list it there because this
324   // interface is going away.
325   // virtual WebContents* GetAsWebContents() OVERRIDE;
326   virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
327   virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
328   virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE;
329   virtual void RenderViewTerminated(RenderViewHost* render_view_host,
330                                     base::TerminationStatus status,
331                                     int error_code) OVERRIDE;
332   virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
333   virtual void UpdateState(RenderViewHost* render_view_host,
334                            int32 page_id,
335                            const PageState& page_state) OVERRIDE;
336   virtual void UpdateTitle(RenderViewHost* render_view_host,
337                            int32 page_id,
338                            const base::string16& title,
339                            base::i18n::TextDirection title_direction) OVERRIDE;
340   virtual void UpdateEncoding(RenderViewHost* render_view_host,
341                               const std::string& encoding) OVERRIDE;
342   virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
343   virtual void Close(RenderViewHost* render_view_host) OVERRIDE;
344   virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
345   virtual void DidCancelLoading() OVERRIDE;
346   virtual void DidChangeLoadProgress(double progress) OVERRIDE;
347   virtual void DidDisownOpener(RenderViewHost* rvh) OVERRIDE;
348   virtual void DidAccessInitialDocument() OVERRIDE;
349   virtual void DocumentAvailableInMainFrame(
350       RenderViewHost* render_view_host) OVERRIDE;
351   virtual void DocumentOnLoadCompletedInMainFrame(
352       RenderViewHost* render_view_host,
353       int32 page_id) OVERRIDE;
354   virtual void RouteCloseEvent(RenderViewHost* rvh) OVERRIDE;
355   virtual void RouteMessageEvent(
356       RenderViewHost* rvh,
357       const ViewMsg_PostMessage_Params& params) OVERRIDE;
358   virtual void RunJavaScriptMessage(RenderViewHost* rvh,
359                                     const base::string16& message,
360                                     const base::string16& default_prompt,
361                                     const GURL& frame_url,
362                                     JavaScriptMessageType type,
363                                     IPC::Message* reply_msg,
364                                     bool* did_suppress_message) OVERRIDE;
365   virtual void RunBeforeUnloadConfirm(RenderViewHost* rvh,
366                                       const base::string16& message,
367                                       bool is_reload,
368                                       IPC::Message* reply_msg) OVERRIDE;
369   virtual bool AddMessageToConsole(int32 level,
370                                    const base::string16& message,
371                                    int32 line_no,
372                                    const base::string16& source_id) OVERRIDE;
373   virtual RendererPreferences GetRendererPrefs(
374       BrowserContext* browser_context) const OVERRIDE;
375   virtual WebPreferences GetWebkitPrefs() OVERRIDE;
376   virtual void OnUserGesture() OVERRIDE;
377   virtual void OnIgnoredUIEvent() OVERRIDE;
378   virtual void RendererUnresponsive(RenderViewHost* render_view_host,
379                                     bool is_during_beforeunload,
380                                     bool is_during_unload) OVERRIDE;
381   virtual void RendererResponsive(RenderViewHost* render_view_host) OVERRIDE;
382   virtual void LoadStateChanged(const GURL& url,
383                                 const net::LoadStateWithParam& load_state,
384                                 uint64 upload_position,
385                                 uint64 upload_size) OVERRIDE;
386   virtual void Activate() OVERRIDE;
387   virtual void Deactivate() OVERRIDE;
388   virtual void LostCapture() OVERRIDE;
389   virtual void HandleMouseDown() OVERRIDE;
390   virtual void HandleMouseUp() OVERRIDE;
391   virtual void HandlePointerActivate() OVERRIDE;
392   virtual void HandleGestureBegin() OVERRIDE;
393   virtual void HandleGestureEnd() OVERRIDE;
394   virtual void RunFileChooser(
395       RenderViewHost* render_view_host,
396       const FileChooserParams& params) OVERRIDE;
397   virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
398   virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
399   virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
400   virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
401   virtual void RequestToLockMouse(bool user_gesture,
402                                   bool last_unlocked_by_target) OVERRIDE;
403   virtual void LostMouseLock() OVERRIDE;
404   virtual void CreateNewWindow(
405       int render_process_id,
406       int route_id,
407       int main_frame_route_id,
408       const ViewHostMsg_CreateWindow_Params& params,
409       SessionStorageNamespace* session_storage_namespace) OVERRIDE;
410   virtual void CreateNewWidget(int render_process_id,
411                                int route_id,
412                                blink::WebPopupType popup_type) OVERRIDE;
413   virtual void CreateNewFullscreenWidget(int render_process_id,
414                                          int route_id) OVERRIDE;
415   virtual void ShowCreatedWindow(int route_id,
416                                  WindowOpenDisposition disposition,
417                                  const gfx::Rect& initial_pos,
418                                  bool user_gesture) OVERRIDE;
419   virtual void ShowCreatedWidget(int route_id,
420                                  const gfx::Rect& initial_pos) OVERRIDE;
421   virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
422   virtual void RequestMediaAccessPermission(
423       const MediaStreamRequest& request,
424       const MediaResponseCallback& callback) OVERRIDE;
425   virtual SessionStorageNamespace* GetSessionStorageNamespace(
426       SiteInstance* instance) OVERRIDE;
427   virtual FrameTree* GetFrameTree() OVERRIDE;
428   virtual void AccessibilityEventReceived(
429       const std::vector<AXEventNotificationDetails>& details) OVERRIDE;
430
431   // NavigatorDelegate ---------------------------------------------------------
432
433   virtual void DidStartProvisionalLoad(
434       RenderFrameHostImpl* render_frame_host,
435       int parent_routing_id,
436       const GURL& validated_url,
437       bool is_error_page,
438       bool is_iframe_srcdoc) OVERRIDE;
439   virtual void DidFailProvisionalLoadWithError(
440       RenderFrameHostImpl* render_frame_host,
441       const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
442       OVERRIDE;
443   virtual void DidFailLoadWithError(
444       RenderFrameHostImpl* render_frame_host,
445       const GURL& url,
446       int error_code,
447       const base::string16& error_description) OVERRIDE;
448   virtual void DidRedirectProvisionalLoad(
449       RenderFrameHostImpl* render_frame_host,
450       const GURL& validated_target_url) OVERRIDE;
451   virtual void DidCommitProvisionalLoad(
452       RenderFrameHostImpl* render_frame_host,
453       const base::string16& frame_unique_name,
454       bool is_main_frame,
455       const GURL& url,
456       PageTransition transition_type) OVERRIDE;
457   virtual void DidNavigateMainFramePreCommit(
458       const FrameHostMsg_DidCommitProvisionalLoad_Params& params) OVERRIDE;
459   virtual void DidNavigateMainFramePostCommit(
460       const LoadCommittedDetails& details,
461       const FrameHostMsg_DidCommitProvisionalLoad_Params& params) OVERRIDE;
462   virtual void DidNavigateAnyFramePostCommit(
463       RenderFrameHostImpl* render_frame_host,
464       const LoadCommittedDetails& details,
465       const FrameHostMsg_DidCommitProvisionalLoad_Params& params) OVERRIDE;
466   virtual void SetMainFrameMimeType(const std::string& mime_type) OVERRIDE;
467   virtual bool CanOverscrollContent() OVERRIDE;
468   virtual void NotifyChangedNavigationState(
469       InvalidateTypes changed_flags) OVERRIDE;
470   virtual void AboutToNavigateRenderFrame(
471       RenderFrameHostImpl* render_frame_host) OVERRIDE;
472   virtual void DidStartNavigationToPendingEntry(
473       RenderFrameHostImpl* render_frame_host,
474       const GURL& url,
475       NavigationController::ReloadType reload_type) OVERRIDE;
476   virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
477                               const OpenURLParams& params) OVERRIDE;
478
479   // RenderWidgetHostDelegate --------------------------------------------------
480
481   virtual void RenderWidgetDeleted(
482       RenderWidgetHostImpl* render_widget_host) OVERRIDE;
483   virtual bool PreHandleKeyboardEvent(
484       const NativeWebKeyboardEvent& event,
485       bool* is_keyboard_shortcut) OVERRIDE;
486   virtual void HandleKeyboardEvent(
487       const NativeWebKeyboardEvent& event) OVERRIDE;
488   virtual bool HandleWheelEvent(
489       const blink::WebMouseWheelEvent& event) OVERRIDE;
490   virtual bool PreHandleGestureEvent(
491       const blink::WebGestureEvent& event) OVERRIDE;
492   virtual void DidSendScreenRects(RenderWidgetHostImpl* rwh) OVERRIDE;
493 #if defined(OS_WIN)
494   virtual gfx::NativeViewAccessible GetParentNativeViewAccessible() OVERRIDE;
495 #endif
496
497   // RenderFrameHostManager::Delegate ------------------------------------------
498
499   virtual bool CreateRenderViewForRenderManager(
500       RenderViewHost* render_view_host,
501       int opener_route_id,
502       CrossProcessFrameConnector* frame_connector) OVERRIDE;
503   virtual void BeforeUnloadFiredFromRenderManager(
504       bool proceed, const base::TimeTicks& proceed_time,
505       bool* proceed_to_fire_unload) OVERRIDE;
506   virtual void RenderProcessGoneFromRenderManager(
507       RenderViewHost* render_view_host) OVERRIDE;
508   virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
509   virtual void CancelModalDialogsForRenderManager() OVERRIDE;
510   virtual void NotifySwappedFromRenderManager(
511       RenderViewHost* old_host, RenderViewHost* new_host) OVERRIDE;
512   virtual int CreateOpenerRenderViewsForRenderManager(
513       SiteInstance* instance) OVERRIDE;
514   virtual NavigationControllerImpl&
515       GetControllerForRenderManager() OVERRIDE;
516   virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
517   virtual NavigationEntry*
518       GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
519   virtual bool FocusLocationBarByDefault() OVERRIDE;
520   virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
521   virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) OVERRIDE;
522   virtual bool IsHidden() OVERRIDE;
523
524   // NotificationObserver ------------------------------------------------------
525
526   virtual void Observe(int type,
527                        const NotificationSource& source,
528                        const NotificationDetails& details) OVERRIDE;
529
530   // NavigationControllerDelegate ----------------------------------------------
531
532   virtual WebContents* GetWebContents() OVERRIDE;
533   virtual void NotifyNavigationEntryCommitted(
534       const LoadCommittedDetails& load_details) OVERRIDE;
535
536   // Invoked before a form repost warning is shown.
537   virtual void NotifyBeforeFormRepostWarningShow() OVERRIDE;
538
539   // Activate this WebContents and show a form repost warning.
540   virtual void ActivateAndShowRepostFormWarningDialog() OVERRIDE;
541
542   // Updates the max page ID for the current SiteInstance in this
543   // WebContentsImpl to be at least |page_id|.
544   virtual void UpdateMaxPageID(int32 page_id) OVERRIDE;
545
546   // Updates the max page ID for the given SiteInstance in this WebContentsImpl
547   // to be at least |page_id|.
548   virtual void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
549                                               int32 page_id) OVERRIDE;
550
551   // Copy the current map of SiteInstance ID to max page ID from another tab.
552   // This is necessary when this tab adopts the NavigationEntries from
553   // |web_contents|.
554   virtual void CopyMaxPageIDsFrom(WebContents* web_contents) OVERRIDE;
555
556   // Called by the NavigationController to cause the WebContentsImpl to navigate
557   // to the current pending entry. The NavigationController should be called
558   // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
559   // The callbacks can be inside of this function, or at some future time.
560   //
561   // The entry has a PageID of -1 if newly created (corresponding to navigation
562   // to a new URL).
563   //
564   // If this method returns false, then the navigation is discarded (equivalent
565   // to calling DiscardPendingEntry on the NavigationController).
566   virtual bool NavigateToPendingEntry(
567       NavigationController::ReloadType reload_type) OVERRIDE;
568
569   // Sets the history for this WebContentsImpl to |history_length| entries, and
570   // moves the current page_id to the last entry in the list if it's valid.
571   // This is mainly used when a prerendered page is swapped into the current
572   // tab. The method is virtual for testing.
573   virtual void SetHistoryLengthAndPrune(
574       const SiteInstance* site_instance,
575       int merge_history_length,
576       int32 minimum_page_id) OVERRIDE;
577
578   // Called by InterstitialPageImpl when it creates a RenderFrameHost.
579   virtual void RenderFrameForInterstitialPageCreated(
580       RenderFrameHost* render_frame_host) OVERRIDE;
581
582   // Sets the passed interstitial as the currently showing interstitial.
583   // No interstitial page should already be attached.
584   virtual void AttachInterstitialPage(
585       InterstitialPageImpl* interstitial_page) OVERRIDE;
586
587   // Unsets the currently showing interstitial.
588   virtual void DetachInterstitialPage() OVERRIDE;
589
590   // Changes the IsLoading state and notifies the delegate as needed.
591   // |details| is used to provide details on the load that just finished
592   // (but can be null if not applicable).
593   virtual void SetIsLoading(RenderViewHost* render_view_host,
594                             bool is_loading,
595                             bool to_different_document,
596                             LoadNotificationDetails* details) OVERRIDE;
597
598   typedef base::Callback<void(WebContents*)> CreatedCallback;
599
600  private:
601   friend class NavigationControllerImpl;
602   friend class TestNavigationObserver;
603   friend class WebContentsObserver;
604   friend class WebContents;  // To implement factory methods.
605
606   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
607   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
608   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending);
609   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
610                            CrossSiteCantPreemptAfterUnload);
611   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContents);
612   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FrameTreeShape);
613   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, GetLastActiveTime);
614   FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
615   FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
616   FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest, PageDoesBackAndReload);
617
618   // So InterstitialPageImpl can access SetIsLoading.
619   friend class InterstitialPageImpl;
620
621   // TODO(brettw) TestWebContents shouldn't exist!
622   friend class TestWebContents;
623
624   class DestructionObserver;
625
626   // See WebContents::Create for a description of these parameters.
627   WebContentsImpl(BrowserContext* browser_context,
628                   WebContentsImpl* opener);
629
630   // Add and remove observers for page navigation notifications. The order in
631   // which notifications are sent to observers is undefined. Clients must be
632   // sure to remove the observer before they go away.
633   void AddObserver(WebContentsObserver* observer);
634   void RemoveObserver(WebContentsObserver* observer);
635
636   // Clears this tab's opener if it has been closed.
637   void OnWebContentsDestroyed(WebContentsImpl* web_contents);
638
639   // Creates and adds to the map a destruction observer watching |web_contents|.
640   // No-op if such an observer already exists.
641   void AddDestructionObserver(WebContentsImpl* web_contents);
642
643   // Deletes and removes from the map a destruction observer
644   // watching |web_contents|. No-op if there is no such observer.
645   void RemoveDestructionObserver(WebContentsImpl* web_contents);
646
647   // Callback function when showing JavaScript dialogs.  Takes in a routing ID
648   // pair to identify the RenderViewHost that opened the dialog, because it's
649   // possible for the RenderViewHost to be deleted by the time this is called.
650   void OnDialogClosed(int render_process_id,
651                       int render_view_id,
652                       IPC::Message* reply_msg,
653                       bool success,
654                       const base::string16& user_input);
655
656   // Callback function when requesting permission to access the PPAPI broker.
657   // |result| is true if permission was granted.
658   void OnPpapiBrokerPermissionResult(int routing_id, bool result);
659
660   bool OnMessageReceived(RenderViewHost* render_view_host,
661                          RenderFrameHost* render_frame_host,
662                          const IPC::Message& message);
663
664   // IPC message handlers.
665   void OnDidLoadResourceFromMemoryCache(const GURL& url,
666                                         const std::string& security_info,
667                                         const std::string& http_request,
668                                         const std::string& mime_type,
669                                         ResourceType::Type resource_type);
670   void OnDidDisplayInsecureContent();
671   void OnDidRunInsecureContent(const std::string& security_origin,
672                                const GURL& target_url);
673   void OnDocumentLoadedInFrame();
674   void OnDidFinishLoad(const GURL& url);
675   void OnGoToEntryAtOffset(int offset);
676   void OnUpdateZoomLimits(int minimum_percent,
677                           int maximum_percent,
678                           bool remember);
679   void OnEnumerateDirectory(int request_id, const base::FilePath& path);
680
681   void OnRegisterProtocolHandler(const std::string& protocol,
682                                  const GURL& url,
683                                  const base::string16& title,
684                                  bool user_gesture);
685   void OnFindReply(int request_id,
686                    int number_of_matches,
687                    const gfx::Rect& selection_rect,
688                    int active_match_ordinal,
689                    bool final_update);
690 #if defined(OS_ANDROID)
691   void OnFindMatchRectsReply(int version,
692                              const std::vector<gfx::RectF>& rects,
693                              const gfx::RectF& active_rect);
694
695   void OnOpenDateTimeDialog(
696       const ViewHostMsg_DateTimeDialogValue_Params& value);
697   void OnJavaBridgeGetChannelHandle(IPC::Message* reply_msg);
698 #endif
699   void OnPepperPluginHung(int plugin_child_id,
700                           const base::FilePath& path,
701                           bool is_hung);
702   void OnPluginCrashed(const base::FilePath& plugin_path,
703                        base::ProcessId plugin_pid);
704   void OnDomOperationResponse(const std::string& json_string,
705                               int automation_id);
706   void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
707   void OnOpenColorChooser(int color_chooser_id,
708                           SkColor color,
709                           const std::vector<ColorSuggestion>& suggestions);
710   void OnEndColorChooser(int color_chooser_id);
711   void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
712   void OnWebUISend(const GURL& source_url,
713                    const std::string& name,
714                    const base::ListValue& args);
715   void OnRequestPpapiBrokerPermission(int routing_id,
716                                       const GURL& url,
717                                       const base::FilePath& plugin_path);
718   void OnBrowserPluginMessage(const IPC::Message& message);
719   void OnDidDownloadImage(int id,
720                           int http_status_code,
721                           const GURL& image_url,
722                           const std::vector<SkBitmap>& bitmaps,
723                           const std::vector<gfx::Size>& original_bitmap_sizes);
724   void OnUpdateFaviconURL(int32 page_id,
725                           const std::vector<FaviconURL>& candidates);
726   void OnFirstVisuallyNonEmptyPaint(int32 page_id);
727   void OnMediaPlayingNotification(int64 player_cookie,
728                                   bool has_video,
729                                   bool has_audio);
730   void OnMediaPausedNotification(int64 player_cookie);
731   void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view,
732                                const base::string16& main_text,
733                                const base::string16& sub_text);
734   void OnHideValidationMessage();
735   void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view);
736
737
738   // Called by derived classes to indicate that we're no longer waiting for a
739   // response. This won't actually update the throbber, but it will get picked
740   // up at the next animation step if the throbber is going.
741   void SetNotWaitingForResponse() { waiting_for_response_ = false; }
742
743   // Navigation helpers --------------------------------------------------------
744   //
745   // These functions are helpers for Navigate() and DidNavigate().
746
747   // Handles post-navigation tasks in DidNavigate AFTER the entry has been
748   // committed to the navigation controller. Note that the navigation entry is
749   // not provided since it may be invalid/changed after being committed. The
750   // current navigation entry is in the NavigationController at this point.
751
752   // If our controller was restored, update the max page ID associated with the
753   // given RenderViewHost to be larger than the number of restored entries.
754   // This is called in CreateRenderView before any navigations in the RenderView
755   // have begun, to prevent any races in updating RenderView::next_page_id.
756   void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh);
757
758   // Saves the given title to the navigation entry and does associated work. It
759   // will update history and the view for the new title, and also synthesize
760   // titles for file URLs that have none (so we require that the URL of the
761   // entry already be set).
762   //
763   // This is used as the backend for state updates, which include a new title,
764   // or the dedicated set title message. It returns true if the new title is
765   // different and was therefore updated.
766   bool UpdateTitleForEntry(NavigationEntryImpl* entry,
767                            const base::string16& title);
768
769   // Recursively creates swapped out RenderViews for this tab's opener chain
770   // (including this tab) in the given SiteInstance, allowing other tabs to send
771   // cross-process JavaScript calls to their opener(s).  Returns the route ID of
772   // this tab's RenderView for |instance|.
773   int CreateOpenerRenderViews(SiteInstance* instance);
774
775   // Helper for CreateNewWidget/CreateNewFullscreenWidget.
776   void CreateNewWidget(int render_process_id,
777                        int route_id,
778                        bool is_fullscreen,
779                        blink::WebPopupType popup_type);
780
781   // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
782   void ShowCreatedWidget(int route_id,
783                          bool is_fullscreen,
784                          const gfx::Rect& initial_pos);
785
786   // Finds the new RenderWidgetHost and returns it. Note that this can only be
787   // called once as this call also removes it from the internal map.
788   RenderWidgetHostView* GetCreatedWidget(int route_id);
789
790   // Finds the new WebContentsImpl by route_id, initializes it for
791   // renderer-initiated creation, and returns it. Note that this can only be
792   // called once as this call also removes it from the internal map.
793   WebContentsImpl* GetCreatedWindow(int route_id);
794
795   // Returns the RenderWidgetHostView that is associated with a native window
796   // and can be used in showing created widgets.
797   // If this WebContents belongs to a browser plugin guest, there is no native
798   // window 'view' associated with this WebContents. This method returns the
799   // 'view' of the embedder instead.
800   RenderWidgetHostViewPort* GetRenderWidgetHostViewPort() const;
801
802   // Misc non-view stuff -------------------------------------------------------
803
804   // Helper functions for sending notifications.
805   void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host);
806   void NotifyDisconnected();
807
808   void SetEncoding(const std::string& encoding);
809
810   // TODO(creis): This should take in a FrameTreeNode to know which node's
811   // render manager to return.  For now, we just return the root's.
812   RenderFrameHostManager* GetRenderManager() const;
813
814   RenderViewHostImpl* GetRenderViewHostImpl();
815
816   // Removes browser plugin embedder if there is one.
817   void RemoveBrowserPluginEmbedder();
818
819   // Clear |render_view_host|'s PowerSaveBlockers.
820   void ClearPowerSaveBlockers(RenderViewHost* render_view_host);
821
822   // Clear all PowerSaveBlockers, leave power_save_blocker_ empty.
823   void ClearAllPowerSaveBlockers();
824
825   // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
826   gfx::Size GetSizeForNewRenderView() const;
827
828   void OnFrameRemoved(RenderViewHostImpl* render_view_host,
829                       int frame_routing_id);
830
831   // Helper method that's called whenever |preferred_size_| or
832   // |preferred_size_for_capture_| changes, to propagate the new value to the
833   // |delegate_|.
834   void OnPreferredSizeChanged(const gfx::Size& old_size);
835
836   // Adds/removes a callback called on creation of each new WebContents.
837   // Deprecated, about to remove.
838   static void AddCreatedCallback(const CreatedCallback& callback);
839   static void RemoveCreatedCallback(const CreatedCallback& callback);
840
841   // Data for core operation ---------------------------------------------------
842
843   // Delegate for notifying our owner about stuff. Not owned by us.
844   WebContentsDelegate* delegate_;
845
846   // Handles the back/forward list and loading.
847   NavigationControllerImpl controller_;
848
849   // The corresponding view.
850   scoped_ptr<WebContentsViewPort> view_;
851
852   // The view of the RVHD. Usually this is our WebContentsView implementation,
853   // but if an embedder uses a different WebContentsView, they'll need to
854   // provide this.
855   RenderViewHostDelegateView* render_view_host_delegate_view_;
856
857   // Tracks created WebContentsImpl objects that have not been shown yet. They
858   // are identified by the route ID passed to CreateNewWindow.
859   typedef std::map<int, WebContentsImpl*> PendingContents;
860   PendingContents pending_contents_;
861
862   // These maps hold on to the widgets that we created on behalf of the renderer
863   // that haven't shown yet.
864   typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews;
865   PendingWidgetViews pending_widget_views_;
866
867   typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers;
868   DestructionObservers destruction_observers_;
869
870   // A list of observers notified when page state changes. Weak references.
871   // This MUST be listed above frame_tree_ since at destruction time the
872   // latter might cause RenderViewHost's destructor to call us and we might use
873   // the observer list then.
874   ObserverList<WebContentsObserver> observers_;
875
876   // The tab that opened this tab, if any.  Will be set to null if the opener
877   // is closed.
878   WebContentsImpl* opener_;
879
880 #if defined(OS_WIN)
881   gfx::NativeViewAccessible accessible_parent_;
882 #endif
883
884   // Helper classes ------------------------------------------------------------
885
886   // Maps the RenderViewHost to its media_player_cookie and PowerSaveBlocker
887   // pairs. Key is the RenderViewHost, value is the map which maps player_cookie
888   // on to PowerSaveBlocker.
889   typedef std::map<RenderViewHost*, std::map<int64, PowerSaveBlocker*> >
890       PowerSaveBlockerMap;
891   PowerSaveBlockerMap power_save_blockers_;
892
893   // Manages the frame tree of the page and process swaps in each node.
894   FrameTree frame_tree_;
895
896 #if defined(OS_ANDROID)
897   // Manages injecting Java objects into all RenderViewHosts associated with
898   // this WebContentsImpl.
899   scoped_ptr<JavaBridgeDispatcherHostManager>
900       java_bridge_dispatcher_host_manager_;
901 #endif
902
903   // SavePackage, lazily created.
904   scoped_refptr<SavePackage> save_package_;
905
906   // Data for loading state ----------------------------------------------------
907
908   // Indicates whether we're currently loading a resource.
909   bool is_loading_;
910
911   // Indicates if the tab is considered crashed.
912   base::TerminationStatus crashed_status_;
913   int crashed_error_code_;
914
915   // Whether this WebContents is waiting for a first-response for the
916   // main resource of the page. This controls whether the throbber state is
917   // "waiting" or "loading."
918   bool waiting_for_response_;
919
920   // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
921   // to a given tab and SiteInstance, and must be valid for the lifetime of the
922   // WebContentsImpl.
923   std::map<int32, int32> max_page_ids_;
924
925   // The current load state and the URL associated with it.
926   net::LoadStateWithParam load_state_;
927   base::string16 load_state_host_;
928   // Upload progress, for displaying in the status bar.
929   // Set to zero when there is no significant upload happening.
930   uint64 upload_size_;
931   uint64 upload_position_;
932
933   // Data for current page -----------------------------------------------------
934
935   // When a title cannot be taken from any entry, this title will be used.
936   base::string16 page_title_when_no_navigation_entry_;
937
938   // When a navigation occurs, we record its contents MIME type. It can be
939   // used to check whether we can do something for some special contents.
940   std::string contents_mime_type_;
941
942   // Character encoding.
943   std::string encoding_;
944
945   // True if this is a secure page which displayed insecure content.
946   bool displayed_insecure_content_;
947
948   // Data for misc internal state ----------------------------------------------
949
950   // When > 0, the WebContents is currently being captured (e.g., for
951   // screenshots or mirroring); and the underlying RenderWidgetHost should not
952   // be told it is hidden.
953   int capturer_count_;
954
955   // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
956   bool should_normally_be_visible_;
957
958   // See getter above.
959   bool is_being_destroyed_;
960
961   // Indicates whether we should notify about disconnection of this
962   // WebContentsImpl. This is used to ensure disconnection notifications only
963   // happen if a connection notification has happened and that they happen only
964   // once.
965   bool notify_disconnection_;
966
967   // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
968   // delegate of this WebContentsImpl is nulled before its destructor is called.
969   JavaScriptDialogManager* dialog_manager_;
970
971   // Set to true when there is an active "before unload" dialog.  When true,
972   // we've forced the throbber to start in Navigate, and we need to remember to
973   // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
974   bool is_showing_before_unload_dialog_;
975
976   // Settings that get passed to the renderer process.
977   RendererPreferences renderer_preferences_;
978
979   // The time that this WebContents was last made active. The initial value is
980   // the WebContents creation time.
981   base::TimeTicks last_active_time_;
982
983   // See description above setter.
984   bool closed_by_user_gesture_;
985
986   // Minimum/maximum zoom percent.
987   int minimum_zoom_percent_;
988   int maximum_zoom_percent_;
989   // If true, the default zoom limits have been overriden for this tab, in which
990   // case we don't want saved settings to apply to it and we don't want to
991   // remember it.
992   bool temporary_zoom_settings_;
993
994   // The intrinsic size of the page.
995   gfx::Size preferred_size_;
996
997   // The preferred size for content screen capture.  When |capturer_count_| > 0,
998   // this overrides |preferred_size_|.
999   gfx::Size preferred_size_for_capture_;
1000
1001 #if defined(OS_ANDROID)
1002   // Date time chooser opened by this tab.
1003   // Only used in Android since all other platforms use a multi field UI.
1004   scoped_ptr<DateTimeChooserAndroid> date_time_chooser_;
1005 #endif
1006
1007   // Color chooser that was opened by this tab.
1008   scoped_ptr<ColorChooser> color_chooser_;
1009
1010   // A unique identifier for the current color chooser.  Identifiers are unique
1011   // across a renderer process.  This avoids race conditions in synchronizing
1012   // the browser and renderer processes.  For example, if a renderer closes one
1013   // chooser and opens another, and simultaneously the user picks a color in the
1014   // first chooser, the IDs can be used to drop the "chose a color" message
1015   // rather than erroneously tell the renderer that the user picked a color in
1016   // the second chooser.
1017   int color_chooser_identifier_;
1018
1019   // Manages the embedder state for browser plugins, if this WebContents is an
1020   // embedder; NULL otherwise.
1021   scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_;
1022   // Manages the guest state for browser plugin, if this WebContents is a guest;
1023   // NULL otherwise.
1024   scoped_ptr<BrowserPluginGuest> browser_plugin_guest_;
1025
1026   // This must be at the end, or else we might get notifications and use other
1027   // member variables that are gone.
1028   NotificationRegistrar registrar_;
1029
1030   // Used during IPC message dispatching from the RenderView/RenderFrame so that
1031   // the handlers can get a pointer to the RVH through which the message was
1032   // received.
1033   RenderViewHost* render_view_message_source_;
1034   RenderFrameHost* render_frame_message_source_;
1035
1036   // All live RenderWidgetHostImpls that are created by this object and may
1037   // outlive it.
1038   std::set<RenderWidgetHostImpl*> created_widgets_;
1039
1040   // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1041   int fullscreen_widget_routing_id_;
1042
1043   // Maps the ids of pending image downloads to their callbacks
1044   typedef std::map<int, ImageDownloadCallback> ImageDownloadMap;
1045   ImageDownloadMap image_download_map_;
1046
1047   // Whether this WebContents is responsible for displaying a subframe in a
1048   // different process from its parent page.
1049   bool is_subframe_;
1050
1051   DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
1052 };
1053
1054 }  // namespace content
1055
1056 #endif  // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_