Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / google / core / browser / google_url_tracker_map_entry.h
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.
4
5 #ifndef COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_MAP_ENTRY_H_
6 #define COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_MAP_ENTRY_H_
7
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"
12
13 class GoogleURLTracker;
14
15 namespace infobars {
16 class InfoBarManager;
17 }
18
19 class GoogleURLTrackerMapEntry : public infobars::InfoBarManager::Observer {
20  public:
21   GoogleURLTrackerMapEntry(
22       GoogleURLTracker* google_url_tracker,
23       infobars::InfoBarManager* infobar_manager,
24       scoped_ptr<GoogleURLTrackerNavigationHelper> navigation_helper);
25   virtual ~GoogleURLTrackerMapEntry();
26
27   bool has_infobar_delegate() const { return !!infobar_delegate_; }
28   GoogleURLTrackerInfoBarDelegate* infobar_delegate() {
29     return infobar_delegate_;
30   }
31   void SetInfoBarDelegate(GoogleURLTrackerInfoBarDelegate* infobar_delegate);
32
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();
38   }
39
40   const infobars::InfoBarManager* infobar_manager() const {
41     return infobar_manager_;
42   }
43
44   void Close(bool redo_search);
45
46  private:
47   friend class GoogleURLTrackerTest;
48
49   // infobars::InfoBarManager::Observer:
50   void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override;
51   void OnManagerShuttingDown(infobars::InfoBarManager* manager) override;
52
53   GoogleURLTracker* const google_url_tracker_;
54   infobars::InfoBarManager* const infobar_manager_;
55   GoogleURLTrackerInfoBarDelegate* infobar_delegate_;
56   scoped_ptr<GoogleURLTrackerNavigationHelper> navigation_helper_;
57   bool observing_;
58
59   DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerMapEntry);
60 };
61
62 #endif  // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_MAP_ENTRY_H_