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 #include "components/infobars/core/infobar_container.h" | 5 #include "components/infobars/core/infobar_container.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram_base.h" | |
12 #include "base/metrics/metrics_hashes.h" | |
13 #include "base/metrics/sparse_histogram.h" | |
11 #include "build/build_config.h" | 14 #include "build/build_config.h" |
12 #include "components/infobars/core/infobar.h" | 15 #include "components/infobars/core/infobar.h" |
13 #include "components/infobars/core/infobar_delegate.h" | 16 #include "components/infobars/core/infobar_delegate.h" |
14 | 17 |
15 namespace infobars { | 18 namespace infobars { |
16 | 19 |
17 InfoBarContainer::Delegate::~Delegate() { | 20 InfoBarContainer::Delegate::~Delegate() { |
18 } | 21 } |
19 | 22 |
20 InfoBarContainer::InfoBarContainer(Delegate* delegate) | 23 InfoBarContainer::InfoBarContainer(Delegate* delegate) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 size_t position, | 148 size_t position, |
146 bool animate) { | 149 bool animate) { |
147 DCHECK(std::find(infobars_.begin(), infobars_.end(), infobar) == | 150 DCHECK(std::find(infobars_.begin(), infobars_.end(), infobar) == |
148 infobars_.end()); | 151 infobars_.end()); |
149 DCHECK_LE(position, infobars_.size()); | 152 DCHECK_LE(position, infobars_.size()); |
150 infobars_.insert(infobars_.begin() + position, infobar); | 153 infobars_.insert(infobars_.begin() + position, infobar); |
151 UpdateInfoBarArrowTargetHeights(); | 154 UpdateInfoBarArrowTargetHeights(); |
152 PlatformSpecificAddInfoBar(infobar, position); | 155 PlatformSpecificAddInfoBar(infobar, position); |
153 infobar->set_container(this); | 156 infobar->set_container(this); |
154 infobar->Show(animate); | 157 infobar->Show(animate); |
158 | |
159 // Record the infobar being displayed. | |
160 std::string id = infobar->delegate()->GetIdentifier(); | |
161 int hashed_id = | |
162 static_cast<base::HistogramBase::Sample>(base::HashMetricName(id)); | |
Peter Kasting
2015/12/14 23:59:14
Nit: Slightly shorter to just inline:
int hashe
gone
2015/12/15 18:36:37
Done.
| |
163 UMA_HISTOGRAM_SPARSE_SLOWLY("InfoBar.Added", hashed_id); | |
155 } | 164 } |
156 | 165 |
157 } // namespace infobars | 166 } // namespace infobars |
OLD | NEW |