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"
23 class RendererPpapiHost
;
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
,
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 // These match the Blink API notifications
43 virtual void DidCommitProvisionalLoad(bool is_new_navigation
) {}
44 virtual void DidStartProvisionalLoad() {}
45 virtual void DidFailProvisionalLoad(const blink::WebURLError
& error
) {}
46 virtual void DidFinishLoad() {}
47 virtual void DidFinishDocumentLoad() {}
48 virtual void WillReleaseScriptContext(v8::Handle
<v8::Context
> context
,
50 virtual void DidClearWindowObject(int world_id
) {}
52 // Called when we receive a console message from Blink for which we requested
53 // extra details (like the stack trace). |message| is the error message,
54 // |source| is the Blink-reported source of the error (either external or
55 // internal), and |stack_trace| is the stack trace of the error in a
56 // human-readable format (each frame is formatted as
57 // "\n at function_name (source:line_number:column_number)").
58 virtual void DetailedConsoleMessageAdded(const base::string16
& message
,
59 const base::string16
& source
,
60 const base::string16
& stack_trace
,
62 int32 severity_level
) {}
64 // IPC::Listener implementation.
65 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
67 // IPC::Sender implementation.
68 virtual bool Send(IPC::Message
* message
) OVERRIDE
;
70 RenderFrame
* render_frame() const;
71 int routing_id() const { return routing_id_
; }
74 explicit RenderFrameObserver(RenderFrame
* render_frame
);
75 virtual ~RenderFrameObserver();
78 friend class RenderFrameImpl
;
80 // This is called by the RenderFrame when it's going away so that this object
81 // can null out its pointer.
82 void RenderFrameGone();
84 RenderFrame
* render_frame_
;
85 // The routing ID of the associated RenderFrame.
88 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver
);
91 } // namespace content
93 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_