summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google/google_url_tracker_map_entry.h
blob: 5cdb2b5fc6ef1d961a8e727f116a2d563738f3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_MAP_ENTRY_H_
#define CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_MAP_ENTRY_H_

#include "base/memory/scoped_ptr.h"
#include "chrome/browser/google/google_url_tracker_infobar_delegate.h"
#include "chrome/browser/google/google_url_tracker_navigation_helper.h"
#include "components/infobars/core/infobar_manager.h"

class GoogleURLTracker;

namespace infobars {
class InfoBarManager;
}

class GoogleURLTrackerMapEntry : public infobars::InfoBarManager::Observer {
 public:
  GoogleURLTrackerMapEntry(
      GoogleURLTracker* google_url_tracker,
      infobars::InfoBarManager* infobar_manager,
      scoped_ptr<GoogleURLTrackerNavigationHelper> navigation_helper);
  virtual ~GoogleURLTrackerMapEntry();

  bool has_infobar_delegate() const { return !!infobar_delegate_; }
  GoogleURLTrackerInfoBarDelegate* infobar_delegate() {
    return infobar_delegate_;
  }
  void SetInfoBarDelegate(GoogleURLTrackerInfoBarDelegate* infobar_delegate);

  GoogleURLTrackerNavigationHelper* navigation_helper() {
    // This object gives ownership of |navigation_helper_| to the infobar
    // delegate in SetInfoBarDelegate().
    return has_infobar_delegate() ?
        infobar_delegate_->navigation_helper() : navigation_helper_.get();
  }

  const infobars::InfoBarManager* infobar_manager() const {
    return infobar_manager_;
  }

  void Close(bool redo_search);

 private:
  friend class GoogleURLTrackerTest;

  // infobars::InfoBarManager::Observer:
  virtual void OnInfoBarRemoved(infobars::InfoBar* infobar,
                                bool animate) OVERRIDE;
  virtual void OnManagerShuttingDown(
      infobars::InfoBarManager* manager) OVERRIDE;

  GoogleURLTracker* const google_url_tracker_;
  infobars::InfoBarManager* const infobar_manager_;
  GoogleURLTrackerInfoBarDelegate* infobar_delegate_;
  scoped_ptr<GoogleURLTrackerNavigationHelper> navigation_helper_;
  bool observing_;

  DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerMapEntry);
};

#endif  // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_MAP_ENTRY_H_