automation_provider_observers.h revision c407dc5cd9bdc5668497f21b26b09d988ab439de
1// Copyright (c) 2009 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_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
6#define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
7
8#include <deque>
9#include <map>
10#include <set>
11
12#include "chrome/browser/bookmarks/bookmark_model_observer.h"
13#include "chrome/browser/browsing_data_remover.h"
14#include "chrome/browser/download/download_item.h"
15#include "chrome/browser/download/download_manager.h"
16#include "chrome/browser/importer/importer.h"
17#include "chrome/browser/importer/importer_data_types.h"
18#include "chrome/browser/password_manager/password_store.h"
19#include "chrome/browser/tab_contents/tab_contents.h"
20#include "chrome/common/notification_observer.h"
21#include "chrome/common/notification_registrar.h"
22#include "chrome/common/notification_type.h"
23#include "chrome/test/automation/automation_messages.h"
24
25class AutomationProvider;
26class Browser;
27class Extension;
28class ExtensionProcessManager;
29class NavigationController;
30class SavePackage;
31class TabContents;
32
33namespace IPC {
34class Message;
35}
36
37class InitialLoadObserver : public NotificationObserver {
38 public:
39  InitialLoadObserver(size_t tab_count, AutomationProvider* automation);
40  ~InitialLoadObserver();
41
42  virtual void Observe(NotificationType type,
43                       const NotificationSource& source,
44                       const NotificationDetails& details);
45
46  // Caller owns the return value and is responsible for deleting it.
47  // Example return value:
48  // {'tabs': [{'start_time_ms': 1, 'stop_time_ms': 2.5},
49  //           {'start_time_ms': 0.5, 'stop_time_ms': 3}]}
50  // stop_time_ms values may be null if WaitForInitialLoads has not finished.
51  // Only includes entries for the |tab_count| tabs we are monitoring.
52  // There is no defined ordering of the return value.
53  DictionaryValue* GetTimingInformation() const;
54
55 private:
56  class TabTime;
57  typedef std::map<uintptr_t, TabTime> TabTimeMap;
58  typedef std::set<uintptr_t> TabSet;
59
60  void ConditionMet();
61
62  NotificationRegistrar registrar_;
63
64  AutomationProvider* automation_;
65  size_t outstanding_tab_count_;
66  base::TimeTicks init_time_;
67  TabTimeMap loading_tabs_;
68  TabSet finished_tabs_;
69
70  DISALLOW_COPY_AND_ASSIGN(InitialLoadObserver);
71};
72
73// Watches for NewTabUI page loads for performance timing purposes.
74class NewTabUILoadObserver : public NotificationObserver {
75 public:
76  explicit NewTabUILoadObserver(AutomationProvider* automation);
77  ~NewTabUILoadObserver();
78
79  virtual void Observe(NotificationType type,
80                       const NotificationSource& source,
81                       const NotificationDetails& details);
82
83 private:
84  NotificationRegistrar registrar_;
85  AutomationProvider* automation_;
86
87  DISALLOW_COPY_AND_ASSIGN(NewTabUILoadObserver);
88};
89
90class NavigationControllerRestoredObserver : public NotificationObserver {
91 public:
92  NavigationControllerRestoredObserver(AutomationProvider* automation,
93                                       NavigationController* controller,
94                                       IPC::Message* reply_message);
95  ~NavigationControllerRestoredObserver();
96
97  virtual void Observe(NotificationType type,
98                       const NotificationSource& source,
99                       const NotificationDetails& details);
100
101 private:
102  bool FinishedRestoring();
103  void SendDone();
104
105  NotificationRegistrar registrar_;
106  AutomationProvider* automation_;
107  NavigationController* controller_;
108  IPC::Message* reply_message_;
109
110  DISALLOW_COPY_AND_ASSIGN(NavigationControllerRestoredObserver);
111};
112
113class NavigationNotificationObserver : public NotificationObserver {
114 public:
115  NavigationNotificationObserver(NavigationController* controller,
116                                 AutomationProvider* automation,
117                                 IPC::Message* reply_message,
118                                 int number_of_navigations,
119                                 bool include_current_navigation);
120  ~NavigationNotificationObserver();
121
122  virtual void Observe(NotificationType type,
123                       const NotificationSource& source,
124                       const NotificationDetails& details);
125
126 private:
127  void ConditionMet(AutomationMsg_NavigationResponseValues navigation_result);
128
129  NotificationRegistrar registrar_;
130  AutomationProvider* automation_;
131  IPC::Message* reply_message_;
132  NavigationController* controller_;
133  int navigations_remaining_;
134  bool navigation_started_;
135
136  DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver);
137};
138
139class TabStripNotificationObserver : public NotificationObserver {
140 public:
141  TabStripNotificationObserver(NotificationType notification,
142                               AutomationProvider* automation);
143  virtual ~TabStripNotificationObserver();
144
145  virtual void Observe(NotificationType type,
146                       const NotificationSource& source,
147                       const NotificationDetails& details);
148
149  virtual void ObserveTab(NavigationController* controller) = 0;
150
151 protected:
152  NotificationRegistrar registrar_;
153  AutomationProvider* automation_;
154  NotificationType notification_;
155};
156
157class TabAppendedNotificationObserver : public TabStripNotificationObserver {
158 public:
159  TabAppendedNotificationObserver(Browser* parent,
160                                  AutomationProvider* automation,
161                                  IPC::Message* reply_message);
162
163  virtual void ObserveTab(NavigationController* controller);
164
165 protected:
166  Browser* parent_;
167  IPC::Message* reply_message_;
168
169 private:
170  DISALLOW_COPY_AND_ASSIGN(TabAppendedNotificationObserver);
171};
172
173class TabClosedNotificationObserver : public TabStripNotificationObserver {
174 public:
175  TabClosedNotificationObserver(AutomationProvider* automation,
176                                bool wait_until_closed,
177                                IPC::Message* reply_message);
178
179  virtual void ObserveTab(NavigationController* controller);
180
181  void set_for_browser_command(bool for_browser_command);
182
183 protected:
184  IPC::Message* reply_message_;
185  bool for_browser_command_;
186
187 private:
188  DISALLOW_COPY_AND_ASSIGN(TabClosedNotificationObserver);
189};
190
191// Observes when an extension has finished installing or possible install
192// errors. This does not guarantee that the extension is ready for use.
193class ExtensionInstallNotificationObserver : public NotificationObserver {
194 public:
195  ExtensionInstallNotificationObserver(AutomationProvider* automation,
196                                       int id,
197                                       IPC::Message* reply_message);
198  ~ExtensionInstallNotificationObserver();
199
200  // Implementation of NotificationObserver.
201  virtual void Observe(NotificationType type,
202                       const NotificationSource& source,
203                       const NotificationDetails& details);
204
205 private:
206  // Send |response| back to the provider's client.
207  void SendResponse(AutomationMsg_ExtensionResponseValues response);
208
209  NotificationRegistrar registrar_;
210  scoped_refptr<AutomationProvider> automation_;
211  int id_;
212  IPC::Message* reply_message_;
213
214  DISALLOW_COPY_AND_ASSIGN(ExtensionInstallNotificationObserver);
215};
216
217// Observes when an extension has finished loading and is ready for use. Also
218// checks for possible install errors.
219class ExtensionReadyNotificationObserver : public NotificationObserver {
220 public:
221  ExtensionReadyNotificationObserver(ExtensionProcessManager* manager,
222                                     AutomationProvider* automation,
223                                     int id,
224                                     IPC::Message* reply_message);
225  ~ExtensionReadyNotificationObserver();
226
227  // Implementation of NotificationObserver.
228  virtual void Observe(NotificationType type,
229                       const NotificationSource& source,
230                       const NotificationDetails& details);
231
232 private:
233  NotificationRegistrar registrar_;
234  ExtensionProcessManager* manager_;
235  scoped_refptr<AutomationProvider> automation_;
236  int id_;
237  IPC::Message* reply_message_;
238  Extension* extension_;
239
240  DISALLOW_COPY_AND_ASSIGN(ExtensionReadyNotificationObserver);
241};
242
243class ExtensionUnloadNotificationObserver : public NotificationObserver {
244 public:
245  ExtensionUnloadNotificationObserver();
246  ~ExtensionUnloadNotificationObserver();
247
248  // Implementation of NotificationObserver.
249  virtual void Observe(NotificationType type,
250                       const NotificationSource& source,
251                       const NotificationDetails& details);
252
253  bool did_receive_unload_notification() {
254    return did_receive_unload_notification_;
255  }
256
257 private:
258  NotificationRegistrar registrar_;
259  bool did_receive_unload_notification_;
260
261  DISALLOW_COPY_AND_ASSIGN(ExtensionUnloadNotificationObserver);
262};
263
264class ExtensionTestResultNotificationObserver : public NotificationObserver {
265 public:
266  explicit ExtensionTestResultNotificationObserver(
267      AutomationProvider* automation);
268  ~ExtensionTestResultNotificationObserver();
269
270  // Implementation of NotificationObserver.
271  virtual void Observe(NotificationType type,
272                       const NotificationSource& source,
273                       const NotificationDetails& details);
274
275  // Sends a test result back to the provider's client, if there is a pending
276  // provider message and there is a result in the queue.
277  void MaybeSendResult();
278
279 private:
280  NotificationRegistrar registrar_;
281  AutomationProvider* automation_;
282  // Two queues containing the test results. Although typically only
283  // one result will be in each queue, there are cases where a queue is
284  // needed.
285  // For example, perhaps two events occur asynchronously and their
286  // order of completion is not guaranteed. If the test wants to make sure
287  // both finish before continuing, a queue is needed. The test would then
288  // need to wait twice.
289  std::deque<bool> results_;
290  std::deque<std::string> messages_;
291
292  DISALLOW_COPY_AND_ASSIGN(ExtensionTestResultNotificationObserver);
293};
294
295class BrowserOpenedNotificationObserver : public NotificationObserver {
296 public:
297  BrowserOpenedNotificationObserver(AutomationProvider* automation,
298                                    IPC::Message* reply_message);
299  ~BrowserOpenedNotificationObserver();
300
301  virtual void Observe(NotificationType type,
302                       const NotificationSource& source,
303                       const NotificationDetails& details);
304
305  void set_for_browser_command(bool for_browser_command);
306
307 private:
308  NotificationRegistrar registrar_;
309  AutomationProvider* automation_;
310  IPC::Message* reply_message_;
311  bool for_browser_command_;
312
313  DISALLOW_COPY_AND_ASSIGN(BrowserOpenedNotificationObserver);
314};
315
316class BrowserClosedNotificationObserver : public NotificationObserver {
317 public:
318  BrowserClosedNotificationObserver(Browser* browser,
319                                    AutomationProvider* automation,
320                                    IPC::Message* reply_message);
321
322  virtual void Observe(NotificationType type,
323                       const NotificationSource& source,
324                       const NotificationDetails& details);
325
326  void set_for_browser_command(bool for_browser_command);
327
328 private:
329  NotificationRegistrar registrar_;
330  AutomationProvider* automation_;
331  IPC::Message* reply_message_;
332  bool for_browser_command_;
333
334  DISALLOW_COPY_AND_ASSIGN(BrowserClosedNotificationObserver);
335};
336
337class BrowserCountChangeNotificationObserver : public NotificationObserver {
338 public:
339  BrowserCountChangeNotificationObserver(int target_count,
340                                         AutomationProvider* automation,
341                                         IPC::Message* reply_message);
342
343  virtual void Observe(NotificationType type,
344                       const NotificationSource& source,
345                       const NotificationDetails& details);
346
347 private:
348  int target_count_;
349  NotificationRegistrar registrar_;
350  AutomationProvider* automation_;
351  IPC::Message* reply_message_;
352
353  DISALLOW_COPY_AND_ASSIGN(BrowserCountChangeNotificationObserver);
354};
355
356class AppModalDialogShownObserver : public NotificationObserver {
357 public:
358  AppModalDialogShownObserver(AutomationProvider* automation,
359                              IPC::Message* reply_message);
360  ~AppModalDialogShownObserver();
361
362  virtual void Observe(NotificationType type,
363                       const NotificationSource& source,
364                       const NotificationDetails& details);
365
366 private:
367  NotificationRegistrar registrar_;
368  AutomationProvider* automation_;
369  IPC::Message* reply_message_;
370
371  DISALLOW_COPY_AND_ASSIGN(AppModalDialogShownObserver);
372};
373
374class ExecuteBrowserCommandObserver : public NotificationObserver {
375 public:
376  ~ExecuteBrowserCommandObserver();
377
378  static bool CreateAndRegisterObserver(AutomationProvider* automation,
379                                        Browser* browser,
380                                        int command,
381                                        IPC::Message* reply_message);
382
383  virtual void Observe(NotificationType type,
384                       const NotificationSource& source,
385                       const NotificationDetails& details);
386
387 private:
388  ExecuteBrowserCommandObserver(AutomationProvider* automation,
389                                IPC::Message* reply_message);
390
391  bool Register(int command);
392
393  bool GetNotificationType(int command, NotificationType::Type* type);
394
395  NotificationRegistrar registrar_;
396  AutomationProvider* automation_;
397  NotificationType::Type notification_type_;
398  IPC::Message* reply_message_;
399
400  DISALLOW_COPY_AND_ASSIGN(ExecuteBrowserCommandObserver);
401};
402
403class FindInPageNotificationObserver : public NotificationObserver {
404 public:
405  FindInPageNotificationObserver(AutomationProvider* automation,
406                                 TabContents* parent_tab,
407                                 IPC::Message* reply_message);
408  ~FindInPageNotificationObserver();
409
410  virtual void Observe(NotificationType type,
411                       const NotificationSource& source,
412                       const NotificationDetails& details);
413
414  // The Find mechanism is over asynchronous IPC, so a search is kicked off and
415  // we wait for notification to find out what the results are. As the user is
416  // typing, new search requests can be issued and the Request ID helps us make
417  // sense of whether this is the current request or an old one. The unit tests,
418  // however, which uses this constant issues only one search at a time, so we
419  // don't need a rolling id to identify each search. But, we still need to
420  // specify one, so we just use a fixed one - its value does not matter.
421  static const int kFindInPageRequestId;
422
423 private:
424  NotificationRegistrar registrar_;
425  AutomationProvider* automation_;
426  // We will at some point (before final update) be notified of the ordinal and
427  // we need to preserve it so we can send it later.
428  int active_match_ordinal_;
429  IPC::Message* reply_message_;
430
431  DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
432};
433
434class DomOperationNotificationObserver : public NotificationObserver {
435 public:
436  explicit DomOperationNotificationObserver(AutomationProvider* automation);
437  ~DomOperationNotificationObserver();
438
439  virtual void Observe(NotificationType type,
440                       const NotificationSource& source,
441                       const NotificationDetails& details);
442
443 private:
444  NotificationRegistrar registrar_;
445  AutomationProvider* automation_;
446
447  DISALLOW_COPY_AND_ASSIGN(DomOperationNotificationObserver);
448};
449
450class DocumentPrintedNotificationObserver : public NotificationObserver {
451 public:
452  DocumentPrintedNotificationObserver(AutomationProvider* automation,
453                                      IPC::Message* reply_message);
454  ~DocumentPrintedNotificationObserver();
455
456  virtual void Observe(NotificationType type, const NotificationSource& source,
457                       const NotificationDetails& details);
458
459 private:
460  NotificationRegistrar registrar_;
461  scoped_refptr<AutomationProvider> automation_;
462  bool success_;
463  IPC::Message* reply_message_;
464
465  DISALLOW_COPY_AND_ASSIGN(DocumentPrintedNotificationObserver);
466};
467
468// Collects METRIC_EVENT_DURATION notifications and keep track of the times.
469class MetricEventDurationObserver : public NotificationObserver {
470 public:
471  MetricEventDurationObserver();
472
473  // Get the duration of an event.  Returns -1 if we haven't seen the event.
474  int GetEventDurationMs(const std::string& event_name);
475
476  // NotificationObserver interface.
477  virtual void Observe(NotificationType type, const NotificationSource& source,
478                       const NotificationDetails& details);
479
480 private:
481  NotificationRegistrar registrar_;
482
483  typedef std::map<std::string, int> EventDurationMap;
484  EventDurationMap durations_;
485
486  DISALLOW_COPY_AND_ASSIGN(MetricEventDurationObserver);
487};
488
489#if defined(OS_CHROMEOS)
490// Collects LOGIN_AUTHENTICATION notifications and returns
491// whether authentication succeeded to the automation provider.
492class LoginManagerObserver : public NotificationObserver {
493 public:
494  LoginManagerObserver(AutomationProvider* automation,
495                       IPC::Message* reply_message);
496
497  // NotificationObserver interface.
498  virtual void Observe(NotificationType type, const NotificationSource& source,
499                       const NotificationDetails& details);
500
501 private:
502  NotificationRegistrar registrar_;
503  AutomationProvider* automation_;
504  IPC::Message* reply_message_;
505
506  DISALLOW_COPY_AND_ASSIGN(LoginManagerObserver);
507};
508#endif
509
510// Waits for the bookmark model to load.
511class AutomationProviderBookmarkModelObserver : BookmarkModelObserver {
512 public:
513  AutomationProviderBookmarkModelObserver(AutomationProvider* provider,
514                                          IPC::Message* reply_message,
515                                          BookmarkModel* model);
516  virtual ~AutomationProviderBookmarkModelObserver();
517
518  virtual void Loaded(BookmarkModel* model) {
519    ReplyAndDelete(true);
520  }
521  virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {
522    ReplyAndDelete(false);
523  }
524  virtual void BookmarkNodeMoved(BookmarkModel* model,
525                                 const BookmarkNode* old_parent,
526                                 int old_index,
527                                 const BookmarkNode* new_parent,
528                                 int new_index) {}
529  virtual void BookmarkNodeAdded(BookmarkModel* model,
530                                 const BookmarkNode* parent,
531                                 int index) {}
532  virtual void BookmarkNodeRemoved(BookmarkModel* model,
533                                   const BookmarkNode* parent,
534                                   int old_index,
535                                   const BookmarkNode* node) {}
536  virtual void BookmarkNodeChanged(BookmarkModel* model,
537                                   const BookmarkNode* node) {}
538  virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
539                                         const BookmarkNode* node) {}
540  virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
541                                             const BookmarkNode* node) {}
542
543 private:
544  // Reply to the automation message with the given success value,
545  // then delete myself (which removes myself from the bookmark model
546  // observer list).
547  void ReplyAndDelete(bool success);
548
549  scoped_refptr<AutomationProvider> automation_provider_;
550  IPC::Message* reply_message_;
551  BookmarkModel* model_;
552
553  DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver);
554};
555
556// When asked for pending downloads, the DownloadManager places
557// results in a DownloadManager::Observer.
558class AutomationProviderDownloadManagerObserver
559    : public DownloadManager::Observer {
560 public:
561  AutomationProviderDownloadManagerObserver() : DownloadManager::Observer()  {}
562  virtual ~AutomationProviderDownloadManagerObserver() {}
563  virtual void ModelChanged() {}
564  virtual void SetDownloads(std::vector<DownloadItem*>& downloads) {
565    downloads_ = downloads;
566  }
567  std::vector<DownloadItem*> Downloads() {
568    return downloads_;
569  }
570 private:
571  std::vector<DownloadItem*> downloads_;
572
573  DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadManagerObserver);
574};
575
576
577// Allows the automation provider to wait for all downloads to finish.
578class AutomationProviderDownloadItemObserver : public DownloadItem::Observer {
579 public:
580  AutomationProviderDownloadItemObserver(
581      AutomationProvider* provider,
582      IPC::Message* reply_message,
583      int downloads) {
584    provider_ = provider;
585    reply_message_ = reply_message;
586    downloads_ = downloads;
587  }
588  virtual ~AutomationProviderDownloadItemObserver() {}
589
590  virtual void OnDownloadUpdated(DownloadItem* download) { }
591  virtual void OnDownloadFileCompleted(DownloadItem* download);
592  virtual void OnDownloadOpened(DownloadItem* download) { }
593
594 private:
595  AutomationProvider* provider_;
596  IPC::Message* reply_message_;
597  int downloads_;
598
599  DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadItemObserver);
600};
601
602// Allows the automation provider to wait for history queries to finish.
603class AutomationProviderHistoryObserver {
604 public:
605  AutomationProviderHistoryObserver(
606      AutomationProvider* provider,
607      IPC::Message* reply_message) {
608    provider_ = provider;
609    reply_message_ = reply_message;
610  }
611  ~AutomationProviderHistoryObserver() {}
612  void HistoryQueryComplete(HistoryService::Handle request_handle,
613                            history::QueryResults* results);
614
615 private:
616  AutomationProvider* provider_;
617  IPC::Message* reply_message_;
618};
619
620// Allows the automation provider to wait for import queries to finish.
621class AutomationProviderImportSettingsObserver
622    : public ImporterHost::Observer {
623 public:
624  AutomationProviderImportSettingsObserver(
625      AutomationProvider* provider,
626      IPC::Message* reply_message)
627    : provider_(provider),
628      reply_message_(reply_message) {}
629  void ImportStarted() {}
630  void ImportItemStarted(importer::ImportItem item) {}
631  void ImportItemEnded(importer::ImportItem item) {}
632  void ImportEnded();
633 private:
634  AutomationProvider* provider_;
635  IPC::Message* reply_message_;
636};
637
638// Allows automation provider to wait for getting passwords to finish.
639class AutomationProviderGetPasswordsObserver :
640    public PasswordStoreConsumer {
641 public:
642  AutomationProviderGetPasswordsObserver(
643      AutomationProvider* provider,
644      IPC::Message* reply_message)
645    : provider_(provider),
646      reply_message_(reply_message) {}
647
648  void OnPasswordStoreRequestDone(
649      int handle, const std::vector<webkit_glue::PasswordForm*>& result);
650
651 private:
652  AutomationProvider* provider_;
653  IPC::Message* reply_message_;
654};
655
656// Allows the automation provider to wait for clearing browser data to finish.
657class AutomationProviderBrowsingDataObserver
658    : public BrowsingDataRemover::Observer {
659 public:
660  AutomationProviderBrowsingDataObserver(
661      AutomationProvider* provider,
662      IPC::Message* reply_message)
663    : provider_(provider),
664      reply_message_(reply_message) {}
665  void OnBrowsingDataRemoverDone();
666
667 private:
668  AutomationProvider* provider_;
669  IPC::Message* reply_message_;
670};
671
672// Allows automation provider to wait until page load after selecting an item
673// in the omnibox popup.
674class OmniboxAcceptNotificationObserver : public NotificationObserver {
675 public:
676  OmniboxAcceptNotificationObserver(NavigationController* controller,
677                                 AutomationProvider* automation,
678                                 IPC::Message* reply_message);
679  ~OmniboxAcceptNotificationObserver();
680
681  virtual void Observe(NotificationType type,
682                       const NotificationSource& source,
683                       const NotificationDetails& details);
684
685 private:
686  NotificationRegistrar registrar_;
687  AutomationProvider* automation_;
688  IPC::Message* reply_message_;
689  NavigationController* controller_;
690
691  DISALLOW_COPY_AND_ASSIGN(OmniboxAcceptNotificationObserver);
692};
693
694// Allows the automation provider to wait for a save package notification.
695class SavePackageNotificationObserver : public NotificationObserver {
696 public:
697  SavePackageNotificationObserver(SavePackage* save_package,
698                                  AutomationProvider* automation,
699                                  IPC::Message* reply_message);
700  virtual ~SavePackageNotificationObserver() {}
701
702  virtual void Observe(NotificationType type,
703                       const NotificationSource& source,
704                       const NotificationDetails& details);
705
706 private:
707  NotificationRegistrar registrar_;
708  AutomationProvider* automation_;
709  IPC::Message* reply_message_;
710
711  DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver);
712};
713
714// Allows the automation provider to wait for a given number of infobars.
715class WaitForInfobarCountObserver : public NotificationObserver {
716 public:
717  WaitForInfobarCountObserver(AutomationProvider* automation,
718                              IPC::Message* reply_message,
719                              TabContents* tab_contents,
720                              int count);
721
722  virtual void Observe(NotificationType type,
723                       const NotificationSource& source,
724                       const NotificationDetails& details);
725
726 private:
727  void ConditionMet();
728
729  NotificationRegistrar registrar_;
730  AutomationProvider* automation_;
731  IPC::Message* reply_message_;
732  TabContents* tab_contents_;
733  int count_;
734
735  DISALLOW_COPY_AND_ASSIGN(WaitForInfobarCountObserver);
736};
737
738#endif  // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
739