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 "base/basictypes.h"
9 #include "content/common/content_export.h"
10 #include "content/public/common/javascript_message_type.h"
19 class RenderFrameHost
;
21 struct ContextMenuParams
;
23 // An interface implemented by an object interested in knowing about the state
24 // of the RenderFrameHost.
25 class CONTENT_EXPORT RenderFrameHostDelegate
{
27 // This is used to give the delegate a chance to filter IPC messages.
28 virtual bool OnMessageReceived(RenderFrameHost
* render_frame_host
,
29 const IPC::Message
& message
);
31 // Gets the last committed URL. See WebContents::GetLastCommittedURL for a
32 // description of the semantics.
33 virtual const GURL
& GetMainFrameLastCommittedURL() const;
35 // A message was added to to the console.
36 virtual bool AddMessageToConsole(int32 level
,
37 const base::string16
& message
,
39 const base::string16
& source_id
);
41 // Informs the delegate whenever a RenderFrameHost is created.
42 virtual void RenderFrameCreated(RenderFrameHost
* render_frame_host
) {}
44 // Informs the delegate whenever a RenderFrameHost is deleted.
45 virtual void RenderFrameDeleted(RenderFrameHost
* render_frame_host
) {}
47 // The top-level RenderFrame began loading a new page. This corresponds to
48 // Blink's notion of the throbber starting.
49 // |to_different_document| will be true unless the load is a fragment
50 // navigation, or triggered by history.pushState/replaceState.
51 virtual void DidStartLoading(RenderFrameHost
* render_frame_host
,
52 bool to_different_document
) {}
54 // The top-level RenderFrame stopped loading a page. This corresponds to
55 // Blink's notion of the throbber stopping.
56 virtual void DidStopLoading(RenderFrameHost
* render_frame_host
) {}
58 // The RenderFrameHost has been swapped out.
59 virtual void SwappedOut(RenderFrameHost
* render_frame_host
) {}
61 // Notification that a worker process has crashed.
62 virtual void WorkerCrashed(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
,
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 set its opener to null, disowning it for the lifetime of the
87 // window. Only called for the top-level frame.
88 virtual void DidDisownOpener(RenderFrameHost
* render_frame_host
) {}
90 // The onload handler in the frame has completed. Only called for the top-
92 virtual void DocumentOnLoadCompleted(RenderFrameHost
* render_frame_host
) {}
94 // Return this object cast to a WebContents, if it is one. If the object is
95 // not a WebContents, returns NULL.
96 virtual WebContents
* GetAsWebContents();
99 virtual ~RenderFrameHostDelegate() {}
102 } // namespace content
104 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_