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