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/containers/scoped_ptr_hash_map.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h"
17 #include "base/process/process.h"
18 #include "base/values.h"
19 #include "content/browser/frame_host/frame_tree.h"
20 #include "content/browser/frame_host/navigation_controller_delegate.h"
21 #include "content/browser/frame_host/navigation_controller_impl.h"
22 #include "content/browser/frame_host/navigator_delegate.h"
23 #include "content/browser/frame_host/render_frame_host_delegate.h"
24 #include "content/browser/frame_host/render_frame_host_manager.h"
25 #include "content/browser/media/audio_stream_monitor.h"
26 #include "content/browser/renderer_host/render_view_host_delegate.h"
27 #include "content/browser/renderer_host/render_widget_host_delegate.h"
28 #include "content/common/accessibility_mode_enums.h"
29 #include "content/common/content_export.h"
30 #include "content/public/browser/color_chooser.h"
31 #include "content/public/browser/notification_observer.h"
32 #include "content/public/browser/notification_registrar.h"
33 #include "content/public/browser/web_contents.h"
34 #include "content/public/common/page_transition_types.h"
35 #include "content/public/common/renderer_preferences.h"
36 #include "content/public/common/resource_type.h"
37 #include "content/public/common/three_d_api_types.h"
38 #include "net/base/load_states.h"
39 #include "net/http/http_response_headers.h"
40 #include "third_party/WebKit/public/web/WebDragOperation.h"
41 #include "ui/gfx/rect_f.h"
42 #include "ui/gfx/size.h"
44 struct BrowserPluginHostMsg_ResizeGuest_Params
;
45 struct ViewHostMsg_DateTimeDialogValue_Params
;
46 struct ViewMsg_PostMessage_Params
;
49 class BrowserPluginEmbedder
;
50 class BrowserPluginGuest
;
51 class BrowserPluginGuestManager
;
52 class DateTimeChooserAndroid
;
54 class GeolocationDispatcherHost
;
55 class InterstitialPageImpl
;
56 class JavaScriptDialogManager
;
57 class ManifestManagerHost
;
58 class MidiDispatcherHost
;
59 class PowerSaveBlocker
;
61 class RenderViewHostDelegateView
;
62 class RenderViewHostImpl
;
63 class RenderWidgetHostImpl
;
65 class ScreenOrientationDispatcherHost
;
67 class TestWebContents
;
68 class WebContentsDelegate
;
69 class WebContentsImpl
;
70 class WebContentsObserver
;
71 class WebContentsView
;
72 class WebContentsViewDelegate
;
73 struct AXEventNotificationDetails
;
74 struct ColorSuggestion
;
76 struct LoadNotificationDetails
;
77 struct ResourceRedirectDetails
;
78 struct ResourceRequestDetails
;
80 #if defined(OS_ANDROID)
81 class WebContentsAndroid
;
84 // Factory function for the implementations that content knows about. Takes
85 // ownership of |delegate|.
86 WebContentsView
* CreateWebContentsView(
87 WebContentsImpl
* web_contents
,
88 WebContentsViewDelegate
* delegate
,
89 RenderViewHostDelegateView
** render_view_host_delegate_view
);
91 class CONTENT_EXPORT WebContentsImpl
92 : public NON_EXPORTED_BASE(WebContents
),
93 public NON_EXPORTED_BASE(RenderFrameHostDelegate
),
94 public RenderViewHostDelegate
,
95 public RenderWidgetHostDelegate
,
96 public RenderFrameHostManager::Delegate
,
97 public NotificationObserver
,
98 public NON_EXPORTED_BASE(NavigationControllerDelegate
),
99 public NON_EXPORTED_BASE(NavigatorDelegate
) {
101 virtual ~WebContentsImpl();
103 static WebContentsImpl
* CreateWithOpener(
104 const WebContents::CreateParams
& params
,
105 WebContentsImpl
* opener
);
107 static std::vector
<WebContentsImpl
*> GetAllWebContents();
109 // Returns the opener WebContentsImpl, if any. This can be set to null if the
110 // opener is closed or the page clears its window.opener.
111 WebContentsImpl
* opener() const { return opener_
; }
113 // Creates a swapped out RenderView. This is used by the browser plugin to
114 // create a swapped out RenderView in the embedder render process for the
115 // guest, to expose the guest's window object to the embedder.
116 // This returns the routing ID of the newly created swapped out RenderView.
117 int CreateSwappedOutRenderView(SiteInstance
* instance
);
119 // Complex initialization here. Specifically needed to avoid having
120 // members call back into our virtual functions in the constructor.
121 virtual void Init(const WebContents::CreateParams
& params
);
123 // Returns the SavePackage which manages the page saving job. May be NULL.
124 SavePackage
* save_package() const { return save_package_
.get(); }
126 #if defined(OS_ANDROID)
127 // In Android WebView, the RenderView needs created even there is no
128 // navigation entry, this allows Android WebViews to use
129 // javascript: URLs that load into the DOMWindow before the first page
130 // load. This is not safe to do in any context that a web page could get a
131 // reference to the DOMWindow before the first page load.
132 bool CreateRenderViewForInitialEmptyDocument();
135 // Expose the render manager for testing.
136 // TODO(creis): Remove this now that we can get to it via FrameTreeNode.
137 RenderFrameHostManager
* GetRenderManagerForTesting();
139 // Returns guest browser plugin object, or NULL if this WebContents is not a
141 BrowserPluginGuest
* GetBrowserPluginGuest() const;
143 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
144 // has a BrowserPluginGuest then that implies that it is being hosted by
145 // a BrowserPlugin object in an embedder renderer process.
146 void SetBrowserPluginGuest(BrowserPluginGuest
* guest
);
148 // Returns embedder browser plugin object, or NULL if this WebContents is not
150 BrowserPluginEmbedder
* GetBrowserPluginEmbedder() const;
152 // Gets the current fullscreen render widget's routing ID. Returns
153 // MSG_ROUTING_NONE when there is no fullscreen render widget.
154 int GetFullscreenWidgetRoutingID() const;
156 // Invoked when visible SSL state (as defined by SSLStatus) changes.
157 void DidChangeVisibleSSLState();
159 // Informs the render view host and the BrowserPluginEmbedder, if present, of
160 // a Drag Source End.
161 void DragSourceEndedAt(int client_x
, int client_y
, int screen_x
,
162 int screen_y
, blink::WebDragOperation operation
);
164 // A response has been received for a resource request.
165 void DidGetResourceResponseStart(
166 const ResourceRequestDetails
& details
);
168 // A redirect was received while requesting a resource.
169 void DidGetRedirectForResourceRequest(
170 RenderViewHost
* render_view_host
,
171 const ResourceRedirectDetails
& details
);
173 WebContentsView
* GetView() const;
175 GeolocationDispatcherHost
* geolocation_dispatcher_host() {
176 return geolocation_dispatcher_host_
.get();
179 ScreenOrientationDispatcherHost
* screen_orientation_dispatcher_host() {
180 return screen_orientation_dispatcher_host_
.get();
183 bool should_normally_be_visible() { return should_normally_be_visible_
; }
185 // Broadcasts the mode change to all frames.
186 void SetAccessibilityMode(AccessibilityMode mode
);
188 // Adds the given accessibility mode to the current accessibility mode
190 void AddAccessibilityMode(AccessibilityMode mode
);
192 // Removes the given accessibility mode from the current accessibility
193 // mode bitmap, managing the bits that are shared with other modes such
194 // that a bit will only be turned off when all modes that depend on it
195 // have been removed.
196 void RemoveAccessibilityMode(AccessibilityMode mode
);
198 // WebContents ------------------------------------------------------
199 virtual WebContentsDelegate
* GetDelegate() OVERRIDE
;
200 virtual void SetDelegate(WebContentsDelegate
* delegate
) OVERRIDE
;
201 virtual NavigationControllerImpl
& GetController() OVERRIDE
;
202 virtual const NavigationControllerImpl
& GetController() const OVERRIDE
;
203 virtual BrowserContext
* GetBrowserContext() const OVERRIDE
;
204 virtual const GURL
& GetURL() const OVERRIDE
;
205 virtual const GURL
& GetVisibleURL() const OVERRIDE
;
206 virtual const GURL
& GetLastCommittedURL() const OVERRIDE
;
207 virtual RenderProcessHost
* GetRenderProcessHost() const OVERRIDE
;
208 virtual RenderFrameHost
* GetMainFrame() OVERRIDE
;
209 virtual RenderFrameHost
* GetFocusedFrame() OVERRIDE
;
210 virtual void ForEachFrame(
211 const base::Callback
<void(RenderFrameHost
*)>& on_frame
) OVERRIDE
;
212 virtual void SendToAllFrames(IPC::Message
* message
) OVERRIDE
;
213 virtual RenderViewHost
* GetRenderViewHost() const OVERRIDE
;
214 virtual int GetRoutingID() const OVERRIDE
;
215 virtual RenderWidgetHostView
* GetRenderWidgetHostView() const OVERRIDE
;
216 virtual RenderWidgetHostView
* GetFullscreenRenderWidgetHostView() const
218 virtual WebUI
* CreateWebUI(const GURL
& url
) OVERRIDE
;
219 virtual WebUI
* GetWebUI() const OVERRIDE
;
220 virtual WebUI
* GetCommittedWebUI() const OVERRIDE
;
221 virtual void SetUserAgentOverride(const std::string
& override
) OVERRIDE
;
222 virtual const std::string
& GetUserAgentOverride() const OVERRIDE
;
223 virtual void EnableTreeOnlyAccessibilityMode() OVERRIDE
;
224 virtual bool IsTreeOnlyAccessibilityModeForTesting() const OVERRIDE
;
225 virtual bool IsFullAccessibilityModeForTesting() const OVERRIDE
;
227 virtual void SetParentNativeViewAccessible(
228 gfx::NativeViewAccessible accessible_parent
) OVERRIDE
;
230 virtual const base::string16
& GetTitle() const OVERRIDE
;
231 virtual int32
GetMaxPageID() OVERRIDE
;
232 virtual int32
GetMaxPageIDForSiteInstance(
233 SiteInstance
* site_instance
) OVERRIDE
;
234 virtual SiteInstance
* GetSiteInstance() const OVERRIDE
;
235 virtual SiteInstance
* GetPendingSiteInstance() const OVERRIDE
;
236 virtual bool IsLoading() const OVERRIDE
;
237 virtual bool IsLoadingToDifferentDocument() const OVERRIDE
;
238 virtual bool IsWaitingForResponse() const OVERRIDE
;
239 virtual const net::LoadStateWithParam
& GetLoadState() const OVERRIDE
;
240 virtual const base::string16
& GetLoadStateHost() const OVERRIDE
;
241 virtual uint64
GetUploadSize() const OVERRIDE
;
242 virtual uint64
GetUploadPosition() const OVERRIDE
;
243 virtual std::set
<GURL
> GetSitesInTab() const OVERRIDE
;
244 virtual const std::string
& GetEncoding() const OVERRIDE
;
245 virtual bool DisplayedInsecureContent() const OVERRIDE
;
246 virtual void IncrementCapturerCount(const gfx::Size
& capture_size
) OVERRIDE
;
247 virtual void DecrementCapturerCount() OVERRIDE
;
248 virtual int GetCapturerCount() const OVERRIDE
;
249 virtual bool IsCrashed() const OVERRIDE
;
250 virtual void SetIsCrashed(base::TerminationStatus status
,
251 int error_code
) OVERRIDE
;
252 virtual base::TerminationStatus
GetCrashedStatus() const OVERRIDE
;
253 virtual bool IsBeingDestroyed() const OVERRIDE
;
254 virtual void NotifyNavigationStateChanged(
255 InvalidateTypes changed_flags
) OVERRIDE
;
256 virtual base::TimeTicks
GetLastActiveTime() const OVERRIDE
;
257 virtual void WasShown() OVERRIDE
;
258 virtual void WasHidden() OVERRIDE
;
259 virtual bool NeedToFireBeforeUnload() OVERRIDE
;
260 virtual void DispatchBeforeUnload(bool for_cross_site_transition
) OVERRIDE
;
261 virtual void Stop() OVERRIDE
;
262 virtual WebContents
* Clone() OVERRIDE
;
263 virtual void ReloadFocusedFrame(bool ignore_cache
) OVERRIDE
;
264 virtual void Undo() OVERRIDE
;
265 virtual void Redo() OVERRIDE
;
266 virtual void Cut() OVERRIDE
;
267 virtual void Copy() OVERRIDE
;
268 virtual void CopyToFindPboard() OVERRIDE
;
269 virtual void Paste() OVERRIDE
;
270 virtual void PasteAndMatchStyle() OVERRIDE
;
271 virtual void Delete() OVERRIDE
;
272 virtual void SelectAll() OVERRIDE
;
273 virtual void Unselect() OVERRIDE
;
274 virtual void Replace(const base::string16
& word
) OVERRIDE
;
275 virtual void ReplaceMisspelling(const base::string16
& word
) OVERRIDE
;
276 virtual void NotifyContextMenuClosed(
277 const CustomContextMenuContext
& context
) OVERRIDE
;
278 virtual void ExecuteCustomContextMenuCommand(
279 int action
, const CustomContextMenuContext
& context
) OVERRIDE
;
280 virtual gfx::NativeView
GetNativeView() OVERRIDE
;
281 virtual gfx::NativeView
GetContentNativeView() OVERRIDE
;
282 virtual gfx::NativeWindow
GetTopLevelNativeWindow() OVERRIDE
;
283 virtual gfx::Rect
GetContainerBounds() OVERRIDE
;
284 virtual gfx::Rect
GetViewBounds() OVERRIDE
;
285 virtual DropData
* GetDropData() OVERRIDE
;
286 virtual void Focus() OVERRIDE
;
287 virtual void SetInitialFocus() OVERRIDE
;
288 virtual void StoreFocus() OVERRIDE
;
289 virtual void RestoreFocus() OVERRIDE
;
290 virtual void FocusThroughTabTraversal(bool reverse
) OVERRIDE
;
291 virtual bool ShowingInterstitialPage() const OVERRIDE
;
292 virtual InterstitialPage
* GetInterstitialPage() const OVERRIDE
;
293 virtual bool IsSavable() OVERRIDE
;
294 virtual void OnSavePage() OVERRIDE
;
295 virtual bool SavePage(const base::FilePath
& main_file
,
296 const base::FilePath
& dir_path
,
297 SavePageType save_type
) OVERRIDE
;
298 virtual void SaveFrame(const GURL
& url
,
299 const Referrer
& referrer
) OVERRIDE
;
300 virtual void GenerateMHTML(
301 const base::FilePath
& file
,
302 const base::Callback
<void(int64
)>& callback
)
304 virtual const std::string
& GetContentsMimeType() const OVERRIDE
;
305 virtual bool WillNotifyDisconnection() const OVERRIDE
;
306 virtual void SetOverrideEncoding(const std::string
& encoding
) OVERRIDE
;
307 virtual void ResetOverrideEncoding() OVERRIDE
;
308 virtual RendererPreferences
* GetMutableRendererPrefs() OVERRIDE
;
309 virtual void Close() OVERRIDE
;
310 virtual void SystemDragEnded() OVERRIDE
;
311 virtual void UserGestureDone() OVERRIDE
;
312 virtual void SetClosedByUserGesture(bool value
) OVERRIDE
;
313 virtual bool GetClosedByUserGesture() const OVERRIDE
;
314 virtual void ViewSource() OVERRIDE
;
315 virtual void ViewFrameSource(const GURL
& url
,
316 const PageState
& page_state
) OVERRIDE
;
317 virtual int GetMinimumZoomPercent() const OVERRIDE
;
318 virtual int GetMaximumZoomPercent() const OVERRIDE
;
319 virtual gfx::Size
GetPreferredSize() const OVERRIDE
;
320 virtual bool GotResponseToLockMouseRequest(bool allowed
) OVERRIDE
;
321 virtual bool HasOpener() const OVERRIDE
;
322 virtual void DidChooseColorInColorChooser(SkColor color
) OVERRIDE
;
323 virtual void DidEndColorChooser() OVERRIDE
;
324 virtual int DownloadImage(const GURL
& url
,
326 uint32_t max_bitmap_size
,
327 const ImageDownloadCallback
& callback
) OVERRIDE
;
328 virtual bool IsSubframe() const OVERRIDE
;
329 virtual void Find(int request_id
,
330 const base::string16
& search_text
,
331 const blink::WebFindOptions
& options
) OVERRIDE
;
332 virtual void StopFinding(StopFindAction action
) OVERRIDE
;
333 virtual void InsertCSS(const std::string
& css
) OVERRIDE
;
334 virtual bool WasRecentlyAudible() OVERRIDE
;
335 virtual void GetManifest(const GetManifestCallback
&) OVERRIDE
;
336 #if defined(OS_ANDROID)
337 virtual base::android::ScopedJavaLocalRef
<jobject
> GetJavaWebContents()
339 virtual WebContentsAndroid
* GetWebContentsAndroid();
340 #elif defined(OS_MACOSX)
341 virtual void SetAllowOtherViews(bool allow
) OVERRIDE
;
342 virtual bool GetAllowOtherViews() OVERRIDE
;
345 // Implementation of PageNavigator.
346 virtual WebContents
* OpenURL(const OpenURLParams
& params
) OVERRIDE
;
348 // Implementation of IPC::Sender.
349 virtual bool Send(IPC::Message
* message
) OVERRIDE
;
351 // RenderFrameHostDelegate ---------------------------------------------------
352 virtual bool OnMessageReceived(RenderFrameHost
* render_frame_host
,
353 const IPC::Message
& message
) OVERRIDE
;
354 virtual const GURL
& GetMainFrameLastCommittedURL() const OVERRIDE
;
355 virtual void RenderFrameCreated(RenderFrameHost
* render_frame_host
) OVERRIDE
;
356 virtual void RenderFrameDeleted(RenderFrameHost
* render_frame_host
) OVERRIDE
;
357 virtual void DidStartLoading(RenderFrameHost
* render_frame_host
,
358 bool to_different_document
) OVERRIDE
;
359 virtual void SwappedOut(RenderFrameHost
* render_frame_host
) OVERRIDE
;
360 virtual void DidDeferAfterResponseStarted(
361 const TransitionLayerData
& transition_data
) OVERRIDE
;
362 virtual bool WillHandleDeferAfterResponseStarted() OVERRIDE
;
363 virtual void WorkerCrashed(RenderFrameHost
* render_frame_host
) OVERRIDE
;
364 virtual void ShowContextMenu(RenderFrameHost
* render_frame_host
,
365 const ContextMenuParams
& params
) OVERRIDE
;
366 virtual void RunJavaScriptMessage(RenderFrameHost
* render_frame_host
,
367 const base::string16
& message
,
368 const base::string16
& default_prompt
,
369 const GURL
& frame_url
,
370 JavaScriptMessageType type
,
371 IPC::Message
* reply_msg
) OVERRIDE
;
372 virtual void RunBeforeUnloadConfirm(RenderFrameHost
* render_frame_host
,
373 const base::string16
& message
,
375 IPC::Message
* reply_msg
) OVERRIDE
;
376 virtual void DidAccessInitialDocument() OVERRIDE
;
377 virtual void DidDisownOpener(RenderFrameHost
* render_frame_host
) OVERRIDE
;
378 virtual void DocumentOnLoadCompleted(
379 RenderFrameHost
* render_frame_host
) OVERRIDE
;
380 virtual void UpdateTitle(RenderFrameHost
* render_frame_host
,
382 const base::string16
& title
,
383 base::i18n::TextDirection title_direction
) OVERRIDE
;
384 virtual void UpdateEncoding(RenderFrameHost
* render_frame_host
,
385 const std::string
& encoding
) OVERRIDE
;
386 virtual WebContents
* GetAsWebContents() OVERRIDE
;
387 virtual bool IsNeverVisible() OVERRIDE
;
388 virtual AccessibilityMode
GetAccessibilityMode() const OVERRIDE
;
389 virtual void AccessibilityEventReceived(
390 const std::vector
<AXEventNotificationDetails
>& details
) OVERRIDE
;
391 virtual RenderFrameHost
* GetGuestByInstanceID(int browser_plugin_instance_id
)
394 virtual gfx::NativeViewAccessible
GetParentNativeViewAccessible() OVERRIDE
;
397 // RenderViewHostDelegate ----------------------------------------------------
398 virtual RenderViewHostDelegateView
* GetDelegateView() OVERRIDE
;
399 virtual bool OnMessageReceived(RenderViewHost
* render_view_host
,
400 const IPC::Message
& message
) OVERRIDE
;
401 // RenderFrameHostDelegate has the same method, so list it there because this
402 // interface is going away.
403 // virtual WebContents* GetAsWebContents() OVERRIDE;
404 virtual gfx::Rect
GetRootWindowResizerRect() const OVERRIDE
;
405 virtual void RenderViewCreated(RenderViewHost
* render_view_host
) OVERRIDE
;
406 virtual void RenderViewReady(RenderViewHost
* render_view_host
) OVERRIDE
;
407 virtual void RenderViewTerminated(RenderViewHost
* render_view_host
,
408 base::TerminationStatus status
,
409 int error_code
) OVERRIDE
;
410 virtual void RenderViewDeleted(RenderViewHost
* render_view_host
) OVERRIDE
;
411 virtual void UpdateState(RenderViewHost
* render_view_host
,
413 const PageState
& page_state
) OVERRIDE
;
414 virtual void UpdateTargetURL(int32 page_id
, const GURL
& url
) OVERRIDE
;
415 virtual void Close(RenderViewHost
* render_view_host
) OVERRIDE
;
416 virtual void RequestMove(const gfx::Rect
& new_bounds
) OVERRIDE
;
417 virtual void DidCancelLoading() OVERRIDE
;
418 virtual void DocumentAvailableInMainFrame(
419 RenderViewHost
* render_view_host
) OVERRIDE
;
420 virtual void RouteCloseEvent(RenderViewHost
* rvh
) OVERRIDE
;
421 virtual void RouteMessageEvent(
423 const ViewMsg_PostMessage_Params
& params
) OVERRIDE
;
424 virtual bool AddMessageToConsole(int32 level
,
425 const base::string16
& message
,
427 const base::string16
& source_id
) OVERRIDE
;
428 virtual RendererPreferences
GetRendererPrefs(
429 BrowserContext
* browser_context
) const OVERRIDE
;
430 virtual WebPreferences
ComputeWebkitPrefs() OVERRIDE
;
431 virtual void OnUserGesture() OVERRIDE
;
432 virtual void OnIgnoredUIEvent() OVERRIDE
;
433 virtual void RendererUnresponsive(RenderViewHost
* render_view_host
,
434 bool is_during_beforeunload
,
435 bool is_during_unload
) OVERRIDE
;
436 virtual void RendererResponsive(RenderViewHost
* render_view_host
) OVERRIDE
;
437 virtual void LoadStateChanged(const GURL
& url
,
438 const net::LoadStateWithParam
& load_state
,
439 uint64 upload_position
,
440 uint64 upload_size
) OVERRIDE
;
441 virtual void Activate() OVERRIDE
;
442 virtual void Deactivate() OVERRIDE
;
443 virtual void LostCapture() OVERRIDE
;
444 virtual void HandleMouseDown() OVERRIDE
;
445 virtual void HandleMouseUp() OVERRIDE
;
446 virtual void HandlePointerActivate() OVERRIDE
;
447 virtual void HandleGestureBegin() OVERRIDE
;
448 virtual void HandleGestureEnd() OVERRIDE
;
449 virtual void RunFileChooser(
450 RenderViewHost
* render_view_host
,
451 const FileChooserParams
& params
) OVERRIDE
;
452 virtual void ToggleFullscreenMode(bool enter_fullscreen
) OVERRIDE
;
453 virtual bool IsFullscreenForCurrentTab() const OVERRIDE
;
454 virtual void UpdatePreferredSize(const gfx::Size
& pref_size
) OVERRIDE
;
455 virtual void ResizeDueToAutoResize(const gfx::Size
& new_size
) OVERRIDE
;
456 virtual void RequestToLockMouse(bool user_gesture
,
457 bool last_unlocked_by_target
) OVERRIDE
;
458 virtual void LostMouseLock() OVERRIDE
;
459 virtual void CreateNewWindow(
460 int render_process_id
,
462 int main_frame_route_id
,
463 const ViewHostMsg_CreateWindow_Params
& params
,
464 SessionStorageNamespace
* session_storage_namespace
) OVERRIDE
;
465 virtual void CreateNewWidget(int render_process_id
,
467 blink::WebPopupType popup_type
) OVERRIDE
;
468 virtual void CreateNewFullscreenWidget(int render_process_id
,
469 int route_id
) OVERRIDE
;
470 virtual void ShowCreatedWindow(int route_id
,
471 WindowOpenDisposition disposition
,
472 const gfx::Rect
& initial_pos
,
473 bool user_gesture
) OVERRIDE
;
474 virtual void ShowCreatedWidget(int route_id
,
475 const gfx::Rect
& initial_pos
) OVERRIDE
;
476 virtual void ShowCreatedFullscreenWidget(int route_id
) OVERRIDE
;
477 virtual void RequestMediaAccessPermission(
478 const MediaStreamRequest
& request
,
479 const MediaResponseCallback
& callback
) OVERRIDE
;
480 virtual SessionStorageNamespace
* GetSessionStorageNamespace(
481 SiteInstance
* instance
) OVERRIDE
;
482 virtual SessionStorageNamespaceMap
GetSessionStorageNamespaceMap() OVERRIDE
;
483 virtual FrameTree
* GetFrameTree() OVERRIDE
;
485 // NavigatorDelegate ---------------------------------------------------------
487 virtual void DidStartProvisionalLoad(
488 RenderFrameHostImpl
* render_frame_host
,
489 const GURL
& validated_url
,
491 bool is_iframe_srcdoc
) OVERRIDE
;
492 virtual void DidStartNavigationTransition(
493 RenderFrameHostImpl
* render_frame_host
) OVERRIDE
;
494 virtual void DidFailProvisionalLoadWithError(
495 RenderFrameHostImpl
* render_frame_host
,
496 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
)
498 virtual void DidFailLoadWithError(
499 RenderFrameHostImpl
* render_frame_host
,
502 const base::string16
& error_description
) OVERRIDE
;
503 virtual void DidRedirectProvisionalLoad(
504 RenderFrameHostImpl
* render_frame_host
,
505 const GURL
& validated_target_url
) OVERRIDE
;
506 virtual void DidCommitProvisionalLoad(
507 RenderFrameHostImpl
* render_frame_host
,
509 PageTransition transition_type
) OVERRIDE
;
510 virtual void DidNavigateMainFramePreCommit(
511 bool navigation_is_within_page
) OVERRIDE
;
512 virtual void DidNavigateMainFramePostCommit(
513 const LoadCommittedDetails
& details
,
514 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) OVERRIDE
;
515 virtual void DidNavigateAnyFramePostCommit(
516 RenderFrameHostImpl
* render_frame_host
,
517 const LoadCommittedDetails
& details
,
518 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) OVERRIDE
;
519 virtual void SetMainFrameMimeType(const std::string
& mime_type
) OVERRIDE
;
520 virtual bool CanOverscrollContent() const OVERRIDE
;
521 virtual void NotifyChangedNavigationState(
522 InvalidateTypes changed_flags
) OVERRIDE
;
523 virtual void AboutToNavigateRenderFrame(
524 RenderFrameHostImpl
* render_frame_host
) OVERRIDE
;
525 virtual void DidStartNavigationToPendingEntry(
526 RenderFrameHostImpl
* render_frame_host
,
528 NavigationController::ReloadType reload_type
) OVERRIDE
;
529 virtual void RequestOpenURL(RenderFrameHostImpl
* render_frame_host
,
530 const OpenURLParams
& params
) OVERRIDE
;
531 virtual bool ShouldPreserveAbortedURLs() OVERRIDE
;
533 // RenderWidgetHostDelegate --------------------------------------------------
535 virtual void RenderWidgetDeleted(
536 RenderWidgetHostImpl
* render_widget_host
) OVERRIDE
;
537 virtual bool PreHandleKeyboardEvent(
538 const NativeWebKeyboardEvent
& event
,
539 bool* is_keyboard_shortcut
) OVERRIDE
;
540 virtual void HandleKeyboardEvent(
541 const NativeWebKeyboardEvent
& event
) OVERRIDE
;
542 virtual bool HandleWheelEvent(
543 const blink::WebMouseWheelEvent
& event
) OVERRIDE
;
544 virtual bool PreHandleGestureEvent(
545 const blink::WebGestureEvent
& event
) OVERRIDE
;
546 virtual bool HandleGestureEvent(
547 const blink::WebGestureEvent
& event
) OVERRIDE
;
548 virtual void DidSendScreenRects(RenderWidgetHostImpl
* rwh
) OVERRIDE
;
549 virtual BrowserAccessibilityManager
* GetRootBrowserAccessibilityManager()
551 virtual BrowserAccessibilityManager
*
552 GetOrCreateRootBrowserAccessibilityManager() OVERRIDE
;
554 // RenderFrameHostManager::Delegate ------------------------------------------
556 virtual bool CreateRenderViewForRenderManager(
557 RenderViewHost
* render_view_host
,
559 int proxy_routing_id
,
560 bool for_main_frame_navigation
) OVERRIDE
;
561 virtual bool CreateRenderFrameForRenderManager(
562 RenderFrameHost
* render_frame_host
,
563 int parent_routing_id
) OVERRIDE
;
564 virtual void BeforeUnloadFiredFromRenderManager(
565 bool proceed
, const base::TimeTicks
& proceed_time
,
566 bool* proceed_to_fire_unload
) OVERRIDE
;
567 virtual void RenderProcessGoneFromRenderManager(
568 RenderViewHost
* render_view_host
) OVERRIDE
;
569 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE
;
570 virtual void CancelModalDialogsForRenderManager() OVERRIDE
;
571 virtual void NotifySwappedFromRenderManager(RenderFrameHost
* old_host
,
572 RenderFrameHost
* new_host
,
573 bool is_main_frame
) OVERRIDE
;
574 virtual int CreateOpenerRenderViewsForRenderManager(
575 SiteInstance
* instance
) OVERRIDE
;
576 virtual NavigationControllerImpl
&
577 GetControllerForRenderManager() OVERRIDE
;
578 virtual WebUIImpl
* CreateWebUIForRenderManager(const GURL
& url
) OVERRIDE
;
579 virtual NavigationEntry
*
580 GetLastCommittedNavigationEntryForRenderManager() OVERRIDE
;
581 virtual bool FocusLocationBarByDefault() OVERRIDE
;
582 virtual void SetFocusToLocationBar(bool select_all
) OVERRIDE
;
583 virtual void CreateViewAndSetSizeForRVH(RenderViewHost
* rvh
) OVERRIDE
;
584 virtual bool IsHidden() OVERRIDE
;
586 // NotificationObserver ------------------------------------------------------
588 virtual void Observe(int type
,
589 const NotificationSource
& source
,
590 const NotificationDetails
& details
) OVERRIDE
;
592 // NavigationControllerDelegate ----------------------------------------------
594 virtual WebContents
* GetWebContents() OVERRIDE
;
595 virtual void NotifyNavigationEntryCommitted(
596 const LoadCommittedDetails
& load_details
) OVERRIDE
;
598 // Invoked before a form repost warning is shown.
599 virtual void NotifyBeforeFormRepostWarningShow() OVERRIDE
;
601 // Activate this WebContents and show a form repost warning.
602 virtual void ActivateAndShowRepostFormWarningDialog() OVERRIDE
;
604 // Whether the initial empty page of this view has been accessed by another
605 // page, making it unsafe to show the pending URL. Always false after the
607 virtual bool HasAccessedInitialDocument() OVERRIDE
;
609 // Updates the max page ID for the current SiteInstance in this
610 // WebContentsImpl to be at least |page_id|.
611 virtual void UpdateMaxPageID(int32 page_id
) OVERRIDE
;
613 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
614 // to be at least |page_id|.
615 virtual void UpdateMaxPageIDForSiteInstance(SiteInstance
* site_instance
,
616 int32 page_id
) OVERRIDE
;
618 // Copy the current map of SiteInstance ID to max page ID from another tab.
619 // This is necessary when this tab adopts the NavigationEntries from
621 virtual void CopyMaxPageIDsFrom(WebContents
* web_contents
) OVERRIDE
;
623 // Called by the NavigationController to cause the WebContentsImpl to navigate
624 // to the current pending entry. The NavigationController should be called
625 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
626 // The callbacks can be inside of this function, or at some future time.
628 // The entry has a PageID of -1 if newly created (corresponding to navigation
631 // If this method returns false, then the navigation is discarded (equivalent
632 // to calling DiscardPendingEntry on the NavigationController).
633 virtual bool NavigateToPendingEntry(
634 NavigationController::ReloadType reload_type
) OVERRIDE
;
636 // Sets the history for this WebContentsImpl to |history_length| entries, and
637 // moves the current page_id to the last entry in the list if it's valid.
638 // This is mainly used when a prerendered page is swapped into the current
639 // tab. The method is virtual for testing.
640 virtual void SetHistoryLengthAndPrune(
641 const SiteInstance
* site_instance
,
642 int merge_history_length
,
643 int32 minimum_page_id
) OVERRIDE
;
645 // Called by InterstitialPageImpl when it creates a RenderFrameHost.
646 virtual void RenderFrameForInterstitialPageCreated(
647 RenderFrameHost
* render_frame_host
) OVERRIDE
;
649 // Sets the passed interstitial as the currently showing interstitial.
650 // No interstitial page should already be attached.
651 virtual void AttachInterstitialPage(
652 InterstitialPageImpl
* interstitial_page
) OVERRIDE
;
654 // Unsets the currently showing interstitial.
655 virtual void DetachInterstitialPage() OVERRIDE
;
657 // Changes the IsLoading state and notifies the delegate as needed.
658 // |details| is used to provide details on the load that just finished
659 // (but can be null if not applicable).
660 virtual void SetIsLoading(RenderViewHost
* render_view_host
,
662 bool to_different_document
,
663 LoadNotificationDetails
* details
) OVERRIDE
;
665 typedef base::Callback
<void(WebContents
*)> CreatedCallback
;
667 // Requests the renderer to select the region between two points in the
668 // currently focused frame.
669 void SelectRange(const gfx::Point
& start
, const gfx::Point
& end
);
671 // Notifies the main frame that it can continue navigation (if it was deferred
672 // immediately at first response).
673 void ResumeResponseDeferredAtStart();
675 // Forces overscroll to be disabled (used by touch emulation).
676 void SetForceDisableOverscrollContent(bool force_disable
);
678 AudioStreamMonitor
* audio_stream_monitor() {
679 return &audio_stream_monitor_
;
682 bool has_audio_power_save_blocker_for_testing() const {
683 return audio_power_save_blocker_
;
686 bool has_video_power_save_blocker_for_testing() const {
687 return video_power_save_blocker_
;
691 friend class TestNavigationObserver
;
692 friend class WebContentsAddedObserver
;
693 friend class WebContentsObserver
;
694 friend class WebContents
; // To implement factory methods.
696 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, NoJSMessageOnInterstitials
);
697 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, UpdateTitle
);
698 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, FindOpenerRVHWhenPending
);
699 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
,
700 CrossSiteCantPreemptAfterUnload
);
701 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, PendingContents
);
702 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, FrameTreeShape
);
703 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, GetLastActiveTime
);
704 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest
, HTMLFiles
);
705 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest
, HistoryNavigate
);
706 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest
, PageDoesBackAndReload
);
707 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest
, CrossSiteIframe
);
708 FRIEND_TEST_ALL_PREFIXES(SitePerProcessAccessibilityBrowserTest
,
709 CrossSiteIframeAccessibility
);
711 // So InterstitialPageImpl can access SetIsLoading.
712 friend class InterstitialPageImpl
;
714 // TODO(brettw) TestWebContents shouldn't exist!
715 friend class TestWebContents
;
717 class DestructionObserver
;
719 // See WebContents::Create for a description of these parameters.
720 WebContentsImpl(BrowserContext
* browser_context
,
721 WebContentsImpl
* opener
);
723 // Add and remove observers for page navigation notifications. The order in
724 // which notifications are sent to observers is undefined. Clients must be
725 // sure to remove the observer before they go away.
726 void AddObserver(WebContentsObserver
* observer
);
727 void RemoveObserver(WebContentsObserver
* observer
);
729 // Clears this tab's opener if it has been closed.
730 void OnWebContentsDestroyed(WebContentsImpl
* web_contents
);
732 // Creates and adds to the map a destruction observer watching |web_contents|.
733 // No-op if such an observer already exists.
734 void AddDestructionObserver(WebContentsImpl
* web_contents
);
736 // Deletes and removes from the map a destruction observer
737 // watching |web_contents|. No-op if there is no such observer.
738 void RemoveDestructionObserver(WebContentsImpl
* web_contents
);
740 // Traverses all the RenderFrameHosts in the FrameTree and creates a set
741 // all the unique RenderWidgetHostViews.
742 std::set
<RenderWidgetHostView
*> GetRenderWidgetHostViewsInTree();
744 // Callback function when showing JavaScript dialogs. Takes in a routing ID
745 // pair to identify the RenderFrameHost that opened the dialog, because it's
746 // possible for the RenderFrameHost to be deleted by the time this is called.
747 void OnDialogClosed(int render_process_id
,
749 IPC::Message
* reply_msg
,
750 bool dialog_was_suppressed
,
752 const base::string16
& user_input
);
754 // Callback function when requesting permission to access the PPAPI broker.
755 // |result| is true if permission was granted.
756 void OnPpapiBrokerPermissionResult(int routing_id
, bool result
);
758 bool OnMessageReceived(RenderViewHost
* render_view_host
,
759 RenderFrameHost
* render_frame_host
,
760 const IPC::Message
& message
);
762 // IPC message handlers.
763 void OnThemeColorChanged(SkColor theme_color
);
764 void OnDidLoadResourceFromMemoryCache(const GURL
& url
,
765 const std::string
& security_info
,
766 const std::string
& http_request
,
767 const std::string
& mime_type
,
768 ResourceType resource_type
);
769 void OnDidDisplayInsecureContent();
770 void OnDidRunInsecureContent(const std::string
& security_origin
,
771 const GURL
& target_url
);
772 void OnDocumentLoadedInFrame();
773 void OnDidFinishLoad(const GURL
& url
);
774 void OnDidStartLoading(bool to_different_document
);
775 void OnDidStopLoading();
776 void OnDidChangeLoadProgress(double load_progress
);
777 void OnGoToEntryAtOffset(int offset
);
778 void OnUpdateZoomLimits(int minimum_percent
,
779 int maximum_percent
);
780 void OnEnumerateDirectory(int request_id
, const base::FilePath
& path
);
782 void OnRegisterProtocolHandler(const std::string
& protocol
,
784 const base::string16
& title
,
786 void OnUnregisterProtocolHandler(const std::string
& protocol
,
789 void OnFindReply(int request_id
,
790 int number_of_matches
,
791 const gfx::Rect
& selection_rect
,
792 int active_match_ordinal
,
794 #if defined(OS_ANDROID)
795 void OnFindMatchRectsReply(int version
,
796 const std::vector
<gfx::RectF
>& rects
,
797 const gfx::RectF
& active_rect
);
799 void OnOpenDateTimeDialog(
800 const ViewHostMsg_DateTimeDialogValue_Params
& value
);
802 void OnPepperPluginHung(int plugin_child_id
,
803 const base::FilePath
& path
,
805 void OnPluginCrashed(const base::FilePath
& plugin_path
,
806 base::ProcessId plugin_pid
);
807 void OnDomOperationResponse(const std::string
& json_string
,
809 void OnAppCacheAccessed(const GURL
& manifest_url
, bool blocked_by_policy
);
810 void OnOpenColorChooser(int color_chooser_id
,
812 const std::vector
<ColorSuggestion
>& suggestions
);
813 void OnEndColorChooser(int color_chooser_id
);
814 void OnSetSelectedColorInColorChooser(int color_chooser_id
, SkColor color
);
815 void OnWebUISend(const GURL
& source_url
,
816 const std::string
& name
,
817 const base::ListValue
& args
);
818 void OnRequestPpapiBrokerPermission(int routing_id
,
820 const base::FilePath
& plugin_path
);
821 void OnBrowserPluginMessage(const IPC::Message
& message
);
822 void OnDidDownloadImage(int id
,
823 int http_status_code
,
824 const GURL
& image_url
,
825 const std::vector
<SkBitmap
>& bitmaps
,
826 const std::vector
<gfx::Size
>& original_bitmap_sizes
);
827 void OnUpdateFaviconURL(const std::vector
<FaviconURL
>& candidates
);
828 void OnFirstVisuallyNonEmptyPaint();
829 void OnMediaPlayingNotification(int64 player_cookie
,
832 void OnMediaPausedNotification(int64 player_cookie
);
833 void OnShowValidationMessage(const gfx::Rect
& anchor_in_root_view
,
834 const base::string16
& main_text
,
835 const base::string16
& sub_text
);
836 void OnHideValidationMessage();
837 void OnMoveValidationMessage(const gfx::Rect
& anchor_in_root_view
);
839 // Called by derived classes to indicate that we're no longer waiting for a
840 // response. This won't actually update the throbber, but it will get picked
841 // up at the next animation step if the throbber is going.
842 void SetNotWaitingForResponse() { waiting_for_response_
= false; }
844 // Navigation helpers --------------------------------------------------------
846 // These functions are helpers for Navigate() and DidNavigate().
848 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
849 // committed to the navigation controller. Note that the navigation entry is
850 // not provided since it may be invalid/changed after being committed. The
851 // current navigation entry is in the NavigationController at this point.
853 // If our controller was restored, update the max page ID associated with the
854 // given RenderViewHost to be larger than the number of restored entries.
855 // This is called in CreateRenderView before any navigations in the RenderView
856 // have begun, to prevent any races in updating RenderView::next_page_id.
857 void UpdateMaxPageIDIfNecessary(RenderViewHost
* rvh
);
859 // Saves the given title to the navigation entry and does associated work. It
860 // will update history and the view for the new title, and also synthesize
861 // titles for file URLs that have none (so we require that the URL of the
862 // entry already be set).
864 // This is used as the backend for state updates, which include a new title,
865 // or the dedicated set title message. It returns true if the new title is
866 // different and was therefore updated.
867 bool UpdateTitleForEntry(NavigationEntryImpl
* entry
,
868 const base::string16
& title
);
870 // Recursively creates swapped out RenderViews for this tab's opener chain
871 // (including this tab) in the given SiteInstance, allowing other tabs to send
872 // cross-process JavaScript calls to their opener(s). Returns the route ID of
873 // this tab's RenderView for |instance|.
874 int CreateOpenerRenderViews(SiteInstance
* instance
);
876 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
877 void CreateNewWidget(int render_process_id
,
880 blink::WebPopupType popup_type
);
882 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
883 void ShowCreatedWidget(int route_id
,
885 const gfx::Rect
& initial_pos
);
887 // Finds the new RenderWidgetHost and returns it. Note that this can only be
888 // called once as this call also removes it from the internal map.
889 RenderWidgetHostView
* GetCreatedWidget(int route_id
);
891 // Finds the new WebContentsImpl by route_id, initializes it for
892 // renderer-initiated creation, and returns it. Note that this can only be
893 // called once as this call also removes it from the internal map.
894 WebContentsImpl
* GetCreatedWindow(int route_id
);
896 // Tracking loading progress -------------------------------------------------
898 // Resets the tracking state of the current load.
899 void ResetLoadProgressState();
901 // Calculates the progress of the current load and notifies the delegate.
902 void SendLoadProgressChanged();
904 // Called once when the last frame on the page has stopped loading.
905 void DidStopLoading(RenderFrameHost
* render_frame_host
);
907 // Misc non-view stuff -------------------------------------------------------
909 // Helper functions for sending notifications.
910 void NotifyViewSwapped(RenderViewHost
* old_host
, RenderViewHost
* new_host
);
911 void NotifyFrameSwapped(RenderFrameHost
* old_host
, RenderFrameHost
* new_host
);
912 void NotifyDisconnected();
914 void SetEncoding(const std::string
& encoding
);
916 // TODO(creis): This should take in a FrameTreeNode to know which node's
917 // render manager to return. For now, we just return the root's.
918 RenderFrameHostManager
* GetRenderManager() const;
920 RenderViewHostImpl
* GetRenderViewHostImpl();
922 // Removes browser plugin embedder if there is one.
923 void RemoveBrowserPluginEmbedder();
925 // Clear |render_frame_host|'s tracking entry for its power save blockers.
926 void ClearPowerSaveBlockers(RenderFrameHost
* render_frame_host
);
928 // Clear tracking entries for all RenderFrameHosts, clears
929 // |audio_power_save_blocker_| and |video_power_save_blocker_|.
930 void ClearAllPowerSaveBlockers();
932 // Creates an audio or video power save blocker respectively.
933 void CreateAudioPowerSaveBlocker();
934 void CreateVideoPowerSaveBlocker();
936 // Releases the audio power save blockers if |active_audio_players_| is empty.
937 // Likewise, releases the video power save blockers if |active_video_players_|
939 void MaybeReleasePowerSaveBlockers();
941 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
942 gfx::Size
GetSizeForNewRenderView();
944 void OnFrameRemoved(RenderFrameHost
* render_frame_host
);
946 // Helper method that's called whenever |preferred_size_| or
947 // |preferred_size_for_capture_| changes, to propagate the new value to the
949 void OnPreferredSizeChanged(const gfx::Size
& old_size
);
951 // Helper methods for adding or removing player entries in |player_map| under
952 // the key |render_frame_message_source_|.
953 typedef std::vector
<int64
> PlayerList
;
954 typedef std::map
<uintptr_t, PlayerList
> ActiveMediaPlayerMap
;
955 void AddMediaPlayerEntry(int64 player_cookie
,
956 ActiveMediaPlayerMap
* player_map
);
957 void RemoveMediaPlayerEntry(int64 player_cookie
,
958 ActiveMediaPlayerMap
* player_map
);
959 // Removes all entries from |player_map| for |render_frame_host|.
960 void RemoveAllMediaPlayerEntries(RenderFrameHost
* render_frame_host
,
961 ActiveMediaPlayerMap
* player_map
);
963 // Adds/removes a callback called on creation of each new WebContents.
964 // Deprecated, about to remove.
965 static void AddCreatedCallback(const CreatedCallback
& callback
);
966 static void RemoveCreatedCallback(const CreatedCallback
& callback
);
968 // Data for core operation ---------------------------------------------------
970 // Delegate for notifying our owner about stuff. Not owned by us.
971 WebContentsDelegate
* delegate_
;
973 // Handles the back/forward list and loading.
974 NavigationControllerImpl controller_
;
976 // The corresponding view.
977 scoped_ptr
<WebContentsView
> view_
;
979 // The view of the RVHD. Usually this is our WebContentsView implementation,
980 // but if an embedder uses a different WebContentsView, they'll need to
982 RenderViewHostDelegateView
* render_view_host_delegate_view_
;
984 // Tracks created WebContentsImpl objects that have not been shown yet. They
985 // are identified by the route ID passed to CreateNewWindow.
986 typedef std::map
<int, WebContentsImpl
*> PendingContents
;
987 PendingContents pending_contents_
;
989 // These maps hold on to the widgets that we created on behalf of the renderer
990 // that haven't shown yet.
991 typedef std::map
<int, RenderWidgetHostView
*> PendingWidgetViews
;
992 PendingWidgetViews pending_widget_views_
;
994 typedef std::map
<WebContentsImpl
*, DestructionObserver
*> DestructionObservers
;
995 DestructionObservers destruction_observers_
;
997 // A list of observers notified when page state changes. Weak references.
998 // This MUST be listed above frame_tree_ since at destruction time the
999 // latter might cause RenderViewHost's destructor to call us and we might use
1000 // the observer list then.
1001 ObserverList
<WebContentsObserver
> observers_
;
1003 // The tab that opened this tab, if any. Will be set to null if the opener
1005 WebContentsImpl
* opener_
;
1007 // True if this tab was opened by another tab. This is not unset if the opener
1009 bool created_with_opener_
;
1012 gfx::NativeViewAccessible accessible_parent_
;
1015 // Helper classes ------------------------------------------------------------
1017 // Tracking variables and associated power save blockers for media playback.
1018 ActiveMediaPlayerMap active_audio_players_
;
1019 ActiveMediaPlayerMap active_video_players_
;
1020 scoped_ptr
<PowerSaveBlocker
> audio_power_save_blocker_
;
1021 scoped_ptr
<PowerSaveBlocker
> video_power_save_blocker_
;
1023 // Manages the frame tree of the page and process swaps in each node.
1024 FrameTree frame_tree_
;
1026 // SavePackage, lazily created.
1027 scoped_refptr
<SavePackage
> save_package_
;
1029 // Data for loading state ----------------------------------------------------
1031 // Indicates whether we're currently loading a resource.
1034 // Indicates whether the current load is to a different document. Only valid
1035 // if is_loading_ is true.
1036 bool is_load_to_different_document_
;
1038 // Indicates if the tab is considered crashed.
1039 base::TerminationStatus crashed_status_
;
1040 int crashed_error_code_
;
1042 // Whether this WebContents is waiting for a first-response for the
1043 // main resource of the page. This controls whether the throbber state is
1044 // "waiting" or "loading."
1045 bool waiting_for_response_
;
1047 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
1048 // to a given tab and SiteInstance, and must be valid for the lifetime of the
1050 std::map
<int32
, int32
> max_page_ids_
;
1052 // The current load state and the URL associated with it.
1053 net::LoadStateWithParam load_state_
;
1054 base::string16 load_state_host_
;
1056 // LoadingProgressMap maps FrameTreeNode IDs to a double representing that
1057 // frame's completion (from 0 to 1).
1058 typedef base::hash_map
<int64
, double> LoadingProgressMap
;
1059 LoadingProgressMap loading_progresses_
;
1060 double loading_total_progress_
;
1062 base::TimeTicks loading_last_progress_update_
;
1064 base::WeakPtrFactory
<WebContentsImpl
> loading_weak_factory_
;
1066 // Counter to track how many frames have sent start notifications but not
1067 // stop notifications.
1068 int loading_frames_in_progress_
;
1070 // Upload progress, for displaying in the status bar.
1071 // Set to zero when there is no significant upload happening.
1072 uint64 upload_size_
;
1073 uint64 upload_position_
;
1075 // Data for current page -----------------------------------------------------
1077 // When a title cannot be taken from any entry, this title will be used.
1078 base::string16 page_title_when_no_navigation_entry_
;
1080 // When a navigation occurs, we record its contents MIME type. It can be
1081 // used to check whether we can do something for some special contents.
1082 std::string contents_mime_type_
;
1084 // The last reported character encoding, not canonicalized.
1085 std::string last_reported_encoding_
;
1087 // The canonicalized character encoding.
1088 std::string canonical_encoding_
;
1090 // True if this is a secure page which displayed insecure content.
1091 bool displayed_insecure_content_
;
1093 // Whether the initial empty page has been accessed by another page, making it
1094 // unsafe to show the pending URL. Usually false unless another window tries
1095 // to modify the blank page. Always false after the first commit.
1096 bool has_accessed_initial_document_
;
1098 // Data for misc internal state ----------------------------------------------
1100 // When > 0, the WebContents is currently being captured (e.g., for
1101 // screenshots or mirroring); and the underlying RenderWidgetHost should not
1102 // be told it is hidden.
1103 int capturer_count_
;
1105 // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
1106 bool should_normally_be_visible_
;
1108 // See getter above.
1109 bool is_being_destroyed_
;
1111 // Indicates whether we should notify about disconnection of this
1112 // WebContentsImpl. This is used to ensure disconnection notifications only
1113 // happen if a connection notification has happened and that they happen only
1115 bool notify_disconnection_
;
1117 // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
1118 // delegate of this WebContentsImpl is nulled before its destructor is called.
1119 JavaScriptDialogManager
* dialog_manager_
;
1121 // Set to true when there is an active "before unload" dialog. When true,
1122 // we've forced the throbber to start in Navigate, and we need to remember to
1123 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
1124 bool is_showing_before_unload_dialog_
;
1126 // Settings that get passed to the renderer process.
1127 RendererPreferences renderer_preferences_
;
1129 // The time that this WebContents was last made active. The initial value is
1130 // the WebContents creation time.
1131 base::TimeTicks last_active_time_
;
1133 // See description above setter.
1134 bool closed_by_user_gesture_
;
1136 // Minimum/maximum zoom percent.
1137 int minimum_zoom_percent_
;
1138 int maximum_zoom_percent_
;
1140 // The raw accumulated zoom value and the actual zoom increments made for an
1141 // an in-progress pinch gesture.
1142 float totalPinchGestureAmount_
;
1143 int currentPinchZoomStepDelta_
;
1145 // The intrinsic size of the page.
1146 gfx::Size preferred_size_
;
1148 // The preferred size for content screen capture. When |capturer_count_| > 0,
1149 // this overrides |preferred_size_|.
1150 gfx::Size preferred_size_for_capture_
;
1152 #if defined(OS_ANDROID)
1153 // Date time chooser opened by this tab.
1154 // Only used in Android since all other platforms use a multi field UI.
1155 scoped_ptr
<DateTimeChooserAndroid
> date_time_chooser_
;
1158 // Holds information about a current color chooser dialog, if one is visible.
1159 struct ColorChooserInfo
{
1160 ColorChooserInfo(int render_process_id
,
1161 int render_frame_id
,
1162 ColorChooser
* chooser
,
1164 ~ColorChooserInfo();
1166 int render_process_id
;
1167 int render_frame_id
;
1169 // Color chooser that was opened by this tab.
1170 scoped_ptr
<ColorChooser
> chooser
;
1172 // A unique identifier for the current color chooser. Identifiers are
1173 // unique across a renderer process. This avoids race conditions in
1174 // synchronizing the browser and renderer processes. For example, if a
1175 // renderer closes one chooser and opens another, and simultaneously the
1176 // user picks a color in the first chooser, the IDs can be used to drop the
1177 // "chose a color" message rather than erroneously tell the renderer that
1178 // the user picked a color in the second chooser.
1182 scoped_ptr
<ColorChooserInfo
> color_chooser_info_
;
1184 // Manages the embedder state for browser plugins, if this WebContents is an
1185 // embedder; NULL otherwise.
1186 scoped_ptr
<BrowserPluginEmbedder
> browser_plugin_embedder_
;
1187 // Manages the guest state for browser plugin, if this WebContents is a guest;
1189 scoped_ptr
<BrowserPluginGuest
> browser_plugin_guest_
;
1191 // This must be at the end, or else we might get notifications and use other
1192 // member variables that are gone.
1193 NotificationRegistrar registrar_
;
1195 // Used during IPC message dispatching from the RenderView/RenderFrame so that
1196 // the handlers can get a pointer to the RVH through which the message was
1198 RenderViewHost
* render_view_message_source_
;
1199 RenderFrameHost
* render_frame_message_source_
;
1201 // All live RenderWidgetHostImpls that are created by this object and may
1203 std::set
<RenderWidgetHostImpl
*> created_widgets_
;
1205 // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1206 int fullscreen_widget_routing_id_
;
1208 // At the time the fullscreen widget was being shut down, did it have focus?
1209 // This is used to restore focus to the WebContentsView after both: 1) the
1210 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has
1211 // completed making layout changes to effect an exit from fullscreen mode.
1212 bool fullscreen_widget_had_focus_at_shutdown_
;
1214 // Maps the ids of pending image downloads to their callbacks
1215 typedef std::map
<int, ImageDownloadCallback
> ImageDownloadMap
;
1216 ImageDownloadMap image_download_map_
;
1218 // Whether this WebContents is responsible for displaying a subframe in a
1219 // different process from its parent page.
1222 // Whether overscroll should be unconditionally disabled.
1223 bool force_disable_overscroll_content_
;
1225 // Whether the last JavaScript dialog shown was suppressed. Used for testing.
1226 bool last_dialog_suppressed_
;
1228 scoped_ptr
<GeolocationDispatcherHost
> geolocation_dispatcher_host_
;
1230 scoped_ptr
<MidiDispatcherHost
> midi_dispatcher_host_
;
1232 scoped_ptr
<ScreenOrientationDispatcherHost
>
1233 screen_orientation_dispatcher_host_
;
1235 scoped_ptr
<ManifestManagerHost
> manifest_manager_host_
;
1237 // The accessibility mode for all frames. This is queried when each frame
1238 // is created, and broadcast to all frames when it changes.
1239 AccessibilityMode accessibility_mode_
;
1241 // Monitors power levels for audio streams associated with this WebContents.
1242 AudioStreamMonitor audio_stream_monitor_
;
1244 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl
);
1247 } // namespace content
1249 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_