Fix compile breakage from r336003.
[chromium-blink-merge.git] / content / public / browser / web_contents.h
blobb2eaf32ca3591147d42a067bc6722d402f00fb66
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 process id of the frame initiating the open.
100 int opener_render_process_id;
102 // The routing id of the frame initiating the open.
103 int opener_render_frame_id;
105 // If the opener is suppressed, then the new WebContents doesn't hold a
106 // reference to its opener.
107 bool opener_suppressed;
109 // Indicates whether this WebContents was created with a window.opener.
110 // This is used when determining whether the WebContents is allowed to be
111 // closed via window.close(). This may be true even with a null |opener|
112 // (e.g., for blocked popups).
113 bool created_with_opener;
115 // The routing ids of the RenderView and of the main RenderFrame. Either
116 // both must be provided, or both must be MSG_ROUTING_NONE to have the
117 // WebContents make the assignment.
118 int routing_id;
119 int main_frame_routing_id;
121 // The name of the top-level frame of the new window. It is non-empty
122 // when creating a named window (e.g. <a target="foo"> or
123 // window.open('', 'bar')).
124 std::string main_frame_name;
126 // Initial size of the new WebContent's view. Can be (0, 0) if not needed.
127 gfx::Size initial_size;
129 // True if the contents should be initially hidden.
130 bool initially_hidden;
132 // If non-null then this WebContents will be hosted by a BrowserPlugin.
133 BrowserPluginGuestDelegate* guest_delegate;
135 // Used to specify the location context which display the new view should
136 // belong. This can be nullptr if not needed.
137 gfx::NativeView context;
139 // Used to specify that the new WebContents creation is driven by the
140 // renderer process. In this case, the renderer-side objects, such as
141 // RenderFrame, have already been created on the renderer side, and
142 // WebContents construction should take this into account.
143 bool renderer_initiated_creation;
146 // Creates a new WebContents.
147 CONTENT_EXPORT static WebContents* Create(const CreateParams& params);
149 // Similar to Create() above but should be used when you need to prepopulate
150 // the SessionStorageNamespaceMap of the WebContents. This can happen if
151 // you duplicate a WebContents, try to reconstitute it from a saved state,
152 // or when you create a new WebContents based on another one (eg., when
153 // servicing a window.open() call).
155 // You do not want to call this. If you think you do, make sure you completely
156 // understand when SessionStorageNamespace objects should be cloned, why
157 // they should not be shared by multiple WebContents, and what bad things
158 // can happen if you share the object.
159 CONTENT_EXPORT static WebContents* CreateWithSessionStorage(
160 const CreateParams& params,
161 const SessionStorageNamespaceMap& session_storage_namespace_map);
163 // Returns a WebContents that wraps the RenderViewHost, or nullptr if the
164 // render view host's delegate isn't a WebContents.
165 CONTENT_EXPORT static WebContents* FromRenderViewHost(
166 const RenderViewHost* rvh);
168 CONTENT_EXPORT static WebContents* FromRenderFrameHost(RenderFrameHost* rfh);
170 ~WebContents() override {}
172 // Intrinsic tab state -------------------------------------------------------
174 // Gets/Sets the delegate.
175 virtual WebContentsDelegate* GetDelegate() = 0;
176 virtual void SetDelegate(WebContentsDelegate* delegate) = 0;
178 // Gets the controller for this WebContents.
179 virtual NavigationController& GetController() = 0;
180 virtual const NavigationController& GetController() const = 0;
182 // Returns the user browser context associated with this WebContents (via the
183 // NavigationController).
184 virtual content::BrowserContext* GetBrowserContext() const = 0;
186 // Gets the URL that is currently being displayed, if there is one.
187 // This method is deprecated. DO NOT USE! Pick either |GetVisibleURL| or
188 // |GetLastCommittedURL| as appropriate.
189 virtual const GURL& GetURL() const = 0;
191 // Gets the URL currently being displayed in the URL bar, if there is one.
192 // This URL might be a pending navigation that hasn't committed yet, so it is
193 // not guaranteed to match the current page in this WebContents. A typical
194 // example of this is interstitials, which show the URL of the new/loading
195 // page (active) but the security context is of the old page (last committed).
196 virtual const GURL& GetVisibleURL() const = 0;
198 // Gets the last committed URL. It represents the current page that is
199 // displayed in this WebContents. It represents the current security
200 // context.
201 virtual const GURL& GetLastCommittedURL() const = 0;
203 // Return the currently active RenderProcessHost and RenderViewHost. Each of
204 // these may change over time.
205 virtual RenderProcessHost* GetRenderProcessHost() const = 0;
207 // Returns the main frame for the currently active view.
208 virtual RenderFrameHost* GetMainFrame() = 0;
210 // Returns the focused frame for the currently active view.
211 virtual RenderFrameHost* GetFocusedFrame() = 0;
213 // Calls |on_frame| for each frame in the currently active view.
214 // Note: The RenderFrameHost parameter is not guaranteed to have a live
215 // RenderFrame counterpart in the renderer process. Callbacks should check
216 // IsRenderFrameLive, as sending IPC messages to it in this case will fail
217 // silently.
218 virtual void ForEachFrame(
219 const base::Callback<void(RenderFrameHost*)>& on_frame) = 0;
221 // Sends the given IPC to all frames in the currently active view. This is a
222 // convenience method instead of calling ForEach.
223 virtual void SendToAllFrames(IPC::Message* message) = 0;
225 // Gets the current RenderViewHost for this tab.
226 virtual RenderViewHost* GetRenderViewHost() const = 0;
228 // Gets the current RenderViewHost's routing id. Returns
229 // MSG_ROUTING_NONE when there is no RenderViewHost.
230 virtual int GetRoutingID() const = 0;
232 // Returns the currently active RenderWidgetHostView. This may change over
233 // time and can be nullptr (during setup and teardown).
234 virtual RenderWidgetHostView* GetRenderWidgetHostView() const = 0;
236 // Causes the current page to be closed, including running its onunload event
237 // handler.
238 virtual void ClosePage() = 0;
240 // Returns the currently active fullscreen widget. If there is none, returns
241 // nullptr.
242 virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() const = 0;
244 // Returns the theme color for the underlying content as set by the
245 // theme-color meta tag.
246 virtual SkColor GetThemeColor() const = 0;
248 // Create a WebUI page for the given url. In most cases, this doesn't need to
249 // be called by embedders since content will create its own WebUI objects as
250 // necessary. However if the embedder wants to create its own WebUI object and
251 // keep track of it manually, it can use this.
252 virtual WebUI* CreateWebUI(const GURL& url) = 0;
254 // Returns the committed WebUI if one exists, otherwise the pending one.
255 virtual WebUI* GetWebUI() const = 0;
256 virtual WebUI* GetCommittedWebUI() const = 0;
258 // Allows overriding the user agent used for NavigationEntries it owns.
259 virtual void SetUserAgentOverride(const std::string& override) = 0;
260 virtual const std::string& GetUserAgentOverride() const = 0;
262 // Enable the accessibility tree for this WebContents in the renderer,
263 // but don't enable creating a native accessibility tree on the browser
264 // side.
265 virtual void EnableTreeOnlyAccessibilityMode() = 0;
267 // Returns true only if "tree only" accessibility mode is on.
268 virtual bool IsTreeOnlyAccessibilityModeForTesting() const = 0;
270 // Returns true only if complete accessibility mode is on, meaning there's
271 // both renderer accessibility, and a native browser accessibility tree.
272 virtual bool IsFullAccessibilityModeForTesting() const = 0;
274 #if defined(OS_WIN)
275 virtual void SetParentNativeViewAccessible(
276 gfx::NativeViewAccessible accessible_parent) = 0;
277 #endif
279 // Tab navigation state ------------------------------------------------------
281 // Returns the current navigation properties, which if a navigation is
282 // pending may be provisional (e.g., the navigation could result in a
283 // download, in which case the URL would revert to what it was previously).
284 virtual const base::string16& GetTitle() const = 0;
286 // The max page ID for any page that the current SiteInstance has loaded in
287 // this WebContents. Page IDs are specific to a given SiteInstance and
288 // WebContents, corresponding to a specific RenderView in the renderer.
289 // Page IDs increase with each new page that is loaded by a tab.
290 virtual int32 GetMaxPageID() = 0;
292 // The max page ID for any page that the given SiteInstance has loaded in
293 // this WebContents.
294 virtual int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) = 0;
296 // Returns the SiteInstance associated with the current page.
297 virtual SiteInstance* GetSiteInstance() const = 0;
299 // Returns the SiteInstance for the pending navigation, if any. Otherwise
300 // returns the current SiteInstance.
301 virtual SiteInstance* GetPendingSiteInstance() const = 0;
303 // Returns whether this WebContents is loading a resource.
304 virtual bool IsLoading() const = 0;
306 // Returns whether this WebContents is loading and and the load is to a
307 // different top-level document (rather than being a navigation within the
308 // same document). This being true implies that IsLoading() is also true.
309 virtual bool IsLoadingToDifferentDocument() const = 0;
311 // Returns whether this WebContents is waiting for a first-response for the
312 // main resource of the page.
313 virtual bool IsWaitingForResponse() const = 0;
315 // Returns the current load state and the URL associated with it.
316 // The load state is only updated while IsLoading() is true.
317 virtual const net::LoadStateWithParam& GetLoadState() const = 0;
318 virtual const base::string16& GetLoadStateHost() const = 0;
320 // Returns the upload progress.
321 virtual uint64 GetUploadSize() const = 0;
322 virtual uint64 GetUploadPosition() const = 0;
324 // Returns a set of the site URLs currently committed in this tab.
325 virtual std::set<GURL> GetSitesInTab() const = 0;
327 // Returns the character encoding of the page.
328 virtual const std::string& GetEncoding() const = 0;
330 // True if this is a secure page which displayed insecure content.
331 virtual bool DisplayedInsecureContent() const = 0;
333 // Internal state ------------------------------------------------------------
335 // Indicates whether the WebContents is being captured (e.g., for screenshots
336 // or mirroring). Increment calls must be balanced with an equivalent number
337 // of decrement calls. |capture_size| specifies the capturer's video
338 // resolution, but can be empty to mean "unspecified." The first screen
339 // capturer that provides a non-empty |capture_size| will override the value
340 // returned by GetPreferredSize() until all captures have ended.
341 virtual void IncrementCapturerCount(const gfx::Size& capture_size) = 0;
342 virtual void DecrementCapturerCount() = 0;
343 virtual int GetCapturerCount() const = 0;
345 // Indicates/Sets whether all audio output from this WebContents is muted.
346 virtual bool IsAudioMuted() const = 0;
347 virtual void SetAudioMuted(bool mute) = 0;
349 // Indicates whether this tab should be considered crashed. The setter will
350 // also notify the delegate when the flag is changed.
351 virtual bool IsCrashed() const = 0;
352 virtual void SetIsCrashed(base::TerminationStatus status, int error_code) = 0;
354 virtual base::TerminationStatus GetCrashedStatus() const = 0;
356 // Whether the tab is in the process of being destroyed.
357 virtual bool IsBeingDestroyed() const = 0;
359 // Convenience method for notifying the delegate of a navigation state
360 // change.
361 virtual void NotifyNavigationStateChanged(InvalidateTypes changed_flags) = 0;
363 // Get/Set the last time that the WebContents was made active (either when it
364 // was created or shown with WasShown()).
365 virtual base::TimeTicks GetLastActiveTime() const = 0;
366 virtual void SetLastActiveTime(base::TimeTicks last_active_time) = 0;
368 // Invoked when the WebContents becomes shown/hidden.
369 virtual void WasShown() = 0;
370 virtual void WasHidden() = 0;
372 // Returns true if the before unload and unload listeners need to be
373 // fired. The value of this changes over time. For example, if true and the
374 // before unload listener is executed and allows the user to exit, then this
375 // returns false.
376 virtual bool NeedToFireBeforeUnload() = 0;
378 // Runs the beforeunload handler for the main frame. See also ClosePage and
379 // SwapOut in RenderViewHost, which run the unload handler.
381 // |for_cross_site_transition| indicates whether this call is for the current
382 // frame during a cross-process navigation. False means we're closing the
383 // entire tab.
385 // TODO(creis): We should run the beforeunload handler for every frame that
386 // has one.
387 virtual void DispatchBeforeUnload(bool for_cross_site_transition) = 0;
389 // Commands ------------------------------------------------------------------
391 // Stop any pending navigation.
392 virtual void Stop() = 0;
394 // Creates a new WebContents with the same state as this one. The returned
395 // heap-allocated pointer is owned by the caller.
396 virtual WebContents* Clone() = 0;
398 // Reloads the focused frame.
399 virtual void ReloadFocusedFrame(bool ignore_cache) = 0;
401 // Editing commands ----------------------------------------------------------
403 virtual void Undo() = 0;
404 virtual void Redo() = 0;
405 virtual void Cut() = 0;
406 virtual void Copy() = 0;
407 virtual void CopyToFindPboard() = 0;
408 virtual void Paste() = 0;
409 virtual void PasteAndMatchStyle() = 0;
410 virtual void Delete() = 0;
411 virtual void SelectAll() = 0;
412 virtual void Unselect() = 0;
414 // Replaces the currently selected word or a word around the cursor.
415 virtual void Replace(const base::string16& word) = 0;
417 // Replaces the misspelling in the current selection.
418 virtual void ReplaceMisspelling(const base::string16& word) = 0;
420 // Let the renderer know that the menu has been closed.
421 virtual void NotifyContextMenuClosed(
422 const CustomContextMenuContext& context) = 0;
424 // Executes custom context menu action that was provided from Blink.
425 virtual void ExecuteCustomContextMenuCommand(
426 int action, const CustomContextMenuContext& context) = 0;
428 // Views and focus -----------------------------------------------------------
430 // Returns the native widget that contains the contents of the tab.
431 virtual gfx::NativeView GetNativeView() = 0;
433 // Returns the native widget with the main content of the tab (i.e. the main
434 // render view host, though there may be many popups in the tab as children of
435 // the container).
436 virtual gfx::NativeView GetContentNativeView() = 0;
438 // Returns the outermost native view. This will be used as the parent for
439 // dialog boxes.
440 virtual gfx::NativeWindow GetTopLevelNativeWindow() = 0;
442 // Computes the rectangle for the native widget that contains the contents of
443 // the tab in the screen coordinate system.
444 virtual gfx::Rect GetContainerBounds() = 0;
446 // Get the bounds of the View, relative to the parent.
447 virtual gfx::Rect GetViewBounds() = 0;
449 // Returns the current drop data, if any.
450 virtual DropData* GetDropData() = 0;
452 // Sets focus to the native widget for this tab.
453 virtual void Focus() = 0;
455 // Sets focus to the appropriate element when the WebContents is shown the
456 // first time.
457 virtual void SetInitialFocus() = 0;
459 // Stores the currently focused view.
460 virtual void StoreFocus() = 0;
462 // Restores focus to the last focus view. If StoreFocus has not yet been
463 // invoked, SetInitialFocus is invoked.
464 virtual void RestoreFocus() = 0;
466 // Focuses the first (last if |reverse| is true) element in the page.
467 // Invoked when this tab is getting the focus through tab traversal (|reverse|
468 // is true when using Shift-Tab).
469 virtual void FocusThroughTabTraversal(bool reverse) = 0;
471 // Interstitials -------------------------------------------------------------
473 // Various other systems need to know about our interstitials.
474 virtual bool ShowingInterstitialPage() const = 0;
476 // Returns the currently showing interstitial, nullptr if no interstitial is
477 // showing.
478 virtual InterstitialPage* GetInterstitialPage() const = 0;
480 // Misc state & callbacks ----------------------------------------------------
482 // Check whether we can do the saving page operation this page given its MIME
483 // type.
484 virtual bool IsSavable() = 0;
486 // Prepare for saving the current web page to disk.
487 virtual void OnSavePage() = 0;
489 // Save page with the main HTML file path, the directory for saving resources,
490 // and the save type: HTML only or complete web page. Returns true if the
491 // saving process has been initiated successfully.
492 virtual bool SavePage(const base::FilePath& main_file,
493 const base::FilePath& dir_path,
494 SavePageType save_type) = 0;
496 // Saves the given frame's URL to the local filesystem.
497 virtual void SaveFrame(const GURL& url,
498 const Referrer& referrer) = 0;
500 // Saves the given frame's URL to the local filesystem. The headers, if
501 // provided, is used to make a request to the URL rather than using cache.
502 // Format of |headers| is a new line separated list of key value pairs:
503 // "<key1>: <value1>\n<key2>: <value2>".
504 virtual void SaveFrameWithHeaders(const GURL& url,
505 const Referrer& referrer,
506 const std::string& headers) = 0;
508 // Generate an MHTML representation of the current page in the given file.
509 virtual void GenerateMHTML(
510 const base::FilePath& file,
511 const base::Callback<void(
512 int64 /* size of the file */)>& callback) = 0;
514 // Returns the contents MIME type after a navigation.
515 virtual const std::string& GetContentsMimeType() const = 0;
517 // Returns true if this WebContents will notify about disconnection.
518 virtual bool WillNotifyDisconnection() const = 0;
520 // Override the encoding and reload the page by sending down
521 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
522 // the opposite of this, by which 'browser' is notified of
523 // the encoding of the current tab from 'renderer' (determined by
524 // auto-detect, http header, meta, bom detection, etc).
525 virtual void SetOverrideEncoding(const std::string& encoding) = 0;
527 // Remove any user-defined override encoding and reload by sending down
528 // ViewMsg_ResetPageEncodingToDefault to the renderer.
529 virtual void ResetOverrideEncoding() = 0;
531 // Returns the settings which get passed to the renderer.
532 virtual content::RendererPreferences* GetMutableRendererPrefs() = 0;
534 // Tells the tab to close now. The tab will take care not to close until it's
535 // out of nested message loops.
536 virtual void Close() = 0;
538 // A render view-originated drag has ended. Informs the render view host and
539 // WebContentsDelegate.
540 virtual void SystemDragEnded() = 0;
542 // Notification the user has made a gesture while focus was on the
543 // page. This is used to avoid uninitiated user downloads (aka carpet
544 // bombing), see DownloadRequestLimiter for details.
545 virtual void UserGestureDone() = 0;
547 // Indicates if this tab was explicitly closed by the user (control-w, close
548 // tab menu item...). This is false for actions that indirectly close the tab,
549 // such as closing the window. The setter is maintained by TabStripModel, and
550 // the getter only useful from within TAB_CLOSED notification
551 virtual void SetClosedByUserGesture(bool value) = 0;
552 virtual bool GetClosedByUserGesture() const = 0;
554 // Opens view-source tab for this contents.
555 virtual void ViewSource() = 0;
557 virtual void ViewFrameSource(const GURL& url,
558 const PageState& page_state)= 0;
560 // Gets the minimum/maximum zoom percent.
561 virtual int GetMinimumZoomPercent() const = 0;
562 virtual int GetMaximumZoomPercent() const = 0;
564 // Set the renderer's page scale back to one.
565 virtual void ResetPageScale() = 0;
567 // Gets the preferred size of the contents.
568 virtual gfx::Size GetPreferredSize() const = 0;
570 // Called when the reponse to a pending mouse lock request has arrived.
571 // Returns true if |allowed| is true and the mouse has been successfully
572 // locked.
573 virtual bool GotResponseToLockMouseRequest(bool allowed) = 0;
575 // Called when the user has selected a color in the color chooser.
576 virtual void DidChooseColorInColorChooser(SkColor color) = 0;
578 // Called when the color chooser has ended.
579 virtual void DidEndColorChooser() = 0;
581 // Returns true if the location bar should be focused by default rather than
582 // the page contents. The view calls this function when the tab is focused
583 // to see what it should do.
584 virtual bool FocusLocationBarByDefault() = 0;
586 // Does this have an opener associated with it?
587 virtual bool HasOpener() const = 0;
589 // Returns the opener if HasOpener() is true, or nullptr otherwise.
590 virtual WebContents* GetOpener() const = 0;
592 typedef base::Callback<void(
593 int, /* id */
594 int, /* HTTP status code */
595 const GURL&, /* image_url */
596 const std::vector<SkBitmap>&, /* bitmaps */
597 /* The sizes in pixel of the bitmaps before they were resized due to the
598 max bitmap size passed to DownloadImage(). Each entry in the bitmaps
599 vector corresponds to an entry in the sizes vector. If a bitmap was
600 resized, there should be a single returned bitmap. */
601 const std::vector<gfx::Size>&)>
602 ImageDownloadCallback;
604 // Sends a request to download the given image |url| and returns the unique
605 // id of the download request. When the download is finished, |callback| will
606 // be called with the bitmaps received from the renderer.
607 // If |is_favicon| is true, the cookies are not sent and not accepted during
608 // download.
609 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
610 // from the bitmap results. If there are no bitmap results <=
611 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and
612 // is the only result. A |max_bitmap_size| of 0 means unlimited.
613 // If |bypass_cache| is true, |url| is requested from the server even if it
614 // is present in the browser cache.
615 virtual int DownloadImage(const GURL& url,
616 bool is_favicon,
617 uint32_t max_bitmap_size,
618 bool bypass_cache,
619 const ImageDownloadCallback& callback) = 0;
621 // Returns true if the WebContents is responsible for displaying a subframe
622 // in a different process from its parent page.
623 // TODO: this doesn't really belong here. With site isolation, this should be
624 // removed since we can then embed iframes in different processes.
625 virtual bool IsSubframe() const = 0;
627 // Finds text on a page.
628 virtual void Find(int request_id,
629 const base::string16& search_text,
630 const blink::WebFindOptions& options) = 0;
632 // Notifies the renderer that the user has closed the FindInPage window
633 // (and what action to take regarding the selection).
634 virtual void StopFinding(StopFindAction action) = 0;
636 // Requests the renderer to insert CSS into the main frame's document.
637 virtual void InsertCSS(const std::string& css) = 0;
639 // Returns true if audio has recently been audible from the WebContents.
640 virtual bool WasRecentlyAudible() = 0;
642 typedef base::Callback<void(const Manifest&)> GetManifestCallback;
644 // Requests the Manifest of the main frame's document.
645 virtual void GetManifest(const GetManifestCallback&) = 0;
647 // Requests the renderer to exit fullscreen.
648 virtual void ExitFullscreen() = 0;
650 // Unblocks requests from renderer for a newly created window. This is
651 // used in showCreatedWindow() or sometimes later in cases where
652 // delegate->ShouldResumeRequestsForCreatedWindow() indicated the requests
653 // should not yet be resumed. Then the client is responsible for calling this
654 // as soon as they are ready.
655 virtual void ResumeLoadingCreatedWebContents() = 0;
657 #if defined(OS_ANDROID)
658 CONTENT_EXPORT static WebContents* FromJavaWebContents(
659 jobject jweb_contents_android);
660 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() = 0;
661 #elif defined(OS_MACOSX)
662 // Allowing other views disables optimizations which assume that only a single
663 // WebContents is present.
664 virtual void SetAllowOtherViews(bool allow) = 0;
666 // Returns true if other views are allowed, false otherwise.
667 virtual bool GetAllowOtherViews() = 0;
668 #endif // OS_ANDROID
670 private:
671 // This interface should only be implemented inside content.
672 friend class WebContentsImpl;
673 WebContents() {}
676 } // namespace content
678 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_