ApplicationImpl cleanup, part 1:
[chromium-blink-merge.git] / content / public / browser / web_contents.h
blob4ed6a40fd9138ab124df0847e76824b4ee5bdd22
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 // Attaches this inner WebContents to its container frame
390 // |outer_contents_frame| in |outer_web_contents|.
391 virtual void AttachToOuterWebContentsFrame(
392 WebContents* outer_web_contents,
393 RenderFrameHost* outer_contents_frame) = 0;
395 // Commands ------------------------------------------------------------------
397 // Stop any pending navigation.
398 virtual void Stop() = 0;
400 // Creates a new WebContents with the same state as this one. The returned
401 // heap-allocated pointer is owned by the caller.
402 virtual WebContents* Clone() = 0;
404 // Reloads the focused frame.
405 virtual void ReloadFocusedFrame(bool ignore_cache) = 0;
407 // Editing commands ----------------------------------------------------------
409 virtual void Undo() = 0;
410 virtual void Redo() = 0;
411 virtual void Cut() = 0;
412 virtual void Copy() = 0;
413 virtual void CopyToFindPboard() = 0;
414 virtual void Paste() = 0;
415 virtual void PasteAndMatchStyle() = 0;
416 virtual void Delete() = 0;
417 virtual void SelectAll() = 0;
418 virtual void Unselect() = 0;
420 // Adjust the selection starting and ending points in the focused frame by
421 // the given amounts. A negative amount moves the selection towards the
422 // beginning of the document, a positive amount moves the selection towards
423 // the end of the document.
424 virtual void AdjustSelectionByCharacterOffset(int start_adjust,
425 int end_adjust) = 0;
427 // Replaces the currently selected word or a word around the cursor.
428 virtual void Replace(const base::string16& word) = 0;
430 // Replaces the misspelling in the current selection.
431 virtual void ReplaceMisspelling(const base::string16& word) = 0;
433 // Let the renderer know that the menu has been closed.
434 virtual void NotifyContextMenuClosed(
435 const CustomContextMenuContext& context) = 0;
437 // Executes custom context menu action that was provided from Blink.
438 virtual void ExecuteCustomContextMenuCommand(
439 int action, const CustomContextMenuContext& context) = 0;
441 // Views and focus -----------------------------------------------------------
443 // Returns the native widget that contains the contents of the tab.
444 virtual gfx::NativeView GetNativeView() = 0;
446 // Returns the native widget with the main content of the tab (i.e. the main
447 // render view host, though there may be many popups in the tab as children of
448 // the container).
449 virtual gfx::NativeView GetContentNativeView() = 0;
451 // Returns the outermost native view. This will be used as the parent for
452 // dialog boxes.
453 virtual gfx::NativeWindow GetTopLevelNativeWindow() = 0;
455 // Computes the rectangle for the native widget that contains the contents of
456 // the tab in the screen coordinate system.
457 virtual gfx::Rect GetContainerBounds() = 0;
459 // Get the bounds of the View, relative to the parent.
460 virtual gfx::Rect GetViewBounds() = 0;
462 // Returns the current drop data, if any.
463 virtual DropData* GetDropData() = 0;
465 // Sets focus to the native widget for this tab.
466 virtual void Focus() = 0;
468 // Sets focus to the appropriate element when the WebContents is shown the
469 // first time.
470 virtual void SetInitialFocus() = 0;
472 // Stores the currently focused view.
473 virtual void StoreFocus() = 0;
475 // Restores focus to the last focus view. If StoreFocus has not yet been
476 // invoked, SetInitialFocus is invoked.
477 virtual void RestoreFocus() = 0;
479 // Focuses the first (last if |reverse| is true) element in the page.
480 // Invoked when this tab is getting the focus through tab traversal (|reverse|
481 // is true when using Shift-Tab).
482 virtual void FocusThroughTabTraversal(bool reverse) = 0;
484 // Interstitials -------------------------------------------------------------
486 // Various other systems need to know about our interstitials.
487 virtual bool ShowingInterstitialPage() const = 0;
489 // Returns the currently showing interstitial, nullptr if no interstitial is
490 // showing.
491 virtual InterstitialPage* GetInterstitialPage() const = 0;
493 // Misc state & callbacks ----------------------------------------------------
495 // Check whether we can do the saving page operation this page given its MIME
496 // type.
497 virtual bool IsSavable() = 0;
499 // Prepare for saving the current web page to disk.
500 virtual void OnSavePage() = 0;
502 // Save page with the main HTML file path, the directory for saving resources,
503 // and the save type: HTML only or complete web page. Returns true if the
504 // saving process has been initiated successfully.
505 virtual bool SavePage(const base::FilePath& main_file,
506 const base::FilePath& dir_path,
507 SavePageType save_type) = 0;
509 // Saves the given frame's URL to the local filesystem.
510 virtual void SaveFrame(const GURL& url,
511 const Referrer& referrer) = 0;
513 // Saves the given frame's URL to the local filesystem. The headers, if
514 // provided, is used to make a request to the URL rather than using cache.
515 // Format of |headers| is a new line separated list of key value pairs:
516 // "<key1>: <value1>\n<key2>: <value2>".
517 virtual void SaveFrameWithHeaders(const GURL& url,
518 const Referrer& referrer,
519 const std::string& headers) = 0;
521 // Generate an MHTML representation of the current page in the given file.
522 virtual void GenerateMHTML(
523 const base::FilePath& file,
524 const base::Callback<void(
525 int64 /* size of the file */)>& callback) = 0;
527 // Returns the contents MIME type after a navigation.
528 virtual const std::string& GetContentsMimeType() const = 0;
530 // Returns true if this WebContents will notify about disconnection.
531 virtual bool WillNotifyDisconnection() const = 0;
533 // Override the encoding and reload the page by sending down
534 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
535 // the opposite of this, by which 'browser' is notified of
536 // the encoding of the current tab from 'renderer' (determined by
537 // auto-detect, http header, meta, bom detection, etc).
538 virtual void SetOverrideEncoding(const std::string& encoding) = 0;
540 // Remove any user-defined override encoding and reload by sending down
541 // ViewMsg_ResetPageEncodingToDefault to the renderer.
542 virtual void ResetOverrideEncoding() = 0;
544 // Returns the settings which get passed to the renderer.
545 virtual content::RendererPreferences* GetMutableRendererPrefs() = 0;
547 // Tells the tab to close now. The tab will take care not to close until it's
548 // out of nested message loops.
549 virtual void Close() = 0;
551 // A render view-originated drag has ended. Informs the render view host and
552 // WebContentsDelegate.
553 virtual void SystemDragEnded() = 0;
555 // Notification the user has made a gesture while focus was on the
556 // page. This is used to avoid uninitiated user downloads (aka carpet
557 // bombing), see DownloadRequestLimiter for details.
558 virtual void UserGestureDone() = 0;
560 // Indicates if this tab was explicitly closed by the user (control-w, close
561 // tab menu item...). This is false for actions that indirectly close the tab,
562 // such as closing the window. The setter is maintained by TabStripModel, and
563 // the getter only useful from within TAB_CLOSED notification
564 virtual void SetClosedByUserGesture(bool value) = 0;
565 virtual bool GetClosedByUserGesture() const = 0;
567 // Opens view-source tab for this contents.
568 virtual void ViewSource() = 0;
570 virtual void ViewFrameSource(const GURL& url,
571 const PageState& page_state) = 0;
573 // Gets the minimum/maximum zoom percent.
574 virtual int GetMinimumZoomPercent() const = 0;
575 virtual int GetMaximumZoomPercent() const = 0;
577 // Set the renderer's page scale back to one.
578 virtual void ResetPageScale() = 0;
580 // Gets the preferred size of the contents.
581 virtual gfx::Size GetPreferredSize() const = 0;
583 // Called when the reponse to a pending mouse lock request has arrived.
584 // Returns true if |allowed| is true and the mouse has been successfully
585 // locked.
586 virtual bool GotResponseToLockMouseRequest(bool allowed) = 0;
588 // Called when the user has selected a color in the color chooser.
589 virtual void DidChooseColorInColorChooser(SkColor color) = 0;
591 // Called when the color chooser has ended.
592 virtual void DidEndColorChooser() = 0;
594 // Returns true if the location bar should be focused by default rather than
595 // the page contents. The view calls this function when the tab is focused
596 // to see what it should do.
597 virtual bool FocusLocationBarByDefault() = 0;
599 // Does this have an opener associated with it?
600 virtual bool HasOpener() const = 0;
602 // Returns the opener if HasOpener() is true, or nullptr otherwise.
603 virtual WebContents* GetOpener() const = 0;
605 typedef base::Callback<void(
606 int, /* id */
607 int, /* HTTP status code */
608 const GURL&, /* image_url */
609 const std::vector<SkBitmap>&, /* bitmaps */
610 /* The sizes in pixel of the bitmaps before they were resized due to the
611 max bitmap size passed to DownloadImage(). Each entry in the bitmaps
612 vector corresponds to an entry in the sizes vector. If a bitmap was
613 resized, there should be a single returned bitmap. */
614 const std::vector<gfx::Size>&)>
615 ImageDownloadCallback;
617 // Sends a request to download the given image |url| and returns the unique
618 // id of the download request. When the download is finished, |callback| will
619 // be called with the bitmaps received from the renderer.
620 // If |is_favicon| is true, the cookies are not sent and not accepted during
621 // download.
622 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
623 // from the bitmap results. If there are no bitmap results <=
624 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and
625 // is the only result. A |max_bitmap_size| of 0 means unlimited.
626 // If |bypass_cache| is true, |url| is requested from the server even if it
627 // is present in the browser cache.
628 virtual int DownloadImage(const GURL& url,
629 bool is_favicon,
630 uint32_t max_bitmap_size,
631 bool bypass_cache,
632 const ImageDownloadCallback& callback) = 0;
634 // Returns true if the WebContents is responsible for displaying a subframe
635 // in a different process from its parent page.
636 // TODO: this doesn't really belong here. With site isolation, this should be
637 // removed since we can then embed iframes in different processes.
638 virtual bool IsSubframe() const = 0;
640 // Finds text on a page.
641 virtual void Find(int request_id,
642 const base::string16& search_text,
643 const blink::WebFindOptions& options) = 0;
645 // Notifies the renderer that the user has closed the FindInPage window
646 // (and what action to take regarding the selection).
647 virtual void StopFinding(StopFindAction action) = 0;
649 // Requests the renderer to insert CSS into the main frame's document.
650 virtual void InsertCSS(const std::string& css) = 0;
652 // Returns true if audio has recently been audible from the WebContents.
653 virtual bool WasRecentlyAudible() = 0;
655 typedef base::Callback<void(const Manifest&)> GetManifestCallback;
657 // Requests the Manifest of the main frame's document.
658 virtual void GetManifest(const GetManifestCallback&) = 0;
660 // Requests the renderer to exit fullscreen.
661 virtual void ExitFullscreen() = 0;
663 // Unblocks requests from renderer for a newly created window. This is
664 // used in showCreatedWindow() or sometimes later in cases where
665 // delegate->ShouldResumeRequestsForCreatedWindow() indicated the requests
666 // should not yet be resumed. Then the client is responsible for calling this
667 // as soon as they are ready.
668 virtual void ResumeLoadingCreatedWebContents() = 0;
670 #if defined(OS_ANDROID)
671 // Requests to resume the current media session.
672 virtual void ResumeMediaSession() = 0;
673 // Requests to suspend the current media session.
674 virtual void SuspendMediaSession() = 0;
676 CONTENT_EXPORT static WebContents* FromJavaWebContents(
677 jobject jweb_contents_android);
678 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() = 0;
679 #elif defined(OS_MACOSX)
680 // Allowing other views disables optimizations which assume that only a single
681 // WebContents is present.
682 virtual void SetAllowOtherViews(bool allow) = 0;
684 // Returns true if other views are allowed, false otherwise.
685 virtual bool GetAllowOtherViews() = 0;
686 #endif // OS_ANDROID
688 private:
689 // This interface should only be implemented inside content.
690 friend class WebContentsImpl;
691 WebContents() {}
694 } // namespace content
696 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_