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/renderer_preferences.h"
35 #include "content/public/common/resource_type.h"
36 #include "content/public/common/three_d_api_types.h"
37 #include "net/base/load_states.h"
38 #include "net/http/http_response_headers.h"
39 #include "third_party/WebKit/public/web/WebDragOperation.h"
40 #include "ui/base/page_transition_types.h"
41 #include "ui/gfx/geometry/rect_f.h"
42 #include "ui/gfx/geometry/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 GeolocationServiceContext
;
55 class InterstitialPageImpl
;
56 class JavaScriptDialogManager
;
57 class ManifestManagerHost
;
58 class PluginContentOriginWhitelist
;
59 class PowerSaveBlocker
;
61 class RenderViewHostDelegateView
;
62 class RenderViewHostImpl
;
63 class RenderWidgetHostImpl
;
65 class ScreenOrientationDispatcherHost
;
67 class TestWebContents
;
68 class WebContentsAudioMuter
;
69 class WebContentsDelegate
;
70 class WebContentsImpl
;
71 class WebContentsObserver
;
72 class WebContentsView
;
73 class WebContentsViewDelegate
;
74 struct AXEventNotificationDetails
;
75 struct ColorSuggestion
;
77 struct LoadNotificationDetails
;
78 struct ResourceRedirectDetails
;
79 struct ResourceRequestDetails
;
81 #if defined(OS_ANDROID)
82 class WebContentsAndroid
;
85 // Factory function for the implementations that content knows about. Takes
86 // ownership of |delegate|.
87 WebContentsView
* CreateWebContentsView(
88 WebContentsImpl
* web_contents
,
89 WebContentsViewDelegate
* delegate
,
90 RenderViewHostDelegateView
** render_view_host_delegate_view
);
92 class CONTENT_EXPORT WebContentsImpl
93 : public NON_EXPORTED_BASE(WebContents
),
94 public NON_EXPORTED_BASE(RenderFrameHostDelegate
),
95 public RenderViewHostDelegate
,
96 public RenderWidgetHostDelegate
,
97 public RenderFrameHostManager::Delegate
,
98 public NotificationObserver
,
99 public NON_EXPORTED_BASE(NavigationControllerDelegate
),
100 public NON_EXPORTED_BASE(NavigatorDelegate
) {
104 ~WebContentsImpl() override
;
106 static WebContentsImpl
* CreateWithOpener(
107 const WebContents::CreateParams
& params
,
108 WebContentsImpl
* opener
);
110 static std::vector
<WebContentsImpl
*> GetAllWebContents();
112 // Returns the opener WebContentsImpl, if any. This can be set to null if the
113 // opener is closed or the page clears its window.opener.
114 WebContentsImpl
* opener() const { return opener_
; }
116 // Creates a swapped out RenderView. This is used by the browser plugin to
117 // create a swapped out RenderView in the embedder render process for the
118 // guest, to expose the guest's window object to the embedder.
119 // This returns the routing ID of the newly created swapped out RenderView.
120 int CreateSwappedOutRenderView(SiteInstance
* instance
);
122 // Complex initialization here. Specifically needed to avoid having
123 // members call back into our virtual functions in the constructor.
124 virtual void Init(const WebContents::CreateParams
& params
);
126 // Returns the SavePackage which manages the page saving job. May be NULL.
127 SavePackage
* save_package() const { return save_package_
.get(); }
129 #if defined(OS_ANDROID)
130 // In Android WebView, the RenderView needs created even there is no
131 // navigation entry, this allows Android WebViews to use
132 // javascript: URLs that load into the DOMWindow before the first page
133 // load. This is not safe to do in any context that a web page could get a
134 // reference to the DOMWindow before the first page load.
135 bool CreateRenderViewForInitialEmptyDocument();
138 // Expose the render manager for testing.
139 // TODO(creis): Remove this now that we can get to it via FrameTreeNode.
140 RenderFrameHostManager
* GetRenderManagerForTesting();
142 // Returns guest browser plugin object, or NULL if this WebContents is not a
144 BrowserPluginGuest
* GetBrowserPluginGuest() const;
146 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
147 // has a BrowserPluginGuest then that implies that it is being hosted by
148 // a BrowserPlugin object in an embedder renderer process.
149 void SetBrowserPluginGuest(BrowserPluginGuest
* guest
);
151 // Returns embedder browser plugin object, or NULL if this WebContents is not
153 BrowserPluginEmbedder
* GetBrowserPluginEmbedder() const;
155 // Gets the current fullscreen render widget's routing ID. Returns
156 // MSG_ROUTING_NONE when there is no fullscreen render widget.
157 int GetFullscreenWidgetRoutingID() const;
159 // Invoked when visible SSL state (as defined by SSLStatus) changes.
160 void DidChangeVisibleSSLState();
162 // Informs the render view host and the BrowserPluginEmbedder, if present, of
163 // a Drag Source End.
164 void DragSourceEndedAt(int client_x
, int client_y
, int screen_x
,
165 int screen_y
, blink::WebDragOperation operation
);
167 // A response has been received for a resource request.
168 void DidGetResourceResponseStart(
169 const ResourceRequestDetails
& details
);
171 // A redirect was received while requesting a resource.
172 void DidGetRedirectForResourceRequest(
173 RenderFrameHost
* render_frame_host
,
174 const ResourceRedirectDetails
& details
);
176 WebContentsView
* GetView() const;
178 ScreenOrientationDispatcherHost
* screen_orientation_dispatcher_host() {
179 return screen_orientation_dispatcher_host_
.get();
182 bool should_normally_be_visible() { return should_normally_be_visible_
; }
184 // Broadcasts the mode change to all frames.
185 void SetAccessibilityMode(AccessibilityMode mode
);
187 // Adds the given accessibility mode to the current accessibility mode
189 void AddAccessibilityMode(AccessibilityMode mode
);
191 // Removes the given accessibility mode from the current accessibility
192 // mode bitmap, managing the bits that are shared with other modes such
193 // that a bit will only be turned off when all modes that depend on it
194 // have been removed.
195 void RemoveAccessibilityMode(AccessibilityMode mode
);
197 // Clear the navigation transition data when the user navigates back to Chrome
198 // from a native app.
199 void ClearNavigationTransitionData();
201 // WebContents ------------------------------------------------------
202 WebContentsDelegate
* GetDelegate() override
;
203 void SetDelegate(WebContentsDelegate
* delegate
) override
;
204 NavigationControllerImpl
& GetController() override
;
205 const NavigationControllerImpl
& GetController() const override
;
206 BrowserContext
* GetBrowserContext() const override
;
207 const GURL
& GetURL() const override
;
208 const GURL
& GetVisibleURL() const override
;
209 const GURL
& GetLastCommittedURL() const override
;
210 RenderProcessHost
* GetRenderProcessHost() const override
;
211 RenderFrameHost
* GetMainFrame() override
;
212 RenderFrameHost
* GetFocusedFrame() override
;
214 const base::Callback
<void(RenderFrameHost
*)>& on_frame
) override
;
215 void SendToAllFrames(IPC::Message
* message
) override
;
216 RenderViewHost
* GetRenderViewHost() const override
;
217 int GetRoutingID() const override
;
218 RenderWidgetHostView
* GetRenderWidgetHostView() const override
;
219 RenderWidgetHostView
* GetFullscreenRenderWidgetHostView() const override
;
220 WebUI
* CreateWebUI(const GURL
& url
) override
;
221 WebUI
* GetWebUI() const override
;
222 WebUI
* GetCommittedWebUI() const override
;
223 void SetUserAgentOverride(const std::string
& override
) override
;
224 const std::string
& GetUserAgentOverride() const override
;
225 void EnableTreeOnlyAccessibilityMode() override
;
226 bool IsTreeOnlyAccessibilityModeForTesting() const override
;
227 bool IsFullAccessibilityModeForTesting() const override
;
229 virtual void SetParentNativeViewAccessible(
230 gfx::NativeViewAccessible accessible_parent
) override
;
232 const base::string16
& GetTitle() const override
;
233 int32
GetMaxPageID() override
;
234 int32
GetMaxPageIDForSiteInstance(SiteInstance
* site_instance
) override
;
235 SiteInstanceImpl
* GetSiteInstance() const override
;
236 SiteInstanceImpl
* GetPendingSiteInstance() const override
;
237 bool IsLoading() const override
;
238 bool IsLoadingToDifferentDocument() const override
;
239 bool IsWaitingForResponse() const override
;
240 const net::LoadStateWithParam
& GetLoadState() const override
;
241 const base::string16
& GetLoadStateHost() const override
;
242 uint64
GetUploadSize() const override
;
243 uint64
GetUploadPosition() const override
;
244 std::set
<GURL
> GetSitesInTab() const override
;
245 const std::string
& GetEncoding() const override
;
246 bool DisplayedInsecureContent() const override
;
247 void IncrementCapturerCount(const gfx::Size
& capture_size
) override
;
248 void DecrementCapturerCount() override
;
249 int GetCapturerCount() const override
;
250 bool IsAudioMuted() const override
;
251 void SetAudioMuted(bool mute
) override
;
252 bool IsCrashed() const override
;
253 void SetIsCrashed(base::TerminationStatus status
, int error_code
) override
;
254 base::TerminationStatus
GetCrashedStatus() const override
;
255 bool IsBeingDestroyed() const override
;
256 void NotifyNavigationStateChanged(InvalidateTypes changed_flags
) override
;
257 base::TimeTicks
GetLastActiveTime() const override
;
258 void WasShown() override
;
259 void WasHidden() override
;
260 bool NeedToFireBeforeUnload() override
;
261 void DispatchBeforeUnload(bool for_cross_site_transition
) override
;
262 void Stop() override
;
263 WebContents
* Clone() override
;
264 void ReloadFocusedFrame(bool ignore_cache
) override
;
265 void Undo() override
;
266 void Redo() override
;
268 void Copy() override
;
269 void CopyToFindPboard() override
;
270 void Paste() override
;
271 void PasteAndMatchStyle() override
;
272 void Delete() override
;
273 void SelectAll() override
;
274 void Unselect() override
;
275 void Replace(const base::string16
& word
) override
;
276 void ReplaceMisspelling(const base::string16
& word
) override
;
277 void NotifyContextMenuClosed(
278 const CustomContextMenuContext
& context
) override
;
279 void ExecuteCustomContextMenuCommand(
281 const CustomContextMenuContext
& context
) override
;
282 gfx::NativeView
GetNativeView() override
;
283 gfx::NativeView
GetContentNativeView() override
;
284 gfx::NativeWindow
GetTopLevelNativeWindow() override
;
285 gfx::Rect
GetContainerBounds() override
;
286 gfx::Rect
GetViewBounds() override
;
287 DropData
* GetDropData() override
;
288 void Focus() override
;
289 void SetInitialFocus() override
;
290 void StoreFocus() override
;
291 void RestoreFocus() override
;
292 void FocusThroughTabTraversal(bool reverse
) override
;
293 bool ShowingInterstitialPage() const override
;
294 InterstitialPage
* GetInterstitialPage() const override
;
295 bool IsSavable() override
;
296 void OnSavePage() override
;
297 bool SavePage(const base::FilePath
& main_file
,
298 const base::FilePath
& dir_path
,
299 SavePageType save_type
) override
;
300 void SaveFrame(const GURL
& url
, const Referrer
& referrer
) override
;
301 void GenerateMHTML(const base::FilePath
& file
,
302 const base::Callback
<void(int64
)>& callback
) override
;
303 const std::string
& GetContentsMimeType() const override
;
304 bool WillNotifyDisconnection() const override
;
305 void SetOverrideEncoding(const std::string
& encoding
) override
;
306 void ResetOverrideEncoding() override
;
307 RendererPreferences
* GetMutableRendererPrefs() override
;
308 void Close() override
;
309 void SystemDragEnded() override
;
310 void UserGestureDone() override
;
311 void SetClosedByUserGesture(bool value
) override
;
312 bool GetClosedByUserGesture() const override
;
313 void ViewSource() override
;
314 void ViewFrameSource(const GURL
& url
, const PageState
& page_state
) override
;
315 int GetMinimumZoomPercent() const override
;
316 int GetMaximumZoomPercent() const override
;
317 gfx::Size
GetPreferredSize() const override
;
318 bool GotResponseToLockMouseRequest(bool allowed
) override
;
319 bool HasOpener() const override
;
320 WebContents
* GetOpener() const override
;
321 void DidChooseColorInColorChooser(SkColor color
) override
;
322 void DidEndColorChooser() override
;
323 int DownloadImage(const GURL
& url
,
325 uint32_t max_bitmap_size
,
326 const ImageDownloadCallback
& callback
) override
;
327 bool IsSubframe() const override
;
328 void Find(int request_id
,
329 const base::string16
& search_text
,
330 const blink::WebFindOptions
& options
) override
;
331 void StopFinding(StopFindAction action
) override
;
332 void InsertCSS(const std::string
& css
) override
;
333 bool WasRecentlyAudible() override
;
334 void GetManifest(const GetManifestCallback
&) override
;
335 #if defined(OS_ANDROID)
336 virtual base::android::ScopedJavaLocalRef
<jobject
> GetJavaWebContents()
338 virtual WebContentsAndroid
* GetWebContentsAndroid();
339 #elif defined(OS_MACOSX)
340 void SetAllowOtherViews(bool allow
) override
;
341 bool GetAllowOtherViews() override
;
344 // Implementation of PageNavigator.
345 WebContents
* OpenURL(const OpenURLParams
& params
) override
;
347 // Implementation of IPC::Sender.
348 bool Send(IPC::Message
* message
) override
;
350 // RenderFrameHostDelegate ---------------------------------------------------
351 bool OnMessageReceived(RenderFrameHost
* render_frame_host
,
352 const IPC::Message
& message
) override
;
353 const GURL
& GetMainFrameLastCommittedURL() const override
;
354 void RenderFrameCreated(RenderFrameHost
* render_frame_host
) override
;
355 void RenderFrameDeleted(RenderFrameHost
* render_frame_host
) override
;
356 void DidStartLoading(RenderFrameHost
* render_frame_host
,
357 bool to_different_document
) override
;
358 void DidStopLoading(RenderFrameHost
* render_frame_host
) override
;
359 void SwappedOut(RenderFrameHost
* render_frame_host
) override
;
360 void DidDeferAfterResponseStarted(
361 const TransitionLayerData
& transition_data
) override
;
362 bool WillHandleDeferAfterResponseStarted() override
;
363 void WorkerCrashed(RenderFrameHost
* render_frame_host
) override
;
364 void ShowContextMenu(RenderFrameHost
* render_frame_host
,
365 const ContextMenuParams
& params
) override
;
366 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 void RunBeforeUnloadConfirm(RenderFrameHost
* render_frame_host
,
373 const base::string16
& message
,
375 IPC::Message
* reply_msg
) override
;
376 void DidAccessInitialDocument() override
;
377 void DidDisownOpener(RenderFrameHost
* render_frame_host
) override
;
378 void DocumentOnLoadCompleted(RenderFrameHost
* render_frame_host
) override
;
379 void UpdateTitle(RenderFrameHost
* render_frame_host
,
381 const base::string16
& title
,
382 base::i18n::TextDirection title_direction
) override
;
383 void UpdateEncoding(RenderFrameHost
* render_frame_host
,
384 const std::string
& encoding
) override
;
385 WebContents
* GetAsWebContents() override
;
386 bool IsNeverVisible() override
;
387 AccessibilityMode
GetAccessibilityMode() const override
;
388 void AccessibilityEventReceived(
389 const std::vector
<AXEventNotificationDetails
>& details
) override
;
390 RenderFrameHost
* GetGuestByInstanceID(
391 int browser_plugin_instance_id
) override
;
392 GeolocationServiceContext
* GetGeolocationServiceContext() override
;
394 gfx::NativeViewAccessible
GetParentNativeViewAccessible() override
;
397 // RenderViewHostDelegate ----------------------------------------------------
398 RenderViewHostDelegateView
* GetDelegateView() override
;
399 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 gfx::Rect
GetRootWindowResizerRect() const override
;
405 void RenderViewCreated(RenderViewHost
* render_view_host
) override
;
406 void RenderViewReady(RenderViewHost
* render_view_host
) override
;
407 void RenderViewTerminated(RenderViewHost
* render_view_host
,
408 base::TerminationStatus status
,
409 int error_code
) override
;
410 void RenderViewDeleted(RenderViewHost
* render_view_host
) override
;
411 void UpdateState(RenderViewHost
* render_view_host
,
413 const PageState
& page_state
) override
;
414 void UpdateTargetURL(const GURL
& url
) override
;
415 void Close(RenderViewHost
* render_view_host
) override
;
416 void RequestMove(const gfx::Rect
& new_bounds
) override
;
417 void DidCancelLoading() override
;
418 void DocumentAvailableInMainFrame(RenderViewHost
* render_view_host
) override
;
419 void RouteCloseEvent(RenderViewHost
* rvh
) override
;
420 void RouteMessageEvent(RenderViewHost
* rvh
,
421 const ViewMsg_PostMessage_Params
& params
) override
;
422 bool AddMessageToConsole(int32 level
,
423 const base::string16
& message
,
425 const base::string16
& source_id
) override
;
426 RendererPreferences
GetRendererPrefs(
427 BrowserContext
* browser_context
) const override
;
428 WebPreferences
ComputeWebkitPrefs() override
;
429 void OnUserGesture() override
;
430 void OnIgnoredUIEvent() override
;
431 void RendererUnresponsive(RenderViewHost
* render_view_host
) override
;
432 void RendererResponsive(RenderViewHost
* render_view_host
) override
;
433 void LoadStateChanged(const GURL
& url
,
434 const net::LoadStateWithParam
& load_state
,
435 uint64 upload_position
,
436 uint64 upload_size
) override
;
437 void Activate() override
;
438 void Deactivate() override
;
439 void LostCapture() override
;
440 void HandleMouseDown() override
;
441 void HandleMouseUp() override
;
442 void HandlePointerActivate() override
;
443 void HandleGestureBegin() override
;
444 void HandleGestureEnd() override
;
445 void RunFileChooser(RenderViewHost
* render_view_host
,
446 const FileChooserParams
& params
) override
;
447 void ToggleFullscreenMode(bool enter_fullscreen
) override
;
448 bool IsFullscreenForCurrentTab() const override
;
449 void UpdatePreferredSize(const gfx::Size
& pref_size
) override
;
450 void ResizeDueToAutoResize(const gfx::Size
& new_size
) override
;
451 void RequestToLockMouse(bool user_gesture
,
452 bool last_unlocked_by_target
) override
;
453 void LostMouseLock() override
;
454 void CreateNewWindow(
455 int render_process_id
,
457 int main_frame_route_id
,
458 const ViewHostMsg_CreateWindow_Params
& params
,
459 SessionStorageNamespace
* session_storage_namespace
) override
;
460 void CreateNewWidget(int render_process_id
,
462 blink::WebPopupType popup_type
) override
;
463 void CreateNewFullscreenWidget(int render_process_id
, int route_id
) override
;
464 void ShowCreatedWindow(int route_id
,
465 WindowOpenDisposition disposition
,
466 const gfx::Rect
& initial_pos
,
467 bool user_gesture
) override
;
468 void ShowCreatedWidget(int route_id
, const gfx::Rect
& initial_pos
) override
;
469 void ShowCreatedFullscreenWidget(int route_id
) override
;
470 void RequestMediaAccessPermission(
471 const MediaStreamRequest
& request
,
472 const MediaResponseCallback
& callback
) override
;
473 bool CheckMediaAccessPermission(const GURL
& security_origin
,
474 MediaStreamType type
) override
;
475 SessionStorageNamespace
* GetSessionStorageNamespace(
476 SiteInstance
* instance
) override
;
477 SessionStorageNamespaceMap
GetSessionStorageNamespaceMap() override
;
478 FrameTree
* GetFrameTree() override
;
479 void SetIsVirtualKeyboardRequested(bool requested
) override
;
480 bool IsVirtualKeyboardRequested() override
;
483 // NavigatorDelegate ---------------------------------------------------------
485 void DidStartProvisionalLoad(RenderFrameHostImpl
* render_frame_host
,
486 const GURL
& validated_url
,
488 bool is_iframe_srcdoc
) override
;
489 void DidStartNavigationTransition(
490 RenderFrameHostImpl
* render_frame_host
) override
;
491 void DidFailProvisionalLoadWithError(
492 RenderFrameHostImpl
* render_frame_host
,
493 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
)
495 void DidFailLoadWithError(RenderFrameHostImpl
* render_frame_host
,
498 const base::string16
& error_description
) override
;
499 void DidCommitProvisionalLoad(RenderFrameHostImpl
* render_frame_host
,
501 ui::PageTransition transition_type
) override
;
502 void DidNavigateMainFramePreCommit(bool navigation_is_within_page
) override
;
503 void DidNavigateMainFramePostCommit(
504 const LoadCommittedDetails
& details
,
505 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) override
;
506 void DidNavigateAnyFramePostCommit(
507 RenderFrameHostImpl
* render_frame_host
,
508 const LoadCommittedDetails
& details
,
509 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) override
;
510 void SetMainFrameMimeType(const std::string
& mime_type
) override
;
511 bool CanOverscrollContent() const override
;
512 void NotifyChangedNavigationState(InvalidateTypes changed_flags
) override
;
513 void AboutToNavigateRenderFrame(
514 RenderFrameHostImpl
* render_frame_host
) override
;
515 void DidStartNavigationToPendingEntry(
516 RenderFrameHostImpl
* render_frame_host
,
518 NavigationController::ReloadType reload_type
) override
;
519 void RequestOpenURL(RenderFrameHostImpl
* render_frame_host
,
520 const OpenURLParams
& params
) override
;
521 bool ShouldPreserveAbortedURLs() override
;
523 // RenderWidgetHostDelegate --------------------------------------------------
525 void RenderWidgetDeleted(RenderWidgetHostImpl
* render_widget_host
) override
;
526 void RenderWidgetGotFocus(RenderWidgetHostImpl
* render_widget_host
) override
;
527 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent
& event
,
528 bool* is_keyboard_shortcut
) override
;
529 void HandleKeyboardEvent(const NativeWebKeyboardEvent
& event
) override
;
530 bool HandleWheelEvent(const blink::WebMouseWheelEvent
& event
) override
;
531 bool PreHandleGestureEvent(const blink::WebGestureEvent
& event
) override
;
532 bool HandleGestureEvent(const blink::WebGestureEvent
& event
) override
;
533 void DidSendScreenRects(RenderWidgetHostImpl
* rwh
) override
;
534 BrowserAccessibilityManager
* GetRootBrowserAccessibilityManager() override
;
535 BrowserAccessibilityManager
* GetOrCreateRootBrowserAccessibilityManager()
538 // RenderFrameHostManager::Delegate ------------------------------------------
540 bool CreateRenderViewForRenderManager(
541 RenderViewHost
* render_view_host
,
543 int proxy_routing_id
,
544 bool for_main_frame_navigation
) override
;
545 bool CreateRenderFrameForRenderManager(RenderFrameHost
* render_frame_host
,
546 int parent_routing_id
,
547 int proxy_routing_id
) override
;
548 void BeforeUnloadFiredFromRenderManager(
550 const base::TimeTicks
& proceed_time
,
551 bool* proceed_to_fire_unload
) override
;
552 void RenderProcessGoneFromRenderManager(
553 RenderViewHost
* render_view_host
) override
;
554 void UpdateRenderViewSizeForRenderManager() override
;
555 void CancelModalDialogsForRenderManager() override
;
556 void NotifySwappedFromRenderManager(RenderFrameHost
* old_host
,
557 RenderFrameHost
* new_host
,
558 bool is_main_frame
) override
;
559 int CreateOpenerRenderViewsForRenderManager(SiteInstance
* instance
) override
;
560 NavigationControllerImpl
& GetControllerForRenderManager() override
;
561 scoped_ptr
<WebUIImpl
> CreateWebUIForRenderManager(const GURL
& url
) override
;
562 NavigationEntry
* GetLastCommittedNavigationEntryForRenderManager() override
;
563 bool FocusLocationBarByDefault() override
;
564 void SetFocusToLocationBar(bool select_all
) override
;
565 bool IsHidden() override
;
567 // NotificationObserver ------------------------------------------------------
569 void Observe(int type
,
570 const NotificationSource
& source
,
571 const NotificationDetails
& details
) override
;
573 // NavigationControllerDelegate ----------------------------------------------
575 WebContents
* GetWebContents() override
;
576 void NotifyNavigationEntryCommitted(
577 const LoadCommittedDetails
& load_details
) override
;
579 // Invoked before a form repost warning is shown.
580 void NotifyBeforeFormRepostWarningShow() override
;
582 // Activate this WebContents and show a form repost warning.
583 void ActivateAndShowRepostFormWarningDialog() override
;
585 // Whether the initial empty page of this view has been accessed by another
586 // page, making it unsafe to show the pending URL. Always false after the
588 bool HasAccessedInitialDocument() override
;
590 // Updates the max page ID for the current SiteInstance in this
591 // WebContentsImpl to be at least |page_id|.
592 void UpdateMaxPageID(int32 page_id
) override
;
594 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
595 // to be at least |page_id|.
596 void UpdateMaxPageIDForSiteInstance(SiteInstance
* site_instance
,
597 int32 page_id
) override
;
599 // Copy the current map of SiteInstance ID to max page ID from another tab.
600 // This is necessary when this tab adopts the NavigationEntries from
602 void CopyMaxPageIDsFrom(WebContents
* web_contents
) override
;
604 // Called by the NavigationController to cause the WebContentsImpl to navigate
605 // to the current pending entry. The NavigationController should be called
606 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
607 // The callbacks can be inside of this function, or at some future time.
609 // The entry has a PageID of -1 if newly created (corresponding to navigation
612 // If this method returns false, then the navigation is discarded (equivalent
613 // to calling DiscardPendingEntry on the NavigationController).
614 bool NavigateToPendingEntry(
615 NavigationController::ReloadType reload_type
) override
;
617 // Sets the history for this WebContentsImpl to |history_length| entries, with
618 // an offset of |history_offset|.
619 void SetHistoryOffsetAndLength(int history_offset
,
620 int history_length
) override
;
622 // Called by InterstitialPageImpl when it creates a RenderFrameHost.
623 void RenderFrameForInterstitialPageCreated(
624 RenderFrameHost
* render_frame_host
) override
;
626 // Sets the passed interstitial as the currently showing interstitial.
627 // No interstitial page should already be attached.
628 void AttachInterstitialPage(InterstitialPageImpl
* interstitial_page
) override
;
630 // Unsets the currently showing interstitial.
631 void DetachInterstitialPage() override
;
633 // Changes the IsLoading state and notifies the delegate as needed.
634 // |details| is used to provide details on the load that just finished
635 // (but can be null if not applicable).
636 void SetIsLoading(RenderViewHost
* render_view_host
,
638 bool to_different_document
,
639 LoadNotificationDetails
* details
) override
;
641 typedef base::Callback
<void(WebContents
*)> CreatedCallback
;
643 // Requests the renderer to move the selection extent to a new position.
644 void MoveRangeSelectionExtent(const gfx::Point
& extent
);
646 // Requests the renderer to select the region between two points in the
647 // currently focused frame.
648 void SelectRange(const gfx::Point
& base
, const gfx::Point
& extent
);
650 // Notifies the main frame that it can continue navigation (if it was deferred
651 // immediately at first response).
652 void ResumeResponseDeferredAtStart();
654 // Forces overscroll to be disabled (used by touch emulation).
655 void SetForceDisableOverscrollContent(bool force_disable
);
657 AudioStreamMonitor
* audio_stream_monitor() {
658 return &audio_stream_monitor_
;
661 bool has_audio_power_save_blocker_for_testing() const {
662 return audio_power_save_blocker_
;
665 bool has_video_power_save_blocker_for_testing() const {
666 return video_power_save_blocker_
;
670 friend class WebContentsObserver
;
671 friend class WebContents
; // To implement factory methods.
673 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, NoJSMessageOnInterstitials
);
674 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, UpdateTitle
);
675 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, FindOpenerRVHWhenPending
);
676 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
,
677 CrossSiteCantPreemptAfterUnload
);
678 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, PendingContents
);
679 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, FrameTreeShape
);
680 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, GetLastActiveTime
);
681 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest
, HTMLFiles
);
682 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest
, HistoryNavigate
);
683 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest
, PageDoesBackAndReload
);
684 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest
, CrossSiteIframe
);
685 FRIEND_TEST_ALL_PREFIXES(SitePerProcessAccessibilityBrowserTest
,
686 CrossSiteIframeAccessibility
);
688 // So InterstitialPageImpl can access SetIsLoading.
689 friend class InterstitialPageImpl
;
691 // TODO(brettw) TestWebContents shouldn't exist!
692 friend class TestWebContents
;
694 class DestructionObserver
;
696 // See WebContents::Create for a description of these parameters.
697 WebContentsImpl(BrowserContext
* browser_context
,
698 WebContentsImpl
* opener
);
700 // Add and remove observers for page navigation notifications. The order in
701 // which notifications are sent to observers is undefined. Clients must be
702 // sure to remove the observer before they go away.
703 void AddObserver(WebContentsObserver
* observer
);
704 void RemoveObserver(WebContentsObserver
* observer
);
706 // Clears this tab's opener if it has been closed.
707 void OnWebContentsDestroyed(WebContentsImpl
* web_contents
);
709 // Creates and adds to the map a destruction observer watching |web_contents|.
710 // No-op if such an observer already exists.
711 void AddDestructionObserver(WebContentsImpl
* web_contents
);
713 // Deletes and removes from the map a destruction observer
714 // watching |web_contents|. No-op if there is no such observer.
715 void RemoveDestructionObserver(WebContentsImpl
* web_contents
);
717 // Traverses all the RenderFrameHosts in the FrameTree and creates a set
718 // all the unique RenderWidgetHostViews.
719 std::set
<RenderWidgetHostView
*> GetRenderWidgetHostViewsInTree();
721 // Callback function when showing JavaScript dialogs. Takes in a routing ID
722 // pair to identify the RenderFrameHost that opened the dialog, because it's
723 // possible for the RenderFrameHost to be deleted by the time this is called.
724 void OnDialogClosed(int render_process_id
,
726 IPC::Message
* reply_msg
,
727 bool dialog_was_suppressed
,
729 const base::string16
& user_input
);
731 bool OnMessageReceived(RenderViewHost
* render_view_host
,
732 RenderFrameHost
* render_frame_host
,
733 const IPC::Message
& message
);
735 // IPC message handlers.
736 void OnThemeColorChanged(SkColor theme_color
);
737 void OnDidLoadResourceFromMemoryCache(const GURL
& url
,
738 const std::string
& security_info
,
739 const std::string
& http_request
,
740 const std::string
& mime_type
,
741 ResourceType resource_type
);
742 void OnDidDisplayInsecureContent();
743 void OnDidRunInsecureContent(const std::string
& security_origin
,
744 const GURL
& target_url
);
745 void OnDocumentLoadedInFrame();
746 void OnDidFinishLoad(const GURL
& url
);
747 void OnDidStartLoading(bool to_different_document
);
748 void OnDidStopLoading();
749 void OnDidChangeLoadProgress(double load_progress
);
750 void OnGoToEntryAtOffset(int offset
);
751 void OnUpdateZoomLimits(int minimum_percent
,
752 int maximum_percent
);
753 void OnEnumerateDirectory(int request_id
, const base::FilePath
& path
);
755 void OnRegisterProtocolHandler(const std::string
& protocol
,
757 const base::string16
& title
,
759 void OnUnregisterProtocolHandler(const std::string
& protocol
,
762 void OnFindReply(int request_id
,
763 int number_of_matches
,
764 const gfx::Rect
& selection_rect
,
765 int active_match_ordinal
,
767 #if defined(OS_ANDROID)
768 void OnFindMatchRectsReply(int version
,
769 const std::vector
<gfx::RectF
>& rects
,
770 const gfx::RectF
& active_rect
);
772 void OnOpenDateTimeDialog(
773 const ViewHostMsg_DateTimeDialogValue_Params
& value
);
775 void OnDomOperationResponse(const std::string
& json_string
,
777 void OnAppCacheAccessed(const GURL
& manifest_url
, bool blocked_by_policy
);
778 void OnOpenColorChooser(int color_chooser_id
,
780 const std::vector
<ColorSuggestion
>& suggestions
);
781 void OnEndColorChooser(int color_chooser_id
);
782 void OnSetSelectedColorInColorChooser(int color_chooser_id
, SkColor color
);
783 void OnWebUISend(const GURL
& source_url
,
784 const std::string
& name
,
785 const base::ListValue
& args
);
786 #if defined(ENABLE_PLUGINS)
787 void OnPepperPluginHung(int plugin_child_id
,
788 const base::FilePath
& path
,
790 void OnPluginCrashed(const base::FilePath
& plugin_path
,
791 base::ProcessId plugin_pid
);
792 void OnRequestPpapiBrokerPermission(int routing_id
,
794 const base::FilePath
& plugin_path
);
796 // Callback function when requesting permission to access the PPAPI broker.
797 // |result| is true if permission was granted.
798 void OnPpapiBrokerPermissionResult(int routing_id
, bool result
);
800 void OnBrowserPluginMessage(const IPC::Message
& message
);
801 #endif // defined(ENABLE_PLUGINS)
802 void OnDidDownloadImage(int id
,
803 int http_status_code
,
804 const GURL
& image_url
,
805 const std::vector
<SkBitmap
>& bitmaps
,
806 const std::vector
<gfx::Size
>& original_bitmap_sizes
);
807 void OnUpdateFaviconURL(const std::vector
<FaviconURL
>& candidates
);
808 void OnFirstVisuallyNonEmptyPaint();
809 void OnMediaPlayingNotification(int64 player_cookie
,
813 void OnMediaPausedNotification(int64 player_cookie
);
814 void OnShowValidationMessage(const gfx::Rect
& anchor_in_root_view
,
815 const base::string16
& main_text
,
816 const base::string16
& sub_text
);
817 void OnHideValidationMessage();
818 void OnMoveValidationMessage(const gfx::Rect
& anchor_in_root_view
);
820 // Called by derived classes to indicate that we're no longer waiting for a
821 // response. This won't actually update the throbber, but it will get picked
822 // up at the next animation step if the throbber is going.
823 void SetNotWaitingForResponse() { waiting_for_response_
= false; }
825 // Navigation helpers --------------------------------------------------------
827 // These functions are helpers for Navigate() and DidNavigate().
829 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
830 // committed to the navigation controller. Note that the navigation entry is
831 // not provided since it may be invalid/changed after being committed. The
832 // current navigation entry is in the NavigationController at this point.
834 // If our controller was restored, update the max page ID associated with the
835 // given RenderViewHost to be larger than the number of restored entries.
836 // This is called in CreateRenderView before any navigations in the RenderView
837 // have begun, to prevent any races in updating RenderView::next_page_id.
838 void UpdateMaxPageIDIfNecessary(RenderViewHost
* rvh
);
840 // Saves the given title to the navigation entry and does associated work. It
841 // will update history and the view for the new title, and also synthesize
842 // titles for file URLs that have none (so we require that the URL of the
843 // entry already be set).
845 // This is used as the backend for state updates, which include a new title,
846 // or the dedicated set title message. It returns true if the new title is
847 // different and was therefore updated.
848 bool UpdateTitleForEntry(NavigationEntryImpl
* entry
,
849 const base::string16
& title
);
851 // Recursively creates swapped out RenderViews for this tab's opener chain
852 // (including this tab) in the given SiteInstance, allowing other tabs to send
853 // cross-process JavaScript calls to their opener(s). Returns the route ID of
854 // this tab's RenderView for |instance|.
855 int CreateOpenerRenderViews(SiteInstance
* instance
);
857 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
858 void CreateNewWidget(int render_process_id
,
861 blink::WebPopupType popup_type
);
863 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
864 void ShowCreatedWidget(int route_id
,
866 const gfx::Rect
& initial_pos
);
868 // Finds the new RenderWidgetHost and returns it. Note that this can only be
869 // called once as this call also removes it from the internal map.
870 RenderWidgetHostView
* GetCreatedWidget(int route_id
);
872 // Finds the new WebContentsImpl by route_id, initializes it for
873 // renderer-initiated creation, and returns it. Note that this can only be
874 // called once as this call also removes it from the internal map.
875 WebContentsImpl
* GetCreatedWindow(int route_id
);
877 // Tracking loading progress -------------------------------------------------
879 // Resets the tracking state of the current load.
880 void ResetLoadProgressState();
882 // Calculates the progress of the current load and notifies the delegate.
883 void SendLoadProgressChanged();
885 // Misc non-view stuff -------------------------------------------------------
887 // Sets the history for a specified RenderViewHost to |history_length|
888 // entries, with an offset of |history_offset|.
889 void SetHistoryOffsetAndLengthForView(RenderViewHost
* render_view_host
,
893 // Helper functions for sending notifications.
894 void NotifyViewSwapped(RenderViewHost
* old_host
, RenderViewHost
* new_host
);
895 void NotifyFrameSwapped(RenderFrameHost
* old_host
, RenderFrameHost
* new_host
);
896 void NotifyDisconnected();
898 void SetEncoding(const std::string
& encoding
);
900 // TODO(creis): This should take in a FrameTreeNode to know which node's
901 // render manager to return. For now, we just return the root's.
902 RenderFrameHostManager
* GetRenderManager() const;
904 RenderViewHostImpl
* GetRenderViewHostImpl();
906 // Removes browser plugin embedder if there is one.
907 void RemoveBrowserPluginEmbedder();
909 // Clear |render_frame_host|'s tracking entry for its power save blockers.
910 void ClearPowerSaveBlockers(RenderFrameHost
* render_frame_host
);
912 // Clear tracking entries for all RenderFrameHosts, clears
913 // |audio_power_save_blocker_| and |video_power_save_blocker_|.
914 void ClearAllPowerSaveBlockers();
916 // Creates an audio or video power save blocker respectively.
917 void CreateAudioPowerSaveBlocker();
918 void CreateVideoPowerSaveBlocker();
920 // Releases the audio power save blockers if |active_audio_players_| is empty.
921 // Likewise, releases the video power save blockers if |active_video_players_|
923 void MaybeReleasePowerSaveBlockers();
925 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
926 gfx::Size
GetSizeForNewRenderView();
928 void OnFrameRemoved(RenderFrameHost
* render_frame_host
);
930 // Helper method that's called whenever |preferred_size_| or
931 // |preferred_size_for_capture_| changes, to propagate the new value to the
933 void OnPreferredSizeChanged(const gfx::Size
& old_size
);
935 // Helper methods for adding or removing player entries in |player_map| under
936 // the key |render_frame_message_source_|.
937 typedef std::vector
<int64
> PlayerList
;
938 typedef std::map
<uintptr_t, PlayerList
> ActiveMediaPlayerMap
;
939 void AddMediaPlayerEntry(int64 player_cookie
,
940 ActiveMediaPlayerMap
* player_map
);
941 void RemoveMediaPlayerEntry(int64 player_cookie
,
942 ActiveMediaPlayerMap
* player_map
);
943 // Removes all entries from |player_map| for |render_frame_host|.
944 void RemoveAllMediaPlayerEntries(RenderFrameHost
* render_frame_host
,
945 ActiveMediaPlayerMap
* player_map
);
947 // Data for core operation ---------------------------------------------------
949 // Delegate for notifying our owner about stuff. Not owned by us.
950 WebContentsDelegate
* delegate_
;
952 // Handles the back/forward list and loading.
953 NavigationControllerImpl controller_
;
955 // The corresponding view.
956 scoped_ptr
<WebContentsView
> view_
;
958 // The view of the RVHD. Usually this is our WebContentsView implementation,
959 // but if an embedder uses a different WebContentsView, they'll need to
961 RenderViewHostDelegateView
* render_view_host_delegate_view_
;
963 // Tracks created WebContentsImpl objects that have not been shown yet. They
964 // are identified by the route ID passed to CreateNewWindow.
965 typedef std::map
<int, WebContentsImpl
*> PendingContents
;
966 PendingContents pending_contents_
;
968 // These maps hold on to the widgets that we created on behalf of the renderer
969 // that haven't shown yet.
970 typedef std::map
<int, RenderWidgetHostView
*> PendingWidgetViews
;
971 PendingWidgetViews pending_widget_views_
;
973 typedef std::map
<WebContentsImpl
*, DestructionObserver
*> DestructionObservers
;
974 DestructionObservers destruction_observers_
;
976 // A list of observers notified when page state changes. Weak references.
977 // This MUST be listed above frame_tree_ since at destruction time the
978 // latter might cause RenderViewHost's destructor to call us and we might use
979 // the observer list then.
980 ObserverList
<WebContentsObserver
> observers_
;
982 // The tab that opened this tab, if any. Will be set to null if the opener
984 WebContentsImpl
* opener_
;
986 // True if this tab was opened by another tab. This is not unset if the opener
988 bool created_with_opener_
;
991 gfx::NativeViewAccessible accessible_parent_
;
994 // Helper classes ------------------------------------------------------------
996 // Tracking variables and associated power save blockers for media playback.
997 ActiveMediaPlayerMap active_audio_players_
;
998 ActiveMediaPlayerMap active_video_players_
;
999 scoped_ptr
<PowerSaveBlocker
> audio_power_save_blocker_
;
1000 scoped_ptr
<PowerSaveBlocker
> video_power_save_blocker_
;
1002 // Manages the frame tree of the page and process swaps in each node.
1003 FrameTree frame_tree_
;
1005 // SavePackage, lazily created.
1006 scoped_refptr
<SavePackage
> save_package_
;
1008 // Data for loading state ----------------------------------------------------
1010 // Indicates whether we're currently loading a resource.
1013 // Indicates whether the current load is to a different document. Only valid
1014 // if is_loading_ is true.
1015 bool is_load_to_different_document_
;
1017 // Indicates if the tab is considered crashed.
1018 base::TerminationStatus crashed_status_
;
1019 int crashed_error_code_
;
1021 // Whether this WebContents is waiting for a first-response for the
1022 // main resource of the page. This controls whether the throbber state is
1023 // "waiting" or "loading."
1024 bool waiting_for_response_
;
1026 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
1027 // to a given tab and SiteInstance, and must be valid for the lifetime of the
1029 std::map
<int32
, int32
> max_page_ids_
;
1031 // The current load state and the URL associated with it.
1032 net::LoadStateWithParam load_state_
;
1033 base::string16 load_state_host_
;
1035 // LoadingProgressMap maps FrameTreeNode IDs to a double representing that
1036 // frame's completion (from 0 to 1).
1037 typedef base::hash_map
<int64
, double> LoadingProgressMap
;
1038 LoadingProgressMap loading_progresses_
;
1039 double loading_total_progress_
;
1041 base::TimeTicks loading_last_progress_update_
;
1043 // Counter to track how many frames have sent start notifications but not
1044 // stop notifications.
1045 int loading_frames_in_progress_
;
1047 // Upload progress, for displaying in the status bar.
1048 // Set to zero when there is no significant upload happening.
1049 uint64 upload_size_
;
1050 uint64 upload_position_
;
1052 // Data for current page -----------------------------------------------------
1054 // When a title cannot be taken from any entry, this title will be used.
1055 base::string16 page_title_when_no_navigation_entry_
;
1057 // When a navigation occurs, we record its contents MIME type. It can be
1058 // used to check whether we can do something for some special contents.
1059 std::string contents_mime_type_
;
1061 // The last reported character encoding, not canonicalized.
1062 std::string last_reported_encoding_
;
1064 // The canonicalized character encoding.
1065 std::string canonical_encoding_
;
1067 // True if this is a secure page which displayed insecure content.
1068 bool displayed_insecure_content_
;
1070 // Whether the initial empty page has been accessed by another page, making it
1071 // unsafe to show the pending URL. Usually false unless another window tries
1072 // to modify the blank page. Always false after the first commit.
1073 bool has_accessed_initial_document_
;
1075 // Data for misc internal state ----------------------------------------------
1077 // When > 0, the WebContents is currently being captured (e.g., for
1078 // screenshots or mirroring); and the underlying RenderWidgetHost should not
1079 // be told it is hidden.
1080 int capturer_count_
;
1082 // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
1083 bool should_normally_be_visible_
;
1085 // See getter above.
1086 bool is_being_destroyed_
;
1088 // Indicates whether we should notify about disconnection of this
1089 // WebContentsImpl. This is used to ensure disconnection notifications only
1090 // happen if a connection notification has happened and that they happen only
1092 bool notify_disconnection_
;
1094 // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
1095 // delegate of this WebContentsImpl is nulled before its destructor is called.
1096 JavaScriptDialogManager
* dialog_manager_
;
1098 // Set to true when there is an active "before unload" dialog. When true,
1099 // we've forced the throbber to start in Navigate, and we need to remember to
1100 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
1101 bool is_showing_before_unload_dialog_
;
1103 // Settings that get passed to the renderer process.
1104 RendererPreferences renderer_preferences_
;
1106 // The time that this WebContents was last made active. The initial value is
1107 // the WebContents creation time.
1108 base::TimeTicks last_active_time_
;
1110 // See description above setter.
1111 bool closed_by_user_gesture_
;
1113 // Minimum/maximum zoom percent.
1114 int minimum_zoom_percent_
;
1115 int maximum_zoom_percent_
;
1117 // The raw accumulated zoom value and the actual zoom increments made for an
1118 // an in-progress pinch gesture.
1119 float totalPinchGestureAmount_
;
1120 int currentPinchZoomStepDelta_
;
1122 // The intrinsic size of the page.
1123 gfx::Size preferred_size_
;
1125 // The preferred size for content screen capture. When |capturer_count_| > 0,
1126 // this overrides |preferred_size_|.
1127 gfx::Size preferred_size_for_capture_
;
1129 #if defined(OS_ANDROID)
1130 // Date time chooser opened by this tab.
1131 // Only used in Android since all other platforms use a multi field UI.
1132 scoped_ptr
<DateTimeChooserAndroid
> date_time_chooser_
;
1135 // Holds information about a current color chooser dialog, if one is visible.
1136 struct ColorChooserInfo
{
1137 ColorChooserInfo(int render_process_id
,
1138 int render_frame_id
,
1139 ColorChooser
* chooser
,
1141 ~ColorChooserInfo();
1143 int render_process_id
;
1144 int render_frame_id
;
1146 // Color chooser that was opened by this tab.
1147 scoped_ptr
<ColorChooser
> chooser
;
1149 // A unique identifier for the current color chooser. Identifiers are
1150 // unique across a renderer process. This avoids race conditions in
1151 // synchronizing the browser and renderer processes. For example, if a
1152 // renderer closes one chooser and opens another, and simultaneously the
1153 // user picks a color in the first chooser, the IDs can be used to drop the
1154 // "chose a color" message rather than erroneously tell the renderer that
1155 // the user picked a color in the second chooser.
1159 scoped_ptr
<ColorChooserInfo
> color_chooser_info_
;
1161 // Manages the embedder state for browser plugins, if this WebContents is an
1162 // embedder; NULL otherwise.
1163 scoped_ptr
<BrowserPluginEmbedder
> browser_plugin_embedder_
;
1164 // Manages the guest state for browser plugin, if this WebContents is a guest;
1166 scoped_ptr
<BrowserPluginGuest
> browser_plugin_guest_
;
1168 #if defined(ENABLE_PLUGINS)
1169 // Manages the whitelist of plugin content origins exempt from power saving.
1170 scoped_ptr
<PluginContentOriginWhitelist
> plugin_content_origin_whitelist_
;
1173 // This must be at the end, or else we might get notifications and use other
1174 // member variables that are gone.
1175 NotificationRegistrar registrar_
;
1177 // Used during IPC message dispatching from the RenderView/RenderFrame so that
1178 // the handlers can get a pointer to the RVH through which the message was
1180 RenderViewHost
* render_view_message_source_
;
1181 RenderFrameHost
* render_frame_message_source_
;
1183 // All live RenderWidgetHostImpls that are created by this object and may
1185 std::set
<RenderWidgetHostImpl
*> created_widgets_
;
1187 // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1188 int fullscreen_widget_routing_id_
;
1190 // At the time the fullscreen widget was being shut down, did it have focus?
1191 // This is used to restore focus to the WebContentsView after both: 1) the
1192 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has
1193 // completed making layout changes to effect an exit from fullscreen mode.
1194 bool fullscreen_widget_had_focus_at_shutdown_
;
1196 // Maps the ids of pending image downloads to their callbacks
1197 typedef std::map
<int, ImageDownloadCallback
> ImageDownloadMap
;
1198 ImageDownloadMap image_download_map_
;
1200 // Whether this WebContents is responsible for displaying a subframe in a
1201 // different process from its parent page.
1204 // Whether overscroll should be unconditionally disabled.
1205 bool force_disable_overscroll_content_
;
1207 // Whether the last JavaScript dialog shown was suppressed. Used for testing.
1208 bool last_dialog_suppressed_
;
1210 scoped_ptr
<GeolocationServiceContext
> geolocation_service_context_
;
1212 scoped_ptr
<ScreenOrientationDispatcherHost
>
1213 screen_orientation_dispatcher_host_
;
1215 scoped_ptr
<ManifestManagerHost
> manifest_manager_host_
;
1217 // The accessibility mode for all frames. This is queried when each frame
1218 // is created, and broadcast to all frames when it changes.
1219 AccessibilityMode accessibility_mode_
;
1221 // Monitors power levels for audio streams associated with this WebContents.
1222 AudioStreamMonitor audio_stream_monitor_
;
1224 // Created on-demand to mute all audio output from this WebContents.
1225 scoped_ptr
<WebContentsAudioMuter
> audio_muter_
;
1227 bool virtual_keyboard_requested_
;
1229 base::WeakPtrFactory
<WebContentsImpl
> loading_weak_factory_
;
1231 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl
);
1234 // Dangerous methods which should never be made part of the public API, so we
1235 // grant their use only to an explicit friend list (c++ attorney/client idiom).
1236 class CONTENT_EXPORT
WebContentsImpl::FriendZone
{
1238 friend class TestNavigationObserver
;
1239 friend class WebContentsAddedObserver
;
1240 friend class ContentBrowserSanityChecker
;
1242 FriendZone(); // Not instantiable.
1244 // Adds/removes a callback called on creation of each new WebContents.
1245 static void AddCreatedCallbackForTesting(const CreatedCallback
& callback
);
1246 static void RemoveCreatedCallbackForTesting(const CreatedCallback
& callback
);
1248 DISALLOW_COPY_AND_ASSIGN(FriendZone
);
1251 } // namespace content
1253 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_