OLD | NEW |
1 <!-- BEGIN AUTHORED CONTENT --> | |
2 <p id="classSummary"> | 1 <p id="classSummary"> |
3 Use the <code>chrome.webNavigation</code> module to receive | 2 Use the <code>chrome.webNavigation</code> module to receive |
4 notifications about the status of navigations requests in-flight. | 3 notifications about the status of navigations requests in-flight. |
5 </p> | 4 </p> |
6 <h2>Manifest</h2> | 5 <h2>Manifest</h2> |
7 <p> | 6 <p> |
8 All <code>chrome.webNavigation</code> methods and events require you to declare | 7 All <code>chrome.webNavigation</code> methods and events require you to declare |
9 the "webNavigation" permission in the <a href="manifest.html">extension | 8 the "webNavigation" permission in the <a href="manifest.html">extension |
10 manifest</a>. | 9 manifest</a>. |
11 For example: | 10 For example: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 before any of its children's <code>onBeforeNavigate</code>; while | 43 before any of its children's <code>onBeforeNavigate</code>; while |
45 <code>onCompleted</code> is fired after all of its children's | 44 <code>onCompleted</code> is fired after all of its children's |
46 <code>onCompleted</code>. | 45 <code>onCompleted</code>. |
47 </p> | 46 </p> |
48 <p> | 47 <p> |
49 If the reference fragment of a frame is changed, a | 48 If the reference fragment of a frame is changed, a |
50 <code>onReferenceFragmentUpdated</code> event is fired. This event can fire any | 49 <code>onReferenceFragmentUpdated</code> event is fired. This event can fire any |
51 time after <code>onDOMContentLoaded</code>, even after | 50 time after <code>onDOMContentLoaded</code>, even after |
52 <code>onCompleted</code>. | 51 <code>onCompleted</code>. |
53 </p> | 52 </p> |
| 53 <p> |
| 54 If the history API is used to modify the state of a frame (e.g. using |
| 55 <code>history.pushState()</code>, a <code>onHistoryStateUpdated</code> event is |
| 56 fired. This event can fire any time after <code>onDOMContentLoaded</code>. |
| 57 </p> |
| 58 <p> |
| 59 If a navigation was triggered via <a |
| 60 href="https://support.google.com/chrome/bin/answer.py?answer=177873">Chrome |
| 61 Instant</a> or <a |
| 62 href="https://support.google.com/chrome/bin/answer.py?answer=1385029">Instant |
| 63 Pages</a>, a completely loaded page is swapped into the current tab. In that |
| 64 case, an <code>onTabReplaced</code> event is fired. |
| 65 </p> |
54 <h2>Relation to webRequest events</h2> | 66 <h2>Relation to webRequest events</h2> |
55 <p> | 67 <p> |
56 There is no defined ordering between events of the <a | 68 There is no defined ordering between events of the <a |
57 href="webRequest.html">webRequest API</a> and the events of the | 69 href="webRequest.html">webRequest API</a> and the events of the |
58 webNavigation API. It is possible that webRequest events are still received for | 70 webNavigation API. It is possible that webRequest events are still received for |
59 frames that already started a new navigation, or that a navigation only | 71 frames that already started a new navigation, or that a navigation only |
60 proceeds after the network resources are already fully loaded. | 72 proceeds after the network resources are already fully loaded. |
61 </p> | 73 </p> |
62 <p> | 74 <p> |
63 In general, the webNavigation events are closely related to the navigation | 75 In general, the webNavigation events are closely related to the navigation |
64 state that is displayed in the UI, while the webRequest events correspond to | 76 state that is displayed in the UI, while the webRequest events correspond to |
65 the state of the network stack which is generally opaque to the user. | 77 the state of the network stack which is generally opaque to the user. |
66 </p> | 78 </p> |
| 79 <h2>A note about tab IDs</h2> |
| 80 <p> |
| 81 Not all navigating tabs correspond to actual tabs in Chrome's UI, e.g., a tab |
| 82 that is being pre-rendered. Such tabs are not accessible via the |
| 83 <a href="tabs.html">tabs API</a> nor can you request information about them via |
| 84 <code>webNavigation.getFrame</code> or <code>webNavigation.getAllFrames</code>. |
| 85 Once such a tab is swapped in, an <code>onTabReplaced</code> event is fired and |
| 86 they become accessible via these APIs. |
| 87 </p> |
67 <h2>A note about timestamps</h2> | 88 <h2>A note about timestamps</h2> |
68 <p> | 89 <p> |
69 It's important to note that some technical oddities in the OS's handling | 90 It's important to note that some technical oddities in the OS's handling |
70 of distinct Chrome processes can cause the clock to be skewed between the | 91 of distinct Chrome processes can cause the clock to be skewed between the |
71 browser itself and extension processes. That means that WebNavigation's events' | 92 browser itself and extension processes. That means that WebNavigation's events' |
72 <code>timeStamp</code> property is only guaranteed to be <i>internally</i> | 93 <code>timeStamp</code> property is only guaranteed to be <i>internally</i> |
73 consistent. Comparing one event to another event will give you the correct | 94 consistent. Comparing one event to another event will give you the correct |
74 offset between them, but comparing them to the current time inside the | 95 offset between them, but comparing them to the current time inside the |
75 extension (via <code>(new Date()).getTime()</code>, for instance) might give | 96 extension (via <code>(new Date()).getTime()</code>, for instance) might give |
76 unexpected results. | 97 unexpected results. |
77 </p> | 98 </p> |
| 99 <h2>A note about frame and process IDs</h2> |
| 100 <p> |
| 101 Due to the multi-process nature of Chrome, a tab might use different processes |
| 102 to render the source and destination of a web page. Therefore, if a navigation |
| 103 takes place in a new process, you might receive events both from the new and |
| 104 the old page until the new navigation is committed (i.e. the |
| 105 <code>onCommitted</code> event is send for the new main frame). Because frame |
| 106 IDs are only unique for a given process, the webNavigation events include a |
| 107 process ID, so you can still determine which frame a navigation came from. |
| 108 </p> |
| 109 <p> |
| 110 Also note that during a provisional load the process might be switched several |
| 111 times. This happens when the load is redirected to a different site. In this |
| 112 case, you will receive repeated <code>onBeforeNavigate</code> and |
| 113 <code>onErrorOccurred</code> events, until you receive the final |
| 114 <code>onCommitted</code> event. |
| 115 </p> |
78 <h2>Transition types and qualifiers</h2> | 116 <h2>Transition types and qualifiers</h2> |
79 <p> | 117 <p> |
80 The webNavigation API's <code>onCommitted</code> event has a | 118 The webNavigation API's <code>onCommitted</code> event has a |
81 <code>transitionType</code> and a <code>transitionQualifiers</code> property. | 119 <code>transitionType</code> and a <code>transitionQualifiers</code> property. |
82 The <em>transition type</em> is the same as used in the <a | 120 The <em>transition type</em> is the same as used in the <a |
83 href="history.html#transition_types">history API</a> describing how the browser | 121 href="history.html#transition_types">history API</a> describing how the browser |
84 navigated to this particular URL. In addition, several <em>transition | 122 navigated to this particular URL. In addition, several <em>transition |
85 qualifiers</em> can be returned that further define the navigation. | 123 qualifiers</em> can be returned that further define the navigation. |
86 </p> | 124 </p> |
87 <p> | 125 <p> |
(...skipping 22 matching lines...) Expand all Loading... |
110 <td> | 148 <td> |
111 The user used the Forward or Back button to initiate the navigation. | 149 The user used the Forward or Back button to initiate the navigation. |
112 </td> | 150 </td> |
113 </tr> | 151 </tr> |
114 <tr> | 152 <tr> |
115 <td>"from_address_bar"</td> | 153 <td>"from_address_bar"</td> |
116 <td> | 154 <td> |
117 The user initiated the navigation from the address bar (aka Omnibox). | 155 The user initiated the navigation from the address bar (aka Omnibox). |
118 </td> | 156 </td> |
119 </tr> | 157 </tr> |
120 </table> | 158 </table> |
121 <!-- END AUTHORED CONTENT --> | |
OLD | NEW |