1 : // Copyright (c) 2006-2008 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.
4 :
5 : #ifndef CHROME_COMMON_NOTIFICATION_TYPE_H_
6 : #define CHROME_COMMON_NOTIFICATION_TYPE_H_
7 :
8 : // This file describes various types used to describe and filter notifications
9 : // that pass through the NotificationService.
10 : //
11 : // It is written as an enum inside a class so that it can be forward declared.
12 : // You're not allowed to forward declare an enum, and we want to forward
13 : // declare this since it's required by NotificationObserver which is included
14 : // by a lot of header files.
15 : //
16 : // Since this class encapsulates an integral value, it should be passed by
17 : // value.
18 : class NotificationType {
19 : public:
20 : enum Type {
21 : // General -----------------------------------------------------------------
22 :
23 : // Special signal value to represent an interest in all notifications.
24 : // Not valid when posting a notification.
25 : ALL = 0,
26 :
27 : // The app is done processing user actions, now is a good time to do
28 : // some background work.
29 : IDLE,
30 :
31 : // Means that the app has just started doing something in response to a
32 : // user action, and that background processes shouldn't run if avoidable.
33 : BUSY,
34 :
35 : // This is sent when the user does a gesture resulting in a noteworthy
36 : // action taking place. This is typically used for logging. The source is
37 : // the profile, and the details is a wstring identifying the action.
38 : USER_ACTION,
39 :
40 : // NavigationController ----------------------------------------------------
41 :
42 : // A new pending navigation has been created. Pending entries are created
43 : // when the user requests the navigation. We don't know if it will actually
44 : // happen until it does (at this point, it will be "committed." Note that
45 : // renderer- initiated navigations such as link clicks will never be
46 : // pending.
47 : //
48 : // This notification is called after the pending entry is created, but
49 : // before we actually try to navigate. The source will be the
50 : // NavigationController that owns the pending entry, and there are no
51 : // details.
52 : NAV_ENTRY_PENDING,
53 :
54 : // A new non-pending navigation entry has been created. This will
55 : // correspond to one NavigationController entry being created (in the case
56 : // of new navigations) or renavigated to (for back/forward navigations).
57 : //
58 : // The source will be the navigation controller doing the commit. The
59 : // details will be NavigationController::LoadCommittedDetails.
60 : NAV_ENTRY_COMMITTED,
61 :
62 : // Indicates that the NavigationController given in the Source has
63 : // decreased its back/forward list count by removing entries from either
64 : // the front or back of its list. This is usually the result of going back
65 : // and then doing a new navigation, meaning all the "forward" items are
66 : // deleted.
67 : //
68 : // This normally happens as a result of a new navigation. It will be
69 : // followed by a NAV_ENTRY_COMMITTED message for the new page that
70 : // caused the pruning. It could also be a result of removing an item from
71 : // the list to fix up after interstitials.
72 : //
73 : // The details are NavigationController::PrunedDetails.
74 : NAV_LIST_PRUNED,
75 :
76 : // Indicates that a NavigationEntry has changed. The source will be the
77 : // NavigationController that owns the NavigationEntry. The details will be
78 : // a NavigationController::EntryChangedDetails struct.
79 : //
80 : // This will NOT be sent on navigation, interested parties should also
81 : // listen for NAV_ENTRY_COMMITTED to handle that case. This will be
82 : // sent when the entry is updated outside of navigation (like when a new
83 : // title comes).
84 : NAV_ENTRY_CHANGED,
85 :
86 : // Other load-related (not from NavigationController) ----------------------
87 :
88 : // A content load is starting. The source will be a
89 : // Source<NavigationController> corresponding to the tab in which the load
90 : // is occurring. No details are expected for this notification.
91 : LOAD_START,
92 :
93 : // A content load has stopped. The source will be a
94 : // Source<NavigationController> corresponding to the tab in which the load
95 : // is occurring. Details in the form of a LoadNotificationDetails object
96 : // are optional.
97 : LOAD_STOP,
98 :
99 : // A frame is staring a provisional load. The source is a
100 : // Source<NavigationController> corresponding to the tab in which the load
101 : // occurs. Details is a bool specifying if the load occurs in the main
102 : // frame (or a sub-frame if false).
103 : FRAME_PROVISIONAL_LOAD_START,
104 :
105 : // Content was loaded from an in-memory cache. The source will be a
106 : // Source<NavigationController> corresponding to the tab in which the load
107 : // occurred. Details in the form of a LoadFromMemoryCacheDetails object
108 : // are provided.
109 : LOAD_FROM_MEMORY_CACHE,
110 :
111 : // A provisional content load has failed with an error. The source will be
112 : // a Source<NavigationController> corresponding to the tab in which the
113 : // load occurred. Details in the form of a ProvisionalLoadDetails object
114 : // are provided.
115 : FAIL_PROVISIONAL_LOAD_WITH_ERROR,
116 :
117 : // A response has been received for a resource request. The source will be
118 : // a Source<NavigationController> corresponding to the tab in which the
119 : // request was issued. Details in the form of a ResourceRequestDetails
120 : // object are provided.
121 : RESOURCE_RESPONSE_STARTED,
122 :
123 : // The response to a resource request has completed. The source will be a
124 : // Source<NavigationController> corresponding to the tab in which the
125 : // request was issued. Details in the form of a ResourceRequestDetails
126 : // object are provided.
127 : RESOURCE_RESPONSE_COMPLETED,
128 :
129 : // A redirect was received while requesting a resource. The source will be
130 : // a Source<NavigationController> corresponding to the tab in which the
131 : // request was issued. Details in the form of a ResourceRedirectDetails
132 : // are provided.
133 : RESOURCE_RECEIVED_REDIRECT,
134 :
135 : // The SSL state of a page has changed in some visible way. For example,
136 : // if an insecure resource is loaded on a secure page. Note that a
137 : // toplevel load commit will also update the SSL state (since the
138 : // NavigationEntry is new) and this message won't always be sent in that
139 : // case. Listen to this notification if you need to refresh SSL-related UI
140 : // elements.
141 : //
142 : // The source will be the navigation controller associated with the load.
143 : // There are no details. The entry changed will be the active entry of the
144 : // controller.
145 : SSL_VISIBLE_STATE_CHANGED,
146 :
147 : // The SSL state of the browser has changed in some internal way. For
148 : // example, the user might have explicitly allowed some broken certificate
149 : // or a secure origin might have included some insecure content. Listen to
150 : // this notifiation if you need to keep track of our internal SSL state.
151 : //
152 : // The source will be the navigation controller associated with the state
153 : // change. There are no details.
154 : SSL_INTERNAL_STATE_CHANGED,
155 :
156 : // Lets resource handlers and other interested observers know when the
157 : // message filter is being deleted and can no longer be used.
158 : RESOURCE_MESSAGE_FILTER_SHUTDOWN,
159 :
160 : // Views -------------------------------------------------------------------
161 :
162 : // Notification that a view was removed from a view hierarchy. The source
163 : // is the view, the details is the parent view.
164 : VIEW_REMOVED,
165 :
166 : // Browser-window ----------------------------------------------------------
167 :
168 : // This message is sent after a window has been opened. The source is a
169 : // Source<Browser> with a pointer to the new window. No details are
170 : // expected.
171 : BROWSER_OPENED,
172 :
173 : // This message is sent after a window has been closed. The source is a
174 : // Source<Browser> with a pointer to the closed window. Details is a
175 : // boolean that if true indicates that the application will be closed as a
176 : // result of this browser window closure (i.e. this was the last opened
177 : // browser window). Note that the boolean pointed to by Details is only
178 : // valid for the duration of this call.
179 : BROWSER_CLOSED,
180 :
181 : // This message is sent when the last window considered to be an
182 : // "application window" has been closed. Dependent/dialog/utility windows
183 : // can use this as a way to know that they should also close. No source or
184 : // details are passed.
185 : ALL_APPWINDOWS_CLOSED,
186 :
187 : // Indicates a new top window has been created. The source is the
188 : // WindowWin.
189 : WINDOW_CREATED,
190 :
191 : // Indicates that a top window has been closed. The source is the HWND
192 : // that was closed, no details are expected.
193 : WINDOW_CLOSED,
194 :
195 : // Sent when an info bubble has been created but not yet shown. The source
196 : // is the InfoBubble.
197 : INFO_BUBBLE_CREATED,
198 :
199 : // Tabs --------------------------------------------------------------------
200 :
201 : // This notification is sent after a tab has been appended to the
202 : // tab_strip. The source is a Source<NavigationController> with a pointer
203 : // to controller for the added tab. There are no details.
204 : TAB_PARENTED,
205 :
206 : // This message is sent before a tab has been closed. The source is a
207 : // Source<NavigationController> with a pointer to the controller for the
208 : // closed tab. No details are expected.
209 : //
210 : // See also TAB_CLOSED.
211 : TAB_CLOSING,
212 :
213 : // Notification that a tab has been closed. The source is the
214 : // NavigationController with no details.
215 : TAB_CLOSED,
216 :
217 : // This notification is sent when a render view host has connected to a
218 : // renderer process. The source is a Source<TabContents> with a pointer to
219 : // the TabContents. A TAB_CONTENTS_DISCONNECTED notification is
220 : // guaranteed before the source pointer becomes junk. No details are
221 : // expected.
222 : TAB_CONTENTS_CONNECTED,
223 :
224 : // This notification is sent when a TabContents swaps its render view host
225 : // with another one, possibly changing processes. The source is a
226 : // Source<TabContents> with a pointer to the TabContents. A
227 : // TAB_CONTENTS_DISCONNECTED notification is guaranteed before the
228 : // source pointer becomes junk. No details are expected.
229 : TAB_CONTENTS_SWAPPED,
230 :
231 : // This message is sent after a TabContents is disconnected from the
232 : // renderer process. The source is a Source<TabContents> with a pointer to
233 : // the TabContents (the pointer is usable). No details are expected.
234 : TAB_CONTENTS_DISCONNECTED,
235 :
236 : // This message is sent when a new InfoBar has been added to a TabContents.
237 : // The source is a Source<TabContents> with a pointer to the TabContents
238 : // the InfoBar was added to. The details is a Details<InfoBarDelegate> with
239 : // a pointer to an object implementing the InfoBarDelegate interface for
240 : // the InfoBar that was added.
241 : TAB_CONTENTS_INFOBAR_ADDED,
242 :
243 : // This message is sent when an InfoBar is about to be removed from a
244 : // TabContents. The source is a Source<TabContents> with a pointer to the
245 : // TabContents the InfoBar was removed from. The details is a
246 : // Details<InfoBarDelegate> with a pointer to an object implementing the
247 : // InfoBarDelegate interface for the InfoBar that was removed.
248 : TAB_CONTENTS_INFOBAR_REMOVED,
249 :
250 : // This is sent when an externally hosted tab is created. The details
251 : // contain the ExternalTabContainer that contains the tab
252 : EXTERNAL_TAB_CREATED,
253 :
254 : // This is sent when an externally hosted tab is closed. No details are
255 : // expected.
256 : EXTERNAL_TAB_CLOSED,
257 :
258 : // Indicates that the new page tab has finished loading. This is used for
259 : // performance testing to see how fast we can load it after startup, and is
260 : // only called once for the lifetime of the browser. The source is unused.
261 : // Details is an integer: the number of milliseconds elapsed between
262 : // starting and finishing all painting.
263 : INITIAL_NEW_TAB_UI_LOAD,
264 :
265 : // This notification is sent when a TabContents is being hidden, e.g. due
266 : // to switching away from this tab. The source is a Source<TabContents>.
267 : TAB_CONTENTS_HIDDEN,
268 :
269 : // This notification is sent when a TabContents is being destroyed. Any
270 : // object holding a reference to a TabContents can listen to that
271 : // notification to properly reset the reference. The source is a
272 : // Source<TabContents>.
273 : TAB_CONTENTS_DESTROYED,
274 :
275 : // Stuff inside the tabs ---------------------------------------------------
276 :
277 : // This message is sent after a constrained window has been closed. The
278 : // source is a Source<ConstrainedWindow> with a pointer to the closed child
279 : // window. (The pointer isn't usable, except for identification.) No
280 : // details are expected.
281 : CWINDOW_CLOSED,
282 :
283 : // Indicates that a RenderProcessHost is destructing. The source will be the
284 : // RenderProcessHost that corresponds to the process.
285 : RENDERER_PROCESS_TERMINATED,
286 :
287 : // Indicates that a render process was closed (meaning it exited, but the
288 : // RenderProcessHost might be reused). The source will be the corresponding
289 : // RenderProcessHost. The details will be a bool which is true if the
290 : // process crashed. This may get sent along with
291 : // RENDERER_PROCESS_TERMINATED.
292 : RENDERER_PROCESS_CLOSED,
293 :
294 : // Indicates that a render process has become unresponsive for a period of
295 : // time. The source will be the RenderWidgetHost that corresponds to the
296 : // hung view, and no details are expected.
297 : RENDERER_PROCESS_HANG,
298 :
299 : // Indicates that a render process is created in the sandbox. The source
300 : // will be the RenderProcessHost that corresponds to the created process
301 : // and the detail is a bool telling us if the process got created on the
302 : // sandbox desktop or not.
303 : RENDERER_PROCESS_IN_SBOX,
304 :
305 : // This is sent to notify that the RenderViewHost displayed in a
306 : // TabContents has changed. Source is the TabContents for which the change
307 : // happened, details is the previous RenderViewHost (can be NULL when the
308 : // first RenderViewHost is set).
309 : RENDER_VIEW_HOST_CHANGED,
310 :
311 : // This is sent when a RenderWidgetHost is being destroyed. The source is
312 : // the RenderWidgetHost, the details are not used.
313 : RENDER_WIDGET_HOST_DESTROYED,
314 :
315 : // Notification from TabContents that we have received a response from the
316 : // renderer after using the dom inspector.
317 : DOM_INSPECT_ELEMENT_RESPONSE,
318 :
319 : // Notification from TabContents that we have received a response from the
320 : // renderer in response to a dom automation controller action.
321 : DOM_OPERATION_RESPONSE,
322 :
323 : // Sent when the bookmark bubble hides. The source is the profile, the
324 : // details unused.
325 : BOOKMARK_BUBBLE_HIDDEN,
326 :
327 : // This notification is sent when the result of a find-in-page search is
328 : // available with the browser process. The source is a Source<TabContents>
329 : // with a pointer to the TabContents. Details encompass a
330 : // FindNotificationDetail object that tells whether the match was found or
331 : // not found.
332 : FIND_RESULT_AVAILABLE,
333 :
334 : // This is sent when the users preference for when the bookmark bar should
335 : // be shown changes. The source is the profile, and the details are
336 : // NoDetails.
337 : BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
338 :
339 : // Used to monitor web cache usage by notifying whenever the
340 : // CacheManagerHost observes new UsageStats. The source will be the
341 : // RenderProcessHost that corresponds to the new statistics. Details are a
342 : // UsageStats object sent by the renderer, and should be copied - ptr not
343 : // guaranteed to be valid after the notification.
344 : WEB_CACHE_STATS_OBSERVED,
345 :
346 : // Child Processes ---------------------------------------------------------
347 :
348 : // This notification is sent when a child process host has connected to a
349 : // child process. There is no usable source, since it is sent from an
350 : // ephemeral task; register for AllSources() to receive this notification.
351 : // The details are in a Details<ChildProcessInfo>.
352 : CHILD_PROCESS_HOST_CONNECTED,
353 :
354 : // This message is sent after a ChildProcessHost is disconnected from the
355 : // child process. There is no usable source, since it is sent from an
356 : // ephemeral task; register for AllSources() to receive this notification.
357 : // The details are in a Details<ChildProcessInfo>.
358 : CHILD_PROCESS_HOST_DISCONNECTED,
359 :
360 : // This message is sent when a child process disappears unexpectedly.
361 : // There is no usable source, since it is sent from an ephemeral task;
362 : // register for AllSources() to receive this notification. The details are
363 : // in a Details<ChildProcessInfo>.
364 : CHILD_PROCESS_CRASHED,
365 :
366 : // This message indicates that an instance of a particular child was
367 : // created in a page. (If one page contains several regions rendered by
368 : // the same child, this notification will occur once for each region
369 : // during the page load.)
370 : //
371 : // There is no usable source, since it is sent from an ephemeral task;
372 : // register for AllSources() to receive this notification. The details are
373 : // in a Details<ChildProcessInfo>.
374 : CHILD_INSTANCE_CREATED,
375 :
376 : // This is sent when network interception is disabled for a plugin, or the
377 : // plugin is unloaded. This should only be sent/received on the browser IO
378 : // thread or the plugin thread. The source is the plugin that is disabling
379 : // interception. No details are expected.
380 : CHROME_PLUGIN_UNLOADED,
381 :
382 : // This is sent when a login prompt is shown. The source is the
383 : // Source<NavigationController> for the tab in which the prompt is shown.
384 : // Details are a LoginNotificationDetails which provide the LoginHandler
385 : // that should be given authentication.
386 : AUTH_NEEDED,
387 :
388 : // This is sent when authentication credentials have been supplied (either
389 : // by the user or by an automation service), but before we've actually
390 : // received another response from the server. The source is the
391 : // Source<NavigationController> for the tab in which the prompt was shown.
392 : // No details are expected.
393 : AUTH_SUPPLIED,
394 :
395 : // History -----------------------------------------------------------------
396 :
397 : // Sent when a history service is created on the main thread. This is sent
398 : // after history is created, but before it has finished loading. Use
399 : // HISTORY_LOADED is you need to know when loading has completed.
400 : // The source is the profile that the history service belongs to, and the
401 : // details is the pointer to the newly created HistoryService object.
402 : HISTORY_CREATED,
403 :
404 : // Sent when a history service has finished loading. The source is the
405 : // profile that the history service belongs to, and the details is the
406 : // HistoryService.
407 : HISTORY_LOADED,
408 :
409 : // Sent when a URL that has been typed has been added or modified. This is
410 : // used by the in-memory URL database (used by autocomplete) to track
411 : // changes to the main history system.
412 : //
413 : // The source is the profile owning the history service that changed, and
414 : // the details is history::URLsModifiedDetails that lists the modified or
415 : // added URLs.
416 : HISTORY_TYPED_URLS_MODIFIED,
417 :
418 : // Sent when the user visits a URL.
419 : //
420 : // The source is the profile owning the history service that changed, and
421 : // the details is history::URLVisitedDetails.
422 : HISTORY_URL_VISITED,
423 :
424 : // Sent when one or more URLs are deleted.
425 : //
426 : // The source is the profile owning the history service that changed, and
427 : // the details is history::URLsDeletedDetails that lists the deleted URLs.
428 : HISTORY_URLS_DELETED,
429 :
430 : // Sent by history when the favicon of a URL changes. The source is the
431 : // profile, and the details is history::FavIconChangeDetails (see
432 : // history_notifications.h).
433 : FAVICON_CHANGED,
434 :
435 : // Bookmarks ---------------------------------------------------------------
436 :
437 : // Sent when the starred state of a URL changes. A URL is starred if there
438 : // is at least one bookmark for it. The source is a Profile and the details
439 : // is history::URLsStarredDetails that contains the list of URLs and
440 : // whether they were starred or unstarred.
441 : URLS_STARRED,
442 :
443 : // Sent when the bookmark bar model finishes loading. This source is the
444 : // Profile, and the details aren't used.
445 : BOOKMARK_MODEL_LOADED,
446 :
447 : // Sent when the spellchecker object changes. Note that this is not sent
448 : // the first time the spellchecker gets initialized. The source is the
449 : // profile, the details is SpellcheckerReinitializedDetails defined in
450 : // profile.
451 : SPELLCHECKER_REINITIALIZED,
452 :
453 : // Sent when the bookmark bubble is shown for a particular URL. The source
454 : // is the profile, the details the URL.
455 : BOOKMARK_BUBBLE_SHOWN,
456 :
457 : // Non-history storage services --------------------------------------------
458 :
459 : // Notification that the TemplateURLModel has finished loading from the
460 : // database. The source is the TemplateURLModel, and the details are
461 : // NoDetails.
462 : TEMPLATE_URL_MODEL_LOADED,
463 :
464 : // Notification triggered when a web application has been installed or
465 : // uninstalled. Any application view should reload its data. The source is
466 : // the profile. No details are provided.
467 : WEB_APP_INSTALL_CHANGED,
468 :
469 : // This is sent to a pref observer when a pref is changed.
470 : PREF_CHANGED,
471 :
472 : // Sent when a default request context has been created, so calling
473 : // Profile::GetDefaultRequestContext() will not return NULL. This is sent
474 : // on the thread where Profile::GetRequestContext() is first called, which
475 : // should be the UI thread.
476 : DEFAULT_REQUEST_CONTEXT_AVAILABLE,
477 :
478 : // Autocomplete ------------------------------------------------------------
479 :
480 : // Sent by the autocomplete controller at least once per query, each time
481 : // new matches are available, subject to rate-limiting/coalescing to reduce
482 : // the number of updates. There are no details.
483 : AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED,
484 :
485 : // Sent by the autocomplete controller once per query, immediately after
486 : // synchronous matches become available. There are no details.
487 : AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_MATCHES_AVAILABLE,
488 :
489 : // This is sent when an item of the Omnibox popup is selected. The source
490 : // is the profile.
491 : OMNIBOX_OPENED_URL,
492 :
493 : // Sent by the autocomplete edit when it is destroyed.
494 : AUTOCOMPLETE_EDIT_DESTROYED,
495 :
496 : // Sent when the main Google URL has been updated. Some services cache
497 : // this value and need to update themselves when it changes. See
498 : // google_util::GetGoogleURLAndUpdateIfNecessary().
499 : GOOGLE_URL_UPDATED,
500 :
501 : // Printing ----------------------------------------------------------------
502 :
503 : // Notification from a PrintedDocument that it has been updated. It may be
504 : // that a printed page has just been generated or that the document's
505 : // number of pages has been calculated. Details is the new page or NULL if
506 : // only the number of pages in the document has been updated.
507 : PRINTED_DOCUMENT_UPDATED,
508 :
509 : // Notification from PrintJob that an event occured. It can be that a page
510 : // finished printing or that the print job failed. Details is
511 : // PrintJob::EventDetails.
512 : PRINT_JOB_EVENT,
513 :
514 : // Shutdown ----------------------------------------------------------------
515 :
516 : // Sent on the browser IO thread when an URLRequestContext is released by
517 : // its owning Profile. The source is a pointer to the URLRequestContext.
518 : URL_REQUEST_CONTEXT_RELEASED,
519 :
520 : // Sent when WM_ENDSESSION has been received, after the browsers have been
521 : // closed but before browser process has been shutdown. The source/details
522 : // are all source and no details.
523 : SESSION_END,
524 :
525 : // Personalization ---------------------------------------------------------
526 :
527 : PERSONALIZATION,
528 : PERSONALIZATION_CREATED,
529 :
530 : // User Scripts ------------------------------------------------------------
531 :
532 : // Sent when there are new user scripts available. The details are a
533 : // pointer to SharedMemory containing the new scripts.
534 : USER_SCRIPTS_LOADED,
535 :
536 : // Extensions --------------------------------------------------------------
537 :
538 : // Sent when new extensions are loaded. The details are an ExtensionList*.
539 : EXTENSIONS_LOADED,
540 :
541 : // Sent when new extensions are installed. The details are a FilePath.
542 : EXTENSION_INSTALLED,
543 :
544 : // Debugging ---------------------------------------------------------------
545 :
546 : // Sent from ~RenderViewHost. The source is the RenderViewHost.
547 : RENDER_VIEW_HOST_DELETED,
548 :
549 : // Count (must be last) ----------------------------------------------------
550 : // Used to determine the number of notification types. Not valid as
551 : // a type parameter when registering for or posting notifications.
552 : NOTIFICATION_TYPE_COUNT
553 : };
554 :
555 0 : NotificationType(Type v) : value(v) {}
556 :
557 : bool operator==(NotificationType t) const { return value == t.value; }
558 : bool operator!=(NotificationType t) const { return value != t.value; }
559 :
560 : // Comparison to explicit enum values.
561 : bool operator==(Type v) const { return value == v; }
562 : bool operator!=(Type v) const { return value != v; }
563 :
564 : Type value;
565 : };
566 :
567 : inline bool operator==(NotificationType::Type a, NotificationType b) {
568 : return a == b.value;
569 : }
570 : inline bool operator!=(NotificationType::Type a, NotificationType b) {
571 : return a != b.value;
572 : }
573 :
574 : #endif // CHROME_COMMON_NOTIFICATION_TYPE_H_
|