Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / public / renderer / render_frame_observer.h
blobd298065e40bb5fe65e9fbde68a40f5f863c2dbcf
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 WebFrame;
18 struct WebURLError;
21 namespace content {
23 class RendererPpapiHost;
24 class RenderFrame;
25 class RenderFrameImpl;
27 // Base class for objects that want to filter incoming IPCs, and also get
28 // notified of changes to the frame.
29 class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
30 public IPC::Sender {
31 public:
32 // By default, observers will be deleted when the RenderFrame goes away. If
33 // they want to outlive it, they can override this function.
34 virtual void OnDestruct();
36 // Called when a Pepper plugin is created.
37 virtual void DidCreatePepperPlugin(RendererPpapiHost* host) {}
39 // Called when a load is explicitly stopped by the user or browser.
40 virtual void OnStop() {}
42 // Called when the RenderFrame visiblity is changed.
43 virtual void WasHidden() {}
44 virtual void WasShown() {}
46 // These match the Blink API notifications
47 virtual void DidCommitProvisionalLoad(bool is_new_navigation) {}
48 virtual void DidStartProvisionalLoad() {}
49 virtual void DidFailProvisionalLoad(const blink::WebURLError& error) {}
50 virtual void DidFinishLoad() {}
51 virtual void DidFinishDocumentLoad() {}
52 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context,
53 int world_id) {}
54 virtual void DidClearWindowObject() {}
55 virtual void DidChangeName(const base::string16& name) {}
57 // Called when the frame will soon be closed. This is the last opportunity to
58 // send messages to the host (e.g., for clean-up, shutdown, etc.).
59 virtual void FrameWillClose() {}
61 // Called when we receive a console message from Blink for which we requested
62 // extra details (like the stack trace). |message| is the error message,
63 // |source| is the Blink-reported source of the error (either external or
64 // internal), and |stack_trace| is the stack trace of the error in a
65 // human-readable format (each frame is formatted as
66 // "\n at function_name (source:line_number:column_number)").
67 virtual void DetailedConsoleMessageAdded(const base::string16& message,
68 const base::string16& source,
69 const base::string16& stack_trace,
70 int32 line_number,
71 int32 severity_level) {}
73 // Called when a compositor frame has committed.
74 virtual void DidCommitCompositorFrame() {}
76 // IPC::Listener implementation.
77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
79 // IPC::Sender implementation.
80 virtual bool Send(IPC::Message* message) OVERRIDE;
82 RenderFrame* render_frame() const;
83 int routing_id() const { return routing_id_; }
85 protected:
86 explicit RenderFrameObserver(RenderFrame* render_frame);
87 virtual ~RenderFrameObserver();
89 private:
90 friend class RenderFrameImpl;
92 // This is called by the RenderFrame when it's going away so that this object
93 // can null out its pointer.
94 void RenderFrameGone();
96 RenderFrame* render_frame_;
97 // The routing ID of the associated RenderFrame.
98 int routing_id_;
100 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver);
103 } // namespace content
105 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_