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.
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
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/color_chooser.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"
40 struct BrowserPluginHostMsg_ResizeGuest_Params;
41 struct ViewHostMsg_DateTimeDialogValue_Params;
42 struct ViewMsg_PostMessage_Params;
45 class BrowserPluginEmbedder;
46 class BrowserPluginGuest;
47 class BrowserPluginGuestManager;
48 class DateTimeChooserAndroid;
50 class GeolocationDispatcherHost;
51 class InterstitialPageImpl;
52 class JavaScriptDialogManager;
53 class MidiDispatcherHost;
54 class PowerSaveBlocker;
56 class RenderViewHostDelegateView;
57 class RenderViewHostImpl;
58 class RenderWidgetHostImpl;
60 class ScreenOrientationDispatcherHost;
62 class TestWebContents;
63 class WebContentsDelegate;
64 class WebContentsImpl;
65 class WebContentsObserver;
66 class WebContentsView;
67 class WebContentsViewDelegate;
68 struct AXEventNotificationDetails;
69 struct ColorSuggestion;
71 struct LoadNotificationDetails;
72 struct ResourceRedirectDetails;
73 struct ResourceRequestDetails;
75 // Factory function for the implementations that content knows about. Takes
76 // ownership of |delegate|.
77 WebContentsView* CreateWebContentsView(
78 WebContentsImpl* web_contents,
79 WebContentsViewDelegate* delegate,
80 RenderViewHostDelegateView** render_view_host_delegate_view);
82 class CONTENT_EXPORT WebContentsImpl
83 : public NON_EXPORTED_BASE(WebContents),
84 public NON_EXPORTED_BASE(RenderFrameHostDelegate),
85 public RenderViewHostDelegate,
86 public RenderWidgetHostDelegate,
87 public RenderFrameHostManager::Delegate,
88 public NotificationObserver,
89 public NON_EXPORTED_BASE(NavigationControllerDelegate),
90 public NON_EXPORTED_BASE(NavigatorDelegate) {
92 virtual ~WebContentsImpl();
94 static WebContentsImpl* CreateWithOpener(
95 const WebContents::CreateParams& params,
96 WebContentsImpl* opener);
98 // Returns the opener WebContentsImpl, if any. This can be set to null if the
99 // opener is closed or the page clears its window.opener.
100 WebContentsImpl* opener() const { return opener_; }
102 // Creates a swapped out RenderView. This is used by the browser plugin to
103 // create a swapped out RenderView in the embedder render process for the
104 // guest, to expose the guest's window object to the embedder.
105 // This returns the routing ID of the newly created swapped out RenderView.
106 int CreateSwappedOutRenderView(SiteInstance* instance);
108 // Complex initialization here. Specifically needed to avoid having
109 // members call back into our virtual functions in the constructor.
110 virtual void Init(const WebContents::CreateParams& params);
112 // Returns the SavePackage which manages the page saving job. May be NULL.
113 SavePackage* save_package() const { return save_package_.get(); }
115 #if defined(OS_ANDROID)
116 // In Android WebView, the RenderView needs created even there is no
117 // navigation entry, this allows Android WebViews to use
118 // javascript: URLs that load into the DOMWindow before the first page
119 // load. This is not safe to do in any context that a web page could get a
120 // reference to the DOMWindow before the first page load.
121 bool CreateRenderViewForInitialEmptyDocument();
124 // Expose the render manager for testing.
125 // TODO(creis): Remove this now that we can get to it via FrameTreeNode.
126 RenderFrameHostManager* GetRenderManagerForTesting();
128 // Returns guest browser plugin object, or NULL if this WebContents is not a
130 BrowserPluginGuest* GetBrowserPluginGuest() const;
132 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
133 // has a BrowserPluginGuest then that implies that it is being hosted by
134 // a BrowserPlugin object in an embedder renderer process.
135 void SetBrowserPluginGuest(BrowserPluginGuest* guest);
137 // Returns embedder browser plugin object, or NULL if this WebContents is not
139 BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
141 // Gets the current fullscreen render widget's routing ID. Returns
142 // MSG_ROUTING_NONE when there is no fullscreen render widget.
143 int GetFullscreenWidgetRoutingID() const;
145 // Invoked when visible SSL state (as defined by SSLStatus) changes.
146 void DidChangeVisibleSSLState();
148 // Informs the render view host and the BrowserPluginEmbedder, if present, of
149 // a Drag Source End.
150 void DragSourceEndedAt(int client_x, int client_y, int screen_x,
151 int screen_y, blink::WebDragOperation operation);
153 // A response has been received for a resource request.
154 void DidGetResourceResponseStart(
155 const ResourceRequestDetails& details);
157 // A redirect was received while requesting a resource.
158 void DidGetRedirectForResourceRequest(
159 RenderViewHost* render_view_host,
160 const ResourceRedirectDetails& details);
162 WebContentsView* GetView() const;
164 GeolocationDispatcherHost* geolocation_dispatcher_host() {
165 return geolocation_dispatcher_host_.get();
168 bool should_normally_be_visible() { return should_normally_be_visible_; }
170 // WebContents ------------------------------------------------------
171 virtual ScreenOrientationDispatcherHost* GetScreenOrientationDispatcherHost() OVERRIDE;
172 virtual WebContentsDelegate* GetDelegate() OVERRIDE;
173 virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE;
174 virtual NavigationControllerImpl& GetController() OVERRIDE;
175 virtual const NavigationControllerImpl& GetController() const OVERRIDE;
176 virtual BrowserContext* GetBrowserContext() const OVERRIDE;
177 virtual const GURL& GetURL() const OVERRIDE;
178 virtual const GURL& GetVisibleURL() const OVERRIDE;
179 virtual const GURL& GetLastCommittedURL() const OVERRIDE;
180 virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE;
181 virtual RenderFrameHost* GetMainFrame() OVERRIDE;
182 virtual RenderFrameHost* GetFocusedFrame() OVERRIDE;
183 virtual void ForEachFrame(
184 const base::Callback<void(RenderFrameHost*)>& on_frame) OVERRIDE;
185 virtual void SendToAllFrames(IPC::Message* message) OVERRIDE;
186 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE;
187 virtual int GetRoutingID() const OVERRIDE;
188 virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE;
189 virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const
191 virtual WebUI* CreateWebUI(const GURL& url) OVERRIDE;
192 virtual WebUI* GetWebUI() const OVERRIDE;
193 virtual WebUI* GetCommittedWebUI() const OVERRIDE;
194 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE;
195 virtual const std::string& GetUserAgentOverride() const OVERRIDE;
197 virtual void SetParentNativeViewAccessible(
198 gfx::NativeViewAccessible accessible_parent) OVERRIDE;
200 virtual const base::string16& GetTitle() const OVERRIDE;
201 virtual int32 GetMaxPageID() OVERRIDE;
202 virtual int32 GetMaxPageIDForSiteInstance(
203 SiteInstance* site_instance) OVERRIDE;
204 virtual SiteInstance* GetSiteInstance() const OVERRIDE;
205 virtual SiteInstance* GetPendingSiteInstance() const OVERRIDE;
206 virtual bool IsLoading() const OVERRIDE;
207 virtual bool IsLoadingToDifferentDocument() const OVERRIDE;
208 virtual bool IsWaitingForResponse() const OVERRIDE;
209 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE;
210 virtual const base::string16& GetLoadStateHost() const OVERRIDE;
211 virtual uint64 GetUploadSize() const OVERRIDE;
212 virtual uint64 GetUploadPosition() const OVERRIDE;
213 virtual std::set<GURL> GetSitesInTab() const OVERRIDE;
214 virtual const std::string& GetEncoding() const OVERRIDE;
215 virtual bool DisplayedInsecureContent() const OVERRIDE;
216 virtual void IncrementCapturerCount(const gfx::Size& capture_size) OVERRIDE;
217 virtual void DecrementCapturerCount() OVERRIDE;
218 virtual int GetCapturerCount() const OVERRIDE;
219 virtual bool IsCrashed() const OVERRIDE;
220 virtual void SetIsCrashed(base::TerminationStatus status,
221 int error_code) OVERRIDE;
222 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
223 virtual bool IsBeingDestroyed() const OVERRIDE;
224 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
225 virtual base::TimeTicks GetLastActiveTime() const OVERRIDE;
226 virtual void WasShown() OVERRIDE;
227 virtual void WasHidden() OVERRIDE;
228 virtual bool NeedToFireBeforeUnload() OVERRIDE;
229 virtual void DispatchBeforeUnload(bool for_cross_site_transition) OVERRIDE;
230 virtual void Stop() OVERRIDE;
231 virtual WebContents* Clone() OVERRIDE;
232 virtual void ReloadFocusedFrame(bool ignore_cache) OVERRIDE;
233 virtual void Undo() OVERRIDE;
234 virtual void Redo() OVERRIDE;
235 virtual void Cut() OVERRIDE;
236 virtual void Copy() OVERRIDE;
237 virtual void CopyToFindPboard() OVERRIDE;
238 virtual void Paste() OVERRIDE;
239 virtual void PasteAndMatchStyle() OVERRIDE;
240 virtual void Delete() OVERRIDE;
241 virtual void SelectAll() OVERRIDE;
242 virtual void Unselect() OVERRIDE;
243 virtual void Replace(const base::string16& word) OVERRIDE;
244 virtual void ReplaceMisspelling(const base::string16& word) OVERRIDE;
245 virtual void NotifyContextMenuClosed(
246 const CustomContextMenuContext& context) OVERRIDE;
247 virtual void ExecuteCustomContextMenuCommand(
248 int action, const CustomContextMenuContext& context) OVERRIDE;
249 virtual gfx::NativeView GetNativeView() OVERRIDE;
250 virtual gfx::NativeView GetContentNativeView() OVERRIDE;
251 virtual gfx::NativeWindow GetTopLevelNativeWindow() OVERRIDE;
252 virtual gfx::Rect GetContainerBounds() OVERRIDE;
253 virtual gfx::Rect GetViewBounds() OVERRIDE;
254 virtual DropData* GetDropData() OVERRIDE;
255 virtual void Focus() OVERRIDE;
256 virtual void SetInitialFocus() OVERRIDE;
257 virtual void StoreFocus() OVERRIDE;
258 virtual void RestoreFocus() OVERRIDE;
259 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
260 virtual bool ShowingInterstitialPage() const OVERRIDE;
261 virtual InterstitialPage* GetInterstitialPage() const OVERRIDE;
262 virtual bool IsSavable() OVERRIDE;
263 virtual void OnSavePage() OVERRIDE;
264 virtual bool SavePage(const base::FilePath& main_file,
265 const base::FilePath& dir_path,
266 SavePageType save_type) OVERRIDE;
267 virtual void SaveFrame(const GURL& url,
268 const Referrer& referrer) OVERRIDE;
269 virtual void GenerateMHTML(
270 const base::FilePath& file,
271 const base::Callback<void(int64)>& callback)
273 virtual const std::string& GetContentsMimeType() const OVERRIDE;
274 virtual bool WillNotifyDisconnection() const OVERRIDE;
275 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE;
276 virtual void ResetOverrideEncoding() OVERRIDE;
277 virtual RendererPreferences* GetMutableRendererPrefs() OVERRIDE;
278 virtual void Close() OVERRIDE;
279 virtual void SystemDragEnded() OVERRIDE;
280 virtual void UserGestureDone() OVERRIDE;
281 virtual void SetClosedByUserGesture(bool value) OVERRIDE;
282 virtual bool GetClosedByUserGesture() const OVERRIDE;
283 virtual int GetZoomPercent(bool* enable_increment,
284 bool* enable_decrement) const OVERRIDE;
285 virtual void ViewSource() OVERRIDE;
286 virtual void ViewFrameSource(const GURL& url,
287 const PageState& page_state) OVERRIDE;
288 virtual int GetMinimumZoomPercent() const OVERRIDE;
289 virtual int GetMaximumZoomPercent() const OVERRIDE;
290 virtual gfx::Size GetPreferredSize() const OVERRIDE;
291 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE;
292 virtual bool HasOpener() const OVERRIDE;
293 virtual void DidChooseColorInColorChooser(SkColor color) OVERRIDE;
294 virtual void DidEndColorChooser() OVERRIDE;
295 virtual int DownloadImage(const GURL& url,
297 uint32_t max_bitmap_size,
298 const ImageDownloadCallback& callback) OVERRIDE;
299 virtual bool IsSubframe() const OVERRIDE;
300 virtual void Find(int request_id,
301 const base::string16& search_text,
302 const blink::WebFindOptions& options) OVERRIDE;
303 virtual void StopFinding(StopFindAction action) OVERRIDE;
304 virtual void InsertCSS(const std::string& css) OVERRIDE;
305 #if defined(OS_ANDROID)
306 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents()
308 #elif defined(OS_MACOSX)
309 virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE;
310 virtual bool GetAllowOverlappingViews() OVERRIDE;
311 virtual void SetOverlayView(WebContents* overlay,
312 const gfx::Point& offset) OVERRIDE;
313 virtual void RemoveOverlayView() OVERRIDE;
316 // Implementation of PageNavigator.
317 virtual WebContents* OpenURL(const OpenURLParams& params) OVERRIDE;
319 // Implementation of IPC::Sender.
320 virtual bool Send(IPC::Message* message) OVERRIDE;
322 // RenderFrameHostDelegate ---------------------------------------------------
323 virtual bool OnMessageReceived(RenderFrameHost* render_frame_host,
324 const IPC::Message& message) OVERRIDE;
325 virtual const GURL& GetMainFrameLastCommittedURL() const OVERRIDE;
326 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE;
327 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE;
328 virtual void DidStartLoading(RenderFrameHost* render_frame_host,
329 bool to_different_document) OVERRIDE;
330 virtual void SwappedOut(RenderFrameHost* render_frame_host) OVERRIDE;
331 virtual void WorkerCrashed(RenderFrameHost* render_frame_host) OVERRIDE;
332 virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
333 const ContextMenuParams& params) OVERRIDE;
334 virtual void RunJavaScriptMessage(RenderFrameHost* render_frame_host,
335 const base::string16& message,
336 const base::string16& default_prompt,
337 const GURL& frame_url,
338 JavaScriptMessageType type,
339 IPC::Message* reply_msg) OVERRIDE;
340 virtual void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host,
341 const base::string16& message,
343 IPC::Message* reply_msg) OVERRIDE;
344 virtual void DidAccessInitialDocument() OVERRIDE;
345 virtual void DidDisownOpener(RenderFrameHost* render_frame_host) OVERRIDE;
346 virtual void DocumentOnLoadCompleted(
347 RenderFrameHost* render_frame_host) OVERRIDE;
348 virtual void UpdateTitle(RenderFrameHost* render_frame_host,
350 const base::string16& title,
351 base::i18n::TextDirection title_direction) OVERRIDE;
352 virtual void UpdateEncoding(RenderFrameHost* render_frame_host,
353 const std::string& encoding) OVERRIDE;
354 virtual WebContents* GetAsWebContents() OVERRIDE;
355 virtual bool IsNeverVisible() OVERRIDE;
357 // RenderViewHostDelegate ----------------------------------------------------
358 virtual RenderViewHostDelegateView* GetDelegateView() OVERRIDE;
359 virtual bool OnMessageReceived(RenderViewHost* render_view_host,
360 const IPC::Message& message) OVERRIDE;
361 // RenderFrameHostDelegate has the same method, so list it there because this
362 // interface is going away.
363 // virtual WebContents* GetAsWebContents() OVERRIDE;
364 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
365 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
366 virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE;
367 virtual void RenderViewTerminated(RenderViewHost* render_view_host,
368 base::TerminationStatus status,
369 int error_code) OVERRIDE;
370 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
371 virtual void UpdateState(RenderViewHost* render_view_host,
373 const PageState& page_state) OVERRIDE;
374 virtual void UpdateTargetURL(int32 page_id, const GURL& url) OVERRIDE;
375 virtual void Close(RenderViewHost* render_view_host) OVERRIDE;
376 virtual void RequestMove(const gfx::Rect& new_bounds) OVERRIDE;
377 virtual void DidCancelLoading() OVERRIDE;
378 virtual void DocumentAvailableInMainFrame(
379 RenderViewHost* render_view_host) OVERRIDE;
380 virtual void RouteCloseEvent(RenderViewHost* rvh) OVERRIDE;
381 virtual void RouteMessageEvent(
383 const ViewMsg_PostMessage_Params& params) OVERRIDE;
384 virtual bool AddMessageToConsole(int32 level,
385 const base::string16& message,
387 const base::string16& source_id) OVERRIDE;
388 virtual RendererPreferences GetRendererPrefs(
389 BrowserContext* browser_context) const OVERRIDE;
390 virtual WebPreferences GetWebkitPrefs() OVERRIDE;
391 virtual void OnUserGesture() OVERRIDE;
392 virtual void OnIgnoredUIEvent() OVERRIDE;
393 virtual void RendererUnresponsive(RenderViewHost* render_view_host,
394 bool is_during_beforeunload,
395 bool is_during_unload) OVERRIDE;
396 virtual void RendererResponsive(RenderViewHost* render_view_host) OVERRIDE;
397 virtual void LoadStateChanged(const GURL& url,
398 const net::LoadStateWithParam& load_state,
399 uint64 upload_position,
400 uint64 upload_size) OVERRIDE;
401 virtual void Activate() OVERRIDE;
402 virtual void Deactivate() OVERRIDE;
403 virtual void LostCapture() OVERRIDE;
404 virtual void HandleMouseDown() OVERRIDE;
405 virtual void HandleMouseUp() OVERRIDE;
406 virtual void HandlePointerActivate() OVERRIDE;
407 virtual void HandleGestureBegin() OVERRIDE;
408 virtual void HandleGestureEnd() OVERRIDE;
409 virtual void RunFileChooser(
410 RenderViewHost* render_view_host,
411 const FileChooserParams& params) OVERRIDE;
412 virtual void ToggleFullscreenMode(bool enter_fullscreen) OVERRIDE;
413 virtual bool IsFullscreenForCurrentTab() const OVERRIDE;
414 virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
415 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
416 virtual void RequestToLockMouse(bool user_gesture,
417 bool last_unlocked_by_target) OVERRIDE;
418 virtual void LostMouseLock() OVERRIDE;
419 virtual void CreateNewWindow(
420 int render_process_id,
422 int main_frame_route_id,
423 const ViewHostMsg_CreateWindow_Params& params,
424 SessionStorageNamespace* session_storage_namespace) OVERRIDE;
425 virtual void CreateNewWidget(int render_process_id,
427 blink::WebPopupType popup_type) OVERRIDE;
428 virtual void CreateNewFullscreenWidget(int render_process_id,
429 int route_id) OVERRIDE;
430 virtual void ShowCreatedWindow(int route_id,
431 WindowOpenDisposition disposition,
432 const gfx::Rect& initial_pos,
433 bool user_gesture) OVERRIDE;
434 virtual void ShowCreatedWidget(int route_id,
435 const gfx::Rect& initial_pos) OVERRIDE;
436 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
437 virtual void RequestMediaAccessPermission(
438 const MediaStreamRequest& request,
439 const MediaResponseCallback& callback) OVERRIDE;
440 virtual SessionStorageNamespace* GetSessionStorageNamespace(
441 SiteInstance* instance) OVERRIDE;
442 virtual SessionStorageNamespaceMap GetSessionStorageNamespaceMap() OVERRIDE;
443 virtual FrameTree* GetFrameTree() OVERRIDE;
444 virtual void AccessibilityEventReceived(
445 const std::vector<AXEventNotificationDetails>& details) OVERRIDE;
447 // NavigatorDelegate ---------------------------------------------------------
449 virtual void DidStartProvisionalLoad(
450 RenderFrameHostImpl* render_frame_host,
451 int parent_routing_id,
452 const GURL& validated_url,
454 bool is_iframe_srcdoc) OVERRIDE;
455 virtual void DidFailProvisionalLoadWithError(
456 RenderFrameHostImpl* render_frame_host,
457 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
459 virtual void DidFailLoadWithError(
460 RenderFrameHostImpl* render_frame_host,
463 const base::string16& error_description) OVERRIDE;
464 virtual void DidRedirectProvisionalLoad(
465 RenderFrameHostImpl* render_frame_host,
466 const GURL& validated_target_url) OVERRIDE;
467 virtual void DidCommitProvisionalLoad(
468 RenderFrameHostImpl* render_frame_host,
469 const base::string16& frame_unique_name,
472 PageTransition transition_type) OVERRIDE;
473 virtual void DidNavigateMainFramePreCommit(
474 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) OVERRIDE;
475 virtual void DidNavigateMainFramePostCommit(
476 const LoadCommittedDetails& details,
477 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) OVERRIDE;
478 virtual void DidNavigateAnyFramePostCommit(
479 RenderFrameHostImpl* render_frame_host,
480 const LoadCommittedDetails& details,
481 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) OVERRIDE;
482 virtual void SetMainFrameMimeType(const std::string& mime_type) OVERRIDE;
483 virtual bool CanOverscrollContent() const OVERRIDE;
484 virtual void NotifyChangedNavigationState(
485 InvalidateTypes changed_flags) OVERRIDE;
486 virtual void AboutToNavigateRenderFrame(
487 RenderFrameHostImpl* render_frame_host) OVERRIDE;
488 virtual void DidStartNavigationToPendingEntry(
489 RenderFrameHostImpl* render_frame_host,
491 NavigationController::ReloadType reload_type) OVERRIDE;
492 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
493 const OpenURLParams& params) OVERRIDE;
494 virtual bool ShouldPreserveAbortedURLs() OVERRIDE;
496 // RenderWidgetHostDelegate --------------------------------------------------
498 virtual void RenderWidgetDeleted(
499 RenderWidgetHostImpl* render_widget_host) OVERRIDE;
500 virtual bool PreHandleKeyboardEvent(
501 const NativeWebKeyboardEvent& event,
502 bool* is_keyboard_shortcut) OVERRIDE;
503 virtual void HandleKeyboardEvent(
504 const NativeWebKeyboardEvent& event) OVERRIDE;
505 virtual bool HandleWheelEvent(
506 const blink::WebMouseWheelEvent& event) OVERRIDE;
507 virtual bool PreHandleGestureEvent(
508 const blink::WebGestureEvent& event) OVERRIDE;
509 virtual bool HandleGestureEvent(
510 const blink::WebGestureEvent& event) OVERRIDE;
511 virtual void DidSendScreenRects(RenderWidgetHostImpl* rwh) OVERRIDE;
512 virtual void OnTouchEmulationEnabled(bool enabled) OVERRIDE;
514 virtual gfx::NativeViewAccessible GetParentNativeViewAccessible() OVERRIDE;
517 // RenderFrameHostManager::Delegate ------------------------------------------
519 virtual bool CreateRenderViewForRenderManager(
520 RenderViewHost* render_view_host,
522 int proxy_routing_id,
523 bool for_main_frame) OVERRIDE;
524 virtual void BeforeUnloadFiredFromRenderManager(
525 bool proceed, const base::TimeTicks& proceed_time,
526 bool* proceed_to_fire_unload) OVERRIDE;
527 virtual void RenderProcessGoneFromRenderManager(
528 RenderViewHost* render_view_host) OVERRIDE;
529 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
530 virtual void CancelModalDialogsForRenderManager() OVERRIDE;
531 virtual void NotifySwappedFromRenderManager(
532 RenderViewHost* old_host, RenderViewHost* new_host) OVERRIDE;
533 virtual int CreateOpenerRenderViewsForRenderManager(
534 SiteInstance* instance) OVERRIDE;
535 virtual NavigationControllerImpl&
536 GetControllerForRenderManager() OVERRIDE;
537 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE;
538 virtual NavigationEntry*
539 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE;
540 virtual bool FocusLocationBarByDefault() OVERRIDE;
541 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
542 virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) OVERRIDE;
543 virtual bool IsHidden() OVERRIDE;
545 // NotificationObserver ------------------------------------------------------
547 virtual void Observe(int type,
548 const NotificationSource& source,
549 const NotificationDetails& details) OVERRIDE;
551 // NavigationControllerDelegate ----------------------------------------------
553 virtual WebContents* GetWebContents() OVERRIDE;
554 virtual void NotifyNavigationEntryCommitted(
555 const LoadCommittedDetails& load_details) OVERRIDE;
557 // Invoked before a form repost warning is shown.
558 virtual void NotifyBeforeFormRepostWarningShow() OVERRIDE;
560 // Activate this WebContents and show a form repost warning.
561 virtual void ActivateAndShowRepostFormWarningDialog() OVERRIDE;
563 // Whether the initial empty page of this view has been accessed by another
564 // page, making it unsafe to show the pending URL. Always false after the
566 virtual bool HasAccessedInitialDocument() OVERRIDE;
568 // Updates the max page ID for the current SiteInstance in this
569 // WebContentsImpl to be at least |page_id|.
570 virtual void UpdateMaxPageID(int32 page_id) OVERRIDE;
572 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
573 // to be at least |page_id|.
574 virtual void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
575 int32 page_id) OVERRIDE;
577 // Copy the current map of SiteInstance ID to max page ID from another tab.
578 // This is necessary when this tab adopts the NavigationEntries from
580 virtual void CopyMaxPageIDsFrom(WebContents* web_contents) OVERRIDE;
582 // Called by the NavigationController to cause the WebContentsImpl to navigate
583 // to the current pending entry. The NavigationController should be called
584 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
585 // The callbacks can be inside of this function, or at some future time.
587 // The entry has a PageID of -1 if newly created (corresponding to navigation
590 // If this method returns false, then the navigation is discarded (equivalent
591 // to calling DiscardPendingEntry on the NavigationController).
592 virtual bool NavigateToPendingEntry(
593 NavigationController::ReloadType reload_type) OVERRIDE;
595 // Sets the history for this WebContentsImpl to |history_length| entries, and
596 // moves the current page_id to the last entry in the list if it's valid.
597 // This is mainly used when a prerendered page is swapped into the current
598 // tab. The method is virtual for testing.
599 virtual void SetHistoryLengthAndPrune(
600 const SiteInstance* site_instance,
601 int merge_history_length,
602 int32 minimum_page_id) OVERRIDE;
604 // Called by InterstitialPageImpl when it creates a RenderFrameHost.
605 virtual void RenderFrameForInterstitialPageCreated(
606 RenderFrameHost* render_frame_host) OVERRIDE;
608 // Sets the passed interstitial as the currently showing interstitial.
609 // No interstitial page should already be attached.
610 virtual void AttachInterstitialPage(
611 InterstitialPageImpl* interstitial_page) OVERRIDE;
613 // Unsets the currently showing interstitial.
614 virtual void DetachInterstitialPage() OVERRIDE;
616 // Changes the IsLoading state and notifies the delegate as needed.
617 // |details| is used to provide details on the load that just finished
618 // (but can be null if not applicable).
619 virtual void SetIsLoading(RenderViewHost* render_view_host,
621 bool to_different_document,
622 LoadNotificationDetails* details) OVERRIDE;
624 typedef base::Callback<void(WebContents*)> CreatedCallback;
626 // Requests the renderer to select the region between two points in the
627 // currently focused frame.
628 void SelectRange(const gfx::Point& start, const gfx::Point& end);
631 friend class TestNavigationObserver;
632 friend class WebContentsAddedObserver;
633 friend class WebContentsObserver;
634 friend class WebContents; // To implement factory methods.
636 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
637 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
638 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending);
639 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
640 CrossSiteCantPreemptAfterUnload);
641 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContents);
642 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FrameTreeShape);
643 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, GetLastActiveTime);
644 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
645 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
646 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest, PageDoesBackAndReload);
647 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrossSiteIframe);
649 // So InterstitialPageImpl can access SetIsLoading.
650 friend class InterstitialPageImpl;
652 // TODO(brettw) TestWebContents shouldn't exist!
653 friend class TestWebContents;
655 class DestructionObserver;
657 // See WebContents::Create for a description of these parameters.
658 WebContentsImpl(BrowserContext* browser_context,
659 WebContentsImpl* opener);
661 // Add and remove observers for page navigation notifications. The order in
662 // which notifications are sent to observers is undefined. Clients must be
663 // sure to remove the observer before they go away.
664 void AddObserver(WebContentsObserver* observer);
665 void RemoveObserver(WebContentsObserver* observer);
667 // Clears this tab's opener if it has been closed.
668 void OnWebContentsDestroyed(WebContentsImpl* web_contents);
670 // Creates and adds to the map a destruction observer watching |web_contents|.
671 // No-op if such an observer already exists.
672 void AddDestructionObserver(WebContentsImpl* web_contents);
674 // Deletes and removes from the map a destruction observer
675 // watching |web_contents|. No-op if there is no such observer.
676 void RemoveDestructionObserver(WebContentsImpl* web_contents);
678 // Traverses all the RenderFrameHosts in the FrameTree and creates a set
679 // all the unique RenderWidgetHostViews.
680 std::set<RenderWidgetHostView*> GetRenderWidgetHostViewsInTree();
682 // Callback function when showing JavaScript dialogs. Takes in a routing ID
683 // pair to identify the RenderFrameHost that opened the dialog, because it's
684 // possible for the RenderFrameHost to be deleted by the time this is called.
685 void OnDialogClosed(int render_process_id,
687 IPC::Message* reply_msg,
688 bool dialog_was_suppressed,
690 const base::string16& user_input);
692 // Callback function when requesting permission to access the PPAPI broker.
693 // |result| is true if permission was granted.
694 void OnPpapiBrokerPermissionResult(int routing_id, bool result);
696 bool OnMessageReceived(RenderViewHost* render_view_host,
697 RenderFrameHost* render_frame_host,
698 const IPC::Message& message);
700 // IPC message handlers.
701 void OnThemeColorChanged(SkColor theme_color);
702 void OnDidLoadResourceFromMemoryCache(const GURL& url,
703 const std::string& security_info,
704 const std::string& http_request,
705 const std::string& mime_type,
706 ResourceType::Type resource_type);
707 void OnDidDisplayInsecureContent();
708 void OnDidRunInsecureContent(const std::string& security_origin,
709 const GURL& target_url);
710 void OnDocumentLoadedInFrame();
711 void OnDidFinishLoad(const GURL& url);
712 void OnDidStartLoading(bool to_different_document);
713 void OnDidStopLoading();
714 void OnDidChangeLoadProgress(double load_progress);
715 void OnGoToEntryAtOffset(int offset);
716 void OnUpdateZoomLimits(int minimum_percent,
717 int maximum_percent);
718 void OnEnumerateDirectory(int request_id, const base::FilePath& path);
720 void OnRegisterProtocolHandler(const std::string& protocol,
722 const base::string16& title,
724 void OnFindReply(int request_id,
725 int number_of_matches,
726 const gfx::Rect& selection_rect,
727 int active_match_ordinal,
729 #if defined(OS_ANDROID)
730 void OnFindMatchRectsReply(int version,
731 const std::vector<gfx::RectF>& rects,
732 const gfx::RectF& active_rect);
734 void OnOpenDateTimeDialog(
735 const ViewHostMsg_DateTimeDialogValue_Params& value);
737 void OnPepperPluginHung(int plugin_child_id,
738 const base::FilePath& path,
740 void OnPluginCrashed(const base::FilePath& plugin_path,
741 base::ProcessId plugin_pid);
742 void OnDomOperationResponse(const std::string& json_string,
744 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
745 void OnOpenColorChooser(int color_chooser_id,
747 const std::vector<ColorSuggestion>& suggestions);
748 void OnEndColorChooser(int color_chooser_id);
749 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
750 void OnWebUISend(const GURL& source_url,
751 const std::string& name,
752 const base::ListValue& args);
753 void OnRequestPpapiBrokerPermission(int routing_id,
755 const base::FilePath& plugin_path);
756 void OnBrowserPluginMessage(const IPC::Message& message);
757 void OnDidDownloadImage(int id,
758 int http_status_code,
759 const GURL& image_url,
760 const std::vector<SkBitmap>& bitmaps,
761 const std::vector<gfx::Size>& original_bitmap_sizes);
762 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates);
763 void OnFirstVisuallyNonEmptyPaint();
764 void OnMediaPlayingNotification(int64 player_cookie,
767 void OnMediaPausedNotification(int64 player_cookie);
768 void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view,
769 const base::string16& main_text,
770 const base::string16& sub_text);
771 void OnHideValidationMessage();
772 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view);
774 // Called by derived classes to indicate that we're no longer waiting for a
775 // response. This won't actually update the throbber, but it will get picked
776 // up at the next animation step if the throbber is going.
777 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
779 // Navigation helpers --------------------------------------------------------
781 // These functions are helpers for Navigate() and DidNavigate().
783 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
784 // committed to the navigation controller. Note that the navigation entry is
785 // not provided since it may be invalid/changed after being committed. The
786 // current navigation entry is in the NavigationController at this point.
788 // If our controller was restored, update the max page ID associated with the
789 // given RenderViewHost to be larger than the number of restored entries.
790 // This is called in CreateRenderView before any navigations in the RenderView
791 // have begun, to prevent any races in updating RenderView::next_page_id.
792 void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh);
794 // Saves the given title to the navigation entry and does associated work. It
795 // will update history and the view for the new title, and also synthesize
796 // titles for file URLs that have none (so we require that the URL of the
797 // entry already be set).
799 // This is used as the backend for state updates, which include a new title,
800 // or the dedicated set title message. It returns true if the new title is
801 // different and was therefore updated.
802 bool UpdateTitleForEntry(NavigationEntryImpl* entry,
803 const base::string16& title);
805 // Recursively creates swapped out RenderViews for this tab's opener chain
806 // (including this tab) in the given SiteInstance, allowing other tabs to send
807 // cross-process JavaScript calls to their opener(s). Returns the route ID of
808 // this tab's RenderView for |instance|.
809 int CreateOpenerRenderViews(SiteInstance* instance);
811 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
812 void CreateNewWidget(int render_process_id,
815 blink::WebPopupType popup_type);
817 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
818 void ShowCreatedWidget(int route_id,
820 const gfx::Rect& initial_pos);
822 // Finds the new RenderWidgetHost and returns it. Note that this can only be
823 // called once as this call also removes it from the internal map.
824 RenderWidgetHostView* GetCreatedWidget(int route_id);
826 // Finds the new WebContentsImpl by route_id, initializes it for
827 // renderer-initiated creation, and returns it. Note that this can only be
828 // called once as this call also removes it from the internal map.
829 WebContentsImpl* GetCreatedWindow(int route_id);
831 // Tracking loading progress -------------------------------------------------
833 // Resets the tracking state of the current load.
834 void ResetLoadProgressState();
836 // Calculates the progress of the current load and notifies the delegate.
837 void SendLoadProgressChanged();
839 // Called once when the last frame on the page has stopped loading.
840 void DidStopLoading(RenderFrameHost* render_frame_host);
842 // Misc non-view stuff -------------------------------------------------------
844 // Helper functions for sending notifications.
845 void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host);
846 void NotifyDisconnected();
848 void SetEncoding(const std::string& encoding);
850 // TODO(creis): This should take in a FrameTreeNode to know which node's
851 // render manager to return. For now, we just return the root's.
852 RenderFrameHostManager* GetRenderManager() const;
854 RenderViewHostImpl* GetRenderViewHostImpl();
856 // Removes browser plugin embedder if there is one.
857 void RemoveBrowserPluginEmbedder();
859 // Clear |render_frame_host|'s PowerSaveBlockers.
860 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host);
862 // Clear all PowerSaveBlockers, leave power_save_blocker_ empty.
863 void ClearAllPowerSaveBlockers();
865 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
866 gfx::Size GetSizeForNewRenderView();
868 void OnFrameRemoved(RenderViewHostImpl* render_view_host,
869 int frame_routing_id);
871 // Helper method that's called whenever |preferred_size_| or
872 // |preferred_size_for_capture_| changes, to propagate the new value to the
874 void OnPreferredSizeChanged(const gfx::Size& old_size);
876 // Adds/removes a callback called on creation of each new WebContents.
877 // Deprecated, about to remove.
878 static void AddCreatedCallback(const CreatedCallback& callback);
879 static void RemoveCreatedCallback(const CreatedCallback& callback);
881 // Data for core operation ---------------------------------------------------
883 // Delegate for notifying our owner about stuff. Not owned by us.
884 WebContentsDelegate* delegate_;
886 // Handles the back/forward list and loading.
887 NavigationControllerImpl controller_;
889 // The corresponding view.
890 scoped_ptr<WebContentsView> view_;
892 // The view of the RVHD. Usually this is our WebContentsView implementation,
893 // but if an embedder uses a different WebContentsView, they'll need to
895 RenderViewHostDelegateView* render_view_host_delegate_view_;
897 // Tracks created WebContentsImpl objects that have not been shown yet. They
898 // are identified by the route ID passed to CreateNewWindow.
899 typedef std::map<int, WebContentsImpl*> PendingContents;
900 PendingContents pending_contents_;
902 // These maps hold on to the widgets that we created on behalf of the renderer
903 // that haven't shown yet.
904 typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews;
905 PendingWidgetViews pending_widget_views_;
907 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers;
908 DestructionObservers destruction_observers_;
910 // A list of observers notified when page state changes. Weak references.
911 // This MUST be listed above frame_tree_ since at destruction time the
912 // latter might cause RenderViewHost's destructor to call us and we might use
913 // the observer list then.
914 ObserverList<WebContentsObserver> observers_;
916 // The tab that opened this tab, if any. Will be set to null if the opener
918 WebContentsImpl* opener_;
920 // True if this tab was opened by another tab. This is not unset if the opener
922 bool created_with_opener_;
925 gfx::NativeViewAccessible accessible_parent_;
928 // Helper classes ------------------------------------------------------------
930 // Maps the RenderFrameHost to its media_player_cookie and PowerSaveBlocker
931 // pairs. Key is the RenderFrameHost, value is the map which maps
932 // player_cookie on to PowerSaveBlocker.
933 typedef std::map<RenderFrameHost*, std::map<int64, PowerSaveBlocker*> >
935 PowerSaveBlockerMap power_save_blockers_;
937 // Manages the frame tree of the page and process swaps in each node.
938 FrameTree frame_tree_;
940 // SavePackage, lazily created.
941 scoped_refptr<SavePackage> save_package_;
943 // Data for loading state ----------------------------------------------------
945 // Indicates whether we're currently loading a resource.
948 // Indicates whether the current load is to a different document. Only valid
949 // if is_loading_ is true.
950 bool is_load_to_different_document_;
952 // Indicates if the tab is considered crashed.
953 base::TerminationStatus crashed_status_;
954 int crashed_error_code_;
956 // Whether this WebContents is waiting for a first-response for the
957 // main resource of the page. This controls whether the throbber state is
958 // "waiting" or "loading."
959 bool waiting_for_response_;
961 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
962 // to a given tab and SiteInstance, and must be valid for the lifetime of the
964 std::map<int32, int32> max_page_ids_;
966 // The current load state and the URL associated with it.
967 net::LoadStateWithParam load_state_;
968 base::string16 load_state_host_;
970 // LoadingProgressMap maps FrameTreeNode IDs to a double representing that
971 // frame's completion (from 0 to 1).
972 typedef base::hash_map<int64, double> LoadingProgressMap;
973 LoadingProgressMap loading_progresses_;
974 double loading_total_progress_;
976 base::TimeTicks loading_last_progress_update_;
978 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_;
980 // Counter to track how many frames have sent start notifications but not
981 // stop notifications.
982 int loading_frames_in_progress_;
984 // Upload progress, for displaying in the status bar.
985 // Set to zero when there is no significant upload happening.
987 uint64 upload_position_;
989 // Data for current page -----------------------------------------------------
991 // When a title cannot be taken from any entry, this title will be used.
992 base::string16 page_title_when_no_navigation_entry_;
994 // When a navigation occurs, we record its contents MIME type. It can be
995 // used to check whether we can do something for some special contents.
996 std::string contents_mime_type_;
998 // The last reported character encoding, not canonicalized.
999 std::string last_reported_encoding_;
1001 // The canonicalized character encoding.
1002 std::string canonical_encoding_;
1004 // True if this is a secure page which displayed insecure content.
1005 bool displayed_insecure_content_;
1007 // Whether the initial empty page has been accessed by another page, making it
1008 // unsafe to show the pending URL. Usually false unless another window tries
1009 // to modify the blank page. Always false after the first commit.
1010 bool has_accessed_initial_document_;
1012 // Data for misc internal state ----------------------------------------------
1014 // When > 0, the WebContents is currently being captured (e.g., for
1015 // screenshots or mirroring); and the underlying RenderWidgetHost should not
1016 // be told it is hidden.
1017 int capturer_count_;
1019 // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
1020 bool should_normally_be_visible_;
1022 // See getter above.
1023 bool is_being_destroyed_;
1025 // Indicates whether we should notify about disconnection of this
1026 // WebContentsImpl. This is used to ensure disconnection notifications only
1027 // happen if a connection notification has happened and that they happen only
1029 bool notify_disconnection_;
1031 // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
1032 // delegate of this WebContentsImpl is nulled before its destructor is called.
1033 JavaScriptDialogManager* dialog_manager_;
1035 // Set to true when there is an active "before unload" dialog. When true,
1036 // we've forced the throbber to start in Navigate, and we need to remember to
1037 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
1038 bool is_showing_before_unload_dialog_;
1040 // Settings that get passed to the renderer process.
1041 RendererPreferences renderer_preferences_;
1043 // The time that this WebContents was last made active. The initial value is
1044 // the WebContents creation time.
1045 base::TimeTicks last_active_time_;
1047 // See description above setter.
1048 bool closed_by_user_gesture_;
1050 // Minimum/maximum zoom percent.
1051 int minimum_zoom_percent_;
1052 int maximum_zoom_percent_;
1054 // The raw accumulated zoom value and the actual zoom increments made for an
1055 // an in-progress pinch gesture.
1056 float totalPinchGestureAmount_;
1057 int currentPinchZoomStepDelta_;
1059 // The intrinsic size of the page.
1060 gfx::Size preferred_size_;
1062 // The preferred size for content screen capture. When |capturer_count_| > 0,
1063 // this overrides |preferred_size_|.
1064 gfx::Size preferred_size_for_capture_;
1066 #if defined(OS_ANDROID)
1067 // Date time chooser opened by this tab.
1068 // Only used in Android since all other platforms use a multi field UI.
1069 scoped_ptr<DateTimeChooserAndroid> date_time_chooser_;
1072 // Holds information about a current color chooser dialog, if one is visible.
1073 struct ColorChooserInfo {
1074 ColorChooserInfo(int render_process_id,
1075 int render_frame_id,
1076 ColorChooser* chooser,
1078 ~ColorChooserInfo();
1080 int render_process_id;
1081 int render_frame_id;
1083 // Color chooser that was opened by this tab.
1084 scoped_ptr<ColorChooser> chooser;
1086 // A unique identifier for the current color chooser. Identifiers are
1087 // unique across a renderer process. This avoids race conditions in
1088 // synchronizing the browser and renderer processes. For example, if a
1089 // renderer closes one chooser and opens another, and simultaneously the
1090 // user picks a color in the first chooser, the IDs can be used to drop the
1091 // "chose a color" message rather than erroneously tell the renderer that
1092 // the user picked a color in the second chooser.
1096 scoped_ptr<ColorChooserInfo> color_chooser_info_;
1098 // Manages the embedder state for browser plugins, if this WebContents is an
1099 // embedder; NULL otherwise.
1100 scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_;
1101 // Manages the guest state for browser plugin, if this WebContents is a guest;
1103 scoped_ptr<BrowserPluginGuest> browser_plugin_guest_;
1105 // This must be at the end, or else we might get notifications and use other
1106 // member variables that are gone.
1107 NotificationRegistrar registrar_;
1109 // Used during IPC message dispatching from the RenderView/RenderFrame so that
1110 // the handlers can get a pointer to the RVH through which the message was
1112 RenderViewHost* render_view_message_source_;
1113 RenderFrameHost* render_frame_message_source_;
1115 // All live RenderWidgetHostImpls that are created by this object and may
1117 std::set<RenderWidgetHostImpl*> created_widgets_;
1119 // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1120 int fullscreen_widget_routing_id_;
1122 // Maps the ids of pending image downloads to their callbacks
1123 typedef std::map<int, ImageDownloadCallback> ImageDownloadMap;
1124 ImageDownloadMap image_download_map_;
1126 // Whether this WebContents is responsible for displaying a subframe in a
1127 // different process from its parent page.
1130 // Whether touch emulation is enabled in RenderWidgetHost.
1131 bool touch_emulation_enabled_;
1133 // Whether the last JavaScript dialog shown was suppressed. Used for testing.
1134 bool last_dialog_suppressed_;
1136 scoped_ptr<GeolocationDispatcherHost> geolocation_dispatcher_host_;
1138 scoped_ptr<MidiDispatcherHost> midi_dispatcher_host_;
1140 scoped_ptr<ScreenOrientationDispatcherHost>
1141 screen_orientation_dispatcher_host_;
1143 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
1146 } // namespace content
1148 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_