1 // Copyright 2014 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.
5 #ifndef COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_MAP_ENTRY_H_
6 #define COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_MAP_ENTRY_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h"
10 #include "components/google/core/browser/google_url_tracker_navigation_helper.h"
11 #include "components/infobars/core/infobar_manager.h"
13 class GoogleURLTracker;
19 class GoogleURLTrackerMapEntry : public infobars::InfoBarManager::Observer {
21 GoogleURLTrackerMapEntry(
22 GoogleURLTracker* google_url_tracker,
23 infobars::InfoBarManager* infobar_manager,
24 scoped_ptr<GoogleURLTrackerNavigationHelper> navigation_helper);
25 virtual ~GoogleURLTrackerMapEntry();
27 bool has_infobar_delegate() const { return !!infobar_delegate_; }
28 GoogleURLTrackerInfoBarDelegate* infobar_delegate() {
29 return infobar_delegate_;
31 void SetInfoBarDelegate(GoogleURLTrackerInfoBarDelegate* infobar_delegate);
33 GoogleURLTrackerNavigationHelper* navigation_helper() {
34 // This object gives ownership of |navigation_helper_| to the infobar
35 // delegate in SetInfoBarDelegate().
36 return has_infobar_delegate() ?
37 infobar_delegate_->navigation_helper() : navigation_helper_.get();
40 const infobars::InfoBarManager* infobar_manager() const {
41 return infobar_manager_;
44 void Close(bool redo_search);
47 friend class GoogleURLTrackerTest;
49 // infobars::InfoBarManager::Observer:
50 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override;
51 void OnManagerShuttingDown(infobars::InfoBarManager* manager) override;
53 GoogleURLTracker* const google_url_tracker_;
54 infobars::InfoBarManager* const infobar_manager_;
55 GoogleURLTrackerInfoBarDelegate* infobar_delegate_;
56 scoped_ptr<GoogleURLTrackerNavigationHelper> navigation_helper_;
59 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerMapEntry);
62 #endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_MAP_ENTRY_H_