OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
7 | 7 |
8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "content/public/browser/navigation_controller.h" | 11 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/common/page_transition_types.h" | 12 #include "content/public/common/page_transition_types.h" |
13 #include "ipc/ipc_listener.h" | 13 #include "ipc/ipc_listener.h" |
14 #include "ipc/ipc_sender.h" | 14 #include "ipc/ipc_sender.h" |
15 #include "ui/base/window_open_disposition.h" | 15 #include "ui/base/window_open_disposition.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 class RenderViewHost; | 19 class RenderViewHost; |
20 class WebContents; | 20 class WebContents; |
21 class WebContentsImpl; | 21 class WebContentsImpl; |
22 struct FaviconURL; | 22 struct FaviconURL; |
23 struct FrameNavigateParams; | 23 struct FrameNavigateParams; |
24 struct LoadCommittedDetails; | 24 struct LoadCommittedDetails; |
| 25 struct LoadFromMemoryCacheDetails; |
25 struct Referrer; | 26 struct Referrer; |
| 27 struct ResourceRedirectDetails; |
| 28 struct ResourceRequestDetails; |
26 | 29 |
27 // An observer API implemented by classes which are interested in various page | 30 // An observer API implemented by classes which are interested in various page |
28 // load events from WebContents. They also get a chance to filter IPC messages. | 31 // load events from WebContents. They also get a chance to filter IPC messages. |
29 // | 32 // |
30 // Since a WebContents can be a delegate to almost arbitrarily many | 33 // Since a WebContents can be a delegate to almost arbitrarily many |
31 // RenderViewHosts, it is important to check in those WebContentsObserver | 34 // RenderViewHosts, it is important to check in those WebContentsObserver |
32 // methods which take a RenderViewHost that the event came from the | 35 // methods which take a RenderViewHost that the event came from the |
33 // RenderViewHost the observer cares about. | 36 // RenderViewHost the observer cares about. |
34 // | 37 // |
35 // Usually, observers should only care about the current RenderViewHost as | 38 // Usually, observers should only care about the current RenderViewHost as |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 int64 parent_frame_id, | 93 int64 parent_frame_id, |
91 bool is_main_frame, | 94 bool is_main_frame, |
92 const GURL& validated_url, | 95 const GURL& validated_url, |
93 bool is_error_page, | 96 bool is_error_page, |
94 bool is_iframe_srcdoc, | 97 bool is_iframe_srcdoc, |
95 RenderViewHost* render_view_host) {} | 98 RenderViewHost* render_view_host) {} |
96 | 99 |
97 // This method is invoked right after the DidStartProvisionalLoadForFrame if | 100 // This method is invoked right after the DidStartProvisionalLoadForFrame if |
98 // the provisional load affects the main frame, or if the provisional load | 101 // the provisional load affects the main frame, or if the provisional load |
99 // was redirected. The latter use case is DEPRECATED. You should listen to | 102 // was redirected. The latter use case is DEPRECATED. You should listen to |
100 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification | 103 // WebContentsObserver::DidGetRedirectForResourceRequest instead. |
101 // instead. | |
102 virtual void ProvisionalChangeToMainFrameUrl( | 104 virtual void ProvisionalChangeToMainFrameUrl( |
103 const GURL& url, | 105 const GURL& url, |
104 RenderViewHost* render_view_host) {} | 106 RenderViewHost* render_view_host) {} |
105 | 107 |
106 // This method is invoked when the provisional load was successfully | 108 // This method is invoked when the provisional load was successfully |
107 // committed. The |render_view_host| is now the current RenderViewHost of the | 109 // committed. The |render_view_host| is now the current RenderViewHost of the |
108 // WebContents. | 110 // WebContents. |
109 // | 111 // |
110 // If the navigation only changed the reference fragment, or was triggered | 112 // If the navigation only changed the reference fragment, or was triggered |
111 // using the history API (e.g. window.history.replaceState), we will receive | 113 // using the history API (e.g. window.history.replaceState), we will receive |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 161 |
160 // This method is like DidFinishLoad, but when the load failed or was | 162 // This method is like DidFinishLoad, but when the load failed or was |
161 // cancelled, e.g. window.stop() is invoked. | 163 // cancelled, e.g. window.stop() is invoked. |
162 virtual void DidFailLoad(int64 frame_id, | 164 virtual void DidFailLoad(int64 frame_id, |
163 const GURL& validated_url, | 165 const GURL& validated_url, |
164 bool is_main_frame, | 166 bool is_main_frame, |
165 int error_code, | 167 int error_code, |
166 const string16& error_description, | 168 const string16& error_description, |
167 RenderViewHost* render_view_host) {} | 169 RenderViewHost* render_view_host) {} |
168 | 170 |
| 171 // This method is invoked when content was loaded from an in-memory cache. |
| 172 virtual void DidLoadResourceFromMemoryCache( |
| 173 const LoadFromMemoryCacheDetails& details) {} |
| 174 |
| 175 // This method is invoked when a response has been received for a resource |
| 176 // request. |
| 177 virtual void DidGetResourceResponseStart( |
| 178 const ResourceRequestDetails& details) {} |
| 179 |
| 180 // This method is invoked when a redirect was received while requesting a |
| 181 // resource. |
| 182 virtual void DidGetRedirectForResourceRequest( |
| 183 const ResourceRedirectDetails& details) {} |
| 184 |
169 // This method is invoked when a new non-pending navigation entry is created. | 185 // This method is invoked when a new non-pending navigation entry is created. |
170 // This corresponds to one NavigationController entry being created | 186 // This corresponds to one NavigationController entry being created |
171 // (in the case of new navigations) or renavigated to (for back/forward | 187 // (in the case of new navigations) or renavigated to (for back/forward |
172 // navigations). | 188 // navigations). |
173 virtual void NavigationEntryCommitted( | 189 virtual void NavigationEntryCommitted( |
174 const LoadCommittedDetails& load_details) {} | 190 const LoadCommittedDetails& load_details) {} |
175 | 191 |
176 // This method is invoked when a new WebContents was created in response to | 192 // This method is invoked when a new WebContents was created in response to |
177 // an action in the observed WebContents, e.g. a link with target=_blank was | 193 // an action in the observed WebContents, e.g. a link with target=_blank was |
178 // clicked. The |source_frame_id| indicates in which frame the action took | 194 // clicked. The |source_frame_id| indicates in which frame the action took |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 void WebContentsImplDestroyed(); | 313 void WebContentsImplDestroyed(); |
298 | 314 |
299 WebContentsImpl* web_contents_; | 315 WebContentsImpl* web_contents_; |
300 | 316 |
301 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); | 317 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); |
302 }; | 318 }; |
303 | 319 |
304 } // namespace content | 320 } // namespace content |
305 | 321 |
306 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 322 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |