Cast: Skip receiver log messages with time delta that can't be encoded.
[chromium-blink-merge.git] / content / public / renderer / render_view_observer.h
blobaed5a2f59d89384569a4e886871a112a8187366a
1 // Copyright (c) 2012 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_VIEW_OBSERVER_H_
6 #define CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "content/common/content_export.h"
11 #include "ipc/ipc_listener.h"
12 #include "ipc/ipc_sender.h"
13 #include "third_party/WebKit/public/platform/WebVector.h"
14 #include "third_party/WebKit/public/web/WebIconURL.h"
16 class GURL;
18 namespace ppapi {
19 namespace host {
20 class PpapiHost;
24 namespace blink {
25 class WebDataSource;
26 class WebFrame;
27 class WebFormElement;
28 class WebGestureEvent;
29 class WebMediaPlayerClient;
30 class WebMouseEvent;
31 class WebNode;
32 class WebTouchEvent;
33 class WebURL;
34 struct WebURLError;
37 namespace content {
39 class RendererPpapiHost;
40 class RenderView;
41 class RenderViewImpl;
43 // Base class for objects that want to filter incoming IPCs, and also get
44 // notified of changes to the frame.
45 class CONTENT_EXPORT RenderViewObserver : public IPC::Listener,
46 public IPC::Sender {
47 public:
48 // By default, observers will be deleted when the RenderView goes away. If
49 // they want to outlive it, they can override this function.
50 virtual void OnDestruct();
52 // These match the WebKit API notifications
53 virtual void DidStartLoading() {}
54 virtual void DidStopLoading() {}
55 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) {}
56 virtual void DidFailLoad(blink::WebFrame* frame,
57 const blink::WebURLError& error) {}
58 virtual void DidFinishLoad(blink::WebFrame* frame) {}
59 virtual void DidStartProvisionalLoad(blink::WebFrame* frame) {}
60 virtual void DidFailProvisionalLoad(blink::WebFrame* frame,
61 const blink::WebURLError& error) {}
62 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
63 bool is_new_navigation) {}
64 virtual void DidClearWindowObject(blink::WebFrame* frame, int world_id) {}
65 virtual void DidCreateDocumentElement(blink::WebFrame* frame) {}
66 virtual void FrameCreated(blink::WebFrame* parent,
67 blink::WebFrame* frame) {}
68 virtual void FrameDetached(blink::WebFrame* frame) {}
69 virtual void FrameWillClose(blink::WebFrame* frame) {}
70 virtual void DidMatchCSS(
71 blink::WebFrame* frame,
72 const blink::WebVector<blink::WebString>& newly_matching_selectors,
73 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {}
74 virtual void WillSendSubmitEvent(blink::WebFrame* frame,
75 const blink::WebFormElement& form) {}
76 virtual void WillSubmitForm(blink::WebFrame* frame,
77 const blink::WebFormElement& form) {}
78 virtual void DidCreateDataSource(blink::WebFrame* frame,
79 blink::WebDataSource* ds) {}
80 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) {}
81 virtual void FocusedNodeChanged(const blink::WebNode& node) {}
82 virtual void WillCreateMediaPlayer(blink::WebFrame* frame,
83 blink::WebMediaPlayerClient* client) {}
84 virtual void ZoomLevelChanged() {};
85 virtual void DidChangeScrollOffset(blink::WebFrame* frame) {}
86 virtual void DraggableRegionsChanged(blink::WebFrame* frame) {}
87 virtual void DidCommitCompositorFrame() {}
88 virtual void DidUpdateLayout() {}
90 // These match the RenderView methods.
91 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
92 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
94 // This matches the RenderWidget method.
95 virtual void WillProcessUserGesture() {}
97 // Called when we receive a console message from WebKit for which we requested
98 // extra details (like the stack trace). |message| is the error message,
99 // |source| is the WebKit-reported source of the error (either external or
100 // internal), and |stack_trace| is the stack trace of the error in a
101 // human-readable format (each frame is formatted as
102 // "\n at function_name (source:line_number:column_number)").
103 virtual void DetailedConsoleMessageAdded(const base::string16& message,
104 const base::string16& source,
105 const base::string16& stack_trace,
106 int32 line_number,
107 int32 severity_level) {}
109 // These match incoming IPCs.
110 virtual void Navigate(const GURL& url) {}
111 virtual void ClosePage() {}
112 virtual void OrientationChangeEvent(int orientation) {}
114 virtual void OnStop() {}
116 // IPC::Listener implementation.
117 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
119 // IPC::Sender implementation.
120 virtual bool Send(IPC::Message* message) OVERRIDE;
122 RenderView* render_view() const;
123 int routing_id() const { return routing_id_; }
125 protected:
126 explicit RenderViewObserver(RenderView* render_view);
127 virtual ~RenderViewObserver();
129 private:
130 friend class RenderViewImpl;
132 // This is called by the RenderView when it's going away so that this object
133 // can null out its pointer.
134 void RenderViewGone();
136 RenderView* render_view_;
137 // The routing ID of the associated RenderView.
138 int routing_id_;
140 DISALLOW_COPY_AND_ASSIGN(RenderViewObserver);
143 } // namespace content
145 #endif // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_OBSERVER_H_