Upstream version 5.34.92.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/notification_observer.h"
28 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/browser/web_contents.h"
30 #include "content/public/common/page_transition_types.h"
31 #include "content/public/common/renderer_preferences.h"
32 #include "content/public/common/three_d_api_types.h"
33 #include "net/base/load_states.h"
34 #include "third_party/WebKit/public/web/WebDragOperation.h"
35 #include "ui/gfx/rect_f.h"
36 #include "ui/gfx/size.h"
37 #include "webkit/common/resource_type.h"
38
39 struct BrowserPluginHostMsg_ResizeGuest_Params;
40 struct ViewHostMsg_DateTimeDialogValue_Params;
41 struct ViewMsg_PostMessage_Params;
42
43 namespace content {
44 class BrowserPluginEmbedder;
45 class BrowserPluginGuest;
46 class BrowserPluginGuestManager;
47 class ColorChooser;
48 class DateTimeChooserAndroid;
49 class DownloadItem;
50 class InterstitialPageImpl;
51 class JavaBridgeDispatcherHostManager;
52 class JavaScriptDialogManager;
53 class PowerSaveBlocker;
54 class RenderViewHost;
55 class RenderViewHostDelegateView;
56 class RenderViewHostImpl;
57 class RenderWidgetHostImpl;
58 class RenderWidgetHostViewPort;
59 class SavePackage;
60 class SessionStorageNamespaceImpl;
61 class SiteInstance;
62 class TestWebContents;
63 class WebContentsDelegate;
64 class WebContentsImpl;
65 class WebContentsObserver;
66 class WebContentsViewPort;
67 class WebContentsViewDelegate;
68 struct ColorSuggestion;
69 struct FaviconURL;
70 struct LoadNotificationDetails;
71 struct ResourceRedirectDetails;
72 struct ResourceRequestDetails;
73
74 // Factory function for the implementations that content knows about. Takes
75 // ownership of |delegate|.
76 WebContentsViewPort* CreateWebContentsView(
77     WebContentsImpl* web_contents,
78     WebContentsViewDelegate* delegate,
79     RenderViewHostDelegateView** render_view_host_delegate_view);
80
81 class CONTENT_EXPORT WebContentsImpl
82     : public NON_EXPORTED_BASE(WebContents),
83       public NON_EXPORTED_BASE(RenderFrameHostDelegate),
84       public RenderViewHostDelegate,
85       public RenderWidgetHostDelegate,
86       public RenderFrameHostManager::Delegate,
87       public NotificationObserver,
88       public NON_EXPORTED_BASE(NavigationControllerDelegate),
89       public NON_EXPORTED_BASE(NavigatorDelegate) {
90  public:
91   virtual ~WebContentsImpl();
92
93   static WebContentsImpl* CreateWithOpener(
94       const WebContents::CreateParams& params,
95       WebContentsImpl* opener);
96
97   // Returns the opener WebContentsImpl, if any. This can be set to null if the
98   // opener is closed or the page clears its window.opener.
99   WebContentsImpl* opener() const { return opener_; }
100
101   // Creates a WebContents to be used as a browser plugin guest.
102   static BrowserPluginGuest* CreateGuest(
103       BrowserContext* browser_context,
104       content::SiteInstance* site_instance,
105       int guest_instance_id,
106       scoped_ptr<base::DictionaryValue> extra_params);
107
108   // Creates a swapped out RenderView. This is used by the browser plugin to
109   // create a swapped out RenderView in the embedder render process for the
110   // guest, to expose the guest's window object to the embedder.
111   // This returns the routing ID of the newly created swapped out RenderView.
112   int CreateSwappedOutRenderView(SiteInstance* instance);
113
114   // Complex initialization here. Specifically needed to avoid having
115   // members call back into our virtual functions in the constructor.
116   virtual void Init(const WebContents::CreateParams& params);
117
118   // Returns the SavePackage which manages the page saving job. May be NULL.
119   SavePackage* save_package() const { return save_package_.get(); }
120
121 #if defined(OS_ANDROID)
122   JavaBridgeDispatcherHostManager* java_bridge_dispatcher_host_manager() const {
123     return java_bridge_dispatcher_host_manager_.get();
124   }
125
126   // In Android WebView, the RenderView needs created even there is no
127   // navigation entry, this allows Android WebViews to use
128   // javascript: URLs that load into the DOMWindow before the first page
129   // load. This is not safe to do in any context that a web page could get a
130   // reference to the DOMWindow before the first page load.
131   bool CreateRenderViewForInitialEmptyDocument();
132 #endif
133
134   // Expose the render manager for testing.
135   RenderFrameHostManager* GetRenderManagerForTesting();
136
137   // Returns guest browser plugin object, or NULL if this WebContents is not a
138   // guest.
139   BrowserPluginGuest* GetBrowserPluginGuest() const;
140
141   // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
142   // has a BrowserPluginGuest then that implies that it is being hosted by
143   // a BrowserPlugin object in an embedder renderer process.
144   void SetBrowserPluginGuest(BrowserPluginGuest* guest);
145
146   // Returns embedder browser plugin object, or NULL if this WebContents is not
147   // an embedder.
148   BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
149
150   // Returns the BrowserPluginGuestManager object, or NULL if this web contents
151   // does not have a BrowserPluginGuestManager.
152   BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
153
154   // Gets the current fullscreen render widget's routing ID. Returns
155   // MSG_ROUTING_NONE when there is no fullscreen render widget.
156   int GetFullscreenWidgetRoutingID() const;
157
158   // Invoked when visible SSL state (as defined by SSLStatus) changes.
159   void DidChangeVisibleSSLState();
160
161   // Informs the render view host and the BrowserPluginEmbedder, if present, of
162   // a Drag Source End.
163   void DragSourceEndedAt(int client_x, int client_y, int screen_x,
164       int screen_y, blink::WebDragOperation operation);
165
166   // Informs the render view host and the BrowserPluginEmbedder, if present, of
167   // a Drag Source Move.
168   void DragSourceMovedTo(int client_x, int client_y,
169                          int screen_x, int screen_y);
170
171   // A response has been received for a resource request.
172   void DidGetResourceResponseStart(
173       const ResourceRequestDetails& details);
174
175   // A redirect was received while requesting a resource.
176   void DidGetRedirectForResourceRequest(
177       RenderViewHost* render_view_host,
178       const ResourceRedirectDetails& details);
179
180   // WebContents ------------------------------------------------------
181   virtual WebContentsDelegate* GetDelegate() OVERRIDE;
182   virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE;
183   virtual NavigationControllerImpl& GetController() OVERRIDE;
184   virtual const NavigationControllerImpl& GetController() const OVERRIDE;
185   virtual BrowserContext* GetBrowserContext() const OVERRIDE;
186   virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
187   virtual RenderFrameHost* GetMainFrame() OVERRIDE;
188   virtual void ForEachFrame(
189       const base::Callback<void(RenderFrameHost*)>& on_frame) OVERRIDE;
190   virtual void SendToAllFrames(IPC::Message* message) OVERRIDE;
191   virtual RenderViewHost* GetRenderViewHost() const OVERRIDE;
192   virtual void GetRenderViewHostAtPosition(
193       int x,
194       int y,
195       const GetRenderViewHostCallback& callback) 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() 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 GetLastSelectedTime() 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 WorkerCrashed() OVERRIDE;
308   virtual WebContents* GetAsWebContents() OVERRIDE;
309
310   // RenderViewHostDelegate ----------------------------------------------------
311   virtual RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
312   virtual RenderViewHostDelegate::RendererManagement*
313       GetRendererManagementDelegate() OVERRIDE;
314   virtual bool OnMessageReceived(RenderViewHost* render_view_host,
315                                  const IPC::Message& message) OVERRIDE;
316   virtual const GURL& GetURL() const OVERRIDE;
317   virtual const GURL& GetVisibleURL() const OVERRIDE;
318   virtual const GURL& GetLastCommittedURL() const OVERRIDE;
319   // RenderFrameHostDelegate has the same method, so list it there because this
320   // interface is going away.
321   // virtual WebContents* GetAsWebContents() OVERRIDE;
322   virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
323   virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
324   virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE;
325   virtual void RenderViewTerminated(RenderViewHost* render_view_host,
326                                     base::TerminationStatus status,
327                                     int error_code) OVERRIDE;
328   virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
329   virtual void DidNavigate(
330       RenderViewHost* render_view_host,
331       const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
332   virtual void UpdateState(RenderViewHost* render_view_host,
333                            int32 page_id,
334                            const PageState& page_state) OVERRIDE;
335   virtual void UpdateTitle(RenderViewHost* render_view_host,
336                            int32 page_id,
337                            const base::string16& title,
338                            base::i18n::TextDirection title_direction) OVERRIDE;
339   virtual void UpdateEncoding(RenderViewHost* render_view_host,
340                               const std::string& encoding) OVERRIDE;
341   virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
342   virtual void Close(RenderViewHost* render_view_host) OVERRIDE;
343   virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
344   virtual void SwappedOut(RenderViewHost* render_view_host) OVERRIDE;
345   virtual void DidStartLoading(RenderViewHost* render_view_host) OVERRIDE;
346   virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
347   virtual void DidCancelLoading() OVERRIDE;
348   virtual void DidChangeLoadProgress(double progress) OVERRIDE;
349   virtual void DidDisownOpener(RenderViewHost* rvh) OVERRIDE;
350   virtual void DidAccessInitialDocument() OVERRIDE;
351   virtual void DocumentAvailableInMainFrame(
352       RenderViewHost* render_view_host) OVERRIDE;
353   virtual void DocumentOnLoadCompletedInMainFrame(
354       RenderViewHost* render_view_host,
355       int32 page_id) OVERRIDE;
356   virtual void RequestOpenURL(RenderViewHost* rvh,
357                               const GURL& url,
358                               const Referrer& referrer,
359                               WindowOpenDisposition disposition,
360                               int64 source_frame_id,
361                               bool should_replace_current_entry,
362                               bool user_gesture) OVERRIDE;
363   virtual void RequestTransferURL(
364       const GURL& url,
365       const std::vector<GURL>& redirect_chain,
366       const Referrer& referrer,
367       PageTransition page_transition,
368       WindowOpenDisposition disposition,
369       int64 source_frame_id,
370       const GlobalRequestID& transferred_global_request_id,
371       bool should_replace_current_entry,
372       bool user_gesture) OVERRIDE;
373   virtual void RouteCloseEvent(RenderViewHost* rvh) OVERRIDE;
374   virtual void RouteMessageEvent(
375       RenderViewHost* rvh,
376       const ViewMsg_PostMessage_Params& params) OVERRIDE;
377   virtual void RunJavaScriptMessage(RenderViewHost* rvh,
378                                     const base::string16& message,
379                                     const base::string16& default_prompt,
380                                     const GURL& frame_url,
381                                     JavaScriptMessageType type,
382                                     IPC::Message* reply_msg,
383                                     bool* did_suppress_message) OVERRIDE;
384   virtual void RunBeforeUnloadConfirm(RenderViewHost* rvh,
385                                       const base::string16& message,
386                                       bool is_reload,
387                                       IPC::Message* reply_msg) OVERRIDE;
388   virtual bool AddMessageToConsole(int32 level,
389                                    const base::string16& message,
390                                    int32 line_no,
391                                    const base::string16& source_id) OVERRIDE;
392   virtual RendererPreferences GetRendererPrefs(
393       BrowserContext* browser_context) const OVERRIDE;
394   virtual WebPreferences GetWebkitPrefs() OVERRIDE;
395   virtual void OnUserGesture() OVERRIDE;
396   virtual void OnIgnoredUIEvent() OVERRIDE;
397   virtual void RendererUnresponsive(RenderViewHost* render_view_host,
398                                     bool is_during_beforeunload,
399                                     bool is_during_unload) OVERRIDE;
400   virtual void RendererResponsive(RenderViewHost* render_view_host) OVERRIDE;
401   virtual void LoadStateChanged(const GURL& url,
402                                 const net::LoadStateWithParam& load_state,
403                                 uint64 upload_position,
404                                 uint64 upload_size) OVERRIDE;
405   virtual void Activate() OVERRIDE;
406   virtual void Deactivate() OVERRIDE;
407   virtual void LostCapture() OVERRIDE;
408   virtual void HandleMouseDown() OVERRIDE;
409   virtual void HandleMouseUp() OVERRIDE;
410   virtual void HandlePointerActivate() OVERRIDE;
411   virtual void HandleGestureBegin() OVERRIDE;
412   virtual void HandleGestureEnd() OVERRIDE;
413   virtual void RunFileChooser(
414       RenderViewHost* render_view_host,
415       const FileChooserParams& params) OVERRIDE;
416   virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
417   virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
418   virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
419   virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
420   virtual void RequestToLockMouse(bool user_gesture,
421                                   bool last_unlocked_by_target) OVERRIDE;
422   virtual void LostMouseLock() OVERRIDE;
423   virtual void CreateNewWindow(
424       int render_process_id,
425       int route_id,
426       int main_frame_route_id,
427       const ViewHostMsg_CreateWindow_Params& params,
428       SessionStorageNamespace* session_storage_namespace) OVERRIDE;
429   virtual void CreateNewWidget(int render_process_id,
430                                int route_id,
431                                blink::WebPopupType popup_type) OVERRIDE;
432   virtual void CreateNewFullscreenWidget(int render_process_id,
433                                          int route_id) OVERRIDE;
434   virtual void ShowCreatedWindow(int route_id,
435                                  WindowOpenDisposition disposition,
436                                  const gfx::Rect& initial_pos,
437                                  bool user_gesture) OVERRIDE;
438   virtual void ShowCreatedWidget(int route_id,
439                                  const gfx::Rect& initial_pos) OVERRIDE;
440   virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
441   virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE;
442   virtual void RequestMediaAccessPermission(
443       const MediaStreamRequest& request,
444       const MediaResponseCallback& callback) OVERRIDE;
445   virtual SessionStorageNamespace* GetSessionStorageNamespace(
446       SiteInstance* instance) OVERRIDE;
447   virtual FrameTree* GetFrameTree() OVERRIDE;
448
449   // NavigatorDelegate ---------------------------------------------------------
450
451   virtual void DidStartProvisionalLoad(
452       RenderFrameHostImpl* render_frame_host,
453       int64 frame_id,
454       int64 parent_frame_id,
455       bool is_main_frame,
456       const GURL& validated_url,
457       bool is_error_page,
458       bool is_iframe_srcdoc) OVERRIDE;
459   virtual void DidFailProvisionalLoadWithError(
460       RenderFrameHostImpl* render_frame_host,
461       const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
462       OVERRIDE;
463   virtual void DidRedirectProvisionalLoad(
464       RenderFrameHostImpl* render_frame_host,
465       const GURL& validated_target_url) OVERRIDE;
466   virtual void NotifyChangedNavigationState(
467       InvalidateTypes changed_flags) OVERRIDE;
468   virtual void AboutToNavigateRenderFrame(
469       RenderFrameHostImpl* render_frame_host) OVERRIDE;
470   virtual void DidStartNavigationToPendingEntry(
471       RenderFrameHostImpl* render_frame_host,
472       const GURL& url,
473       NavigationController::ReloadType reload_type) OVERRIDE;
474
475   // RenderWidgetHostDelegate --------------------------------------------------
476
477   virtual void RenderWidgetDeleted(
478       RenderWidgetHostImpl* render_widget_host) OVERRIDE;
479   virtual bool PreHandleKeyboardEvent(
480       const NativeWebKeyboardEvent& event,
481       bool* is_keyboard_shortcut) OVERRIDE;
482   virtual void HandleKeyboardEvent(
483       const NativeWebKeyboardEvent& event) OVERRIDE;
484   virtual bool PreHandleWheelEvent(
485       const blink::WebMouseWheelEvent& event) OVERRIDE;
486   virtual void DidSendScreenRects(RenderWidgetHostImpl* rwh) OVERRIDE;
487 #if defined(OS_WIN)
488   virtual gfx::NativeViewAccessible GetParentNativeViewAccessible() OVERRIDE;
489 #endif
490
491   // RenderFrameHostManager::Delegate ------------------------------------------
492
493   virtual bool CreateRenderViewForRenderManager(
494       RenderViewHost* render_view_host,
495       int opener_route_id,
496       CrossProcessFrameConnector* frame_connector) OVERRIDE;
497   virtual void BeforeUnloadFiredFromRenderManager(
498       bool proceed, const base::TimeTicks& proceed_time,
499       bool* proceed_to_fire_unload) OVERRIDE;
500   virtual void RenderProcessGoneFromRenderManager(
501       RenderViewHost* render_view_host) OVERRIDE;
502   virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
503   virtual void CancelModalDialogsForRenderManager() OVERRIDE;
504   virtual void NotifySwappedFromRenderManager(
505       RenderViewHost* old_host, RenderViewHost* new_host) OVERRIDE;
506   virtual int CreateOpenerRenderViewsForRenderManager(
507       SiteInstance* instance) OVERRIDE;
508   virtual NavigationControllerImpl&
509       GetControllerForRenderManager() OVERRIDE;
510   virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
511   virtual NavigationEntry*
512       GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
513   virtual bool FocusLocationBarByDefault() OVERRIDE;
514   virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
515   virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) OVERRIDE;
516   virtual bool IsHidden() OVERRIDE;
517
518   // NotificationObserver ------------------------------------------------------
519
520   virtual void Observe(int type,
521                        const NotificationSource& source,
522                        const NotificationDetails& details) OVERRIDE;
523
524   // NavigationControllerDelegate ----------------------------------------------
525
526   virtual WebContents* GetWebContents() OVERRIDE;
527   virtual void NotifyNavigationEntryCommitted(
528       const LoadCommittedDetails& load_details) OVERRIDE;
529
530   // Invoked before a form repost warning is shown.
531   virtual void NotifyBeforeFormRepostWarningShow() OVERRIDE;
532
533   // Activate this WebContents and show a form repost warning.
534   virtual void ActivateAndShowRepostFormWarningDialog() OVERRIDE;
535
536   // Updates the max page ID for the current SiteInstance in this
537   // WebContentsImpl to be at least |page_id|.
538   virtual void UpdateMaxPageID(int32 page_id) OVERRIDE;
539
540   // Updates the max page ID for the given SiteInstance in this WebContentsImpl
541   // to be at least |page_id|.
542   virtual void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
543                                               int32 page_id) OVERRIDE;
544
545   // Copy the current map of SiteInstance ID to max page ID from another tab.
546   // This is necessary when this tab adopts the NavigationEntries from
547   // |web_contents|.
548   virtual void CopyMaxPageIDsFrom(WebContents* web_contents) OVERRIDE;
549
550   // Called by the NavigationController to cause the WebContentsImpl to navigate
551   // to the current pending entry. The NavigationController should be called
552   // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
553   // The callbacks can be inside of this function, or at some future time.
554   //
555   // The entry has a PageID of -1 if newly created (corresponding to navigation
556   // to a new URL).
557   //
558   // If this method returns false, then the navigation is discarded (equivalent
559   // to calling DiscardPendingEntry on the NavigationController).
560   virtual bool NavigateToPendingEntry(
561       NavigationController::ReloadType reload_type) OVERRIDE;
562
563   // Sets the history for this WebContentsImpl to |history_length| entries, and
564   // moves the current page_id to the last entry in the list if it's valid.
565   // This is mainly used when a prerendered page is swapped into the current
566   // tab. The method is virtual for testing.
567   virtual void SetHistoryLengthAndPrune(
568       const SiteInstance* site_instance,
569       int merge_history_length,
570       int32 minimum_page_id) OVERRIDE;
571
572   // Called by InterstitialPageImpl when it creates a RenderFrameHost.
573   virtual void RenderFrameForInterstitialPageCreated(
574       RenderFrameHost* render_frame_host) OVERRIDE;
575
576   // Sets the passed interstitial as the currently showing interstitial.
577   // No interstitial page should already be attached.
578   virtual void AttachInterstitialPage(
579       InterstitialPageImpl* interstitial_page) OVERRIDE;
580
581   // Unsets the currently showing interstitial.
582   virtual void DetachInterstitialPage() OVERRIDE;
583
584   // Changes the IsLoading state and notifies the delegate as needed.
585   // |details| is used to provide details on the load that just finished
586   // (but can be null if not applicable).
587   virtual void SetIsLoading(RenderViewHost* render_view_host,
588                             bool is_loading,
589                             LoadNotificationDetails* details) OVERRIDE;
590
591   typedef base::Callback<void(WebContents*)> CreatedCallback;
592
593  private:
594   friend class NavigationControllerImpl;
595   friend class TestNavigationObserver;
596   friend class WebContentsObserver;
597   friend class WebContents;  // To implement factory methods.
598
599   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
600   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
601   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending);
602   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
603                            CrossSiteCantPreemptAfterUnload);
604   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContents);
605   FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FrameTreeShape);
606   FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
607   FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
608   FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest, PageDoesBackAndReload);
609
610   // So InterstitialPageImpl can access SetIsLoading.
611   friend class InterstitialPageImpl;
612
613   // TODO(brettw) TestWebContents shouldn't exist!
614   friend class TestWebContents;
615
616   class DestructionObserver;
617
618   // See WebContents::Create for a description of these parameters.
619   WebContentsImpl(BrowserContext* browser_context,
620                   WebContentsImpl* opener);
621
622   // Add and remove observers for page navigation notifications. The order in
623   // which notifications are sent to observers is undefined. Clients must be
624   // sure to remove the observer before they go away.
625   void AddObserver(WebContentsObserver* observer);
626   void RemoveObserver(WebContentsObserver* observer);
627
628   // Clears this tab's opener if it has been closed.
629   void OnWebContentsDestroyed(WebContentsImpl* web_contents);
630
631   // Creates and adds to the map a destruction observer watching |web_contents|.
632   // No-op if such an observer already exists.
633   void AddDestructionObserver(WebContentsImpl* web_contents);
634
635   // Deletes and removes from the map a destruction observer
636   // watching |web_contents|. No-op if there is no such observer.
637   void RemoveDestructionObserver(WebContentsImpl* web_contents);
638
639   // Callback function when showing JS dialogs.
640   void OnDialogClosed(RenderViewHost* rvh,
641                       IPC::Message* reply_msg,
642                       bool success,
643                       const base::string16& user_input);
644
645   // Callback function when requesting permission to access the PPAPI broker.
646   // |result| is true if permission was granted.
647   void OnPpapiBrokerPermissionResult(int routing_id, bool result);
648
649   bool OnMessageReceived(RenderViewHost* render_view_host,
650                          RenderFrameHost* render_frame_host,
651                          const IPC::Message& message);
652
653   // IPC message handlers.
654   void OnDidLoadResourceFromMemoryCache(const GURL& url,
655                                         const std::string& security_info,
656                                         const std::string& http_request,
657                                         const std::string& mime_type,
658                                         ResourceType::Type resource_type);
659   void OnDidDisplayInsecureContent();
660   void OnDidRunInsecureContent(const std::string& security_origin,
661                                const GURL& target_url);
662   void OnDocumentLoadedInFrame(int64 frame_id);
663   void OnDidFinishLoad(int64 frame_id,
664                        const GURL& url,
665                        bool is_main_frame);
666   void OnDidFailLoadWithError(int64 frame_id,
667                               const GURL& url,
668                               bool is_main_frame,
669                               int error_code,
670                               const base::string16& error_description);
671   void OnGoToEntryAtOffset(int offset);
672   void OnUpdateZoomLimits(int minimum_percent,
673                           int maximum_percent,
674                           bool remember);
675   void OnEnumerateDirectory(int request_id, const base::FilePath& path);
676   void OnJSOutOfMemory();
677
678   void OnRegisterProtocolHandler(const std::string& protocol,
679                                  const GURL& url,
680                                  const base::string16& title,
681                                  bool user_gesture);
682   void OnFindReply(int request_id,
683                    int number_of_matches,
684                    const gfx::Rect& selection_rect,
685                    int active_match_ordinal,
686                    bool final_update);
687 #if defined(OS_ANDROID)
688   void OnFindMatchRectsReply(int version,
689                              const std::vector<gfx::RectF>& rects,
690                              const gfx::RectF& active_rect);
691
692   void OnOpenDateTimeDialog(
693       const ViewHostMsg_DateTimeDialogValue_Params& value);
694   void OnJavaBridgeGetChannelHandle(IPC::Message* reply_msg);
695 #endif
696   void OnPepperPluginHung(int plugin_child_id,
697                           const base::FilePath& path,
698                           bool is_hung);
699   void OnPluginCrashed(const base::FilePath& plugin_path,
700                        base::ProcessId plugin_pid);
701   void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
702   void OnOpenColorChooser(int color_chooser_id,
703                           SkColor color,
704                           const std::vector<ColorSuggestion>& suggestions);
705   void OnEndColorChooser(int color_chooser_id);
706   void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
707   void OnWebUISend(const GURL& source_url,
708                    const std::string& name,
709                    const base::ListValue& args);
710   void OnRequestPpapiBrokerPermission(int routing_id,
711                                       const GURL& url,
712                                       const base::FilePath& plugin_path);
713   void OnBrowserPluginMessage(const IPC::Message& message);
714   void OnDidDownloadImage(int id,
715                           int http_status_code,
716                           const GURL& image_url,
717                           const std::vector<SkBitmap>& bitmaps,
718                           const std::vector<gfx::Size>& original_bitmap_sizes);
719   void OnUpdateFaviconURL(int32 page_id,
720                           const std::vector<FaviconURL>& candidates);
721   void OnFirstVisuallyNonEmptyPaint(int32 page_id);
722   void OnMediaNotification(int64 player_cookie,
723                            bool has_video,
724                            bool has_audio,
725                            bool is_playing);
726   void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view,
727                                const base::string16& main_text,
728                                const base::string16& sub_text);
729   void OnHideValidationMessage();
730   void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view);
731
732
733   // Called by derived classes to indicate that we're no longer waiting for a
734   // response. This won't actually update the throbber, but it will get picked
735   // up at the next animation step if the throbber is going.
736   void SetNotWaitingForResponse() { waiting_for_response_ = false; }
737
738   // Navigation helpers --------------------------------------------------------
739   //
740   // These functions are helpers for Navigate() and DidNavigate().
741
742   // Handles post-navigation tasks in DidNavigate AFTER the entry has been
743   // committed to the navigation controller. Note that the navigation entry is
744   // not provided since it may be invalid/changed after being committed. The
745   // current navigation entry is in the NavigationController at this point.
746   void DidNavigateMainFramePostCommit(
747       const LoadCommittedDetails& details,
748       const ViewHostMsg_FrameNavigate_Params& params);
749   void DidNavigateAnyFramePostCommit(
750       RenderViewHost* render_view_host,
751       const LoadCommittedDetails& details,
752       const ViewHostMsg_FrameNavigate_Params& params);
753
754   // Specifies whether the passed in URL should be assigned as the site of the
755   // current SiteInstance, if it does not yet have a site.
756   bool ShouldAssignSiteForURL(const GURL& url);
757
758   // If our controller was restored, update the max page ID associated with the
759   // given RenderViewHost to be larger than the number of restored entries.
760   // This is called in CreateRenderView before any navigations in the RenderView
761   // have begun, to prevent any races in updating RenderView::next_page_id.
762   void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh);
763
764   // Saves the given title to the navigation entry and does associated work. It
765   // will update history and the view for the new title, and also synthesize
766   // titles for file URLs that have none (so we require that the URL of the
767   // entry already be set).
768   //
769   // This is used as the backend for state updates, which include a new title,
770   // or the dedicated set title message. It returns true if the new title is
771   // different and was therefore updated.
772   bool UpdateTitleForEntry(NavigationEntryImpl* entry,
773                            const base::string16& title);
774
775   // Recursively creates swapped out RenderViews for this tab's opener chain
776   // (including this tab) in the given SiteInstance, allowing other tabs to send
777   // cross-process JavaScript calls to their opener(s).  Returns the route ID of
778   // this tab's RenderView for |instance|.
779   int CreateOpenerRenderViews(SiteInstance* instance);
780
781   // Helper for CreateNewWidget/CreateNewFullscreenWidget.
782   void CreateNewWidget(int render_process_id,
783                        int route_id,
784                        bool is_fullscreen,
785                        blink::WebPopupType popup_type);
786
787   // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
788   void ShowCreatedWidget(int route_id,
789                          bool is_fullscreen,
790                          const gfx::Rect& initial_pos);
791
792   // Finds the new RenderWidgetHost and returns it. Note that this can only be
793   // called once as this call also removes it from the internal map.
794   RenderWidgetHostView* GetCreatedWidget(int route_id);
795
796   // Finds the new WebContentsImpl by route_id, initializes it for
797   // renderer-initiated creation, and returns it. Note that this can only be
798   // called once as this call also removes it from the internal map.
799   WebContentsImpl* GetCreatedWindow(int route_id);
800
801   // Returns the RenderWidgetHostView that is associated with a native window
802   // and can be used in showing created widgets.
803   // If this WebContents belongs to a browser plugin guest, there is no native
804   // window 'view' associated with this WebContents. This method returns the
805   // 'view' of the embedder instead.
806   RenderWidgetHostViewPort* GetRenderWidgetHostViewPort() const;
807
808   // Misc non-view stuff -------------------------------------------------------
809
810   // Helper functions for sending notifications.
811   void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host);
812   void NotifyDisconnected();
813
814   void SetEncoding(const std::string& encoding);
815
816   // TODO(creis): This should take in a FrameTreeNode to know which node's
817   // render manager to return.  For now, we just return the root's.
818   RenderFrameHostManager* GetRenderManager() const;
819
820   RenderViewHostImpl* GetRenderViewHostImpl();
821
822   // Removes browser plugin embedder if there is one.
823   void RemoveBrowserPluginEmbedder();
824
825   // Clear |render_view_host|'s PowerSaveBlockers.
826   void ClearPowerSaveBlockers(RenderViewHost* render_view_host);
827
828   // Clear all PowerSaveBlockers, leave power_save_blocker_ empty.
829   void ClearAllPowerSaveBlockers();
830
831   // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
832   gfx::Size GetSizeForNewRenderView() const;
833
834   void OnFrameRemoved(RenderViewHostImpl* render_view_host, int64 frame_id);
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 tab was last selected.
980   base::TimeTicks last_selected_time_;
981
982   // See description above setter.
983   bool closed_by_user_gesture_;
984
985   // Minimum/maximum zoom percent.
986   int minimum_zoom_percent_;
987   int maximum_zoom_percent_;
988   // If true, the default zoom limits have been overriden for this tab, in which
989   // case we don't want saved settings to apply to it and we don't want to
990   // remember it.
991   bool temporary_zoom_settings_;
992
993   // The intrinsic size of the page.
994   gfx::Size preferred_size_;
995
996 #if defined(OS_ANDROID)
997   // Date time chooser opened by this tab.
998   // Only used in Android since all other platforms use a multi field UI.
999   scoped_ptr<DateTimeChooserAndroid> date_time_chooser_;
1000 #endif
1001
1002   // Color chooser that was opened by this tab.
1003   scoped_ptr<ColorChooser> color_chooser_;
1004
1005   // A unique identifier for the current color chooser.  Identifiers are unique
1006   // across a renderer process.  This avoids race conditions in synchronizing
1007   // the browser and renderer processes.  For example, if a renderer closes one
1008   // chooser and opens another, and simultaneously the user picks a color in the
1009   // first chooser, the IDs can be used to drop the "chose a color" message
1010   // rather than erroneously tell the renderer that the user picked a color in
1011   // the second chooser.
1012   int color_chooser_identifier_;
1013
1014   // Manages the embedder state for browser plugins, if this WebContents is an
1015   // embedder; NULL otherwise.
1016   scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_;
1017   // Manages the guest state for browser plugin, if this WebContents is a guest;
1018   // NULL otherwise.
1019   scoped_ptr<BrowserPluginGuest> browser_plugin_guest_;
1020
1021   // This must be at the end, or else we might get notifications and use other
1022   // member variables that are gone.
1023   NotificationRegistrar registrar_;
1024
1025   // Used during IPC message dispatching from the RenderView so that the
1026   // handlers can get a pointer to the RVH through which the message was
1027   // received.
1028   RenderViewHost* render_view_message_source_;
1029
1030   // All live RenderWidgetHostImpls that are created by this object and may
1031   // outlive it.
1032   std::set<RenderWidgetHostImpl*> created_widgets_;
1033
1034   // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1035   int fullscreen_widget_routing_id_;
1036
1037   // Maps the ids of pending image downloads to their callbacks
1038   typedef std::map<int, ImageDownloadCallback> ImageDownloadMap;
1039   ImageDownloadMap image_download_map_;
1040
1041   // Whether this WebContents is responsible for displaying a subframe in a
1042   // different process from its parent page.
1043   bool is_subframe_;
1044
1045   DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
1046 };
1047
1048 }  // namespace content
1049
1050 #endif  // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_