Introduce the PlatformNotificationContext class.
[chromium-blink-merge.git] / content / public / renderer / render_frame_observer.h
blob79957c4f96c4a0946e7c91f17d2450618e0b2252
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 // These match the Blink API notifications
49 virtual void DidCommitProvisionalLoad(bool is_new_navigation,
50 bool is_same_page_navigation) {}
51 virtual void DidStartProvisionalLoad() {}
52 virtual void DidFailProvisionalLoad(const blink::WebURLError& error) {}
53 virtual void DidFinishLoad() {}
54 virtual void DidFinishDocumentLoad() {}
55 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context,
56 int world_id) {}
57 virtual void DidClearWindowObject() {}
58 virtual void DidChangeManifest() {}
59 virtual void DidChangeDefaultPresentation() {}
60 virtual void DidChangeScrollOffset() {}
61 virtual void WillSendSubmitEvent(const blink::WebFormElement& form) {}
62 virtual void WillSubmitForm(const blink::WebFormElement& form) {}
64 // Called before FrameWillClose, when this frame has been detached from the
65 // view, but has not been closed yet. This *will* be called when parent frames
66 // are closing. NB: IPCs to the browser will fail silently by the time this
67 // notification is sent.
68 virtual void FrameDetached() {}
70 // Called when the frame will soon be closed. This is the last opportunity to
71 // send messages to the host (e.g., for clean-up, shutdown, etc.). This is
72 // *not* called on child frames when parent frames are being closed.
73 virtual void FrameWillClose() {}
75 // Called when we receive a console message from Blink for which we requested
76 // extra details (like the stack trace). |message| is the error message,
77 // |source| is the Blink-reported source of the error (either external or
78 // internal), and |stack_trace| is the stack trace of the error in a
79 // human-readable format (each frame is formatted as
80 // "\n at function_name (source:line_number:column_number)").
81 virtual void DetailedConsoleMessageAdded(const base::string16& message,
82 const base::string16& source,
83 const base::string16& stack_trace,
84 int32 line_number,
85 int32 severity_level) {}
87 // Called when a compositor frame has committed.
88 virtual void DidCommitCompositorFrame() {}
90 // Called when the focused node has changed to |node|.
91 virtual void FocusedNodeChanged(const blink::WebNode& node) {}
93 // IPC::Listener implementation.
94 bool OnMessageReceived(const IPC::Message& message) override;
96 // IPC::Sender implementation.
97 bool Send(IPC::Message* message) override;
99 RenderFrame* render_frame() const;
100 int routing_id() const { return routing_id_; }
102 protected:
103 explicit RenderFrameObserver(RenderFrame* render_frame);
104 ~RenderFrameObserver() override;
106 private:
107 friend class RenderFrameImpl;
109 // This is called by the RenderFrame when it's going away so that this object
110 // can null out its pointer.
111 void RenderFrameGone();
113 RenderFrame* render_frame_;
114 // The routing ID of the associated RenderFrame.
115 int routing_id_;
117 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver);
120 } // namespace content
122 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_