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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_LOAD_COMPLETE_LISTENER_H_
6#define CHROME_BROWSER_UI_VIEWS_LOAD_COMPLETE_LISTENER_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "content/public/browser/notification_observer.h"
11#include "content/public/browser/notification_registrar.h"
12
13// A class which takes  a delegate which can be notified after the first page
14// load has been completed. This is particularly useful for triggering
15// IO-intensive tasks which should not be run until start-up is complete.
16class LoadCompleteListener : public content::NotificationObserver {
17 public:
18  class Delegate {
19   public:
20    // Invoked when initial page load has completed.
21    virtual void OnLoadCompleted() = 0;
22
23   protected:
24    virtual ~Delegate() {}
25  };
26
27  explicit LoadCompleteListener(Delegate* delegate);
28
29  virtual ~LoadCompleteListener();
30
31 private:
32  // content::NotificationObserver:
33  virtual void Observe(int type,
34                       const content::NotificationSource& source,
35                       const content::NotificationDetails& details) OVERRIDE;
36
37  content::NotificationRegistrar registrar_;
38
39  // Delegate to be notified after the first page load has completed.
40  Delegate* delegate_;
41
42  DISALLOW_COPY_AND_ASSIGN(LoadCompleteListener);
43};
44
45#endif  // CHROME_BROWSER_UI_VIEWS_LOAD_COMPLETE_LISTENER_H_
46