Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / frame_host / render_frame_host_delegate.h
blob40af1dba20c272427e2dc4af89622628cd87094e
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/common/javascript_message_type.h"
15 #include "content/public/common/media_stream_request.h"
16 #include "net/http/http_response_headers.h"
18 #if defined(OS_WIN)
19 #include "ui/gfx/native_widget_types.h"
20 #endif
22 class GURL;
24 namespace IPC {
25 class Message;
28 namespace content {
29 class RenderFrameHost;
30 class WebContents;
31 struct AXEventNotificationDetails;
32 struct ContextMenuParams;
33 struct TransitionLayerData;
35 // An interface implemented by an object interested in knowing about the state
36 // of the RenderFrameHost.
37 class CONTENT_EXPORT RenderFrameHostDelegate {
38 public:
39 // This is used to give the delegate a chance to filter IPC messages.
40 virtual bool OnMessageReceived(RenderFrameHost* render_frame_host,
41 const IPC::Message& message);
43 // Gets the last committed URL. See WebContents::GetLastCommittedURL for a
44 // description of the semantics.
45 virtual const GURL& GetMainFrameLastCommittedURL() const;
47 // A message was added to to the console.
48 virtual bool AddMessageToConsole(int32 level,
49 const base::string16& message,
50 int32 line_no,
51 const base::string16& source_id);
53 // Informs the delegate whenever a RenderFrameHost is created.
54 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) {}
56 // Informs the delegate whenever a RenderFrameHost is deleted.
57 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) {}
59 // The top-level RenderFrame began loading a new page. This corresponds to
60 // Blink's notion of the throbber starting.
61 // |to_different_document| will be true unless the load is a fragment
62 // navigation, or triggered by history.pushState/replaceState.
63 virtual void DidStartLoading(RenderFrameHost* render_frame_host,
64 bool to_different_document) {}
66 // The RenderFrameHost has been swapped out.
67 virtual void SwappedOut(RenderFrameHost* render_frame_host) {}
69 // Notification that the navigation on the main frame is blocked waiting
70 // for transition to occur.
71 virtual void DidDeferAfterResponseStarted(
72 const TransitionLayerData& transition_data) {}
74 // Used to query whether the navigation transition will be handled.
75 virtual bool WillHandleDeferAfterResponseStarted();
77 // Notification that a worker process has crashed.
78 virtual void WorkerCrashed(RenderFrameHost* render_frame_host) {}
80 // A context menu should be shown, to be built using the context information
81 // provided in the supplied params.
82 virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
83 const ContextMenuParams& params) {}
85 // A JavaScript message, confirmation or prompt should be shown.
86 virtual void RunJavaScriptMessage(RenderFrameHost* render_frame_host,
87 const base::string16& message,
88 const base::string16& default_prompt,
89 const GURL& frame_url,
90 JavaScriptMessageType type,
91 IPC::Message* reply_msg) {}
93 virtual void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host,
94 const base::string16& message,
95 bool is_reload,
96 IPC::Message* reply_msg) {}
98 // Another page accessed the top-level initial empty document, which means it
99 // is no longer safe to display a pending URL without risking a URL spoof.
100 virtual void DidAccessInitialDocument() {}
102 // The frame set its opener to null, disowning it for the lifetime of the
103 // window. Only called for the top-level frame.
104 virtual void DidDisownOpener(RenderFrameHost* render_frame_host) {}
106 // The onload handler in the frame has completed. Only called for the top-
107 // level frame.
108 virtual void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) {}
110 // The page's title was changed and should be updated. Only called for the
111 // top-level frame.
112 virtual void UpdateTitle(RenderFrameHost* render_frame_host,
113 int32 page_id,
114 const base::string16& title,
115 base::i18n::TextDirection title_direction) {}
117 // The page's encoding was changed and should be updated. Only called for the
118 // top-level frame.
119 virtual void UpdateEncoding(RenderFrameHost* render_frame_host,
120 const std::string& encoding) {}
122 // Return this object cast to a WebContents, if it is one. If the object is
123 // not a WebContents, returns NULL.
124 virtual WebContents* GetAsWebContents();
126 // The render frame has requested access to media devices listed in
127 // |request|, and the client should grant or deny that permission by
128 // calling |callback|.
129 virtual void RequestMediaAccessPermission(
130 const MediaStreamRequest& request,
131 const MediaResponseCallback& callback);
133 // Get the accessibility mode for the WebContents that owns this frame.
134 virtual AccessibilityMode GetAccessibilityMode() const;
136 // Invoked when an accessibility event is received from the renderer.
137 virtual void AccessibilityEventReceived(
138 const std::vector<AXEventNotificationDetails>& details) {}
140 #if defined(OS_WIN)
141 // Returns the frame's parent's NativeViewAccessible.
142 virtual gfx::NativeViewAccessible GetParentNativeViewAccessible();
143 #endif
145 protected:
146 virtual ~RenderFrameHostDelegate() {}
149 } // namespace content
151 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_