Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / public / renderer / render_frame_observer.h
blob1e3c6717945067d9aacb6ba5b855d97782e443e9
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 "third_party/WebKit/public/platform/WebVector.h"
15 #include "v8/include/v8.h"
17 namespace blink {
18 class WebFormElement;
19 class WebFrame;
20 class WebNode;
21 class WebString;
22 struct WebURLError;
25 namespace content {
27 class RendererPpapiHost;
28 class RenderFrame;
29 class RenderFrameImpl;
31 // Base class for objects that want to filter incoming IPCs, and also get
32 // notified of changes to the frame.
33 class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
34 public IPC::Sender {
35 public:
36 // By default, observers will be deleted when the RenderFrame goes away. If
37 // they want to outlive it, they can override this function.
38 virtual void OnDestruct();
40 // Called when a Pepper plugin is created.
41 virtual void DidCreatePepperPlugin(RendererPpapiHost* host) {}
43 // Called when a load is explicitly stopped by the user or browser.
44 virtual void OnStop() {}
46 // Called when the RenderFrame visiblity is changed.
47 virtual void WasHidden() {}
48 virtual void WasShown() {}
50 // Called when associated widget is about to close.
51 virtual void WidgetWillClose() {}
53 // These match the Blink API notifications
54 virtual void DidCreateNewDocument() {}
55 virtual void DidCreateDocumentElement() {}
56 virtual void DidCommitProvisionalLoad(bool is_new_navigation,
57 bool is_same_page_navigation) {}
58 virtual void DidStartProvisionalLoad() {}
59 virtual void DidFailProvisionalLoad(const blink::WebURLError& error) {}
60 virtual void DidFinishLoad() {}
61 virtual void DidFinishDocumentLoad() {}
62 virtual void DidCreateScriptContext(v8::Local<v8::Context> context,
63 int extension_group,
64 int world_id) {}
65 virtual void WillReleaseScriptContext(v8::Local<v8::Context> context,
66 int world_id) {}
67 virtual void DidClearWindowObject() {}
68 virtual void DidChangeManifest() {}
69 virtual void DidChangeScrollOffset() {}
70 virtual void WillSendSubmitEvent(const blink::WebFormElement& form) {}
71 virtual void WillSubmitForm(const blink::WebFormElement& form) {}
72 virtual void DidMatchCSS(
73 const blink::WebVector<blink::WebString>& newly_matching_selectors,
74 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {}
76 // Called before FrameWillClose, when this frame has been detached from the
77 // view, but has not been closed yet. This *will* be called when parent frames
78 // are closing. Since the frame is already detached from the DOM at this time
79 // it should not be inspected.
80 virtual void FrameDetached() {}
82 // Called when the frame will soon be closed. This is the last opportunity to
83 // send messages to the host (e.g., for clean-up, shutdown, etc.). This is
84 // *not* called on child frames when parent frames are being closed.
85 virtual void FrameWillClose() {}
87 // Called when we receive a console message from Blink for which we requested
88 // extra details (like the stack trace). |message| is the error message,
89 // |source| is the Blink-reported source of the error (either external or
90 // internal), and |stack_trace| is the stack trace of the error in a
91 // human-readable format (each frame is formatted as
92 // "\n at function_name (source:line_number:column_number)").
93 virtual void DetailedConsoleMessageAdded(const base::string16& message,
94 const base::string16& source,
95 const base::string16& stack_trace,
96 int32 line_number,
97 int32 severity_level) {}
99 // Called when a compositor frame has committed.
100 virtual void DidCommitCompositorFrame() {}
102 // Called when the focused node has changed to |node|.
103 virtual void FocusedNodeChanged(const blink::WebNode& node) {}
105 // IPC::Listener implementation.
106 bool OnMessageReceived(const IPC::Message& message) override;
108 // IPC::Sender implementation.
109 bool Send(IPC::Message* message) override;
111 RenderFrame* render_frame() const;
112 int routing_id() const { return routing_id_; }
114 protected:
115 explicit RenderFrameObserver(RenderFrame* render_frame);
116 ~RenderFrameObserver() override;
118 private:
119 friend class RenderFrameImpl;
121 // This is called by the RenderFrame when it's going away so that this object
122 // can null out its pointer.
123 void RenderFrameGone();
125 RenderFrame* render_frame_;
126 // The routing ID of the associated RenderFrame.
127 int routing_id_;
129 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver);
132 } // namespace content
134 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_