Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / omnibox / browser / omnibox_event_global_tracker.h
blobd8729d0c65316d627dcce572e53335c46854ae98
1 // Copyright 2015 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_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_
8 #include "base/callback_list.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
12 namespace base {
13 template <typename T>
14 struct DefaultSingletonTraits;
15 } // namespace base
17 struct OmniboxLog;
19 // Omnibox code tracks events on a per-user-context basis, but there are
20 // several clients who need to observe these events for all user contexts
21 // (e.g., all Profiles in the //chrome embedder). This class serves as an
22 // intermediary to bridge the gap: omnibox code calls the
23 // OmniboxEventGlobalTracker singleton on an event of interest, and it then
24 // forwards the event to its registered observers.
25 class OmniboxEventGlobalTracker {
26 public:
27 typedef base::Callback<void(OmniboxLog*)> OnURLOpenedCallback;
29 // Returns the instance of OmniboxEventGlobalTracker.
30 static OmniboxEventGlobalTracker* GetInstance();
32 // Registers |cb| to be invoked when user open an URL from the omnibox.
33 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription>
34 RegisterCallback(const OnURLOpenedCallback& cb);
36 // Called to notify all registered callbacks that an URL was opened from
37 // the omnibox.
38 void OnURLOpened(OmniboxLog* log);
40 private:
41 friend struct base::DefaultSingletonTraits<OmniboxEventGlobalTracker>;
43 OmniboxEventGlobalTracker();
44 ~OmniboxEventGlobalTracker();
46 base::CallbackList<void(OmniboxLog*)> on_url_opened_callback_list_;
48 DISALLOW_COPY_AND_ASSIGN(OmniboxEventGlobalTracker);
51 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_