Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / public / renderer / render_frame_observer.h
blobbf8698fc18441cbf154208581474d12405e6fb7e
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_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_
6 #define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/strings/string16.h"
11 #include "content/common/content_export.h"
12 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_sender.h"
14 #include "v8/include/v8.h"
16 namespace blink {
17 class WebFormElement;
18 class WebFrame;
19 class WebNode;
20 struct WebURLError;
23 namespace content {
25 class RendererPpapiHost;
26 class RenderFrame;
27 class RenderFrameImpl;
29 // Base class for objects that want to filter incoming IPCs, and also get
30 // notified of changes to the frame.
31 class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
32 public IPC::Sender {
33 public:
34 // By default, observers will be deleted when the RenderFrame goes away. If
35 // they want to outlive it, they can override this function.
36 virtual void OnDestruct();
38 // Called when a Pepper plugin is created.
39 virtual void DidCreatePepperPlugin(RendererPpapiHost* host) {}
41 // Called when a load is explicitly stopped by the user or browser.
42 virtual void OnStop() {}
44 // Called when the RenderFrame visiblity is changed.
45 virtual void WasHidden() {}
46 virtual void WasShown() {}
48 // Called when associated widget is about to close.
49 virtual void WidgetWillClose() {}
51 // These match the Blink API notifications
52 virtual void DidCommitProvisionalLoad(bool is_new_navigation,
53 bool is_same_page_navigation) {}
54 virtual void DidStartProvisionalLoad() {}
55 virtual void DidFailProvisionalLoad(const blink::WebURLError& error) {}
56 virtual void DidFinishLoad() {}
57 virtual void DidFinishDocumentLoad() {}
58 virtual void DidCreateScriptContext(v8::Handle<v8::Context> context,
59 int extension_group,
60 int world_id) {}
61 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context,
62 int world_id) {}
63 virtual void DidClearWindowObject() {}
64 virtual void DidChangeManifest() {}
65 virtual void DidChangeDefaultPresentation() {}
66 virtual void DidChangeScrollOffset() {}
67 virtual void WillSendSubmitEvent(const blink::WebFormElement& form) {}
68 virtual void WillSubmitForm(const blink::WebFormElement& form) {}
70 // Called before FrameWillClose, when this frame has been detached from the
71 // view, but has not been closed yet. This *will* be called when parent frames
72 // are closing. Since the frame is already detached from the DOM at this time
73 // it should not be inspected.
74 virtual void FrameDetached() {}
76 // Called when the frame will soon be closed. This is the last opportunity to
77 // send messages to the host (e.g., for clean-up, shutdown, etc.). This is
78 // *not* called on child frames when parent frames are being closed.
79 virtual void FrameWillClose() {}
81 // Called when we receive a console message from Blink for which we requested
82 // extra details (like the stack trace). |message| is the error message,
83 // |source| is the Blink-reported source of the error (either external or
84 // internal), and |stack_trace| is the stack trace of the error in a
85 // human-readable format (each frame is formatted as
86 // "\n at function_name (source:line_number:column_number)").
87 virtual void DetailedConsoleMessageAdded(const base::string16& message,
88 const base::string16& source,
89 const base::string16& stack_trace,
90 int32 line_number,
91 int32 severity_level) {}
93 // Called when a compositor frame has committed.
94 virtual void DidCommitCompositorFrame() {}
96 // Called when the focused node has changed to |node|.
97 virtual void FocusedNodeChanged(const blink::WebNode& node) {}
99 // IPC::Listener implementation.
100 bool OnMessageReceived(const IPC::Message& message) override;
102 // IPC::Sender implementation.
103 bool Send(IPC::Message* message) override;
105 RenderFrame* render_frame() const;
106 int routing_id() const { return routing_id_; }
108 protected:
109 explicit RenderFrameObserver(RenderFrame* render_frame);
110 ~RenderFrameObserver() override;
112 private:
113 friend class RenderFrameImpl;
115 // This is called by the RenderFrame when it's going away so that this object
116 // can null out its pointer.
117 void RenderFrameGone();
119 RenderFrame* render_frame_;
120 // The routing ID of the associated RenderFrame.
121 int routing_id_;
123 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver);
126 } // namespace content
128 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_