Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / browser / web_contents.h
blob43804129322c4ed56ffc7b451c6ae1e5b84bfc2d
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_PUBLIC_BROWSER_WEB_CONTENTS_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h"
13 #include "base/process/kill.h"
14 #include "base/strings/string16.h"
15 #include "base/supports_user_data.h"
16 #include "content/common/content_export.h"
17 #include "content/public/browser/invalidate_type.h"
18 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/page_navigator.h"
20 #include "content/public/browser/save_page_type.h"
21 #include "content/public/browser/web_ui.h"
22 #include "content/public/common/stop_find_action.h"
23 #include "ipc/ipc_sender.h"
24 #include "third_party/skia/include/core/SkColor.h"
25 #include "ui/base/window_open_disposition.h"
26 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/native_widget_types.h"
29 #if defined(OS_ANDROID)
30 #include "base/android/scoped_java_ref.h"
31 #endif
33 namespace base {
34 class DictionaryValue;
35 class TimeTicks;
38 namespace blink {
39 struct WebFindOptions;
42 namespace net {
43 struct LoadStateWithParam;
46 namespace content {
48 class BrowserContext;
49 class BrowserPluginGuestDelegate;
50 class InterstitialPage;
51 class PageState;
52 class RenderFrameHost;
53 class RenderProcessHost;
54 class RenderViewHost;
55 class RenderWidgetHostView;
56 class SiteInstance;
57 class WebContentsDelegate;
58 struct CustomContextMenuContext;
59 struct DropData;
60 struct Manifest;
61 struct RendererPreferences;
63 // WebContents is the core class in content/. A WebContents renders web content
64 // (usually HTML) in a rectangular area.
66 // Instantiating one is simple:
67 // scoped_ptr<content::WebContents> web_contents(
68 // content::WebContents::Create(
69 // content::WebContents::CreateParams(browser_context)));
70 // gfx::NativeView view = web_contents->GetNativeView();
71 // // |view| is an HWND, NSView*, GtkWidget*, etc.; insert it into the view
72 // // hierarchy wherever it needs to go.
74 // That's it; go to your kitchen, grab a scone, and chill. WebContents will do
75 // all the multi-process stuff behind the scenes. More details are at
76 // http://www.chromium.org/developers/design-documents/multi-process-architecture .
78 // Each WebContents has exactly one NavigationController; each
79 // NavigationController belongs to one WebContents. The NavigationController can
80 // be obtained from GetController(), and is used to load URLs into the
81 // WebContents, navigate it backwards/forwards, etc. See navigation_controller.h
82 // for more details.
83 class WebContents : public PageNavigator,
84 public IPC::Sender,
85 public base::SupportsUserData {
86 public:
87 struct CONTENT_EXPORT CreateParams {
88 explicit CreateParams(BrowserContext* context);
89 ~CreateParams();
90 CreateParams(BrowserContext* context, SiteInstance* site);
92 BrowserContext* browser_context;
94 // Specifying a SiteInstance here is optional. It can be set to avoid an
95 // extra process swap if the first navigation is expected to require a
96 // privileged process.
97 SiteInstance* site_instance;
99 // The opener WebContents is the WebContents that initiated this request,
100 // if any.
101 WebContents* opener;
103 // If the opener is suppressed, then the new WebContents doesn't hold a
104 // reference to its opener.
105 bool opener_suppressed;
107 // The routing ids of the RenderView and of the main RenderFrame. Either
108 // both must be provided, or both must be MSG_ROUTING_NONE to have the
109 // WebContents make the assignment.
110 int routing_id;
111 int main_frame_routing_id;
113 // Initial size of the new WebContent's view. Can be (0, 0) if not needed.
114 gfx::Size initial_size;
116 // True if the contents should be initially hidden.
117 bool initially_hidden;
119 // If non-null then this WebContents will be hosted by a BrowserPlugin.
120 BrowserPluginGuestDelegate* guest_delegate;
122 // Used to specify the location context which display the new view should
123 // belong. This can be nullptr if not needed.
124 gfx::NativeView context;
126 // Used to specify that the new WebContents creation is driven by the
127 // renderer process. In this case, the renderer-side objects, such as
128 // RenderFrame, have already been created on the renderer side, and
129 // WebContents construction should take this into account.
130 bool renderer_initiated_creation;
133 // Creates a new WebContents.
134 CONTENT_EXPORT static WebContents* Create(const CreateParams& params);
136 // Similar to Create() above but should be used when you need to prepopulate
137 // the SessionStorageNamespaceMap of the WebContents. This can happen if
138 // you duplicate a WebContents, try to reconstitute it from a saved state,
139 // or when you create a new WebContents based on another one (eg., when
140 // servicing a window.open() call).
142 // You do not want to call this. If you think you do, make sure you completely
143 // understand when SessionStorageNamespace objects should be cloned, why
144 // they should not be shared by multiple WebContents, and what bad things
145 // can happen if you share the object.
146 CONTENT_EXPORT static WebContents* CreateWithSessionStorage(
147 const CreateParams& params,
148 const SessionStorageNamespaceMap& session_storage_namespace_map);
150 // Returns a WebContents that wraps the RenderViewHost, or nullptr if the
151 // render view host's delegate isn't a WebContents.
152 CONTENT_EXPORT static WebContents* FromRenderViewHost(
153 const RenderViewHost* rvh);
155 CONTENT_EXPORT static WebContents* FromRenderFrameHost(RenderFrameHost* rfh);
157 ~WebContents() override {}
159 // Intrinsic tab state -------------------------------------------------------
161 // Gets/Sets the delegate.
162 virtual WebContentsDelegate* GetDelegate() = 0;
163 virtual void SetDelegate(WebContentsDelegate* delegate) = 0;
165 // Gets the controller for this WebContents.
166 virtual NavigationController& GetController() = 0;
167 virtual const NavigationController& GetController() const = 0;
169 // Returns the user browser context associated with this WebContents (via the
170 // NavigationController).
171 virtual content::BrowserContext* GetBrowserContext() const = 0;
173 // Gets the URL that is currently being displayed, if there is one.
174 // This method is deprecated. DO NOT USE! Pick either |GetVisibleURL| or
175 // |GetLastCommittedURL| as appropriate.
176 virtual const GURL& GetURL() const = 0;
178 // Gets the URL currently being displayed in the URL bar, if there is one.
179 // This URL might be a pending navigation that hasn't committed yet, so it is
180 // not guaranteed to match the current page in this WebContents. A typical
181 // example of this is interstitials, which show the URL of the new/loading
182 // page (active) but the security context is of the old page (last committed).
183 virtual const GURL& GetVisibleURL() const = 0;
185 // Gets the last committed URL. It represents the current page that is
186 // displayed in this WebContents. It represents the current security
187 // context.
188 virtual const GURL& GetLastCommittedURL() const = 0;
190 // Return the currently active RenderProcessHost and RenderViewHost. Each of
191 // these may change over time.
192 virtual RenderProcessHost* GetRenderProcessHost() const = 0;
194 // Returns the main frame for the currently active view.
195 virtual RenderFrameHost* GetMainFrame() = 0;
197 // Returns the focused frame for the currently active view.
198 virtual RenderFrameHost* GetFocusedFrame() = 0;
200 // Calls |on_frame| for each frame in the currently active view.
201 // Note: The RenderFrameHost parameter is not guaranteed to have a live
202 // RenderFrame counterpart in the renderer process. Callbacks should check
203 // IsRenderFrameLive, as sending IPC messages to it in this case will fail
204 // silently.
205 virtual void ForEachFrame(
206 const base::Callback<void(RenderFrameHost*)>& on_frame) = 0;
208 // Sends the given IPC to all frames in the currently active view. This is a
209 // convenience method instead of calling ForEach.
210 virtual void SendToAllFrames(IPC::Message* message) = 0;
212 // Gets the current RenderViewHost for this tab.
213 virtual RenderViewHost* GetRenderViewHost() const = 0;
215 // Gets the current RenderViewHost's routing id. Returns
216 // MSG_ROUTING_NONE when there is no RenderViewHost.
217 virtual int GetRoutingID() const = 0;
219 // Returns the currently active RenderWidgetHostView. This may change over
220 // time and can be nullptr (during setup and teardown).
221 virtual RenderWidgetHostView* GetRenderWidgetHostView() const = 0;
223 // Returns the currently active fullscreen widget. If there is none, returns
224 // nullptr.
225 virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const = 0;
227 // Returns the theme color for the underlying content as set by the
228 // theme-color meta tag.
229 virtual SkColor GetThemeColor() const = 0;
231 // Create a WebUI page for the given url. In most cases, this doesn't need to
232 // be called by embedders since content will create its own WebUI objects as
233 // necessary. However if the embedder wants to create its own WebUI object and
234 // keep track of it manually, it can use this.
235 virtual WebUI* CreateWebUI(const GURL& url) = 0;
237 // Returns the committed WebUI if one exists, otherwise the pending one.
238 virtual WebUI* GetWebUI() const = 0;
239 virtual WebUI* GetCommittedWebUI() const = 0;
241 // Allows overriding the user agent used for NavigationEntries it owns.
242 virtual void SetUserAgentOverride(const std::string& override) = 0;
243 virtual const std::string& GetUserAgentOverride() const = 0;
245 // Enable the accessibility tree for this WebContents in the renderer,
246 // but don't enable creating a native accessibility tree on the browser
247 // side.
248 virtual void EnableTreeOnlyAccessibilityMode() = 0;
250 // Returns true only if "tree only" accessibility mode is on.
251 virtual bool IsTreeOnlyAccessibilityModeForTesting() const = 0;
253 // Returns true only if complete accessibility mode is on, meaning there's
254 // both renderer accessibility, and a native browser accessibility tree.
255 virtual bool IsFullAccessibilityModeForTesting() const = 0;
257 #if defined(OS_WIN)
258 virtual void SetParentNativeViewAccessible(
259 gfx::NativeViewAccessible accessible_parent) = 0;
260 #endif
262 // Tab navigation state ------------------------------------------------------
264 // Returns the current navigation properties, which if a navigation is
265 // pending may be provisional (e.g., the navigation could result in a
266 // download, in which case the URL would revert to what it was previously).
267 virtual const base::string16& GetTitle() const = 0;
269 // The max page ID for any page that the current SiteInstance has loaded in
270 // this WebContents. Page IDs are specific to a given SiteInstance and
271 // WebContents, corresponding to a specific RenderView in the renderer.
272 // Page IDs increase with each new page that is loaded by a tab.
273 virtual int32 GetMaxPageID() = 0;
275 // The max page ID for any page that the given SiteInstance has loaded in
276 // this WebContents.
277 virtual int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) = 0;
279 // Returns the SiteInstance associated with the current page.
280 virtual SiteInstance* GetSiteInstance() const = 0;
282 // Returns the SiteInstance for the pending navigation, if any. Otherwise
283 // returns the current SiteInstance.
284 virtual SiteInstance* GetPendingSiteInstance() const = 0;
286 // Returns whether this WebContents is loading a resource.
287 virtual bool IsLoading() const = 0;
289 // Returns whether this WebContents is loading and and the load is to a
290 // different top-level document (rather than being a navigation within the
291 // same document). This being true implies that IsLoading() is also true.
292 virtual bool IsLoadingToDifferentDocument() const = 0;
294 // Returns whether this WebContents is waiting for a first-response for the
295 // main resource of the page.
296 virtual bool IsWaitingForResponse() const = 0;
298 // Returns the current load state and the URL associated with it.
299 virtual const net::LoadStateWithParam& GetLoadState() const = 0;
300 virtual const base::string16& GetLoadStateHost() const = 0;
302 // Returns the upload progress.
303 virtual uint64 GetUploadSize() const = 0;
304 virtual uint64 GetUploadPosition() const = 0;
306 // Returns a set of the site URLs currently committed in this tab.
307 virtual std::set<GURL> GetSitesInTab() const = 0;
309 // Returns the character encoding of the page.
310 virtual const std::string& GetEncoding() const = 0;
312 // True if this is a secure page which displayed insecure content.
313 virtual bool DisplayedInsecureContent() const = 0;
315 // Internal state ------------------------------------------------------------
317 // Indicates whether the WebContents is being captured (e.g., for screenshots
318 // or mirroring). Increment calls must be balanced with an equivalent number
319 // of decrement calls. |capture_size| specifies the capturer's video
320 // resolution, but can be empty to mean "unspecified." The first screen
321 // capturer that provides a non-empty |capture_size| will override the value
322 // returned by GetPreferredSize() until all captures have ended.
323 virtual void IncrementCapturerCount(const gfx::Size& capture_size) = 0;
324 virtual void DecrementCapturerCount() = 0;
325 virtual int GetCapturerCount() const = 0;
327 // Indicates/Sets whether all audio output from this WebContents is muted.
328 virtual bool IsAudioMuted() const = 0;
329 virtual void SetAudioMuted(bool mute) = 0;
331 // Indicates whether this tab should be considered crashed. The setter will
332 // also notify the delegate when the flag is changed.
333 virtual bool IsCrashed() const = 0;
334 virtual void SetIsCrashed(base::TerminationStatus status, int error_code) = 0;
336 virtual base::TerminationStatus GetCrashedStatus() const = 0;
338 // Whether the tab is in the process of being destroyed.
339 virtual bool IsBeingDestroyed() const = 0;
341 // Convenience method for notifying the delegate of a navigation state
342 // change.
343 virtual void NotifyNavigationStateChanged(InvalidateTypes changed_flags) = 0;
345 // Get the last time that the WebContents was made active (either when it was
346 // created or shown with WasShown()).
347 virtual base::TimeTicks GetLastActiveTime() const = 0;
349 // Invoked when the WebContents becomes shown/hidden.
350 virtual void WasShown() = 0;
351 virtual void WasHidden() = 0;
353 // Returns true if the before unload and unload listeners need to be
354 // fired. The value of this changes over time. For example, if true and the
355 // before unload listener is executed and allows the user to exit, then this
356 // returns false.
357 virtual bool NeedToFireBeforeUnload() = 0;
359 // Runs the beforeunload handler for the main frame. See also ClosePage and
360 // SwapOut in RenderViewHost, which run the unload handler.
362 // |for_cross_site_transition| indicates whether this call is for the current
363 // frame during a cross-process navigation. False means we're closing the
364 // entire tab.
366 // TODO(creis): We should run the beforeunload handler for every frame that
367 // has one.
368 virtual void DispatchBeforeUnload(bool for_cross_site_transition) = 0;
370 // Commands ------------------------------------------------------------------
372 // Stop any pending navigation.
373 virtual void Stop() = 0;
375 // Creates a new WebContents with the same state as this one. The returned
376 // heap-allocated pointer is owned by the caller.
377 virtual WebContents* Clone() = 0;
379 // Reloads the focused frame.
380 virtual void ReloadFocusedFrame(bool ignore_cache) = 0;
382 // Editing commands ----------------------------------------------------------
384 virtual void Undo() = 0;
385 virtual void Redo() = 0;
386 virtual void Cut() = 0;
387 virtual void Copy() = 0;
388 virtual void CopyToFindPboard() = 0;
389 virtual void Paste() = 0;
390 virtual void PasteAndMatchStyle() = 0;
391 virtual void Delete() = 0;
392 virtual void SelectAll() = 0;
393 virtual void Unselect() = 0;
395 // Replaces the currently selected word or a word around the cursor.
396 virtual void Replace(const base::string16& word) = 0;
398 // Replaces the misspelling in the current selection.
399 virtual void ReplaceMisspelling(const base::string16& word) = 0;
401 // Let the renderer know that the menu has been closed.
402 virtual void NotifyContextMenuClosed(
403 const CustomContextMenuContext& context) = 0;
405 // Executes custom context menu action that was provided from Blink.
406 virtual void ExecuteCustomContextMenuCommand(
407 int action, const CustomContextMenuContext& context) = 0;
409 // Views and focus -----------------------------------------------------------
411 // Returns the native widget that contains the contents of the tab.
412 virtual gfx::NativeView GetNativeView() = 0;
414 // Returns the native widget with the main content of the tab (i.e. the main
415 // render view host, though there may be many popups in the tab as children of
416 // the container).
417 virtual gfx::NativeView GetContentNativeView() = 0;
419 // Returns the outermost native view. This will be used as the parent for
420 // dialog boxes.
421 virtual gfx::NativeWindow GetTopLevelNativeWindow() = 0;
423 // Computes the rectangle for the native widget that contains the contents of
424 // the tab in the screen coordinate system.
425 virtual gfx::Rect GetContainerBounds() = 0;
427 // Get the bounds of the View, relative to the parent.
428 virtual gfx::Rect GetViewBounds() = 0;
430 // Returns the current drop data, if any.
431 virtual DropData* GetDropData() = 0;
433 // Sets focus to the native widget for this tab.
434 virtual void Focus() = 0;
436 // Sets focus to the appropriate element when the WebContents is shown the
437 // first time.
438 virtual void SetInitialFocus() = 0;
440 // Stores the currently focused view.
441 virtual void StoreFocus() = 0;
443 // Restores focus to the last focus view. If StoreFocus has not yet been
444 // invoked, SetInitialFocus is invoked.
445 virtual void RestoreFocus() = 0;
447 // Focuses the first (last if |reverse| is true) element in the page.
448 // Invoked when this tab is getting the focus through tab traversal (|reverse|
449 // is true when using Shift-Tab).
450 virtual void FocusThroughTabTraversal(bool reverse) = 0;
452 // Interstitials -------------------------------------------------------------
454 // Various other systems need to know about our interstitials.
455 virtual bool ShowingInterstitialPage() const = 0;
457 // Returns the currently showing interstitial, nullptr if no interstitial is
458 // showing.
459 virtual InterstitialPage* GetInterstitialPage() const = 0;
461 // Misc state & callbacks ----------------------------------------------------
463 // Check whether we can do the saving page operation this page given its MIME
464 // type.
465 virtual bool IsSavable() = 0;
467 // Prepare for saving the current web page to disk.
468 virtual void OnSavePage() = 0;
470 // Save page with the main HTML file path, the directory for saving resources,
471 // and the save type: HTML only or complete web page. Returns true if the
472 // saving process has been initiated successfully.
473 virtual bool SavePage(const base::FilePath& main_file,
474 const base::FilePath& dir_path,
475 SavePageType save_type) = 0;
477 // Saves the given frame's URL to the local filesystem.
478 virtual void SaveFrame(const GURL& url,
479 const Referrer& referrer) = 0;
481 // Saves the given frame's URL to the local filesystem. The headers, if
482 // provided, is used to make a request to the URL rather than using cache.
483 // Format of |headers| is a new line separated list of key value pairs:
484 // "<key1>: <value1>\n<key2>: <value2>".
485 virtual void SaveFrameWithHeaders(const GURL& url,
486 const Referrer& referrer,
487 const std::string& headers) = 0;
489 // Generate an MHTML representation of the current page in the given file.
490 virtual void GenerateMHTML(
491 const base::FilePath& file,
492 const base::Callback<void(
493 int64 /* size of the file */)>& callback) = 0;
495 // Returns the contents MIME type after a navigation.
496 virtual const std::string& GetContentsMimeType() const = 0;
498 // Returns true if this WebContents will notify about disconnection.
499 virtual bool WillNotifyDisconnection() const = 0;
501 // Override the encoding and reload the page by sending down
502 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
503 // the opposite of this, by which 'browser' is notified of
504 // the encoding of the current tab from 'renderer' (determined by
505 // auto-detect, http header, meta, bom detection, etc).
506 virtual void SetOverrideEncoding(const std::string& encoding) = 0;
508 // Remove any user-defined override encoding and reload by sending down
509 // ViewMsg_ResetPageEncodingToDefault to the renderer.
510 virtual void ResetOverrideEncoding() = 0;
512 // Returns the settings which get passed to the renderer.
513 virtual content::RendererPreferences* GetMutableRendererPrefs() = 0;
515 // Tells the tab to close now. The tab will take care not to close until it's
516 // out of nested message loops.
517 virtual void Close() = 0;
519 // A render view-originated drag has ended. Informs the render view host and
520 // WebContentsDelegate.
521 virtual void SystemDragEnded() = 0;
523 // Notification the user has made a gesture while focus was on the
524 // page. This is used to avoid uninitiated user downloads (aka carpet
525 // bombing), see DownloadRequestLimiter for details.
526 virtual void UserGestureDone() = 0;
528 // Indicates if this tab was explicitly closed by the user (control-w, close
529 // tab menu item...). This is false for actions that indirectly close the tab,
530 // such as closing the window. The setter is maintained by TabStripModel, and
531 // the getter only useful from within TAB_CLOSED notification
532 virtual void SetClosedByUserGesture(bool value) = 0;
533 virtual bool GetClosedByUserGesture() const = 0;
535 // Opens view-source tab for this contents.
536 virtual void ViewSource() = 0;
538 virtual void ViewFrameSource(const GURL& url,
539 const PageState& page_state)= 0;
541 // Gets the minimum/maximum zoom percent.
542 virtual int GetMinimumZoomPercent() const = 0;
543 virtual int GetMaximumZoomPercent() const = 0;
545 // Set the renderer's page scale back to one.
546 virtual void ResetPageScale() = 0;
548 // Gets the preferred size of the contents.
549 virtual gfx::Size GetPreferredSize() const = 0;
551 // Called when the reponse to a pending mouse lock request has arrived.
552 // Returns true if |allowed| is true and the mouse has been successfully
553 // locked.
554 virtual bool GotResponseToLockMouseRequest(bool allowed) = 0;
556 // Called when the user has selected a color in the color chooser.
557 virtual void DidChooseColorInColorChooser(SkColor color) = 0;
559 // Called when the color chooser has ended.
560 virtual void DidEndColorChooser() = 0;
562 // Returns true if the location bar should be focused by default rather than
563 // the page contents. The view calls this function when the tab is focused
564 // to see what it should do.
565 virtual bool FocusLocationBarByDefault() = 0;
567 // Does this have an opener associated with it?
568 virtual bool HasOpener() const = 0;
570 // Returns the opener if HasOpener() is true, or nullptr otherwise.
571 virtual WebContents* GetOpener() const = 0;
573 typedef base::Callback<void(
574 int, /* id */
575 int, /* HTTP status code */
576 const GURL&, /* image_url */
577 const std::vector<SkBitmap>&, /* bitmaps */
578 /* The sizes in pixel of the bitmaps before they were resized due to the
579 max bitmap size passed to DownloadImage(). Each entry in the bitmaps
580 vector corresponds to an entry in the sizes vector. If a bitmap was
581 resized, there should be a single returned bitmap. */
582 const std::vector<gfx::Size>&)>
583 ImageDownloadCallback;
585 // Sends a request to download the given image |url| and returns the unique
586 // id of the download request. When the download is finished, |callback| will
587 // be called with the bitmaps received from the renderer.
588 // If |is_favicon| is true, the cookies are not sent and not accepted during
589 // download.
590 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
591 // from the bitmap results. If there are no bitmap results <=
592 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and
593 // is the only result. A |max_bitmap_size| of 0 means unlimited.
594 // If |bypass_cache| is true, |url| is requested from the server even if it
595 // is present in the browser cache.
596 virtual int DownloadImage(const GURL& url,
597 bool is_favicon,
598 uint32_t max_bitmap_size,
599 bool bypass_cache,
600 const ImageDownloadCallback& callback) = 0;
602 // Returns true if the WebContents is responsible for displaying a subframe
603 // in a different process from its parent page.
604 // TODO: this doesn't really belong here. With site isolation, this should be
605 // removed since we can then embed iframes in different processes.
606 virtual bool IsSubframe() const = 0;
608 // Finds text on a page.
609 virtual void Find(int request_id,
610 const base::string16& search_text,
611 const blink::WebFindOptions& options) = 0;
613 // Notifies the renderer that the user has closed the FindInPage window
614 // (and what action to take regarding the selection).
615 virtual void StopFinding(StopFindAction action) = 0;
617 // Requests the renderer to insert CSS into the main frame's document.
618 virtual void InsertCSS(const std::string& css) = 0;
620 // Returns true if audio has recently been audible from the WebContents.
621 virtual bool WasRecentlyAudible() = 0;
623 typedef base::Callback<void(const Manifest&)> GetManifestCallback;
625 // Requests the Manifest of the main frame's document.
626 virtual void GetManifest(const GetManifestCallback&) = 0;
628 // Requests the renderer to exit fullscreen.
629 virtual void ExitFullscreen() = 0;
631 #if defined(OS_ANDROID)
632 CONTENT_EXPORT static WebContents* FromJavaWebContents(
633 jobject jweb_contents_android);
634 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() = 0;
635 #elif defined(OS_MACOSX)
636 // Allowing other views disables optimizations which assume that only a single
637 // WebContents is present.
638 virtual void SetAllowOtherViews(bool allow) = 0;
640 // Returns true if other views are allowed, false otherwise.
641 virtual bool GetAllowOtherViews() = 0;
642 #endif // OS_ANDROID
644 private:
645 // This interface should only be implemented inside content.
646 friend class WebContentsImpl;
647 WebContents() {}
650 } // namespace content
652 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_