OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_METRICS_OMNIBOX_METRICS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_OMNIBOX_METRICS_PROVIDER_H_ |
6 #define CHROME_BROWSER_METRICS_OMNIBOX_METRICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_OMNIBOX_METRICS_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "components/metrics/metrics_provider.h" | 9 #include "components/metrics/metrics_provider.h" |
10 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 10 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
11 #include "components/omnibox/browser/omnibox_event_global_tracker.h" | 11 #include "components/omnibox/browser/omnibox_event_global_tracker.h" |
12 | 12 |
13 struct OmniboxLog; | 13 struct OmniboxLog; |
14 | 14 |
15 // OmniboxMetricsProvider is responsible for filling out the |omnibox_event| | 15 // OmniboxMetricsProvider is responsible for filling out the |omnibox_event| |
16 // section of the UMA proto. | 16 // section of the UMA proto. |
17 class OmniboxMetricsProvider : public metrics::MetricsProvider { | 17 class OmniboxMetricsProvider : public metrics::MetricsProvider { |
18 public: | 18 public: |
19 OmniboxMetricsProvider(); | 19 explicit OmniboxMetricsProvider( |
| 20 const base::Callback<bool(void)>& is_off_the_record_callback); |
20 ~OmniboxMetricsProvider() override; | 21 ~OmniboxMetricsProvider() override; |
21 | 22 |
22 // metrics::MetricsDataProvider: | 23 // metrics::MetricsDataProvider: |
23 void OnRecordingEnabled() override; | 24 void OnRecordingEnabled() override; |
24 void OnRecordingDisabled() override; | 25 void OnRecordingDisabled() override; |
25 void ProvideGeneralMetrics( | 26 void ProvideGeneralMetrics( |
26 metrics::ChromeUserMetricsExtension* uma_proto) override; | 27 metrics::ChromeUserMetricsExtension* uma_proto) override; |
27 | 28 |
28 private: | 29 private: |
29 // Called when a URL is opened from the Omnibox. | 30 // Called when a URL is opened from the Omnibox. |
30 void OnURLOpenedFromOmnibox(OmniboxLog* log); | 31 void OnURLOpenedFromOmnibox(OmniboxLog* log); |
31 | 32 |
32 // Records the input text, available choices, and selected entry when the | 33 // Records the input text, available choices, and selected entry when the |
33 // user uses the Omnibox to open a URL. | 34 // user uses the Omnibox to open a URL. |
34 void RecordOmniboxOpenedURL(const OmniboxLog& log); | 35 void RecordOmniboxOpenedURL(const OmniboxLog& log); |
35 | 36 |
36 // Subscription for receiving Omnibox event callbacks. | 37 // Subscription for receiving Omnibox event callbacks. |
37 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> subscription_; | 38 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> subscription_; |
38 | 39 |
39 // Saved cache of generated Omnibox event protos, to be copied into the UMA | 40 // Saved cache of generated Omnibox event protos, to be copied into the UMA |
40 // proto when ProvideGeneralMetrics() is called. | 41 // proto when ProvideGeneralMetrics() is called. |
41 metrics::ChromeUserMetricsExtension omnibox_events_cache; | 42 metrics::ChromeUserMetricsExtension omnibox_events_cache; |
42 | 43 |
| 44 // Callback passed in from the embedder that returns whether the user is |
| 45 // currently operating off-the-record. |
| 46 const base::Callback<bool(void)> is_off_the_record_callback_; |
| 47 |
43 DISALLOW_COPY_AND_ASSIGN(OmniboxMetricsProvider); | 48 DISALLOW_COPY_AND_ASSIGN(OmniboxMetricsProvider); |
44 }; | 49 }; |
45 | 50 |
46 #endif // CHROME_BROWSER_METRICS_OMNIBOX_METRICS_PROVIDER_H_ | 51 #endif // CHROME_BROWSER_METRICS_OMNIBOX_METRICS_PROVIDER_H_ |
OLD | NEW |