Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_impl.h
blobf94639f921df4d22aea97de6d096c4f2448cf27d
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_
8 #include <map>
9 #include <set>
10 #include <string>
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_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;
48 namespace content {
49 class BrowserPluginEmbedder;
50 class BrowserPluginGuest;
51 class BrowserPluginGuestManager;
52 class DateTimeChooserAndroid;
53 class DownloadItem;
54 class GeolocationServiceContext;
55 class InterstitialPageImpl;
56 class JavaScriptDialogManager;
57 class ManifestManagerHost;
58 class MediaWebContentsObserver;
59 class PluginContentOriginWhitelist;
60 class PowerSaveBlocker;
61 class RenderViewHost;
62 class RenderViewHostDelegateView;
63 class RenderWidgetHostImpl;
64 class RenderWidgetHostInputEventRouter;
65 class SavePackage;
66 class ScreenOrientationDispatcherHost;
67 class SiteInstance;
68 class TestWebContents;
69 class WebContentsAudioMuter;
70 class WebContentsDelegate;
71 class WebContentsImpl;
72 class WebContentsObserver;
73 class WebContentsView;
74 class WebContentsViewDelegate;
75 struct AXEventNotificationDetails;
76 struct ColorSuggestion;
77 struct FaviconURL;
78 struct LoadNotificationDetails;
79 struct ResourceRedirectDetails;
80 struct ResourceRequestDetails;
82 #if defined(OS_ANDROID)
83 class WebContentsAndroid;
84 #endif
86 // Factory function for the implementations that content knows about. Takes
87 // ownership of |delegate|.
88 WebContentsView* CreateWebContentsView(
89 WebContentsImpl* web_contents,
90 WebContentsViewDelegate* delegate,
91 RenderViewHostDelegateView** render_view_host_delegate_view);
93 class CONTENT_EXPORT WebContentsImpl
94 : public NON_EXPORTED_BASE(WebContents),
95 public NON_EXPORTED_BASE(RenderFrameHostDelegate),
96 public RenderViewHostDelegate,
97 public RenderWidgetHostDelegate,
98 public RenderFrameHostManager::Delegate,
99 public NotificationObserver,
100 public NON_EXPORTED_BASE(NavigationControllerDelegate),
101 public NON_EXPORTED_BASE(NavigatorDelegate) {
102 public:
103 class FriendZone;
105 ~WebContentsImpl() override;
107 static WebContentsImpl* CreateWithOpener(
108 const WebContents::CreateParams& params,
109 FrameTreeNode* opener);
111 static std::vector<WebContentsImpl*> GetAllWebContents();
113 static WebContentsImpl* FromFrameTreeNode(FrameTreeNode* frame_tree_node);
115 // Creates a swapped out RenderView. This is used by the browser plugin to
116 // create a swapped out RenderView in the embedder render process for the
117 // guest, to expose the guest's window object to the embedder.
118 // This returns the routing ID of the newly created swapped out RenderView.
119 int CreateSwappedOutRenderView(SiteInstance* instance);
121 // Complex initialization here. Specifically needed to avoid having
122 // members call back into our virtual functions in the constructor.
123 virtual void Init(const WebContents::CreateParams& params);
125 // Returns the SavePackage which manages the page saving job. May be NULL.
126 SavePackage* save_package() const { return save_package_.get(); }
128 #if defined(OS_ANDROID)
129 // In Android WebView, the RenderView needs created even there is no
130 // navigation entry, this allows Android WebViews to use
131 // javascript: URLs that load into the DOMWindow before the first page
132 // load. This is not safe to do in any context that a web page could get a
133 // reference to the DOMWindow before the first page load.
134 bool CreateRenderViewForInitialEmptyDocument();
135 #endif
137 // Expose the render manager for testing.
138 // TODO(creis): Remove this now that we can get to it via FrameTreeNode.
139 RenderFrameHostManager* GetRenderManagerForTesting();
141 // Returns guest browser plugin object, or NULL if this WebContents is not a
142 // guest.
143 BrowserPluginGuest* GetBrowserPluginGuest() const;
145 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
146 // has a BrowserPluginGuest then that implies that it is being hosted by
147 // a BrowserPlugin object in an embedder renderer process.
148 void SetBrowserPluginGuest(BrowserPluginGuest* guest);
150 // Returns embedder browser plugin object, or NULL if this WebContents is not
151 // an embedder.
152 BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
154 // Creates a BrowserPluginEmbedder object for this WebContents if one doesn't
155 // already exist.
156 void CreateBrowserPluginEmbedderIfNecessary();
158 // Cancels modal dialogs in this WebContents, as well as in any browser
159 // plugins it is hosting.
160 void CancelActiveAndPendingDialogs();
162 // Gets the current fullscreen render widget's routing ID. Returns
163 // MSG_ROUTING_NONE when there is no fullscreen render widget.
164 int GetFullscreenWidgetRoutingID() const;
166 // Invoked when visible SSL state (as defined by SSLStatus) changes.
167 void DidChangeVisibleSSLState();
169 // Informs the render view host and the BrowserPluginEmbedder, if present, of
170 // a Drag Source End.
171 void DragSourceEndedAt(int client_x, int client_y, int screen_x,
172 int screen_y, blink::WebDragOperation operation);
174 // A response has been received for a resource request.
175 void DidGetResourceResponseStart(
176 const ResourceRequestDetails& details);
178 // A redirect was received while requesting a resource.
179 void DidGetRedirectForResourceRequest(
180 RenderFrameHost* render_frame_host,
181 const ResourceRedirectDetails& details);
183 // Notify observers that the web contents has been focused.
184 void NotifyWebContentsFocused();
186 WebContentsView* GetView() const;
188 ScreenOrientationDispatcherHost* screen_orientation_dispatcher_host() {
189 return screen_orientation_dispatcher_host_.get();
192 bool should_normally_be_visible() { return should_normally_be_visible_; }
194 // Indicate if the window has been occluded, and pass this to the views, only
195 // if there is no active capture going on (otherwise it is dropped on the
196 // floor).
197 void WasOccluded();
198 void WasUnOccluded();
200 // Broadcasts the mode change to all frames.
201 void SetAccessibilityMode(AccessibilityMode mode);
203 // Adds the given accessibility mode to the current accessibility mode
204 // bitmap.
205 void AddAccessibilityMode(AccessibilityMode mode);
207 // Removes the given accessibility mode from the current accessibility
208 // mode bitmap, managing the bits that are shared with other modes such
209 // that a bit will only be turned off when all modes that depend on it
210 // have been removed.
211 void RemoveAccessibilityMode(AccessibilityMode mode);
213 // Request a one-time snapshot of the accessibility tree without changing
214 // the accessibility mode.
215 using AXTreeSnapshotCallback =
216 base::Callback<void(const ui::AXTreeUpdate<ui::AXNodeData>&)>;
217 void RequestAXTreeSnapshot(AXTreeSnapshotCallback callback);
219 // WebContents ------------------------------------------------------
220 WebContentsDelegate* GetDelegate() override;
221 void SetDelegate(WebContentsDelegate* delegate) override;
222 NavigationControllerImpl& GetController() override;
223 const NavigationControllerImpl& GetController() const override;
224 BrowserContext* GetBrowserContext() const override;
225 const GURL& GetURL() const override;
226 const GURL& GetVisibleURL() const override;
227 const GURL& GetLastCommittedURL() const override;
228 RenderProcessHost* GetRenderProcessHost() const override;
229 RenderFrameHostImpl* GetMainFrame() override;
230 RenderFrameHostImpl* GetFocusedFrame() override;
231 void ForEachFrame(
232 const base::Callback<void(RenderFrameHost*)>& on_frame) override;
233 void SendToAllFrames(IPC::Message* message) override;
234 RenderViewHostImpl* GetRenderViewHost() const override;
235 int GetRoutingID() const override;
236 RenderWidgetHostView* GetRenderWidgetHostView() const override;
237 void ClosePage() override;
238 RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const override;
239 SkColor GetThemeColor() const override;
240 WebUI* CreateSubframeWebUI(const GURL& url,
241 const std::string& frame_name) override;
242 WebUI* GetWebUI() const override;
243 WebUI* GetCommittedWebUI() const override;
244 void SetUserAgentOverride(const std::string& override) override;
245 const std::string& GetUserAgentOverride() const override;
246 void EnableTreeOnlyAccessibilityMode() override;
247 bool IsTreeOnlyAccessibilityModeForTesting() const override;
248 bool IsFullAccessibilityModeForTesting() const override;
249 #if defined(OS_WIN)
250 void SetParentNativeViewAccessible(
251 gfx::NativeViewAccessible accessible_parent) override;
252 #endif
253 const base::string16& GetTitle() const override;
254 int32 GetMaxPageID() override;
255 int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) override;
256 SiteInstanceImpl* GetSiteInstance() const override;
257 SiteInstanceImpl* GetPendingSiteInstance() const override;
258 bool IsLoading() const override;
259 bool IsLoadingToDifferentDocument() const override;
260 bool IsWaitingForResponse() const override;
261 const net::LoadStateWithParam& GetLoadState() const override;
262 const base::string16& GetLoadStateHost() const override;
263 uint64 GetUploadSize() const override;
264 uint64 GetUploadPosition() const override;
265 std::set<GURL> GetSitesInTab() const override;
266 const std::string& GetEncoding() const override;
267 bool DisplayedInsecureContent() const override;
268 void IncrementCapturerCount(const gfx::Size& capture_size) override;
269 void DecrementCapturerCount() override;
270 int GetCapturerCount() const override;
271 bool IsAudioMuted() const override;
272 void SetAudioMuted(bool mute) override;
273 bool IsCrashed() const override;
274 void SetIsCrashed(base::TerminationStatus status, int error_code) override;
275 base::TerminationStatus GetCrashedStatus() const override;
276 bool IsBeingDestroyed() const override;
277 void NotifyNavigationStateChanged(InvalidateTypes changed_flags) override;
278 base::TimeTicks GetLastActiveTime() const override;
279 void SetLastActiveTime(base::TimeTicks last_active_time) override;
280 void WasShown() override;
281 void WasHidden() override;
282 bool NeedToFireBeforeUnload() override;
283 void DispatchBeforeUnload(bool for_cross_site_transition) override;
284 void AttachToOuterWebContentsFrame(
285 WebContents* outer_web_contents,
286 RenderFrameHost* outer_contents_frame) override;
287 void Stop() override;
288 WebContents* Clone() override;
289 void ReloadFocusedFrame(bool ignore_cache) override;
290 void Undo() override;
291 void Redo() override;
292 void Cut() override;
293 void Copy() override;
294 void CopyToFindPboard() override;
295 void Paste() override;
296 void PasteAndMatchStyle() override;
297 void Delete() override;
298 void SelectAll() override;
299 void Unselect() override;
300 void Replace(const base::string16& word) override;
301 void ReplaceMisspelling(const base::string16& word) override;
302 void NotifyContextMenuClosed(
303 const CustomContextMenuContext& context) override;
304 void ExecuteCustomContextMenuCommand(
305 int action,
306 const CustomContextMenuContext& context) override;
307 gfx::NativeView GetNativeView() override;
308 gfx::NativeView GetContentNativeView() override;
309 gfx::NativeWindow GetTopLevelNativeWindow() override;
310 gfx::Rect GetContainerBounds() override;
311 gfx::Rect GetViewBounds() override;
312 DropData* GetDropData() override;
313 void Focus() override;
314 void SetInitialFocus() override;
315 void StoreFocus() override;
316 void RestoreFocus() override;
317 void FocusThroughTabTraversal(bool reverse) override;
318 bool ShowingInterstitialPage() const override;
319 InterstitialPage* GetInterstitialPage() const override;
320 bool IsSavable() override;
321 void OnSavePage() override;
322 bool SavePage(const base::FilePath& main_file,
323 const base::FilePath& dir_path,
324 SavePageType save_type) override;
325 void SaveFrame(const GURL& url, const Referrer& referrer) override;
326 void SaveFrameWithHeaders(const GURL& url,
327 const Referrer& referrer,
328 const std::string& headers) override;
329 void GenerateMHTML(const base::FilePath& file,
330 const base::Callback<void(int64)>& callback) override;
331 const std::string& GetContentsMimeType() const override;
332 bool WillNotifyDisconnection() const override;
333 void SetOverrideEncoding(const std::string& encoding) override;
334 void ResetOverrideEncoding() override;
335 RendererPreferences* GetMutableRendererPrefs() override;
336 void Close() override;
337 void SystemDragEnded() override;
338 void UserGestureDone() override;
339 void SetClosedByUserGesture(bool value) override;
340 bool GetClosedByUserGesture() const override;
341 void ViewSource() override;
342 void ViewFrameSource(const GURL& url, const PageState& page_state) override;
343 int GetMinimumZoomPercent() const override;
344 int GetMaximumZoomPercent() const override;
345 void ResetPageScale() override;
346 gfx::Size GetPreferredSize() const override;
347 bool GotResponseToLockMouseRequest(bool allowed) override;
348 bool HasOpener() const override;
349 WebContentsImpl* GetOpener() const override;
350 void DidChooseColorInColorChooser(SkColor color) override;
351 void DidEndColorChooser() override;
352 int DownloadImage(const GURL& url,
353 bool is_favicon,
354 uint32_t max_bitmap_size,
355 bool bypass_cache,
356 const ImageDownloadCallback& callback) override;
357 bool IsSubframe() const override;
358 void Find(int request_id,
359 const base::string16& search_text,
360 const blink::WebFindOptions& options) override;
361 void StopFinding(StopFindAction action) override;
362 void InsertCSS(const std::string& css) override;
363 bool WasRecentlyAudible() override;
364 void GetManifest(const GetManifestCallback&) override;
365 void ExitFullscreen() override;
366 void ResumeLoadingCreatedWebContents() override;
367 #if defined(OS_ANDROID)
368 void OnMediaSessionStateChanged();
369 void ResumeMediaSession() override;
370 void SuspendMediaSession() override;
371 void StopMediaSession() override;
373 base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() override;
374 virtual WebContentsAndroid* GetWebContentsAndroid();
375 #elif defined(OS_MACOSX)
376 void SetAllowOtherViews(bool allow) override;
377 bool GetAllowOtherViews() override;
378 #endif
380 // Implementation of PageNavigator.
381 WebContents* OpenURL(const OpenURLParams& params) override;
383 // Implementation of IPC::Sender.
384 bool Send(IPC::Message* message) override;
386 // RenderFrameHostDelegate ---------------------------------------------------
387 bool OnMessageReceived(RenderFrameHost* render_frame_host,
388 const IPC::Message& message) override;
389 const GURL& GetMainFrameLastCommittedURL() const override;
390 void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
391 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
392 void SwappedOut(RenderFrameHost* render_frame_host) override;
393 void ShowContextMenu(RenderFrameHost* render_frame_host,
394 const ContextMenuParams& params) override;
395 void RunJavaScriptMessage(RenderFrameHost* render_frame_host,
396 const base::string16& message,
397 const base::string16& default_prompt,
398 const GURL& frame_url,
399 JavaScriptMessageType type,
400 IPC::Message* reply_msg) override;
401 void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host,
402 const base::string16& message,
403 bool is_reload,
404 IPC::Message* reply_msg) override;
405 void DidAccessInitialDocument() override;
406 void DidChangeName(RenderFrameHost* render_frame_host,
407 const std::string& name) override;
408 void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) override;
409 void UpdateTitle(RenderFrameHost* render_frame_host,
410 int32 page_id,
411 const base::string16& title,
412 base::i18n::TextDirection title_direction) override;
413 void UpdateEncoding(RenderFrameHost* render_frame_host,
414 const std::string& encoding) override;
415 WebContents* GetAsWebContents() override;
416 bool IsNeverVisible() override;
417 AccessibilityMode GetAccessibilityMode() const override;
418 void AccessibilityEventReceived(
419 const std::vector<AXEventNotificationDetails>& details) override;
420 RenderFrameHost* GetGuestByInstanceID(
421 RenderFrameHost* render_frame_host,
422 int browser_plugin_instance_id) override;
423 GeolocationServiceContext* GetGeolocationServiceContext() override;
424 void EnterFullscreenMode(const GURL& origin) override;
425 void ExitFullscreenMode() override;
426 bool ShouldRouteMessageEvent(
427 RenderFrameHost* target_rfh,
428 SiteInstance* source_site_instance) const override;
429 void EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) override;
430 #if defined(OS_WIN)
431 gfx::NativeViewAccessible GetParentNativeViewAccessible() override;
432 #endif
434 // RenderViewHostDelegate ----------------------------------------------------
435 RenderViewHostDelegateView* GetDelegateView() override;
436 bool OnMessageReceived(RenderViewHost* render_view_host,
437 const IPC::Message& message) override;
438 // RenderFrameHostDelegate has the same method, so list it there because this
439 // interface is going away.
440 // WebContents* GetAsWebContents() override;
441 gfx::Rect GetRootWindowResizerRect() const override;
442 void RenderViewCreated(RenderViewHost* render_view_host) override;
443 void RenderViewReady(RenderViewHost* render_view_host) override;
444 void RenderViewTerminated(RenderViewHost* render_view_host,
445 base::TerminationStatus status,
446 int error_code) override;
447 void RenderViewDeleted(RenderViewHost* render_view_host) override;
448 void UpdateState(RenderViewHost* render_view_host,
449 int32 page_id,
450 const PageState& page_state) override;
451 void UpdateTargetURL(RenderViewHost* render_view_host,
452 const GURL& url) override;
453 void Close(RenderViewHost* render_view_host) override;
454 void RequestMove(const gfx::Rect& new_bounds) override;
455 void DidCancelLoading() override;
456 void DocumentAvailableInMainFrame(RenderViewHost* render_view_host) override;
457 void RouteCloseEvent(RenderViewHost* rvh) override;
458 bool AddMessageToConsole(int32 level,
459 const base::string16& message,
460 int32 line_no,
461 const base::string16& source_id) override;
462 RendererPreferences GetRendererPrefs(
463 BrowserContext* browser_context) const override;
464 void OnUserGesture() override;
465 void OnIgnoredUIEvent() override;
466 void RendererUnresponsive(RenderViewHost* render_view_host) override;
467 void RendererResponsive(RenderViewHost* render_view_host) override;
468 void LoadStateChanged(const GURL& url,
469 const net::LoadStateWithParam& load_state,
470 uint64 upload_position,
471 uint64 upload_size) override;
472 void Activate() override;
473 void Deactivate() override;
474 void LostCapture() override;
475 void RunFileChooser(RenderViewHost* render_view_host,
476 const FileChooserParams& params) override;
477 bool IsFullscreenForCurrentTab() const override;
478 blink::WebDisplayMode GetDisplayMode() const override;
479 void UpdatePreferredSize(const gfx::Size& pref_size) override;
480 void ResizeDueToAutoResize(const gfx::Size& new_size) override;
481 void RequestToLockMouse(bool user_gesture,
482 bool last_unlocked_by_target) override;
483 void LostMouseLock() override;
484 void CreateNewWindow(
485 SiteInstance* source_site_instance,
486 int route_id,
487 int main_frame_route_id,
488 const ViewHostMsg_CreateWindow_Params& params,
489 SessionStorageNamespace* session_storage_namespace) override;
490 void CreateNewWidget(int32 render_process_id,
491 int32 route_id,
492 int32 surface_id,
493 blink::WebPopupType popup_type) override;
494 void CreateNewFullscreenWidget(int32 render_process_id,
495 int32 route_id,
496 int32 surface_id) override;
497 void ShowCreatedWindow(int route_id,
498 WindowOpenDisposition disposition,
499 const gfx::Rect& initial_rect,
500 bool user_gesture) override;
501 void ShowCreatedWidget(int route_id, const gfx::Rect& initial_rect) override;
502 void ShowCreatedFullscreenWidget(int route_id) override;
503 void RequestMediaAccessPermission(
504 const MediaStreamRequest& request,
505 const MediaResponseCallback& callback) override;
506 bool CheckMediaAccessPermission(const GURL& security_origin,
507 MediaStreamType type) override;
508 SessionStorageNamespace* GetSessionStorageNamespace(
509 SiteInstance* instance) override;
510 SessionStorageNamespaceMap GetSessionStorageNamespaceMap() override;
511 FrameTree* GetFrameTree() override;
512 void SetIsVirtualKeyboardRequested(bool requested) override;
513 bool IsVirtualKeyboardRequested() override;
515 // NavigatorDelegate ---------------------------------------------------------
517 void DidStartNavigation(NavigationHandle* navigation_handle) override;
518 void DidRedirectNavigation(NavigationHandle* navigation_handle) override;
519 void DidCommitNavigation(NavigationHandle* navigation_handle) override;
520 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
521 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
522 const GURL& validated_url,
523 bool is_error_page,
524 bool is_iframe_srcdoc) override;
525 void DidFailProvisionalLoadWithError(
526 RenderFrameHostImpl* render_frame_host,
527 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
528 override;
529 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
530 const GURL& url,
531 int error_code,
532 const base::string16& error_description,
533 bool was_ignored_by_handler) override;
534 void DidCommitProvisionalLoad(RenderFrameHostImpl* render_frame_host,
535 const GURL& url,
536 ui::PageTransition transition_type) override;
537 void DidNavigateMainFramePreCommit(bool navigation_is_within_page) override;
538 void DidNavigateMainFramePostCommit(
539 RenderFrameHostImpl* render_frame_host,
540 const LoadCommittedDetails& details,
541 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) override;
542 void DidNavigateAnyFramePostCommit(
543 RenderFrameHostImpl* render_frame_host,
544 const LoadCommittedDetails& details,
545 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) override;
546 void SetMainFrameMimeType(const std::string& mime_type) override;
547 bool CanOverscrollContent() const override;
548 void NotifyChangedNavigationState(InvalidateTypes changed_flags) override;
549 void AboutToNavigateRenderFrame(
550 RenderFrameHostImpl* old_host,
551 RenderFrameHostImpl* new_host) override;
552 void DidStartNavigationToPendingEntry(
553 const GURL& url,
554 NavigationController::ReloadType reload_type) override;
555 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
556 const OpenURLParams& params) override;
557 bool ShouldPreserveAbortedURLs() override;
558 void DidStartLoading(FrameTreeNode* frame_tree_node,
559 bool to_different_document) override;
560 void DidStopLoading() override;
561 void DidChangeLoadProgress() override;
563 // RenderWidgetHostDelegate --------------------------------------------------
565 void RenderWidgetDeleted(RenderWidgetHostImpl* render_widget_host) override;
566 void RenderWidgetGotFocus(RenderWidgetHostImpl* render_widget_host) override;
567 void RenderWidgetWasResized(RenderWidgetHostImpl* render_widget_host,
568 bool width_changed) override;
569 void ScreenInfoChanged() override;
570 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
571 bool* is_keyboard_shortcut) override;
572 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override;
573 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override;
574 bool PreHandleGestureEvent(const blink::WebGestureEvent& event) override;
575 void DidSendScreenRects(RenderWidgetHostImpl* rwh) override;
576 BrowserAccessibilityManager* GetRootBrowserAccessibilityManager() override;
577 BrowserAccessibilityManager* GetOrCreateRootBrowserAccessibilityManager()
578 override;
579 // The following 4 functions are already listed under WebContents overrides:
580 // void Cut() override;
581 // void Copy() override;
582 // void Paste() override;
583 // void SelectAll() override;
584 void MoveRangeSelectionExtent(const gfx::Point& extent) override;
585 void SelectRange(const gfx::Point& base, const gfx::Point& extent) override;
586 void AdjustSelectionByCharacterOffset(int start_adjust, int end_adjust)
587 override;
588 RenderWidgetHostInputEventRouter* GetInputEventRouter() override;
590 // RenderFrameHostManager::Delegate ------------------------------------------
592 bool CreateRenderViewForRenderManager(
593 RenderViewHost* render_view_host,
594 int opener_frame_routing_id,
595 int proxy_routing_id,
596 const FrameReplicationState& replicated_frame_state,
597 bool for_main_frame_navigation) override;
598 bool CreateRenderFrameForRenderManager(
599 RenderFrameHost* render_frame_host,
600 int proxy_routing_id,
601 int opener_routing_id,
602 int parent_routing_id,
603 int previous_sibling_routing_id) override;
604 void BeforeUnloadFiredFromRenderManager(
605 bool proceed,
606 const base::TimeTicks& proceed_time,
607 bool* proceed_to_fire_unload) override;
608 void RenderProcessGoneFromRenderManager(
609 RenderViewHost* render_view_host) override;
610 void UpdateRenderViewSizeForRenderManager() override;
611 void CancelModalDialogsForRenderManager() override;
612 void NotifySwappedFromRenderManager(RenderFrameHost* old_host,
613 RenderFrameHost* new_host,
614 bool is_main_frame) override;
615 void NotifyMainFrameSwappedFromRenderManager(
616 RenderViewHost* old_host,
617 RenderViewHost* new_host) override;
618 NavigationControllerImpl& GetControllerForRenderManager() override;
619 scoped_ptr<WebUIImpl> CreateWebUIForRenderManager(const GURL& url) override;
620 NavigationEntry* GetLastCommittedNavigationEntryForRenderManager() override;
621 bool FocusLocationBarByDefault() override;
622 void SetFocusToLocationBar(bool select_all) override;
623 bool IsHidden() override;
624 int GetOuterDelegateFrameTreeNodeID() override;
626 // NotificationObserver ------------------------------------------------------
628 void Observe(int type,
629 const NotificationSource& source,
630 const NotificationDetails& details) override;
632 // NavigationControllerDelegate ----------------------------------------------
634 WebContents* GetWebContents() override;
635 void NotifyNavigationEntryCommitted(
636 const LoadCommittedDetails& load_details) override;
638 // Invoked before a form repost warning is shown.
639 void NotifyBeforeFormRepostWarningShow() override;
641 // Activate this WebContents and show a form repost warning.
642 void ActivateAndShowRepostFormWarningDialog() override;
644 // Whether the initial empty page of this view has been accessed by another
645 // page, making it unsafe to show the pending URL. Always false after the
646 // first commit.
647 bool HasAccessedInitialDocument() override;
649 // Updates the max page ID for the current SiteInstance in this
650 // WebContentsImpl to be at least |page_id|.
651 void UpdateMaxPageID(int32 page_id) override;
653 // Updates the max page ID for the given SiteInstance in this WebContentsImpl
654 // to be at least |page_id|.
655 void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
656 int32 page_id) override;
658 // Copy the current map of SiteInstance ID to max page ID from another tab.
659 // This is necessary when this tab adopts the NavigationEntries from
660 // |web_contents|.
661 void CopyMaxPageIDsFrom(WebContents* web_contents) override;
663 // Sets the history for this WebContentsImpl to |history_length| entries, with
664 // an offset of |history_offset|.
665 void SetHistoryOffsetAndLength(int history_offset,
666 int history_length) override;
668 // Called by InterstitialPageImpl when it creates a RenderFrameHost.
669 void RenderFrameForInterstitialPageCreated(
670 RenderFrameHost* render_frame_host) override;
672 // Sets the passed interstitial as the currently showing interstitial.
673 // No interstitial page should already be attached.
674 void AttachInterstitialPage(InterstitialPageImpl* interstitial_page) override;
676 // Unsets the currently showing interstitial.
677 void DetachInterstitialPage() override;
679 // Changes the IsLoading state and notifies the delegate as needed.
680 // |details| is used to provide details on the load that just finished
681 // (but can be null if not applicable).
682 void SetIsLoading(bool is_loading,
683 bool to_different_document,
684 LoadNotificationDetails* details) override;
686 typedef base::Callback<void(WebContents*)> CreatedCallback;
688 // Forces overscroll to be disabled (used by touch emulation).
689 void SetForceDisableOverscrollContent(bool force_disable);
691 AudioStreamMonitor* audio_stream_monitor() {
692 return &audio_stream_monitor_;
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();
707 #endif
709 private:
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(WebContentsImplTest,
722 LoadResourceFromMemoryCacheWithBadSecurityInfo);
723 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
724 LoadResourceFromMemoryCacheWithEmptySecurityInfo);
725 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
726 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
727 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest, PageDoesBackAndReload);
728 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrossSiteIframe);
729 FRIEND_TEST_ALL_PREFIXES(SitePerProcessAccessibilityBrowserTest,
730 CrossSiteIframeAccessibility);
732 // So InterstitialPageImpl can access SetIsLoading.
733 friend class InterstitialPageImpl;
735 // TODO(brettw) TestWebContents shouldn't exist!
736 friend class TestWebContents;
738 class DestructionObserver;
740 // Represents a WebContents node in a tree of WebContents structure.
742 // Two WebContents with separate FrameTrees can be connected by
743 // outer/inner relationship using this class. Note that their FrameTrees
744 // still remain disjoint.
745 // The parent is referred to as "outer WebContents" and the descendents are
746 // referred to as "inner WebContents".
747 // For each inner WebContents, the outer WebContents will have a
748 // corresponding FrameTreeNode.
749 struct WebContentsTreeNode {
750 public:
751 WebContentsTreeNode();
752 ~WebContentsTreeNode();
754 typedef std::set<WebContentsTreeNode*> ChildrenSet;
756 void ConnectToOuterWebContents(WebContentsImpl* outer_web_contents,
757 RenderFrameHostImpl* outer_contents_frame);
759 WebContentsImpl* outer_web_contents() { return outer_web_contents_; }
760 int outer_contents_frame_tree_node_id() {
761 return outer_contents_frame_tree_node_id_;
764 private:
765 // The outer Webontents.
766 WebContentsImpl* outer_web_contents_;
767 // The ID of the FrameTreeNode in outer WebContents that is hosting us.
768 int outer_contents_frame_tree_node_id_;
769 // List of inner WebContents that we host.
770 ChildrenSet inner_web_contents_tree_nodes_;
773 // See WebContents::Create for a description of these parameters.
774 WebContentsImpl(BrowserContext* browser_context);
776 // Add and remove observers for page navigation notifications. The order in
777 // which notifications are sent to observers is undefined. Clients must be
778 // sure to remove the observer before they go away.
779 void AddObserver(WebContentsObserver* observer);
780 void RemoveObserver(WebContentsObserver* observer);
782 // Clears a pending contents that has been closed before being shown.
783 void OnWebContentsDestroyed(WebContentsImpl* web_contents);
785 // Creates and adds to the map a destruction observer watching |web_contents|.
786 // No-op if such an observer already exists.
787 void AddDestructionObserver(WebContentsImpl* web_contents);
789 // Deletes and removes from the map a destruction observer
790 // watching |web_contents|. No-op if there is no such observer.
791 void RemoveDestructionObserver(WebContentsImpl* web_contents);
793 // Traverses all the RenderFrameHosts in the FrameTree and creates a set
794 // all the unique RenderWidgetHostViews.
795 std::set<RenderWidgetHostView*> GetRenderWidgetHostViewsInTree();
797 // Callback function when showing JavaScript dialogs. Takes in a routing ID
798 // pair to identify the RenderFrameHost that opened the dialog, because it's
799 // possible for the RenderFrameHost to be deleted by the time this is called.
800 void OnDialogClosed(int render_process_id,
801 int render_frame_id,
802 IPC::Message* reply_msg,
803 bool dialog_was_suppressed,
804 bool success,
805 const base::string16& user_input);
807 bool OnMessageReceived(RenderViewHost* render_view_host,
808 RenderFrameHost* render_frame_host,
809 const IPC::Message& message);
811 // Checks whether render_frame_message_source_ is set to non-null value,
812 // otherwise it terminates the main frame renderer process.
813 bool HasValidFrameSource();
815 // IPC message handlers.
816 void OnThemeColorChanged(SkColor theme_color);
817 void OnDidLoadResourceFromMemoryCache(const GURL& url,
818 const std::string& security_info,
819 const std::string& http_request,
820 const std::string& mime_type,
821 ResourceType resource_type);
822 void OnDidDisplayInsecureContent();
823 void OnDidRunInsecureContent(const std::string& security_origin,
824 const GURL& target_url);
825 void OnDocumentLoadedInFrame();
826 void OnDidFinishLoad(const GURL& url);
827 void OnGoToEntryAtOffset(int offset);
828 void OnUpdateZoomLimits(int minimum_percent,
829 int maximum_percent);
830 void OnEnumerateDirectory(int request_id, const base::FilePath& path);
832 void OnRegisterProtocolHandler(const std::string& protocol,
833 const GURL& url,
834 const base::string16& title,
835 bool user_gesture);
836 void OnUnregisterProtocolHandler(const std::string& protocol,
837 const GURL& url,
838 bool user_gesture);
839 void OnFindReply(int request_id,
840 int number_of_matches,
841 const gfx::Rect& selection_rect,
842 int active_match_ordinal,
843 bool final_update);
844 #if defined(OS_ANDROID)
845 void OnFindMatchRectsReply(int version,
846 const std::vector<gfx::RectF>& rects,
847 const gfx::RectF& active_rect);
849 void OnOpenDateTimeDialog(
850 const ViewHostMsg_DateTimeDialogValue_Params& value);
851 #endif
852 void OnDomOperationResponse(const std::string& json_string,
853 int automation_id);
854 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
855 void OnOpenColorChooser(int color_chooser_id,
856 SkColor color,
857 const std::vector<ColorSuggestion>& suggestions);
858 void OnEndColorChooser(int color_chooser_id);
859 void OnSetSelectedColorInColorChooser(int color_chooser_id, SkColor color);
860 void OnWebUISend(const GURL& source_url,
861 const std::string& name,
862 const base::ListValue& args);
863 #if defined(ENABLE_PLUGINS)
864 void OnPepperInstanceCreated();
865 void OnPepperInstanceDeleted();
866 void OnPepperPluginHung(int plugin_child_id,
867 const base::FilePath& path,
868 bool is_hung);
869 void OnPluginCrashed(const base::FilePath& plugin_path,
870 base::ProcessId plugin_pid);
871 void OnRequestPpapiBrokerPermission(int routing_id,
872 const GURL& url,
873 const base::FilePath& plugin_path);
875 // Callback function when requesting permission to access the PPAPI broker.
876 // |result| is true if permission was granted.
877 void OnPpapiBrokerPermissionResult(int routing_id, bool result);
879 void OnBrowserPluginMessage(RenderFrameHost* render_frame_host,
880 const IPC::Message& message);
881 #endif // defined(ENABLE_PLUGINS)
882 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates);
883 void OnFirstVisuallyNonEmptyPaint();
884 void OnMediaPlayingNotification(int64 player_cookie,
885 bool has_video,
886 bool has_audio,
887 bool is_remote);
888 void OnMediaPausedNotification(int64 player_cookie);
889 void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view,
890 const base::string16& main_text,
891 const base::string16& sub_text);
892 void OnHideValidationMessage();
893 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view);
895 // Called by derived classes to indicate that we're no longer waiting for a
896 // response. This won't actually update the throbber, but it will get picked
897 // up at the next animation step if the throbber is going.
898 void SetNotWaitingForResponse() { waiting_for_response_ = false; }
900 // Navigation helpers --------------------------------------------------------
902 // These functions are helpers for Navigate() and DidNavigate().
904 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
905 // committed to the navigation controller. Note that the navigation entry is
906 // not provided since it may be invalid/changed after being committed. The
907 // current navigation entry is in the NavigationController at this point.
909 // If our controller was restored, update the max page ID associated with the
910 // given RenderViewHost to be larger than the number of restored entries.
911 // This is called in CreateRenderView before any navigations in the RenderView
912 // have begun, to prevent any races in updating RenderView::next_page_id.
913 void UpdateMaxPageIDIfNecessary(RenderViewHost* rvh);
915 // Saves the given title to the navigation entry and does associated work. It
916 // will update history and the view for the new title, and also synthesize
917 // titles for file URLs that have none (so we require that the URL of the
918 // entry already be set).
920 // This is used as the backend for state updates, which include a new title,
921 // or the dedicated set title message. It returns true if the new title is
922 // different and was therefore updated.
923 bool UpdateTitleForEntry(NavigationEntryImpl* entry,
924 const base::string16& title);
926 // Helper for CreateNewWidget/CreateNewFullscreenWidget.
927 void CreateNewWidget(int32 render_process_id,
928 int32 route_id,
929 int32 surface_id,
930 bool is_fullscreen,
931 blink::WebPopupType popup_type);
933 // Helper for ShowCreatedWidget/ShowCreatedFullscreenWidget.
934 void ShowCreatedWidget(int route_id,
935 bool is_fullscreen,
936 const gfx::Rect& initial_rect);
938 // Finds the new RenderWidgetHost and returns it. Note that this can only be
939 // called once as this call also removes it from the internal map.
940 RenderWidgetHostView* GetCreatedWidget(int route_id);
942 // Finds the new WebContentsImpl by route_id, initializes it for
943 // renderer-initiated creation, and returns it. Note that this can only be
944 // called once as this call also removes it from the internal map.
945 WebContentsImpl* GetCreatedWindow(int route_id);
947 // Tracking loading progress -------------------------------------------------
949 // Resets the tracking state of the current load progress.
950 void ResetLoadProgressState();
952 // Notifies the delegate that the load progress was updated.
953 void SendChangeLoadProgress();
955 // Misc non-view stuff -------------------------------------------------------
957 // Sets the history for a specified RenderViewHost to |history_length|
958 // entries, with an offset of |history_offset|.
959 void SetHistoryOffsetAndLengthForView(RenderViewHost* render_view_host,
960 int history_offset,
961 int history_length);
963 // Helper functions for sending notifications.
964 void NotifyViewSwapped(RenderViewHost* old_host, RenderViewHost* new_host);
965 void NotifyFrameSwapped(RenderFrameHost* old_host, RenderFrameHost* new_host);
966 void NotifyDisconnected();
968 void SetEncoding(const std::string& encoding);
970 // TODO(creis): This should take in a FrameTreeNode to know which node's
971 // render manager to return. For now, we just return the root's.
972 RenderFrameHostManager* GetRenderManager() const;
974 // Removes browser plugin embedder if there is one.
975 void RemoveBrowserPluginEmbedder();
977 // Clear |render_frame_host|'s tracking entry for its power save blockers.
978 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host);
980 // Clear tracking entries for all RenderFrameHosts, clears
981 // |audio_power_save_blocker_| and |video_power_save_blocker_|.
982 void ClearAllPowerSaveBlockers();
984 // Creates an audio or video power save blocker respectively.
985 void CreateAudioPowerSaveBlocker();
986 void CreateVideoPowerSaveBlocker();
988 // Releases the audio power save blockers if |active_audio_players_| is empty.
989 // Likewise, releases the video power save blockers if |active_video_players_|
990 // is empty.
991 void MaybeReleasePowerSaveBlockers();
993 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView().
994 gfx::Size GetSizeForNewRenderView();
996 void OnFrameRemoved(RenderFrameHost* render_frame_host);
998 // Helper method that's called whenever |preferred_size_| or
999 // |preferred_size_for_capture_| changes, to propagate the new value to the
1000 // |delegate_|.
1001 void OnPreferredSizeChanged(const gfx::Size& old_size);
1003 // Helper methods for adding or removing player entries in |player_map| under
1004 // the key |render_frame_message_source_|.
1005 typedef std::vector<int64> PlayerList;
1006 typedef std::map<uintptr_t, PlayerList> ActiveMediaPlayerMap;
1007 void AddMediaPlayerEntry(int64 player_cookie,
1008 ActiveMediaPlayerMap* player_map);
1009 void RemoveMediaPlayerEntry(int64 player_cookie,
1010 ActiveMediaPlayerMap* player_map);
1011 // Removes all entries from |player_map| for |render_frame_host|.
1012 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host,
1013 ActiveMediaPlayerMap* player_map);
1015 // Internal helper to create WebUI objects associated with |this|. |url| is
1016 // used to determine which WebUI should be created (if any). |frame_name|
1017 // corresponds to the name of a frame that the WebUI should be created for (or
1018 // the main frame if empty).
1019 WebUI* CreateWebUI(const GURL& url, const std::string& frame_name);
1021 // Data for core operation ---------------------------------------------------
1023 // Delegate for notifying our owner about stuff. Not owned by us.
1024 WebContentsDelegate* delegate_;
1026 // Handles the back/forward list and loading.
1027 NavigationControllerImpl controller_;
1029 // The corresponding view.
1030 scoped_ptr<WebContentsView> view_;
1032 // The view of the RVHD. Usually this is our WebContentsView implementation,
1033 // but if an embedder uses a different WebContentsView, they'll need to
1034 // provide this.
1035 RenderViewHostDelegateView* render_view_host_delegate_view_;
1037 // Tracks created WebContentsImpl objects that have not been shown yet. They
1038 // are identified by the route ID passed to CreateNewWindow.
1039 typedef std::map<int, WebContentsImpl*> PendingContents;
1040 PendingContents pending_contents_;
1042 // These maps hold on to the widgets that we created on behalf of the renderer
1043 // that haven't shown yet.
1044 typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews;
1045 PendingWidgetViews pending_widget_views_;
1047 typedef std::map<WebContentsImpl*, DestructionObserver*> DestructionObservers;
1048 DestructionObservers destruction_observers_;
1050 // A list of observers notified when page state changes. Weak references.
1051 // This MUST be listed above frame_tree_ since at destruction time the
1052 // latter might cause RenderViewHost's destructor to call us and we might use
1053 // the observer list then.
1054 base::ObserverList<WebContentsObserver> observers_;
1056 // True if this tab was opened by another tab. This is not unset if the opener
1057 // is closed.
1058 bool created_with_opener_;
1060 #if defined(OS_WIN)
1061 gfx::NativeViewAccessible accessible_parent_;
1062 #endif
1064 // Helper classes ------------------------------------------------------------
1066 // Tracking variables and associated power save blockers for media playback.
1067 ActiveMediaPlayerMap active_audio_players_;
1068 ActiveMediaPlayerMap active_video_players_;
1069 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_;
1070 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_;
1072 // Manages the frame tree of the page and process swaps in each node.
1073 FrameTree frame_tree_;
1075 // If this WebContents is part of a "tree of WebContents", then this contains
1076 // information about the structure.
1077 scoped_ptr<WebContentsTreeNode> node_;
1079 // SavePackage, lazily created.
1080 scoped_refptr<SavePackage> save_package_;
1082 // Data for loading state ----------------------------------------------------
1084 // Indicates whether we're currently loading a resource.
1085 bool is_loading_;
1087 // Indicates whether the current load is to a different document. Only valid
1088 // if is_loading_ is true.
1089 bool is_load_to_different_document_;
1091 // Indicates if the tab is considered crashed.
1092 base::TerminationStatus crashed_status_;
1093 int crashed_error_code_;
1095 // Whether this WebContents is waiting for a first-response for the
1096 // main resource of the page. This controls whether the throbber state is
1097 // "waiting" or "loading."
1098 bool waiting_for_response_;
1100 // Map of SiteInstance ID to max page ID for this tab. A page ID is specific
1101 // to a given tab and SiteInstance, and must be valid for the lifetime of the
1102 // WebContentsImpl.
1103 std::map<int32, int32> max_page_ids_;
1105 // The current load state and the URL associated with it.
1106 net::LoadStateWithParam load_state_;
1107 base::string16 load_state_host_;
1109 base::TimeTicks loading_last_progress_update_;
1111 // Upload progress, for displaying in the status bar.
1112 // Set to zero when there is no significant upload happening.
1113 uint64 upload_size_;
1114 uint64 upload_position_;
1116 // Tracks that this WebContents needs to unblock requests to the renderer.
1117 // See ResumeLoadingCreatedWebContents.
1118 bool is_resume_pending_;
1120 // Data for current page -----------------------------------------------------
1122 // When a title cannot be taken from any entry, this title will be used.
1123 base::string16 page_title_when_no_navigation_entry_;
1125 // When a navigation occurs, we record its contents MIME type. It can be
1126 // used to check whether we can do something for some special contents.
1127 std::string contents_mime_type_;
1129 // The last reported character encoding, not canonicalized.
1130 std::string last_reported_encoding_;
1132 // The canonicalized character encoding.
1133 std::string canonical_encoding_;
1135 // True if this is a secure page which displayed insecure content.
1136 bool displayed_insecure_content_;
1138 // Whether the initial empty page has been accessed by another page, making it
1139 // unsafe to show the pending URL. Usually false unless another window tries
1140 // to modify the blank page. Always false after the first commit.
1141 bool has_accessed_initial_document_;
1143 // The theme color for the underlying document as specified
1144 // by theme-color meta tag.
1145 SkColor theme_color_;
1147 // The last published theme color.
1148 SkColor last_sent_theme_color_;
1150 // Whether the first visually non-empty paint has occurred.
1151 bool did_first_visually_non_empty_paint_;
1153 // Data for misc internal state ----------------------------------------------
1155 // When > 0, the WebContents is currently being captured (e.g., for
1156 // screenshots or mirroring); and the underlying RenderWidgetHost should not
1157 // be told it is hidden.
1158 int capturer_count_;
1160 // Tracks whether RWHV should be visible once capturer_count_ becomes zero.
1161 bool should_normally_be_visible_;
1163 // See getter above.
1164 bool is_being_destroyed_;
1166 // Indicates whether we should notify about disconnection of this
1167 // WebContentsImpl. This is used to ensure disconnection notifications only
1168 // happen if a connection notification has happened and that they happen only
1169 // once.
1170 bool notify_disconnection_;
1172 // Pointer to the JavaScript dialog manager, lazily assigned. Used because the
1173 // delegate of this WebContentsImpl is nulled before its destructor is called.
1174 JavaScriptDialogManager* dialog_manager_;
1176 // Set to true when there is an active "before unload" dialog. When true,
1177 // we've forced the throbber to start in Navigate, and we need to remember to
1178 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
1179 bool is_showing_before_unload_dialog_;
1181 // Settings that get passed to the renderer process.
1182 RendererPreferences renderer_preferences_;
1184 // The time that this WebContents was last made active. The initial value is
1185 // the WebContents creation time.
1186 base::TimeTicks last_active_time_;
1188 // See description above setter.
1189 bool closed_by_user_gesture_;
1191 // Minimum/maximum zoom percent.
1192 int minimum_zoom_percent_;
1193 int maximum_zoom_percent_;
1195 // The intrinsic size of the page.
1196 gfx::Size preferred_size_;
1198 // The preferred size for content screen capture. When |capturer_count_| > 0,
1199 // this overrides |preferred_size_|.
1200 gfx::Size preferred_size_for_capture_;
1202 #if defined(OS_ANDROID)
1203 // Date time chooser opened by this tab.
1204 // Only used in Android since all other platforms use a multi field UI.
1205 scoped_ptr<DateTimeChooserAndroid> date_time_chooser_;
1206 #endif
1208 // Holds information about a current color chooser dialog, if one is visible.
1209 struct ColorChooserInfo {
1210 ColorChooserInfo(int render_process_id,
1211 int render_frame_id,
1212 ColorChooser* chooser,
1213 int identifier);
1214 ~ColorChooserInfo();
1216 int render_process_id;
1217 int render_frame_id;
1219 // Color chooser that was opened by this tab.
1220 scoped_ptr<ColorChooser> chooser;
1222 // A unique identifier for the current color chooser. Identifiers are
1223 // unique across a renderer process. This avoids race conditions in
1224 // synchronizing the browser and renderer processes. For example, if a
1225 // renderer closes one chooser and opens another, and simultaneously the
1226 // user picks a color in the first chooser, the IDs can be used to drop the
1227 // "chose a color" message rather than erroneously tell the renderer that
1228 // the user picked a color in the second chooser.
1229 int identifier;
1232 scoped_ptr<ColorChooserInfo> color_chooser_info_;
1234 // Manages the embedder state for browser plugins, if this WebContents is an
1235 // embedder; NULL otherwise.
1236 scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_;
1237 // Manages the guest state for browser plugin, if this WebContents is a guest;
1238 // NULL otherwise.
1239 scoped_ptr<BrowserPluginGuest> browser_plugin_guest_;
1241 #if defined(ENABLE_PLUGINS)
1242 // Manages the whitelist of plugin content origins exempt from power saving.
1243 scoped_ptr<PluginContentOriginWhitelist> plugin_content_origin_whitelist_;
1244 #endif
1246 // This must be at the end, or else we might get notifications and use other
1247 // member variables that are gone.
1248 NotificationRegistrar registrar_;
1250 // Used during IPC message dispatching from the RenderView/RenderFrame so that
1251 // the handlers can get a pointer to the RVH through which the message was
1252 // received.
1253 RenderViewHost* render_view_message_source_;
1254 RenderFrameHost* render_frame_message_source_;
1256 // All live RenderWidgetHostImpls that are created by this object and may
1257 // outlive it.
1258 std::set<RenderWidgetHostImpl*> created_widgets_;
1260 // Routing id of the shown fullscreen widget or MSG_ROUTING_NONE otherwise.
1261 int fullscreen_widget_routing_id_;
1263 // At the time the fullscreen widget was being shut down, did it have focus?
1264 // This is used to restore focus to the WebContentsView after both: 1) the
1265 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has
1266 // completed making layout changes to effect an exit from fullscreen mode.
1267 bool fullscreen_widget_had_focus_at_shutdown_;
1269 // Whether this WebContents is responsible for displaying a subframe in a
1270 // different process from its parent page.
1271 bool is_subframe_;
1273 // When a new tab is created asynchronously, stores the OpenURLParams needed
1274 // to continue loading the page once the tab is ready.
1275 scoped_ptr<OpenURLParams> delayed_open_url_params_;
1277 // Whether overscroll should be unconditionally disabled.
1278 bool force_disable_overscroll_content_;
1280 // Whether the last JavaScript dialog shown was suppressed. Used for testing.
1281 bool last_dialog_suppressed_;
1283 scoped_ptr<GeolocationServiceContext> geolocation_service_context_;
1285 scoped_ptr<ScreenOrientationDispatcherHost>
1286 screen_orientation_dispatcher_host_;
1288 scoped_ptr<ManifestManagerHost> manifest_manager_host_;
1290 // The accessibility mode for all frames. This is queried when each frame
1291 // is created, and broadcast to all frames when it changes.
1292 AccessibilityMode accessibility_mode_;
1294 // Monitors power levels for audio streams associated with this WebContents.
1295 AudioStreamMonitor audio_stream_monitor_;
1297 // Created on-demand to mute all audio output from this WebContents.
1298 scoped_ptr<WebContentsAudioMuter> audio_muter_;
1300 bool virtual_keyboard_requested_;
1302 #if defined(ENABLE_BROWSER_CDMS)
1303 // Manages all the media player and CDM managers and forwards IPCs to them.
1304 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_;
1305 #endif
1307 scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_;
1309 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_;
1311 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
1314 // Dangerous methods which should never be made part of the public API, so we
1315 // grant their use only to an explicit friend list (c++ attorney/client idiom).
1316 class CONTENT_EXPORT WebContentsImpl::FriendZone {
1317 private:
1318 friend class TestNavigationObserver;
1319 friend class WebContentsAddedObserver;
1320 friend class ContentBrowserSanityChecker;
1322 FriendZone(); // Not instantiable.
1324 // Adds/removes a callback called on creation of each new WebContents.
1325 static void AddCreatedCallbackForTesting(const CreatedCallback& callback);
1326 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback);
1328 DISALLOW_COPY_AND_ASSIGN(FriendZone);
1331 } // namespace content
1333 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_