15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <set>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/callback.h"
137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "content/public/browser/invalidate_type.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/navigation_type.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/media_stream_request.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/window_container_type.h"
197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebDragOperation.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkColor.h"
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/window_open_disposition.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect_f.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GURL;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class FilePath;
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ListValue;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserContext;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ColorChooser;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DownloadItem;
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class JavaScriptDialogManager;
3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class PageState;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderViewHost;
393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)class SessionStorageNamespace;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebContents;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebContentsImpl;
42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)struct ColorSuggestion;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ContextMenuParams;
44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochstruct DropData;
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct FileChooserParams;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct NativeWebKeyboardEvent;
47a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstruct Referrer;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct SSLStatus;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace gfx {
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Point;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Rect;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Size;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace blink {
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class WebGestureEvent;
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebLayer;
60a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstruct WebWindowFeatures;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct OpenURLParams;
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Objects implement this interface to get notified about changes in the
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// WebContents and to provide necessary functionality.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT WebContentsDelegate {
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebContentsDelegate();
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Opens a new URL inside the passed in WebContents (if source is 0 open
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // in the current front-most tab), unless |disposition| indicates the url
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // should be opened in a new tab or window.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A NULL source indicates the current tab (callers should probably use
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // OpenURL() for these cases which does it for you).
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the WebContents the URL is opened in, or NULL if the URL wasn't
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // opened immediately.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual WebContents* OpenURLFromTab(WebContents* source,
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      const OpenURLParams& params);
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to inform the delegate that the WebContents's navigation state
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // changed. The |changed_flags| indicates the parts of the navigation state
876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // that have been updated.
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NavigationStateChanged(const WebContents* source,
896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                                      InvalidateTypes changed_flags) {}
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // Called to inform the delegate that the WebContent's visible SSL state (as
9246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // defined by SSLStatus) changed.
9346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  virtual void VisibleSSLStateChanged(const WebContents* source) {}
9446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates a new tab with the already-created WebContents 'new_contents'.
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The window for the added contents should be reparented correctly when this
97424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // method returns.  If |disposition| is NEW_POPUP, |initial_pos| should hold
98424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // the initial position. If |was_blocked| is non-NULL, then |*was_blocked|
99424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // will be set to true if the popup gets blocked, and left unchanged
100424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // otherwise.
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void AddNewContents(WebContents* source,
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              WebContents* new_contents,
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              WindowOpenDisposition disposition,
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const gfx::Rect& initial_pos,
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              bool user_gesture,
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              bool* was_blocked) {}
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Selects the specified contents, bringing its container to the front.
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ActivateContents(WebContents* contents) {}
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Deactivates the specified contents by deactivating its container and
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // potentialy moving it to the back of the Z order.
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DeactivateContents(WebContents* contents) {}
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the delegate that this contents is starting or is done loading
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // some resource. The delegate should use this notification to represent
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // loading feedback. See WebContents::IsLoading()
118effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // |to_different_document| will be true unless the load is a fragment
119effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // navigation, or triggered by history.pushState/replaceState.
120effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual void LoadingStateChanged(WebContents* source,
121effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                                   bool to_different_document) {}
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the delegate that the page has made some progress loading.
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |progress| is a value between 0.0 (nothing loaded) to 1.0 (page fully
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // loaded).
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LoadProgressChanged(WebContents* source,
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   double progress) {}
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Request the delegate to close this web contents, and do whatever cleanup
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // it needs to do.
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void CloseContents(WebContents* source) {}
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the delegate that the underlying RenderViewHost has been swapped
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // out so it can perform any cleanup necessary.
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SwappedOut(WebContents* source) {}
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Request the delegate to move this WebContents to the specified position
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // in screen coordinates.
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void MoveContents(WebContents* source, const gfx::Rect& pos) {}
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to determine if the WebContents is contained in a popup window
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // or a panel window.
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsPopupOrPanel(const WebContents* source) const;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the target URL has changed.
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateTargetURL(WebContents* source,
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                               const GURL& url) {}
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that there was a mouse event, along with the absolute
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // coordinates of the mouse pointer and whether it was a normal motion event
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (otherwise, the pointer left the contents area).
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ContentsMouseEvent(WebContents* source,
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  const gfx::Point& location,
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  bool motion) {}
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Request the delegate to change the zoom level of the current tab.
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ContentsZoomChange(bool zoom_in) {}
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Called to determine if the WebContents can be overscrolled with touch/wheel
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // gestures.
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool CanOverscrollContent() const;
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
163bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  // Callback that allows vertical overscroll activies to be communicated to the
1641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // delegate. |delta_y| is the total amount of overscroll.
165bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  virtual void OverscrollUpdate(int delta_y) {}
166bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch
1671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Invoked when a vertical overscroll completes.
1681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void OverscrollComplete() {}
1691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return the rect where to display the resize corner, if any, otherwise
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // an empty rect.
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Rect GetRootWindowResizerRect() const;
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked prior to showing before unload handler confirmation dialog.
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WillRunBeforeUnloadConfirm() {}
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if javascript dialogs and unload alerts are suppressed.
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Default is false.
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ShouldSuppressDialogs();
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1810529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Returns whether pending NavigationEntries for aborted browser-initiated
1820529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // navigations should be preserved (and thus returned from GetVisibleURL).
1830529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Defaults to false.
1840529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  virtual bool ShouldPreserveAbortedURLs(WebContents* source);
1850529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Add a message to the console. Returning true indicates that the delegate
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // handled the message. If false is returned the default logging mechanism
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // will be used for the message.
1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool AddMessageToConsole(WebContents* source,
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   int32 level,
191a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                   const base::string16& message,
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   int32 line_no,
193a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                   const base::string16& source_id);
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells us that we've finished firing this tab's beforeunload event.
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The proceed bool tells us whether the user chose to proceed closing the
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tab. Returns true if the tab can continue on firing its unload event.
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If we're closing the entire browser, then we'll want to delay firing
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // unload events until all the beforeunload events have fired.
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void BeforeUnloadFired(WebContents* tab,
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 bool proceed,
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 bool* proceed_to_fire_unload);
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns true if the location bar should be focused by default rather than
2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the page contents. NOTE: this is only used if WebContents can't determine
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // for itself whether the location bar should be focused by default. For a
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // complete check, you should use WebContents::FocusLocationBarByDefault().
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ShouldFocusLocationBarByDefault(WebContents* source);
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets focus to the location bar or some other place that is appropriate.
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is called when the tab wants to encourage user input, like for the
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // new tab page.
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetFocusToLocationBar(bool select_all) {}
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns whether the page should be focused when transitioning from crashed
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to live. Default is true.
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ShouldFocusPageAfterCrash();
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is called when WebKit tells us that it is done tabbing through
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // controls on the page. Provides a way for WebContentsDelegates to handle
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this. Returns true if the delegate successfully handled it.
2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool TakeFocus(WebContents* source,
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         bool reverse);
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when the page loses mouse capture.
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LostCapture() {}
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that |contents| has gained focus.
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WebContentsFocused(WebContents* contents) {}
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Asks the delegate if the given tab can download.
232c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Invoking the |callback| synchronously is OK.
233c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void CanDownload(RenderViewHost* render_view_host,
234cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                           const GURL& url,
235c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                           const std::string& request_method,
236c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                           const base::Callback<void(bool)>& callback);
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return much extra vertical space should be allotted to the
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // render view widget during various animations (e.g. infobar closing).
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is used to make painting look smoother.
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetExtraRenderViewHeight() const;
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the context menu operation was handled by the delegate.
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool HandleContextMenu(const content::ContextMenuParams& params);
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Opens source view for given WebContents that is navigated to the given
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // page url.
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ViewSourceForTab(WebContents* source, const GURL& page_url);
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Opens source view for the given subframe.
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ViewSourceForFrame(WebContents* source,
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  const GURL& url,
25390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                  const PageState& page_state);
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Allows delegates to handle keyboard events before sending to the renderer.
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the |event| was handled. Otherwise, if the |event| would be
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |*is_keyboard_shortcut| should be set to true.
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool PreHandleKeyboardEvent(WebContents* source,
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      const NativeWebKeyboardEvent& event,
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      bool* is_keyboard_shortcut);
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Allows delegates to handle unhandled keyboard messages coming back from
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the renderer.
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void HandleKeyboardEvent(WebContents* source,
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   const NativeWebKeyboardEvent& event) {}
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void HandleMouseDown() {}
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void HandleMouseUp() {}
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handles activation resulting from a pointer event (e.g. when mouse is
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // pressed, or a touch-gesture begins).
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void HandlePointerActivate() {}
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Allows delegates to handle gesture events before sending to the renderer.
2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns true if the |event| was handled and thus shouldn't be processed
2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // by the renderer's event handler. Note that the touch events that create
2785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // the gesture are always passed to the renderer since the gesture is created
2795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // and dispatched after the touches return without being "preventDefault()"ed.
2805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual bool PreHandleGestureEvent(
2815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      WebContents* source,
2825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const blink::WebGestureEvent& event);
2835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void HandleGestureBegin() {}
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void HandleGestureEnd() {}
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2877d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Called when an external drag event enters the web contents window. Return
2887d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // true to allow dragging and dropping on the web contents window or false to
2897d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // cancel the operation. This method is used by Chromium Embedded Framework.
2907d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  virtual bool CanDragEnter(WebContents* source,
291eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                            const DropData& data,
292f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                            blink::WebDragOperationsMask operations_allowed);
2937d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Render view drag n drop ended.
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragEnded() {}
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Shows the repost form confirmation dialog box.
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ShowRepostFormWarningDialog(WebContents* source) {}
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Allows delegate to override navigation to the history entries.
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true to allow WebContents to continue with the default processing.
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnGoToEntryOffset(int offset);
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Allows delegate to control whether a WebContents will be created. Returns
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // true to allow the creation. Default is to allow it. In cases where the
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // delegate handles the creation/navigation itself, it will use |target_url|.
3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The embedder has to synchronously adopt |route_id| or else the view will
3085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // be destroyed.
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ShouldCreateWebContents(
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      WebContents* web_contents,
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int route_id,
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      WindowContainerType window_container_type,
313a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& frame_name,
3147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch      const GURL& target_url,
3153551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      const std::string& partition_id,
3163551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      SessionStorageNamespace* session_storage_namespace);
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the delegate about the creation of a new WebContents. This
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // typically happens when popups are created.
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WebContentsCreated(WebContents* source_contents,
321effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                                  int opener_render_frame_id,
322a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                  const base::string16& frame_name,
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  const GURL& target_url,
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  WebContents* new_contents) {}
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the tab is hung.
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RendererUnresponsive(WebContents* source) {}
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the tab is no longer hung.
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RendererResponsive(WebContents* source) {}
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that a worker associated with this tab has crashed.
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WorkerCrashed(WebContents* source) {}
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when a main fram navigation occurs.
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidNavigateMainFramePostCommit(WebContents* source) {}
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when navigating to a pending entry. When invoked the
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NavigationController has configured its pending entry, but it has not yet
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // been committed.
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidNavigateToPendingEntry(WebContents* source) {}
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns a pointer to a service to manage JavaScript dialogs. May return
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NULL in which case dialogs aren't shown.
3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual JavaScriptDialogManager* GetJavaScriptDialogManager();
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when color chooser should open. Returns the opened color chooser.
3485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns NULL if we failed to open the color chooser (e.g. when there is a
3495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // ColorChooserDialog already open on Windows). Ownership of the returned
3505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // pointer is transferred to the caller.
351a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual ColorChooser* OpenColorChooser(
352a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      WebContents* web_contents,
353a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      SkColor color,
354a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const std::vector<ColorSuggestion>& suggestions);
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a file selection is to be done.
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RunFileChooser(WebContents* web_contents,
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const FileChooserParams& params) {}
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Request to enumerate a directory.  This is equivalent to running the file
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // chooser in directory-enumeration mode and having the user select the given
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // directory.
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void EnumerateDirectory(WebContents* web_contents,
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  int request_id,
3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                  const base::FilePath& path) {}
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
367d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns true if the delegate will embed a WebContents-owned fullscreen
368d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // render widget.  In this case, the delegate may access the widget by calling
369d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // WebContents::GetFullscreenRenderWidgetHostView().  If false is returned,
370d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // WebContents will be responsible for showing the fullscreen widget.
371d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual bool EmbedsFullscreenWidget() const;
372d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the renderer puts a tab into or out of fullscreen mode.
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ToggleFullscreenModeForTab(WebContents* web_contents,
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                          bool enter_fullscreen) {}
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsFullscreenForTabOrPending(
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const WebContents* web_contents) const;
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Register a new handler for URL requests with the given scheme.
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |user_gesture| is true if the registration is made in the context of a user
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // gesture.
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RegisterProtocolHandler(WebContents* web_contents,
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       const std::string& protocol,
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       const GURL& url,
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       bool user_gesture) {}
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
387116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Unregister the registered handler for URL requests with the given scheme.
388116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // |user_gesture| is true if the registration is made in the context of a user
389116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // gesture.
390116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void UnregisterProtocolHandler(WebContents* web_contents,
391116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                                         const std::string& protocol,
392116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                                         const GURL& url,
393116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                                         bool user_gesture) {}
394116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Result of string search in the page. This includes the number of matches
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // found and the selection rect (in screen coordinates) for the string found.
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If |final_update| is false, it indicates that more results follow.
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void FindReply(WebContents* web_contents,
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         int request_id,
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         int number_of_matches,
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const gfx::Rect& selection_rect,
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         int active_match_ordinal,
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         bool final_update) {}
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Provides the rects of the current find-in-page matches.
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sent as a reply to RequestFindMatchRects.
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void FindMatchRectsReply(WebContents* web_contents,
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   int version,
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   const std::vector<gfx::RectF>& rects,
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   const gfx::RectF& active_rect) {}
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when the preferred size of the contents has been changed.
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdatePreferredSize(WebContents* web_contents,
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   const gfx::Size& pref_size) {}
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Invoked when the contents auto-resized and the container should match it.
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ResizeDueToAutoResize(WebContents* web_contents,
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                     const gfx::Size& new_size) {}
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification message from HTML UI.
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WebUISend(WebContents* web_contents,
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const GURL& source_url,
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::string& name,
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const base::ListValue& args) {}
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Requests to lock the mouse. Once the request is approved or rejected,
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GotResponseToLockMouseRequest() will be called on the requesting tab
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // contents.
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RequestToLockMouse(WebContents* web_contents,
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  bool user_gesture,
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  bool last_unlocked_by_target) {}
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the page has lost the mouse lock.
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LostMouseLock() {}
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Asks permission to use the camera and/or microphone. If permission is
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // granted, a call should be made to |callback| with the devices. If the
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // request is denied, a call should be made to |callback| with an empty list
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of devices. |request| has the details of the request (e.g. which of audio
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and/or video devices are requested, and lists of available devices).
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RequestMediaAccessPermission(
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      WebContents* web_contents,
4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const MediaStreamRequest& request,
44658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)      const MediaResponseCallback& callback);
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Checks if we have permission to access the microphone or camera. Note that
4491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // this does not query the user. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE
4501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // or MEDIA_DEVICE_VIDEO_CAPTURE.
4511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CheckMediaAccessPermission(WebContents* web_contents,
4521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                          const GURL& security_origin,
4531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                          MediaStreamType type);
4541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Requests permission to access the PPAPI broker. The delegate should return
4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // true and call the passed in |callback| with the result, or return false
4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // to indicate that it does not support asking for permission.
4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool RequestPpapiBrokerPermission(
4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      WebContents* web_contents,
4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const GURL& url,
4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::FilePath& plugin_path,
4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::Callback<void(bool)>& callback);
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
464424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Returns the size for the new render view created for the pending entry in
465424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // |web_contents|; if there's no size, returns an empty size.
466424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // This is optional for implementations of WebContentsDelegate; if the
467424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // delegate doesn't provide a size, the current WebContentsView's size will be
468424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // used.
469010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual gfx::Size GetSizeForNewRenderView(WebContents* web_contents) const;
470424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
4715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Notification that validation of a form displayed by the |web_contents|
4725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // has failed. There can only be one message per |web_contents| at a time.
4735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void ShowValidationMessage(WebContents* web_contents,
4745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                     const gfx::Rect& anchor_in_root_view,
4755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                     const base::string16& main_text,
4765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                     const base::string16& sub_text) {}
4775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
4785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Notification that the delegate should hide any showing form validation
4795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // message.
4805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void HideValidationMessage(WebContents* web_contents) {}
4815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
4825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Notification that the form element that triggered the validation failure
4835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // has moved.
4845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void MoveValidationMessage(WebContents* web_contents,
4855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                     const gfx::Rect& anchor_in_root_view) {}
4865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
4870529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Returns true if the WebContents is never visible.
4880529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  virtual bool IsNeverVisible(WebContents* web_contents);
4890529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~WebContentsDelegate();
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class WebContentsImpl;
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when |this| becomes the WebContentsDelegate for |source|.
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Attach(WebContents* source);
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when |this| is no longer the WebContentsDelegate for |source|.
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Detach(WebContents* source);
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The WebContents that this is currently a delegate for.
5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::set<WebContents*> attached_contents_;
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_
509