Add long running gmail memory benchmark for background tab.
[chromium-blink-merge.git] / content / browser / frame_host / render_frame_host_delegate.h
blobe4fa4fa56bdc17afab8f6ceb65c272ebd8ae53bc
1 // Copyright 2013 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_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/i18n/rtl.h"
12 #include "content/common/content_export.h"
13 #include "content/common/frame_message_enums.h"
14 #include "content/public/browser/site_instance.h"
15 #include "content/public/common/javascript_message_type.h"
16 #include "content/public/common/media_stream_request.h"
17 #include "net/http/http_response_headers.h"
19 #if defined(OS_WIN)
20 #include "ui/gfx/native_widget_types.h"
21 #endif
23 class GURL;
25 namespace IPC {
26 class Message;
29 namespace content {
30 class GeolocationServiceContext;
31 class RenderFrameHost;
32 class WebContents;
33 struct AXEventNotificationDetails;
34 struct ContextMenuParams;
35 struct TransitionLayerData;
37 // An interface implemented by an object interested in knowing about the state
38 // of the RenderFrameHost.
39 class CONTENT_EXPORT RenderFrameHostDelegate {
40 public:
41 // This is used to give the delegate a chance to filter IPC messages.
42 virtual bool OnMessageReceived(RenderFrameHost* render_frame_host,
43 const IPC::Message& message);
45 // Gets the last committed URL. See WebContents::GetLastCommittedURL for a
46 // description of the semantics.
47 virtual const GURL& GetMainFrameLastCommittedURL() const;
49 // A message was added to to the console.
50 virtual bool AddMessageToConsole(int32 level,
51 const base::string16& message,
52 int32 line_no,
53 const base::string16& source_id);
55 // Informs the delegate whenever a RenderFrameHost is created.
56 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) {}
58 // Informs the delegate whenever a RenderFrameHost is deleted.
59 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) {}
61 // The RenderFrameHost has been swapped out.
62 virtual void SwappedOut(RenderFrameHost* render_frame_host) {}
64 // A context menu should be shown, to be built using the context information
65 // provided in the supplied params.
66 virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
67 const ContextMenuParams& params) {}
69 // A JavaScript message, confirmation or prompt should be shown.
70 virtual void RunJavaScriptMessage(RenderFrameHost* render_frame_host,
71 const base::string16& message,
72 const base::string16& default_prompt,
73 const GURL& frame_url,
74 JavaScriptMessageType type,
75 IPC::Message* reply_msg) {}
77 virtual void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host,
78 const base::string16& message,
79 bool is_reload,
80 IPC::Message* reply_msg) {}
82 // Another page accessed the top-level initial empty document, which means it
83 // is no longer safe to display a pending URL without risking a URL spoof.
84 virtual void DidAccessInitialDocument() {}
86 // The frame changed its window.name property.
87 virtual void DidChangeName(RenderFrameHost* render_frame_host,
88 const std::string& name) {}
90 // The onload handler in the frame has completed. Only called for the top-
91 // level frame.
92 virtual void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) {}
94 // The page's title was changed and should be updated. Only called for the
95 // top-level frame.
96 virtual void UpdateTitle(RenderFrameHost* render_frame_host,
97 int32 page_id,
98 const base::string16& title,
99 base::i18n::TextDirection title_direction) {}
101 // The page's encoding was changed and should be updated. Only called for the
102 // top-level frame.
103 virtual void UpdateEncoding(RenderFrameHost* render_frame_host,
104 const std::string& encoding) {}
106 // Return this object cast to a WebContents, if it is one. If the object is
107 // not a WebContents, returns NULL.
108 virtual WebContents* GetAsWebContents();
110 // The render frame has requested access to media devices listed in
111 // |request|, and the client should grant or deny that permission by
112 // calling |callback|.
113 virtual void RequestMediaAccessPermission(
114 const MediaStreamRequest& request,
115 const MediaResponseCallback& callback);
117 // Checks if we have permission to access the microphone or camera. Note that
118 // this does not query the user. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE
119 // or MEDIA_DEVICE_VIDEO_CAPTURE.
120 virtual bool CheckMediaAccessPermission(const GURL& security_origin,
121 MediaStreamType type);
123 // Get the accessibility mode for the WebContents that owns this frame.
124 virtual AccessibilityMode GetAccessibilityMode() const;
126 // Invoked when an accessibility event is received from the renderer.
127 virtual void AccessibilityEventReceived(
128 const std::vector<AXEventNotificationDetails>& details) {}
130 // Find a guest RenderFrameHost by its parent |render_frame_host| and
131 // |browser_plugin_instance_id|.
132 virtual RenderFrameHost* GetGuestByInstanceID(
133 RenderFrameHost* render_frame_host,
134 int browser_plugin_instance_id);
136 // Gets the GeolocationServiceContext associated with this delegate.
137 virtual GeolocationServiceContext* GetGeolocationServiceContext();
139 // Notification that the frame wants to go into fullscreen mode.
140 // |origin| represents the origin of the frame that requests fullscreen.
141 virtual void EnterFullscreenMode(const GURL& origin) {}
143 // Notification that the frame wants to go out of fullscreen mode.
144 virtual void ExitFullscreenMode() {}
146 // Let the delegate decide whether postMessage should be delivered to
147 // |target_rfh| from a source frame in the given SiteInstance. This defaults
148 // to false and overrides the RenderFrameHost's decision if true.
149 virtual bool ShouldRouteMessageEvent(
150 RenderFrameHost* target_rfh,
151 SiteInstance* source_site_instance) const;
153 // Ensure that |source_rfh| has swapped-out RenderViews and
154 // RenderFrameProxies for itself and for all frames on its opener chain in
155 // the current frame's SiteInstance. Returns the routing ID of the
156 // swapped-out RenderView corresponding to |source_rfh|.
158 // TODO(alexmos): This method currently supports cross-process postMessage,
159 // where we may need to create any missing proxies for the message's source
160 // frame and its opener chain. It currently exists in WebContents due to a
161 // special case for <webview> guests, but this logic should eventually be
162 // moved down into RenderFrameProxyHost::RouteMessageEvent when <webview>
163 // refactoring for --site-per-process mode is further along. See
164 // https://crbug.com/330264.
165 virtual void EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) {}
167 #if defined(OS_WIN)
168 // Returns the frame's parent's NativeViewAccessible.
169 virtual gfx::NativeViewAccessible GetParentNativeViewAccessible();
170 #endif
172 protected:
173 virtual ~RenderFrameHostDelegate() {}
176 } // namespace content
178 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_