Move about://-related constants from //content to //url
[chromium-blink-merge.git] / content / browser / frame_host / render_frame_host_delegate.h
blobb4db5d4c9c91cea306c7e13cd2a6590c962313fe
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 "base/i18n/rtl.h"
10 #include "content/common/content_export.h"
11 #include "content/public/common/javascript_message_type.h"
13 class GURL;
15 namespace IPC {
16 class Message;
19 namespace content {
20 class RenderFrameHost;
21 class WebContents;
22 struct ContextMenuParams;
24 // An interface implemented by an object interested in knowing about the state
25 // of the RenderFrameHost.
26 class CONTENT_EXPORT RenderFrameHostDelegate {
27 public:
28 // This is used to give the delegate a chance to filter IPC messages.
29 virtual bool OnMessageReceived(RenderFrameHost* render_frame_host,
30 const IPC::Message& message);
32 // Gets the last committed URL. See WebContents::GetLastCommittedURL for a
33 // description of the semantics.
34 virtual const GURL& GetMainFrameLastCommittedURL() const;
36 // A message was added to to the console.
37 virtual bool AddMessageToConsole(int32 level,
38 const base::string16& message,
39 int32 line_no,
40 const base::string16& source_id);
42 // Informs the delegate whenever a RenderFrameHost is created.
43 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) {}
45 // Informs the delegate whenever a RenderFrameHost is deleted.
46 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) {}
48 // The top-level RenderFrame began loading a new page. This corresponds to
49 // Blink's notion of the throbber starting.
50 // |to_different_document| will be true unless the load is a fragment
51 // navigation, or triggered by history.pushState/replaceState.
52 virtual void DidStartLoading(RenderFrameHost* render_frame_host,
53 bool to_different_document) {}
55 // The RenderFrameHost has been swapped out.
56 virtual void SwappedOut(RenderFrameHost* render_frame_host) {}
58 // Notification that a worker process has crashed.
59 virtual void WorkerCrashed(RenderFrameHost* render_frame_host) {}
61 // A context menu should be shown, to be built using the context information
62 // provided in the supplied params.
63 virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
64 const ContextMenuParams& params) {}
66 // A JavaScript message, confirmation or prompt should be shown.
67 virtual void RunJavaScriptMessage(RenderFrameHost* render_frame_host,
68 const base::string16& message,
69 const base::string16& default_prompt,
70 const GURL& frame_url,
71 JavaScriptMessageType type,
72 IPC::Message* reply_msg) {}
74 virtual void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host,
75 const base::string16& message,
76 bool is_reload,
77 IPC::Message* reply_msg) {}
79 // Another page accessed the top-level initial empty document, which means it
80 // is no longer safe to display a pending URL without risking a URL spoof.
81 virtual void DidAccessInitialDocument() {}
83 // The frame set its opener to null, disowning it for the lifetime of the
84 // window. Only called for the top-level frame.
85 virtual void DidDisownOpener(RenderFrameHost* render_frame_host) {}
87 // The onload handler in the frame has completed. Only called for the top-
88 // level frame.
89 virtual void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) {}
91 // The page's title was changed and should be updated. Only called for the
92 // top-level frame.
93 virtual void UpdateTitle(RenderFrameHost* render_frame_host,
94 int32 page_id,
95 const base::string16& title,
96 base::i18n::TextDirection title_direction) {}
98 // The page's encoding was changed and should be updated. Only called for the
99 // top-level frame.
100 virtual void UpdateEncoding(RenderFrameHost* render_frame_host,
101 const std::string& encoding) {}
103 // Return this object cast to a WebContents, if it is one. If the object is
104 // not a WebContents, returns NULL.
105 virtual WebContents* GetAsWebContents();
107 protected:
108 virtual ~RenderFrameHostDelegate() {}
111 } // namespace content
113 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_