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_state_provider.h"
26 #include "content/browser/renderer_host/render_view_host_delegate.h"
27 #include "content/browser/renderer_host/render_view_host_impl.h"
28 #include "content/browser/renderer_host/render_widget_host_delegate.h"
29 #include "content/common/accessibility_mode_enums.h"
30 #include "content/common/content_export.h"
31 #include "content/public/browser/color_chooser.h"
32 #include "content/public/browser/notification_observer.h"
33 #include "content/public/browser/notification_registrar.h"
34 #include "content/public/browser/web_contents.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/base/page_transition_types.h"
42 #include "ui/gfx/geometry/rect_f.h"
43 #include "ui/gfx/geometry/size.h"
45 struct BrowserPluginHostMsg_ResizeGuest_Params
;
46 struct ViewHostMsg_DateTimeDialogValue_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 MediaWebContentsObserver
;
59 class PluginContentOriginWhitelist
;
60 class PowerSaveBlocker
;
62 class RenderViewHostDelegateView
;
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 // Creates a BrowserPluginEmbedder object for this WebContents if one doesn't
157 void CreateBrowserPluginEmbedderIfNecessary();
159 // Gets the current fullscreen render widget's routing ID. Returns
160 // MSG_ROUTING_NONE when there is no fullscreen render widget.
161 int GetFullscreenWidgetRoutingID() const;
163 // Invoked when visible SSL state (as defined by SSLStatus) changes.
164 void DidChangeVisibleSSLState();
166 // Informs the render view host and the BrowserPluginEmbedder, if present, of
167 // a Drag Source End.
168 void DragSourceEndedAt(int client_x
, int client_y
, int screen_x
,
169 int screen_y
, blink::WebDragOperation operation
);
171 // A response has been received for a resource request.
172 void DidGetResourceResponseStart(
173 const ResourceRequestDetails
& details
);
175 // A redirect was received while requesting a resource.
176 void DidGetRedirectForResourceRequest(
177 RenderFrameHost
* render_frame_host
,
178 const ResourceRedirectDetails
& details
);
180 // Notify observers that the web contents has been focused.
181 void NotifyWebContentsFocused();
183 WebContentsView
* GetView() const;
185 ScreenOrientationDispatcherHost
* screen_orientation_dispatcher_host() {
186 return screen_orientation_dispatcher_host_
.get();
189 bool should_normally_be_visible() { return should_normally_be_visible_
; }
191 // Indicate if the window has been occluded, and pass this to the views, only
192 // if there is no active capture going on (otherwise it is dropped on the
195 void WasUnOccluded();
197 // Broadcasts the mode change to all frames.
198 void SetAccessibilityMode(AccessibilityMode mode
);
200 // Adds the given accessibility mode to the current accessibility mode
202 void AddAccessibilityMode(AccessibilityMode mode
);
204 // Removes the given accessibility mode from the current accessibility
205 // mode bitmap, managing the bits that are shared with other modes such
206 // that a bit will only be turned off when all modes that depend on it
207 // have been removed.
208 void RemoveAccessibilityMode(AccessibilityMode mode
);
210 // Request a one-time snapshot of the accessibility tree without changing
211 // the accessibility mode.
212 typedef base::Callback
<void(const ui::AXTreeUpdate
&)>
213 AXTreeSnapshotCallback
;
214 void RequestAXTreeSnapshot(AXTreeSnapshotCallback callback
);
216 // Clear the navigation transition data when the user navigates back to Chrome
217 // from a native app.
218 void ClearNavigationTransitionData();
220 // WebContents ------------------------------------------------------
221 WebContentsDelegate
* GetDelegate() override
;
222 void SetDelegate(WebContentsDelegate
* delegate
) override
;
223 NavigationControllerImpl
& GetController() override
;
224 const NavigationControllerImpl
& GetController() const override
;
225 BrowserContext
* GetBrowserContext() const override
;
226 const GURL
& GetURL() const override
;
227 const GURL
& GetVisibleURL() const override
;
228 const GURL
& GetLastCommittedURL() const override
;
229 RenderProcessHost
* GetRenderProcessHost() const override
;
230 RenderFrameHostImpl
* GetMainFrame() override
;
231 RenderFrameHostImpl
* GetFocusedFrame() override
;
233 const base::Callback
<void(RenderFrameHost
*)>& on_frame
) override
;
234 void SendToAllFrames(IPC::Message
* message
) override
;
235 RenderViewHostImpl
* GetRenderViewHost() const override
;
236 int GetRoutingID() const override
;
237 RenderWidgetHostView
* GetRenderWidgetHostView() const override
;
238 RenderWidgetHostView
* GetFullscreenRenderWidgetHostView() const override
;
239 SkColor
GetThemeColor() const override
;
240 WebUI
* CreateWebUI(const GURL
& url
) override
;
241 WebUI
* GetWebUI() const override
;
242 WebUI
* GetCommittedWebUI() const override
;
243 void SetUserAgentOverride(const std::string
& override
) override
;
244 const std::string
& GetUserAgentOverride() const override
;
245 void EnableTreeOnlyAccessibilityMode() override
;
246 bool IsTreeOnlyAccessibilityModeForTesting() const override
;
247 bool IsFullAccessibilityModeForTesting() const override
;
249 void SetParentNativeViewAccessible(
250 gfx::NativeViewAccessible accessible_parent
) override
;
252 const base::string16
& GetTitle() const override
;
253 int32
GetMaxPageID() override
;
254 int32
GetMaxPageIDForSiteInstance(SiteInstance
* site_instance
) override
;
255 SiteInstanceImpl
* GetSiteInstance() const override
;
256 SiteInstanceImpl
* GetPendingSiteInstance() const override
;
257 bool IsLoading() const override
;
258 bool IsLoadingToDifferentDocument() const override
;
259 bool IsWaitingForResponse() const override
;
260 const net::LoadStateWithParam
& GetLoadState() const override
;
261 const base::string16
& GetLoadStateHost() const override
;
262 uint64
GetUploadSize() const override
;
263 uint64
GetUploadPosition() const override
;
264 std::set
<GURL
> GetSitesInTab() const override
;
265 const std::string
& GetEncoding() const override
;
266 bool DisplayedInsecureContent() const override
;
267 void IncrementCapturerCount(const gfx::Size
& capture_size
) override
;
268 void DecrementCapturerCount() override
;
269 int GetCapturerCount() const override
;
270 bool IsAudioMuted() const override
;
271 void SetAudioMuted(bool mute
) override
;
272 bool IsCrashed() const override
;
273 void SetIsCrashed(base::TerminationStatus status
, int error_code
) override
;
274 base::TerminationStatus
GetCrashedStatus() const override
;
275 bool IsBeingDestroyed() const override
;
276 void NotifyNavigationStateChanged(InvalidateTypes changed_flags
) override
;
277 base::TimeTicks
GetLastActiveTime() const override
;
278 void WasShown() override
;
279 void WasHidden() override
;
280 bool NeedToFireBeforeUnload() override
;
281 void DispatchBeforeUnload(bool for_cross_site_transition
) override
;
282 void Stop() override
;
283 WebContents
* Clone() override
;
284 void ReloadFocusedFrame(bool ignore_cache
) override
;
285 void Undo() override
;
286 void Redo() override
;
288 void Copy() override
;
289 void CopyToFindPboard() override
;
290 void Paste() override
;
291 void PasteAndMatchStyle() override
;
292 void Delete() override
;
293 void SelectAll() override
;
294 void Unselect() override
;
295 void Replace(const base::string16
& word
) override
;
296 void ReplaceMisspelling(const base::string16
& word
) override
;
297 void NotifyContextMenuClosed(
298 const CustomContextMenuContext
& context
) override
;
299 void ExecuteCustomContextMenuCommand(
301 const CustomContextMenuContext
& context
) override
;
302 gfx::NativeView
GetNativeView() override
;
303 gfx::NativeView
GetContentNativeView() override
;
304 gfx::NativeWindow
GetTopLevelNativeWindow() override
;
305 gfx::Rect
GetContainerBounds() override
;
306 gfx::Rect
GetViewBounds() override
;
307 DropData
* GetDropData() override
;
308 void Focus() override
;
309 void SetInitialFocus() override
;
310 void StoreFocus() override
;
311 void RestoreFocus() override
;
312 void FocusThroughTabTraversal(bool reverse
) override
;
313 bool ShowingInterstitialPage() const override
;
314 InterstitialPage
* GetInterstitialPage() const override
;
315 bool IsSavable() override
;
316 void OnSavePage() override
;
317 bool SavePage(const base::FilePath
& main_file
,
318 const base::FilePath
& dir_path
,
319 SavePageType save_type
) override
;
320 void SaveFrame(const GURL
& url
, const Referrer
& referrer
) override
;
321 void SaveFrameWithHeaders(const GURL
& url
,
322 const Referrer
& referrer
,
323 const std::string
& headers
) override
;
324 void GenerateMHTML(const base::FilePath
& file
,
325 const base::Callback
<void(int64
)>& callback
) override
;
326 const std::string
& GetContentsMimeType() const override
;
327 bool WillNotifyDisconnection() const override
;
328 void SetOverrideEncoding(const std::string
& encoding
) override
;
329 void ResetOverrideEncoding() override
;
330 RendererPreferences
* GetMutableRendererPrefs() override
;
331 void Close() override
;
332 void SystemDragEnded() override
;
333 void UserGestureDone() override
;
334 void SetClosedByUserGesture(bool value
) override
;
335 bool GetClosedByUserGesture() const override
;
336 void ViewSource() override
;
337 void ViewFrameSource(const GURL
& url
, const PageState
& page_state
) override
;
338 int GetMinimumZoomPercent() const override
;
339 int GetMaximumZoomPercent() const override
;
340 void ResetPageScale() override
;
341 gfx::Size
GetPreferredSize() const override
;
342 bool GotResponseToLockMouseRequest(bool allowed
) override
;
343 bool HasOpener() const override
;
344 WebContents
* GetOpener() const override
;
345 void DidChooseColorInColorChooser(SkColor color
) override
;
346 void DidEndColorChooser() override
;
347 int DownloadImage(const GURL
& url
,
349 uint32_t max_bitmap_size
,
351 const ImageDownloadCallback
& callback
) override
;
352 bool IsSubframe() const override
;
353 void Find(int request_id
,
354 const base::string16
& search_text
,
355 const blink::WebFindOptions
& options
) override
;
356 void StopFinding(StopFindAction action
) override
;
357 void InsertCSS(const std::string
& css
) override
;
358 bool WasRecentlyAudible() override
;
359 void GetManifest(const GetManifestCallback
&) override
;
360 void ExitFullscreen() override
;
361 void ResumeLoadingCreatedWebContents() override
;
362 #if defined(OS_ANDROID)
363 base::android::ScopedJavaLocalRef
<jobject
> GetJavaWebContents() override
;
364 virtual WebContentsAndroid
* GetWebContentsAndroid();
365 #elif defined(OS_MACOSX)
366 void SetAllowOtherViews(bool allow
) override
;
367 bool GetAllowOtherViews() override
;
370 // Implementation of PageNavigator.
371 WebContents
* OpenURL(const OpenURLParams
& params
) override
;
373 // Implementation of IPC::Sender.
374 bool Send(IPC::Message
* message
) override
;
376 // RenderFrameHostDelegate ---------------------------------------------------
377 bool OnMessageReceived(RenderFrameHost
* render_frame_host
,
378 const IPC::Message
& message
) override
;
379 const GURL
& GetMainFrameLastCommittedURL() const override
;
380 void RenderFrameCreated(RenderFrameHost
* render_frame_host
) override
;
381 void RenderFrameDeleted(RenderFrameHost
* render_frame_host
) override
;
382 void SwappedOut(RenderFrameHost
* render_frame_host
) override
;
383 void DidDeferAfterResponseStarted(
384 const TransitionLayerData
& transition_data
) override
;
385 bool WillHandleDeferAfterResponseStarted() override
;
386 void WorkerCrashed(RenderFrameHost
* render_frame_host
) override
;
387 void ShowContextMenu(RenderFrameHost
* render_frame_host
,
388 const ContextMenuParams
& params
) override
;
389 void RunJavaScriptMessage(RenderFrameHost
* render_frame_host
,
390 const base::string16
& message
,
391 const base::string16
& default_prompt
,
392 const GURL
& frame_url
,
393 JavaScriptMessageType type
,
394 IPC::Message
* reply_msg
) override
;
395 void RunBeforeUnloadConfirm(RenderFrameHost
* render_frame_host
,
396 const base::string16
& message
,
398 IPC::Message
* reply_msg
) override
;
399 void DidAccessInitialDocument() override
;
400 void DidChangeName(RenderFrameHost
* render_frame_host
,
401 const std::string
& name
) override
;
402 void DidDisownOpener(RenderFrameHost
* render_frame_host
) override
;
403 void DocumentOnLoadCompleted(RenderFrameHost
* render_frame_host
) override
;
404 void UpdateTitle(RenderFrameHost
* render_frame_host
,
406 const base::string16
& title
,
407 base::i18n::TextDirection title_direction
) override
;
408 void UpdateEncoding(RenderFrameHost
* render_frame_host
,
409 const std::string
& encoding
) override
;
410 WebContents
* GetAsWebContents() override
;
411 bool IsNeverVisible() override
;
412 AccessibilityMode
GetAccessibilityMode() const override
;
413 void AccessibilityEventReceived(
414 const std::vector
<AXEventNotificationDetails
>& details
) override
;
415 RenderFrameHost
* GetGuestByInstanceID(
416 RenderFrameHost
* render_frame_host
,
417 int browser_plugin_instance_id
) override
;
418 GeolocationServiceContext
* GetGeolocationServiceContext() override
;
419 void EnterFullscreenMode(const GURL
& origin
) override
;
420 void ExitFullscreenMode() override
;
421 bool ShouldRouteMessageEvent(
422 RenderFrameHost
* target_rfh
,
423 SiteInstance
* source_site_instance
) const override
;
424 int EnsureOpenerRenderViewsExist(RenderFrameHost
* source_rfh
) override
;
426 gfx::NativeViewAccessible
GetParentNativeViewAccessible() override
;
429 // RenderViewHostDelegate ----------------------------------------------------
430 RenderViewHostDelegateView
* GetDelegateView() override
;
431 bool OnMessageReceived(RenderViewHost
* render_view_host
,
432 const IPC::Message
& message
) override
;
433 // RenderFrameHostDelegate has the same method, so list it there because this
434 // interface is going away.
435 // WebContents* GetAsWebContents() override;
436 gfx::Rect
GetRootWindowResizerRect() const override
;
437 void RenderViewCreated(RenderViewHost
* render_view_host
) override
;
438 void RenderViewReady(RenderViewHost
* render_view_host
) override
;
439 void RenderViewTerminated(RenderViewHost
* render_view_host
,
440 base::TerminationStatus status
,
441 int error_code
) override
;
442 void RenderViewDeleted(RenderViewHost
* render_view_host
) override
;
443 void UpdateState(RenderViewHost
* render_view_host
,
445 const PageState
& page_state
) override
;
446 void UpdateTargetURL(RenderViewHost
* render_view_host
,
447 const GURL
& url
) override
;
448 void Close(RenderViewHost
* render_view_host
) override
;
449 void RequestMove(const gfx::Rect
& new_bounds
) override
;
450 void DidCancelLoading() override
;
451 void DocumentAvailableInMainFrame(RenderViewHost
* render_view_host
) override
;
452 void RouteCloseEvent(RenderViewHost
* rvh
) override
;
453 bool AddMessageToConsole(int32 level
,
454 const base::string16
& message
,
456 const base::string16
& source_id
) override
;
457 RendererPreferences
GetRendererPrefs(
458 BrowserContext
* browser_context
) const override
;
459 void OnUserGesture() override
;
460 void OnIgnoredUIEvent() override
;
461 void RendererUnresponsive(RenderViewHost
* render_view_host
) override
;
462 void RendererResponsive(RenderViewHost
* render_view_host
) override
;
463 void LoadStateChanged(const GURL
& url
,
464 const net::LoadStateWithParam
& load_state
,
465 uint64 upload_position
,
466 uint64 upload_size
) override
;
467 void Activate() override
;
468 void Deactivate() override
;
469 void LostCapture() override
;
470 void RunFileChooser(RenderViewHost
* render_view_host
,
471 const FileChooserParams
& params
) override
;
472 bool IsFullscreenForCurrentTab() const override
;
473 blink::WebDisplayMode
GetDisplayMode() const override
;
474 void UpdatePreferredSize(const gfx::Size
& pref_size
) override
;
475 void ResizeDueToAutoResize(const gfx::Size
& new_size
) override
;
476 void RequestToLockMouse(bool user_gesture
,
477 bool last_unlocked_by_target
) override
;
478 void LostMouseLock() override
;
479 void CreateNewWindow(
480 int render_process_id
,
482 int main_frame_route_id
,
483 const ViewHostMsg_CreateWindow_Params
& params
,
484 SessionStorageNamespace
* session_storage_namespace
) override
;
485 void CreateNewWidget(int render_process_id
,
487 blink::WebPopupType popup_type
) override
;
488 void CreateNewFullscreenWidget(int render_process_id
, int route_id
) override
;
489 void ShowCreatedWindow(int route_id
,
490 WindowOpenDisposition disposition
,
491 const gfx::Rect
& initial_rect
,
492 bool user_gesture
) override
;
493 void ShowCreatedWidget(int route_id
, const gfx::Rect
& initial_rect
) override
;
494 void ShowCreatedFullscreenWidget(int route_id
) override
;
495 void RequestMediaAccessPermission(
496 const MediaStreamRequest
& request
,
497 const MediaResponseCallback
& callback
) override
;
498 bool CheckMediaAccessPermission(const GURL
& security_origin
,
499 MediaStreamType type
) override
;
500 SessionStorageNamespace
* GetSessionStorageNamespace(
501 SiteInstance
* instance
) override
;
502 SessionStorageNamespaceMap
GetSessionStorageNamespaceMap() override
;
503 FrameTree
* GetFrameTree() override
;
504 void SetIsVirtualKeyboardRequested(bool requested
) override
;
505 bool IsVirtualKeyboardRequested() override
;
508 // NavigatorDelegate ---------------------------------------------------------
510 void DidStartProvisionalLoad(RenderFrameHostImpl
* render_frame_host
,
511 const GURL
& validated_url
,
513 bool is_iframe_srcdoc
) override
;
514 void DidStartNavigationTransition(
515 RenderFrameHostImpl
* render_frame_host
) override
;
516 void DidFailProvisionalLoadWithError(
517 RenderFrameHostImpl
* render_frame_host
,
518 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
)
520 void DidFailLoadWithError(RenderFrameHostImpl
* render_frame_host
,
523 const base::string16
& error_description
) override
;
524 void DidCommitProvisionalLoad(RenderFrameHostImpl
* render_frame_host
,
526 ui::PageTransition transition_type
) override
;
527 void DidNavigateMainFramePreCommit(bool navigation_is_within_page
) override
;
528 void DidNavigateMainFramePostCommit(
529 RenderFrameHostImpl
* render_frame_host
,
530 const LoadCommittedDetails
& details
,
531 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) override
;
532 void DidNavigateAnyFramePostCommit(
533 RenderFrameHostImpl
* render_frame_host
,
534 const LoadCommittedDetails
& details
,
535 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) override
;
536 void SetMainFrameMimeType(const std::string
& mime_type
) override
;
537 bool CanOverscrollContent() const override
;
538 void NotifyChangedNavigationState(InvalidateTypes changed_flags
) override
;
539 void AboutToNavigateRenderFrame(
540 RenderFrameHostImpl
* old_host
,
541 RenderFrameHostImpl
* new_host
) override
;
542 void DidStartNavigationToPendingEntry(
544 NavigationController::ReloadType reload_type
) override
;
545 void RequestOpenURL(RenderFrameHostImpl
* render_frame_host
,
546 const OpenURLParams
& params
) override
;
547 bool ShouldPreserveAbortedURLs() override
;
548 void DidStartLoading(FrameTreeNode
* frame_tree_node
,
549 bool to_different_document
) override
;
550 void DidStopLoading() override
;
551 void DidChangeLoadProgress() override
;
553 // RenderWidgetHostDelegate --------------------------------------------------
555 void RenderWidgetDeleted(RenderWidgetHostImpl
* render_widget_host
) override
;
556 void RenderWidgetGotFocus(RenderWidgetHostImpl
* render_widget_host
) override
;
557 void RenderWidgetWasResized(RenderWidgetHostImpl
* render_widget_host
,
558 bool width_changed
) override
;
559 void ScreenInfoChanged() override
;
560 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent
& event
,
561 bool* is_keyboard_shortcut
) override
;
562 void HandleKeyboardEvent(const NativeWebKeyboardEvent
& event
) override
;
563 bool HandleWheelEvent(const blink::WebMouseWheelEvent
& event
) override
;
564 bool PreHandleGestureEvent(const blink::WebGestureEvent
& event
) override
;
565 void DidSendScreenRects(RenderWidgetHostImpl
* rwh
) override
;
566 BrowserAccessibilityManager
* GetRootBrowserAccessibilityManager() override
;
567 BrowserAccessibilityManager
* GetOrCreateRootBrowserAccessibilityManager()
570 // RenderFrameHostManager::Delegate ------------------------------------------
572 bool CreateRenderViewForRenderManager(
573 RenderViewHost
* render_view_host
,
575 int proxy_routing_id
,
576 bool for_main_frame_navigation
) override
;
577 bool CreateRenderFrameForRenderManager(RenderFrameHost
* render_frame_host
,
578 int parent_routing_id
,
579 int proxy_routing_id
) override
;
580 void BeforeUnloadFiredFromRenderManager(
582 const base::TimeTicks
& proceed_time
,
583 bool* proceed_to_fire_unload
) override
;
584 void RenderProcessGoneFromRenderManager(
585 RenderViewHost
* render_view_host
) override
;
586 void UpdateRenderViewSizeForRenderManager() override
;
587 void CancelModalDialogsForRenderManager() override
;
588 void NotifySwappedFromRenderManager(RenderFrameHost
* old_host
,
589 RenderFrameHost
* new_host
,
590 bool is_main_frame
) override
;
591 void NotifyMainFrameSwappedFromRenderManager(
592 RenderViewHost
* old_host
,
593 RenderViewHost
* new_host
) override
;
594 int CreateOpenerRenderViewsForRenderManager(SiteInstance
* instance
) override
;
595 NavigationControllerImpl
& GetControllerForRenderManager() override
;
596 scoped_ptr
<WebUIImpl
> CreateWebUIForRenderManager(const GURL
& url
) override
;
597 NavigationEntry
* GetLastCommittedNavigationEntryForRenderManager() override
;
598 bool FocusLocationBarByDefault() override
;
599 void SetFocusToLocationBar(bool select_all
) override
;
600 bool IsHidden() override
;
602 // NotificationObserver ------------------------------------------------------
604 void Observe(int type
,
605 const NotificationSource
& source
,
606 const NotificationDetails
& details
) override
;
608 // NavigationControllerDelegate ----------------------------------------------
610 WebContents
* GetWebContents() override
;
611 void NotifyNavigationEntryCommitted(
612 const LoadCommittedDetails
& load_details
) override
;
614 // Invoked before a form repost warning is shown.
615 void NotifyBeforeFormRepostWarningShow() override
;
617 // Activate this WebContents and show a form repost warning.
618 void ActivateAndShowRepostFormWarningDialog() override
;
620 // Whether the initial empty page of this view has been accessed by another
621 // page, making it unsafe to show the pending URL. Always false after the
623 bool HasAccessedInitialDocument() override
;
625 // Updates the max page ID for the current SiteInstance in this
626 // WebContentsImpl to be at least |page_id|.
627 void UpdateMaxPageID(int32 page_id
) override
;
629 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
630 // to be at least |page_id|.
631 void UpdateMaxPageIDForSiteInstance(SiteInstance
* site_instance
,
632 int32 page_id
) override
;
634 // Copy the current map of SiteInstance ID to max page ID from another tab.
635 // This is necessary when this tab adopts the NavigationEntries from
637 void CopyMaxPageIDsFrom(WebContents
* web_contents
) override
;
639 // Called by the NavigationController to cause the WebContentsImpl to navigate
640 // to the current pending entry. The NavigationController should be called
641 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
642 // The callbacks can be inside of this function, or at some future time.
644 // The entry has a PageID of -1 if newly created (corresponding to navigation
647 // If this method returns false, then the navigation is discarded (equivalent
648 // to calling DiscardPendingEntry on the NavigationController).
649 bool NavigateToPendingEntry(
650 NavigationController::ReloadType reload_type
) override
;
652 // Sets the history for this WebContentsImpl to |history_length| entries, with
653 // an offset of |history_offset|.
654 void SetHistoryOffsetAndLength(int history_offset
,
655 int history_length
) override
;
657 // Called by InterstitialPageImpl when it creates a RenderFrameHost.
658 void RenderFrameForInterstitialPageCreated(
659 RenderFrameHost
* render_frame_host
) override
;
661 // Sets the passed interstitial as the currently showing interstitial.
662 // No interstitial page should already be attached.
663 void AttachInterstitialPage(InterstitialPageImpl
* interstitial_page
) override
;
665 // Unsets the currently showing interstitial.
666 void DetachInterstitialPage() override
;
668 // Changes the IsLoading state and notifies the delegate as needed.
669 // |details| is used to provide details on the load that just finished
670 // (but can be null if not applicable).
671 void SetIsLoading(bool is_loading
,
672 bool to_different_document
,
673 LoadNotificationDetails
* details
) override
;
675 typedef base::Callback
<void(WebContents
*)> CreatedCallback
;
677 // Requests the renderer to move the selection extent to a new position.
678 void MoveRangeSelectionExtent(const gfx::Point
& extent
);
680 // Requests the renderer to select the region between two points in the
681 // currently focused frame.
682 void SelectRange(const gfx::Point
& base
, const gfx::Point
& extent
);
684 // Notifies the main frame that it can continue navigation (if it was deferred
685 // immediately at first response).
686 void ResumeResponseDeferredAtStart();
688 // Forces overscroll to be disabled (used by touch emulation).
689 void SetForceDisableOverscrollContent(bool force_disable
);
691 AudioStateProvider
* audio_state_provider() {
692 return audio_state_provider_
.get();
695 bool has_audio_power_save_blocker_for_testing() const {
696 return audio_power_save_blocker_
;
699 bool has_video_power_save_blocker_for_testing() const {
700 return video_power_save_blocker_
;
703 #if defined(ENABLE_BROWSER_CDMS)
704 MediaWebContentsObserver
* media_web_contents_observer() {
705 return media_web_contents_observer_
.get();
710 friend class WebContentsObserver
;
711 friend class WebContents
; // To implement factory methods.
713 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, NoJSMessageOnInterstitials
);
714 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, UpdateTitle
);
715 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, FindOpenerRVHWhenPending
);
716 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
,
717 CrossSiteCantPreemptAfterUnload
);
718 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, PendingContents
);
719 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, FrameTreeShape
);
720 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest
, GetLastActiveTime
);
721 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest
, HTMLFiles
);
722 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest
, HistoryNavigate
);
723 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest
, PageDoesBackAndReload
);
724 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest
, CrossSiteIframe
);
725 FRIEND_TEST_ALL_PREFIXES(SitePerProcessAccessibilityBrowserTest
,
726 CrossSiteIframeAccessibility
);
728 // So InterstitialPageImpl can access SetIsLoading.
729 friend class InterstitialPageImpl
;
731 // TODO(brettw) TestWebContents shouldn't exist!
732 friend class TestWebContents
;
734 class DestructionObserver
;
736 // See WebContents::Create for a description of these parameters.
737 WebContentsImpl(BrowserContext
* browser_context
,
738 WebContentsImpl
* opener
);
740 // Add and remove observers for page navigation notifications. The order in
741 // which notifications are sent to observers is undefined. Clients must be
742 // sure to remove the observer before they go away.
743 void AddObserver(WebContentsObserver
* observer
);
744 void RemoveObserver(WebContentsObserver
* observer
);
746 // Clears this tab's opener if it has been closed.
747 void OnWebContentsDestroyed(WebContentsImpl
* web_contents
);
749 // Creates and adds to the map a destruction observer watching |web_contents|.
750 // No-op if such an observer already exists.
751 void AddDestructionObserver(WebContentsImpl
* web_contents
);
753 // Deletes and removes from the map a destruction observer
754 // watching |web_contents|. No-op if there is no such observer.
755 void RemoveDestructionObserver(WebContentsImpl
* web_contents
);
757 // Traverses all the RenderFrameHosts in the FrameTree and creates a set
758 // all the unique RenderWidgetHostViews.
759 std::set
<RenderWidgetHostView
*> GetRenderWidgetHostViewsInTree();
761 // Callback function when showing JavaScript dialogs. Takes in a routing ID
762 // pair to identify the RenderFrameHost that opened the dialog, because it's
763 // possible for the RenderFrameHost to be deleted by the time this is called.
764 void OnDialogClosed(int render_process_id
,
766 IPC::Message
* reply_msg
,
767 bool dialog_was_suppressed
,
769 const base::string16
& user_input
);
771 bool OnMessageReceived(RenderViewHost
* render_view_host
,
772 RenderFrameHost
* render_frame_host
,
773 const IPC::Message
& message
);
775 // Checks whether render_frame_message_source_ is set to non-null value,
776 // otherwise it terminates the main frame renderer process.
777 bool HasValidFrameSource();
779 // IPC message handlers.
780 void OnThemeColorChanged(SkColor theme_color
);
781 void OnDidLoadResourceFromMemoryCache(const GURL
& url
,
782 const std::string
& security_info
,
783 const std::string
& http_request
,
784 const std::string
& mime_type
,
785 ResourceType resource_type
);
786 void OnDidDisplayInsecureContent();
787 void OnDidRunInsecureContent(const std::string
& security_origin
,
788 const GURL
& target_url
);
789 void OnDocumentLoadedInFrame();
790 void OnDidFinishLoad(const GURL
& url
);
791 void OnGoToEntryAtOffset(int offset
);
792 void OnUpdateZoomLimits(int minimum_percent
,
793 int maximum_percent
);
794 void OnEnumerateDirectory(int request_id
, const base::FilePath
& path
);
796 void OnRegisterProtocolHandler(const std::string
& protocol
,
798 const base::string16
& title
,
800 void OnUnregisterProtocolHandler(const std::string
& protocol
,
803 void OnFindReply(int request_id
,
804 int number_of_matches
,
805 const gfx::Rect
& selection_rect
,
806 int active_match_ordinal
,
808 #if defined(OS_ANDROID)
809 void OnFindMatchRectsReply(int version
,
810 const std::vector
<gfx::RectF
>& rects
,
811 const gfx::RectF
& active_rect
);
813 void OnOpenDateTimeDialog(
814 const ViewHostMsg_DateTimeDialogValue_Params
& value
);
816 void OnDomOperationResponse(const std::string
& json_string
,
818 void OnAppCacheAccessed(const GURL
& manifest_url
, bool blocked_by_policy
);
819 void OnOpenColorChooser(int color_chooser_id
,
821 const std::vector
<ColorSuggestion
>& suggestions
);
822 void OnEndColorChooser(int color_chooser_id
);
823 void OnSetSelectedColorInColorChooser(int color_chooser_id
, SkColor color
);
824 void OnWebUISend(const GURL
& source_url
,
825 const std::string
& name
,
826 const base::ListValue
& args
);
827 #if defined(ENABLE_PLUGINS)
828 void OnPepperPluginHung(int plugin_child_id
,
829 const base::FilePath
& path
,
831 void OnPluginCrashed(const base::FilePath
& plugin_path
,
832 base::ProcessId plugin_pid
);
833 void OnRequestPpapiBrokerPermission(int routing_id
,
835 const base::FilePath
& plugin_path
);
837 // Callback function when requesting permission to access the PPAPI broker.
838 // |result| is true if permission was granted.
839 void OnPpapiBrokerPermissionResult(int routing_id
, bool result
);
841 void OnBrowserPluginMessage(RenderFrameHost
* render_frame_host
,
842 const IPC::Message
& message
);
843 #endif // defined(ENABLE_PLUGINS)
844 void OnDidDownloadImage(int id
,
845 int http_status_code
,
846 const GURL
& image_url
,
847 const std::vector
<SkBitmap
>& bitmaps
,
848 const std::vector
<gfx::Size
>& original_bitmap_sizes
);
849 void OnUpdateFaviconURL(const std::vector
<FaviconURL
>& candidates
);
850 void OnFirstVisuallyNonEmptyPaint();
851 void OnMediaPlayingNotification(int64 player_cookie
,
855 void OnMediaPausedNotification(int64 player_cookie
);
856 void OnShowValidationMessage(const gfx::Rect
& anchor_in_root_view
,
857 const base::string16
& main_text
,
858 const base::string16
& sub_text
);
859 void OnHideValidationMessage();
860 void OnMoveValidationMessage(const gfx::Rect
& anchor_in_root_view
);
862 // Called by derived classes to indicate that we're no longer waiting for a
863 // response. This won't actually update the throbber, but it will get picked
864 // up at the next animation step if the throbber is going.
865 void SetNotWaitingForResponse() { waiting_for_response_
= false; }
867 // Navigation helpers --------------------------------------------------------
869 // These functions are helpers for Navigate() and DidNavigate().
871 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
872 // committed to the navigation controller. Note that the navigation entry is
873 // not provided since it may be invalid/changed after being committed. The
874 // current navigation entry is in the NavigationController at this point.
876 // If our controller was restored, update the max page ID associated with the
877 // given RenderViewHost to be larger than the number of restored entries.
878 // This is called in CreateRenderView before any navigations in the RenderView
879 // have begun, to prevent any races in updating RenderView::next_page_id.
880 void UpdateMaxPageIDIfNecessary(RenderViewHost
* rvh
);
882 // Saves the given title to the navigation entry and does associated work. It
883 // will update history and the view for the new title, and also synthesize
884 // titles for file URLs that have none (so we require that the URL of the
885 // entry already be set).
887 // This is used as the backend for state updates, which include a new title,
888 // or the dedicated set title message. It returns true if the new title is
889 // different and was therefore updated.
890 bool UpdateTitleForEntry(NavigationEntryImpl
* entry
,
891 const base::string16
& title
);
893 // Recursively creates swapped out RenderViews for this tab's opener chain
894 // (including this tab) in the given SiteInstance, allowing other tabs to send
895 // cross-process JavaScript calls to their opener(s). Returns the route ID of
896 // this tab's RenderView for |instance|.
897 int CreateOpenerRenderViews(SiteInstance
* instance
);
899 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
900 void CreateNewWidget(int render_process_id
,
903 blink::WebPopupType popup_type
);
905 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
906 void ShowCreatedWidget(int route_id
,
908 const gfx::Rect
& initial_rect
);
910 // Finds the new RenderWidgetHost and returns it. Note that this can only be
911 // called once as this call also removes it from the internal map.
912 RenderWidgetHostView
* GetCreatedWidget(int route_id
);
914 // Finds the new WebContentsImpl by route_id, initializes it for
915 // renderer-initiated creation, and returns it. Note that this can only be
916 // called once as this call also removes it from the internal map.
917 WebContentsImpl
* GetCreatedWindow(int route_id
);
919 // Tracking loading progress -------------------------------------------------
921 // Resets the tracking state of the current load progress.
922 void ResetLoadProgressState();
924 // Notifies the delegate that the load progress was updated.
925 void SendChangeLoadProgress();
927 // Misc non-view stuff -------------------------------------------------------
929 // Sets the history for a specified RenderViewHost to |history_length|
930 // entries, with an offset of |history_offset|.
931 void SetHistoryOffsetAndLengthForView(RenderViewHost
* render_view_host
,
935 // Helper functions for sending notifications.
936 void NotifyViewSwapped(RenderViewHost
* old_host
, RenderViewHost
* new_host
);
937 void NotifyFrameSwapped(RenderFrameHost
* old_host
, RenderFrameHost
* new_host
);
938 void NotifyDisconnected();
940 void SetEncoding(const std::string
& encoding
);
942 // TODO(creis): This should take in a FrameTreeNode to know which node's
943 // render manager to return. For now, we just return the root's.
944 RenderFrameHostManager
* GetRenderManager() const;
946 // Removes browser plugin embedder if there is one.
947 void RemoveBrowserPluginEmbedder();
949 // Clear |render_frame_host|'s tracking entry for its power save blockers.
950 void ClearPowerSaveBlockers(RenderFrameHost
* render_frame_host
);
952 // Clear tracking entries for all RenderFrameHosts, clears
953 // |audio_power_save_blocker_| and |video_power_save_blocker_|.
954 void ClearAllPowerSaveBlockers();
956 // Creates an audio or video power save blocker respectively.
957 void CreateAudioPowerSaveBlocker();
958 void CreateVideoPowerSaveBlocker();
960 // Releases the audio power save blockers if |active_audio_players_| is empty.
961 // Likewise, releases the video power save blockers if |active_video_players_|
963 void MaybeReleasePowerSaveBlockers();
965 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
966 gfx::Size
GetSizeForNewRenderView();
968 void OnFrameRemoved(RenderFrameHost
* render_frame_host
);
970 // Helper method that's called whenever |preferred_size_| or
971 // |preferred_size_for_capture_| changes, to propagate the new value to the
973 void OnPreferredSizeChanged(const gfx::Size
& old_size
);
975 // Helper methods for adding or removing player entries in |player_map| under
976 // the key |render_frame_message_source_|.
977 typedef std::vector
<int64
> PlayerList
;
978 typedef std::map
<uintptr_t, PlayerList
> ActiveMediaPlayerMap
;
979 void AddMediaPlayerEntry(int64 player_cookie
,
980 ActiveMediaPlayerMap
* player_map
);
981 void RemoveMediaPlayerEntry(int64 player_cookie
,
982 ActiveMediaPlayerMap
* player_map
);
983 // Removes all entries from |player_map| for |render_frame_host|.
984 void RemoveAllMediaPlayerEntries(RenderFrameHost
* render_frame_host
,
985 ActiveMediaPlayerMap
* player_map
);
987 // Data for core operation ---------------------------------------------------
989 // Delegate for notifying our owner about stuff. Not owned by us.
990 WebContentsDelegate
* delegate_
;
992 // Handles the back/forward list and loading.
993 NavigationControllerImpl controller_
;
995 // The corresponding view.
996 scoped_ptr
<WebContentsView
> view_
;
998 // The view of the RVHD. Usually this is our WebContentsView implementation,
999 // but if an embedder uses a different WebContentsView, they'll need to
1001 RenderViewHostDelegateView
* render_view_host_delegate_view_
;
1003 // Tracks created WebContentsImpl objects that have not been shown yet. They
1004 // are identified by the route ID passed to CreateNewWindow.
1005 typedef std::map
<int, WebContentsImpl
*> PendingContents
;
1006 PendingContents pending_contents_
;
1008 // These maps hold on to the widgets that we created on behalf of the renderer
1009 // that haven't shown yet.
1010 typedef std::map
<int, RenderWidgetHostView
*> PendingWidgetViews
;
1011 PendingWidgetViews pending_widget_views_
;
1013 typedef std::map
<WebContentsImpl
*, DestructionObserver
*> DestructionObservers
;
1014 DestructionObservers destruction_observers_
;
1016 // A list of observers notified when page state changes. Weak references.
1017 // This MUST be listed above frame_tree_ since at destruction time the
1018 // latter might cause RenderViewHost's destructor to call us and we might use
1019 // the observer list then.
1020 ObserverList
<WebContentsObserver
> observers_
;
1022 // The tab that opened this tab, if any. Will be set to null if the opener
1024 WebContentsImpl
* opener_
;
1026 // True if this tab was opened by another tab. This is not unset if the opener
1028 bool created_with_opener_
;
1031 gfx::NativeViewAccessible accessible_parent_
;
1034 // Helper classes ------------------------------------------------------------
1036 // Tracking variables and associated power save blockers for media playback.
1037 ActiveMediaPlayerMap active_audio_players_
;
1038 ActiveMediaPlayerMap active_video_players_
;
1039 scoped_ptr
<PowerSaveBlocker
> audio_power_save_blocker_
;
1040 scoped_ptr
<PowerSaveBlocker
> video_power_save_blocker_
;
1042 // Tells whether this WebContents is actively producing sound.
1043 // Order is important: the |frame_tree_| destruction uses
1044 // |audio_state_provider_|.
1045 scoped_ptr
<AudioStateProvider
> audio_state_provider_
;
1047 // Manages the frame tree of the page and process swaps in each node.
1048 FrameTree frame_tree_
;
1050 // SavePackage, lazily created.
1051 scoped_refptr
<SavePackage
> save_package_
;
1053 // Data for loading state ----------------------------------------------------
1055 // Indicates whether we're currently loading a resource.
1058 // Indicates whether the current load is to a different document. Only valid
1059 // if is_loading_ is true.
1060 bool is_load_to_different_document_
;
1062 // Indicates if the tab is considered crashed.
1063 base::TerminationStatus crashed_status_
;
1064 int crashed_error_code_
;
1066 // Whether this WebContents is waiting for a first-response for the
1067 // main resource of the page. This controls whether the throbber state is
1068 // "waiting" or "loading."
1069 bool waiting_for_response_
;
1071 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
1072 // to a given tab and SiteInstance, and must be valid for the lifetime of the
1074 std::map
<int32
, int32
> max_page_ids_
;
1076 // The current load state and the URL associated with it.
1077 net::LoadStateWithParam load_state_
;
1078 base::string16 load_state_host_
;
1080 base::TimeTicks loading_last_progress_update_
;
1082 // Upload progress, for displaying in the status bar.
1083 // Set to zero when there is no significant upload happening.
1084 uint64 upload_size_
;
1085 uint64 upload_position_
;
1087 // Data for current page -----------------------------------------------------
1089 // When a title cannot be taken from any entry, this title will be used.
1090 base::string16 page_title_when_no_navigation_entry_
;
1092 // When a navigation occurs, we record its contents MIME type. It can be
1093 // used to check whether we can do something for some special contents.
1094 std::string contents_mime_type_
;
1096 // The last reported character encoding, not canonicalized.
1097 std::string last_reported_encoding_
;
1099 // The canonicalized character encoding.
1100 std::string canonical_encoding_
;
1102 // True if this is a secure page which displayed insecure content.
1103 bool displayed_insecure_content_
;
1105 // Whether the initial empty page has been accessed by another page, making it
1106 // unsafe to show the pending URL. Usually false unless another window tries
1107 // to modify the blank page. Always false after the first commit.
1108 bool has_accessed_initial_document_
;
1110 // The theme color for the underlying document as specified
1111 // by theme-color meta tag.
1112 SkColor theme_color_
;
1114 // The last published theme color.
1115 SkColor last_sent_theme_color_
;
1117 // Data for misc internal state ----------------------------------------------
1119 // When > 0, the WebContents is currently being captured (e.g., for
1120 // screenshots or mirroring); and the underlying RenderWidgetHost should not
1121 // be told it is hidden.
1122 int capturer_count_
;
1124 // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
1125 bool should_normally_be_visible_
;
1127 // See getter above.
1128 bool is_being_destroyed_
;
1130 // Indicates whether we should notify about disconnection of this
1131 // WebContentsImpl. This is used to ensure disconnection notifications only
1132 // happen if a connection notification has happened and that they happen only
1134 bool notify_disconnection_
;
1136 // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
1137 // delegate of this WebContentsImpl is nulled before its destructor is called.
1138 JavaScriptDialogManager
* dialog_manager_
;
1140 // Set to true when there is an active "before unload" dialog. When true,
1141 // we've forced the throbber to start in Navigate, and we need to remember to
1142 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
1143 bool is_showing_before_unload_dialog_
;
1145 // Settings that get passed to the renderer process.
1146 RendererPreferences renderer_preferences_
;
1148 // The time that this WebContents was last made active. The initial value is
1149 // the WebContents creation time.
1150 base::TimeTicks last_active_time_
;
1152 // See description above setter.
1153 bool closed_by_user_gesture_
;
1155 // Minimum/maximum zoom percent.
1156 int minimum_zoom_percent_
;
1157 int maximum_zoom_percent_
;
1159 // The intrinsic size of the page.
1160 gfx::Size preferred_size_
;
1162 // The preferred size for content screen capture. When |capturer_count_| > 0,
1163 // this overrides |preferred_size_|.
1164 gfx::Size preferred_size_for_capture_
;
1166 #if defined(OS_ANDROID)
1167 // Date time chooser opened by this tab.
1168 // Only used in Android since all other platforms use a multi field UI.
1169 scoped_ptr
<DateTimeChooserAndroid
> date_time_chooser_
;
1172 // Holds information about a current color chooser dialog, if one is visible.
1173 struct ColorChooserInfo
{
1174 ColorChooserInfo(int render_process_id
,
1175 int render_frame_id
,
1176 ColorChooser
* chooser
,
1178 ~ColorChooserInfo();
1180 int render_process_id
;
1181 int render_frame_id
;
1183 // Color chooser that was opened by this tab.
1184 scoped_ptr
<ColorChooser
> chooser
;
1186 // A unique identifier for the current color chooser. Identifiers are
1187 // unique across a renderer process. This avoids race conditions in
1188 // synchronizing the browser and renderer processes. For example, if a
1189 // renderer closes one chooser and opens another, and simultaneously the
1190 // user picks a color in the first chooser, the IDs can be used to drop the
1191 // "chose a color" message rather than erroneously tell the renderer that
1192 // the user picked a color in the second chooser.
1196 scoped_ptr
<ColorChooserInfo
> color_chooser_info_
;
1198 // Manages the embedder state for browser plugins, if this WebContents is an
1199 // embedder; NULL otherwise.
1200 scoped_ptr
<BrowserPluginEmbedder
> browser_plugin_embedder_
;
1201 // Manages the guest state for browser plugin, if this WebContents is a guest;
1203 scoped_ptr
<BrowserPluginGuest
> browser_plugin_guest_
;
1205 #if defined(ENABLE_PLUGINS)
1206 // Manages the whitelist of plugin content origins exempt from power saving.
1207 scoped_ptr
<PluginContentOriginWhitelist
> plugin_content_origin_whitelist_
;
1210 // This must be at the end, or else we might get notifications and use other
1211 // member variables that are gone.
1212 NotificationRegistrar registrar_
;
1214 // Used during IPC message dispatching from the RenderView/RenderFrame so that
1215 // the handlers can get a pointer to the RVH through which the message was
1217 RenderViewHost
* render_view_message_source_
;
1218 RenderFrameHost
* render_frame_message_source_
;
1220 // All live RenderWidgetHostImpls that are created by this object and may
1222 std::set
<RenderWidgetHostImpl
*> created_widgets_
;
1224 // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1225 int fullscreen_widget_routing_id_
;
1227 // At the time the fullscreen widget was being shut down, did it have focus?
1228 // This is used to restore focus to the WebContentsView after both: 1) the
1229 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has
1230 // completed making layout changes to effect an exit from fullscreen mode.
1231 bool fullscreen_widget_had_focus_at_shutdown_
;
1233 // Maps the ids of pending image downloads to their callbacks
1234 typedef std::map
<int, ImageDownloadCallback
> ImageDownloadMap
;
1235 ImageDownloadMap image_download_map_
;
1237 // Whether this WebContents is responsible for displaying a subframe in a
1238 // different process from its parent page.
1241 // Whether overscroll should be unconditionally disabled.
1242 bool force_disable_overscroll_content_
;
1244 // Whether the last JavaScript dialog shown was suppressed. Used for testing.
1245 bool last_dialog_suppressed_
;
1247 scoped_ptr
<GeolocationServiceContext
> geolocation_service_context_
;
1249 scoped_ptr
<ScreenOrientationDispatcherHost
>
1250 screen_orientation_dispatcher_host_
;
1252 scoped_ptr
<ManifestManagerHost
> manifest_manager_host_
;
1254 // The accessibility mode for all frames. This is queried when each frame
1255 // is created, and broadcast to all frames when it changes.
1256 AccessibilityMode accessibility_mode_
;
1258 // Created on-demand to mute all audio output from this WebContents.
1259 scoped_ptr
<WebContentsAudioMuter
> audio_muter_
;
1261 bool virtual_keyboard_requested_
;
1263 #if defined(ENABLE_BROWSER_CDMS)
1264 // Manages all the media player and CDM managers and forwards IPCs to them.
1265 scoped_ptr
<MediaWebContentsObserver
> media_web_contents_observer_
;
1268 base::WeakPtrFactory
<WebContentsImpl
> loading_weak_factory_
;
1270 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl
);
1273 // Dangerous methods which should never be made part of the public API, so we
1274 // grant their use only to an explicit friend list (c++ attorney/client idiom).
1275 class CONTENT_EXPORT
WebContentsImpl::FriendZone
{
1277 friend class TestNavigationObserver
;
1278 friend class WebContentsAddedObserver
;
1279 friend class ContentBrowserSanityChecker
;
1281 FriendZone(); // Not instantiable.
1283 // Adds/removes a callback called on creation of each new WebContents.
1284 static void AddCreatedCallbackForTesting(const CreatedCallback
& callback
);
1285 static void RemoveCreatedCallbackForTesting(const CreatedCallback
& callback
);
1287 DISALLOW_COPY_AND_ASSIGN(FriendZone
);
1290 } // namespace content
1292 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_