Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / browser / web_contents.h
blob47decf4c6ea90c6e5f2cc716adf666cc9073014b
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. |frame_name| is used to
252 // identify the frame and cannot be empty.
253 virtual WebUI* CreateSubframeWebUI(const GURL& url,
254 const std::string& frame_name) = 0;
256 // Returns the committed WebUI if one exists, otherwise the pending one.
257 virtual WebUI* GetWebUI() const = 0;
258 virtual WebUI* GetCommittedWebUI() const = 0;
260 // Allows overriding the user agent used for NavigationEntries it owns.
261 virtual void SetUserAgentOverride(const std::string& override) = 0;
262 virtual const std::string& GetUserAgentOverride() const = 0;
264 // Enable the accessibility tree for this WebContents in the renderer,
265 // but don't enable creating a native accessibility tree on the browser
266 // side.
267 virtual void EnableTreeOnlyAccessibilityMode() = 0;
269 // Returns true only if "tree only" accessibility mode is on.
270 virtual bool IsTreeOnlyAccessibilityModeForTesting() const = 0;
272 // Returns true only if complete accessibility mode is on, meaning there's
273 // both renderer accessibility, and a native browser accessibility tree.
274 virtual bool IsFullAccessibilityModeForTesting() const = 0;
276 #if defined(OS_WIN)
277 virtual void SetParentNativeViewAccessible(
278 gfx::NativeViewAccessible accessible_parent) = 0;
279 #endif
281 // Tab navigation state ------------------------------------------------------
283 // Returns the current navigation properties, which if a navigation is
284 // pending may be provisional (e.g., the navigation could result in a
285 // download, in which case the URL would revert to what it was previously).
286 virtual const base::string16& GetTitle() const = 0;
288 // The max page ID for any page that the current SiteInstance has loaded in
289 // this WebContents. Page IDs are specific to a given SiteInstance and
290 // WebContents, corresponding to a specific RenderView in the renderer.
291 // Page IDs increase with each new page that is loaded by a tab.
292 virtual int32 GetMaxPageID() = 0;
294 // The max page ID for any page that the given SiteInstance has loaded in
295 // this WebContents.
296 virtual int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) = 0;
298 // Returns the SiteInstance associated with the current page.
299 virtual SiteInstance* GetSiteInstance() const = 0;
301 // Returns the SiteInstance for the pending navigation, if any. Otherwise
302 // returns the current SiteInstance.
303 virtual SiteInstance* GetPendingSiteInstance() const = 0;
305 // Returns whether this WebContents is loading a resource.
306 virtual bool IsLoading() const = 0;
308 // Returns whether this WebContents is loading and and the load is to a
309 // different top-level document (rather than being a navigation within the
310 // same document). This being true implies that IsLoading() is also true.
311 virtual bool IsLoadingToDifferentDocument() const = 0;
313 // Returns whether this WebContents is waiting for a first-response for the
314 // main resource of the page.
315 virtual bool IsWaitingForResponse() const = 0;
317 // Returns the current load state and the URL associated with it.
318 // The load state is only updated while IsLoading() is true.
319 virtual const net::LoadStateWithParam& GetLoadState() const = 0;
320 virtual const base::string16& GetLoadStateHost() const = 0;
322 // Returns the upload progress.
323 virtual uint64 GetUploadSize() const = 0;
324 virtual uint64 GetUploadPosition() const = 0;
326 // Returns a set of the site URLs currently committed in this tab.
327 virtual std::set<GURL> GetSitesInTab() const = 0;
329 // Returns the character encoding of the page.
330 virtual const std::string& GetEncoding() const = 0;
332 // True if this is a secure page which displayed insecure content.
333 virtual bool DisplayedInsecureContent() const = 0;
335 // Internal state ------------------------------------------------------------
337 // Indicates whether the WebContents is being captured (e.g., for screenshots
338 // or mirroring). Increment calls must be balanced with an equivalent number
339 // of decrement calls. |capture_size| specifies the capturer's video
340 // resolution, but can be empty to mean "unspecified." The first screen
341 // capturer that provides a non-empty |capture_size| will override the value
342 // returned by GetPreferredSize() until all captures have ended.
343 virtual void IncrementCapturerCount(const gfx::Size& capture_size) = 0;
344 virtual void DecrementCapturerCount() = 0;
345 virtual int GetCapturerCount() const = 0;
347 // Indicates/Sets whether all audio output from this WebContents is muted.
348 virtual bool IsAudioMuted() const = 0;
349 virtual void SetAudioMuted(bool mute) = 0;
351 // Indicates whether this tab should be considered crashed. The setter will
352 // also notify the delegate when the flag is changed.
353 virtual bool IsCrashed() const = 0;
354 virtual void SetIsCrashed(base::TerminationStatus status, int error_code) = 0;
356 virtual base::TerminationStatus GetCrashedStatus() const = 0;
358 // Whether the tab is in the process of being destroyed.
359 virtual bool IsBeingDestroyed() const = 0;
361 // Convenience method for notifying the delegate of a navigation state
362 // change.
363 virtual void NotifyNavigationStateChanged(InvalidateTypes changed_flags) = 0;
365 // Get/Set the last time that the WebContents was made active (either when it
366 // was created or shown with WasShown()).
367 virtual base::TimeTicks GetLastActiveTime() const = 0;
368 virtual void SetLastActiveTime(base::TimeTicks last_active_time) = 0;
370 // Invoked when the WebContents becomes shown/hidden.
371 virtual void WasShown() = 0;
372 virtual void WasHidden() = 0;
374 // Returns true if the before unload and unload listeners need to be
375 // fired. The value of this changes over time. For example, if true and the
376 // before unload listener is executed and allows the user to exit, then this
377 // returns false.
378 virtual bool NeedToFireBeforeUnload() = 0;
380 // Runs the beforeunload handler for the main frame. See also ClosePage and
381 // SwapOut in RenderViewHost, which run the unload handler.
383 // |for_cross_site_transition| indicates whether this call is for the current
384 // frame during a cross-process navigation. False means we're closing the
385 // entire tab.
387 // TODO(creis): We should run the beforeunload handler for every frame that
388 // has one.
389 virtual void DispatchBeforeUnload(bool for_cross_site_transition) = 0;
391 // Attaches this inner WebContents to its container frame
392 // |outer_contents_frame| in |outer_web_contents|.
393 virtual void AttachToOuterWebContentsFrame(
394 WebContents* outer_web_contents,
395 RenderFrameHost* outer_contents_frame) = 0;
397 // Commands ------------------------------------------------------------------
399 // Stop any pending navigation.
400 virtual void Stop() = 0;
402 // Creates a new WebContents with the same state as this one. The returned
403 // heap-allocated pointer is owned by the caller.
404 virtual WebContents* Clone() = 0;
406 // Reloads the focused frame.
407 virtual void ReloadFocusedFrame(bool ignore_cache) = 0;
409 // Editing commands ----------------------------------------------------------
411 virtual void Undo() = 0;
412 virtual void Redo() = 0;
413 virtual void Cut() = 0;
414 virtual void Copy() = 0;
415 virtual void CopyToFindPboard() = 0;
416 virtual void Paste() = 0;
417 virtual void PasteAndMatchStyle() = 0;
418 virtual void Delete() = 0;
419 virtual void SelectAll() = 0;
420 virtual void Unselect() = 0;
422 // Adjust the selection starting and ending points in the focused frame by
423 // the given amounts. A negative amount moves the selection towards the
424 // beginning of the document, a positive amount moves the selection towards
425 // the end of the document.
426 virtual void AdjustSelectionByCharacterOffset(int start_adjust,
427 int end_adjust) = 0;
429 // Replaces the currently selected word or a word around the cursor.
430 virtual void Replace(const base::string16& word) = 0;
432 // Replaces the misspelling in the current selection.
433 virtual void ReplaceMisspelling(const base::string16& word) = 0;
435 // Let the renderer know that the menu has been closed.
436 virtual void NotifyContextMenuClosed(
437 const CustomContextMenuContext& context) = 0;
439 // Executes custom context menu action that was provided from Blink.
440 virtual void ExecuteCustomContextMenuCommand(
441 int action, const CustomContextMenuContext& context) = 0;
443 // Views and focus -----------------------------------------------------------
445 // Returns the native widget that contains the contents of the tab.
446 virtual gfx::NativeView GetNativeView() = 0;
448 // Returns the native widget with the main content of the tab (i.e. the main
449 // render view host, though there may be many popups in the tab as children of
450 // the container).
451 virtual gfx::NativeView GetContentNativeView() = 0;
453 // Returns the outermost native view. This will be used as the parent for
454 // dialog boxes.
455 virtual gfx::NativeWindow GetTopLevelNativeWindow() = 0;
457 // Computes the rectangle for the native widget that contains the contents of
458 // the tab in the screen coordinate system.
459 virtual gfx::Rect GetContainerBounds() = 0;
461 // Get the bounds of the View, relative to the parent.
462 virtual gfx::Rect GetViewBounds() = 0;
464 // Returns the current drop data, if any.
465 virtual DropData* GetDropData() = 0;
467 // Sets focus to the native widget for this tab.
468 virtual void Focus() = 0;
470 // Sets focus to the appropriate element when the WebContents is shown the
471 // first time.
472 virtual void SetInitialFocus() = 0;
474 // Stores the currently focused view.
475 virtual void StoreFocus() = 0;
477 // Restores focus to the last focus view. If StoreFocus has not yet been
478 // invoked, SetInitialFocus is invoked.
479 virtual void RestoreFocus() = 0;
481 // Focuses the first (last if |reverse| is true) element in the page.
482 // Invoked when this tab is getting the focus through tab traversal (|reverse|
483 // is true when using Shift-Tab).
484 virtual void FocusThroughTabTraversal(bool reverse) = 0;
486 // Interstitials -------------------------------------------------------------
488 // Various other systems need to know about our interstitials.
489 virtual bool ShowingInterstitialPage() const = 0;
491 // Returns the currently showing interstitial, nullptr if no interstitial is
492 // showing.
493 virtual InterstitialPage* GetInterstitialPage() const = 0;
495 // Misc state & callbacks ----------------------------------------------------
497 // Check whether we can do the saving page operation this page given its MIME
498 // type.
499 virtual bool IsSavable() = 0;
501 // Prepare for saving the current web page to disk.
502 virtual void OnSavePage() = 0;
504 // Save page with the main HTML file path, the directory for saving resources,
505 // and the save type: HTML only or complete web page. Returns true if the
506 // saving process has been initiated successfully.
507 virtual bool SavePage(const base::FilePath& main_file,
508 const base::FilePath& dir_path,
509 SavePageType save_type) = 0;
511 // Saves the given frame's URL to the local filesystem.
512 virtual void SaveFrame(const GURL& url,
513 const Referrer& referrer) = 0;
515 // Saves the given frame's URL to the local filesystem. The headers, if
516 // provided, is used to make a request to the URL rather than using cache.
517 // Format of |headers| is a new line separated list of key value pairs:
518 // "<key1>: <value1>\n<key2>: <value2>".
519 virtual void SaveFrameWithHeaders(const GURL& url,
520 const Referrer& referrer,
521 const std::string& headers) = 0;
523 // Generate an MHTML representation of the current page in the given file.
524 virtual void GenerateMHTML(
525 const base::FilePath& file,
526 const base::Callback<void(
527 int64 /* size of the file */)>& callback) = 0;
529 // Returns the contents MIME type after a navigation.
530 virtual const std::string& GetContentsMimeType() const = 0;
532 // Returns true if this WebContents will notify about disconnection.
533 virtual bool WillNotifyDisconnection() const = 0;
535 // Override the encoding and reload the page by sending down
536 // ViewMsg_SetPageEncoding to the renderer. |UpdateEncoding| is kinda
537 // the opposite of this, by which 'browser' is notified of
538 // the encoding of the current tab from 'renderer' (determined by
539 // auto-detect, http header, meta, bom detection, etc).
540 virtual void SetOverrideEncoding(const std::string& encoding) = 0;
542 // Remove any user-defined override encoding and reload by sending down
543 // ViewMsg_ResetPageEncodingToDefault to the renderer.
544 virtual void ResetOverrideEncoding() = 0;
546 // Returns the settings which get passed to the renderer.
547 virtual content::RendererPreferences* GetMutableRendererPrefs() = 0;
549 // Tells the tab to close now. The tab will take care not to close until it's
550 // out of nested message loops.
551 virtual void Close() = 0;
553 // A render view-originated drag has ended. Informs the render view host and
554 // WebContentsDelegate.
555 virtual void SystemDragEnded() = 0;
557 // Notification the user has made a gesture while focus was on the
558 // page. This is used to avoid uninitiated user downloads (aka carpet
559 // bombing), see DownloadRequestLimiter for details.
560 virtual void UserGestureDone() = 0;
562 // Indicates if this tab was explicitly closed by the user (control-w, close
563 // tab menu item...). This is false for actions that indirectly close the tab,
564 // such as closing the window. The setter is maintained by TabStripModel, and
565 // the getter only useful from within TAB_CLOSED notification
566 virtual void SetClosedByUserGesture(bool value) = 0;
567 virtual bool GetClosedByUserGesture() const = 0;
569 // Opens view-source tab for this contents.
570 virtual void ViewSource() = 0;
572 virtual void ViewFrameSource(const GURL& url,
573 const PageState& page_state) = 0;
575 // Gets the minimum/maximum zoom percent.
576 virtual int GetMinimumZoomPercent() const = 0;
577 virtual int GetMaximumZoomPercent() const = 0;
579 // Set the renderer's page scale back to one.
580 virtual void ResetPageScale() = 0;
582 // Gets the preferred size of the contents.
583 virtual gfx::Size GetPreferredSize() const = 0;
585 // Called when the reponse to a pending mouse lock request has arrived.
586 // Returns true if |allowed| is true and the mouse has been successfully
587 // locked.
588 virtual bool GotResponseToLockMouseRequest(bool allowed) = 0;
590 // Called when the user has selected a color in the color chooser.
591 virtual void DidChooseColorInColorChooser(SkColor color) = 0;
593 // Called when the color chooser has ended.
594 virtual void DidEndColorChooser() = 0;
596 // Returns true if the location bar should be focused by default rather than
597 // the page contents. The view calls this function when the tab is focused
598 // to see what it should do.
599 virtual bool FocusLocationBarByDefault() = 0;
601 // Does this have an opener associated with it?
602 virtual bool HasOpener() const = 0;
604 // Returns the opener if HasOpener() is true, or nullptr otherwise.
605 virtual WebContents* GetOpener() const = 0;
607 typedef base::Callback<void(
608 int, /* id */
609 int, /* HTTP status code */
610 const GURL&, /* image_url */
611 const std::vector<SkBitmap>&, /* bitmaps */
612 /* The sizes in pixel of the bitmaps before they were resized due to the
613 max bitmap size passed to DownloadImage(). Each entry in the bitmaps
614 vector corresponds to an entry in the sizes vector. If a bitmap was
615 resized, there should be a single returned bitmap. */
616 const std::vector<gfx::Size>&)>
617 ImageDownloadCallback;
619 // Sends a request to download the given image |url| and returns the unique
620 // id of the download request. When the download is finished, |callback| will
621 // be called with the bitmaps received from the renderer.
622 // If |is_favicon| is true, the cookies are not sent and not accepted during
623 // download.
624 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
625 // from the bitmap results. If there are no bitmap results <=
626 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and
627 // is the only result. A |max_bitmap_size| of 0 means unlimited.
628 // If |bypass_cache| is true, |url| is requested from the server even if it
629 // is present in the browser cache.
630 virtual int DownloadImage(const GURL& url,
631 bool is_favicon,
632 uint32_t max_bitmap_size,
633 bool bypass_cache,
634 const ImageDownloadCallback& callback) = 0;
636 // Returns true if the WebContents is responsible for displaying a subframe
637 // in a different process from its parent page.
638 // TODO: this doesn't really belong here. With site isolation, this should be
639 // removed since we can then embed iframes in different processes.
640 virtual bool IsSubframe() const = 0;
642 // Finds text on a page.
643 virtual void Find(int request_id,
644 const base::string16& search_text,
645 const blink::WebFindOptions& options) = 0;
647 // Notifies the renderer that the user has closed the FindInPage window
648 // (and what action to take regarding the selection).
649 virtual void StopFinding(StopFindAction action) = 0;
651 // Requests the renderer to insert CSS into the main frame's document.
652 virtual void InsertCSS(const std::string& css) = 0;
654 // Returns true if audio has recently been audible from the WebContents.
655 virtual bool WasRecentlyAudible() = 0;
657 typedef base::Callback<void(const Manifest&)> GetManifestCallback;
659 // Requests the Manifest of the main frame's document.
660 virtual void GetManifest(const GetManifestCallback&) = 0;
662 // Requests the renderer to exit fullscreen.
663 virtual void ExitFullscreen() = 0;
665 // Unblocks requests from renderer for a newly created window. This is
666 // used in showCreatedWindow() or sometimes later in cases where
667 // delegate->ShouldResumeRequestsForCreatedWindow() indicated the requests
668 // should not yet be resumed. Then the client is responsible for calling this
669 // as soon as they are ready.
670 virtual void ResumeLoadingCreatedWebContents() = 0;
672 #if defined(OS_ANDROID)
673 // Requests to resume the current media session.
674 virtual void ResumeMediaSession() = 0;
675 // Requests to suspend the current media session.
676 virtual void SuspendMediaSession() = 0;
677 // Requests to stop the current media session.
678 virtual void StopMediaSession() = 0;
680 CONTENT_EXPORT static WebContents* FromJavaWebContents(
681 jobject jweb_contents_android);
682 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() = 0;
683 #elif defined(OS_MACOSX)
684 // Allowing other views disables optimizations which assume that only a single
685 // WebContents is present.
686 virtual void SetAllowOtherViews(bool allow) = 0;
688 // Returns true if other views are allowed, false otherwise.
689 virtual bool GetAllowOtherViews() = 0;
690 #endif // OS_ANDROID
692 private:
693 // This interface should only be implemented inside content.
694 friend class WebContentsImpl;
695 WebContents() {}
698 } // namespace content
700 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_