OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/chrome_bubble_manager.h" | 5 #include "chrome/browser/ui/chrome_bubble_manager.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "components/bubble/bubble_controller.h" | 10 #include "components/bubble/bubble_controller.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 BUBBLE_TYPE_MOCK = 1, // Used for testing. | 24 BUBBLE_TYPE_MOCK = 1, // Used for testing. |
25 | 25 |
26 // Extension-related bubbles: | 26 // Extension-related bubbles: |
27 BUBBLE_TYPE_EXTENSION_INSTALLED = 10, // Displayed after installing. | 27 BUBBLE_TYPE_EXTENSION_INSTALLED = 10, // Displayed after installing. |
28 | 28 |
29 // Translation-related bubbles: | 29 // Translation-related bubbles: |
30 BUBBLE_TYPE_TRANSLATE = 20, // Displays a request to translate a page. | 30 BUBBLE_TYPE_TRANSLATE = 20, // Displays a request to translate a page. |
31 | 31 |
32 // Permissions-related bubbles: | 32 // Permissions-related bubbles: |
33 BUBBLE_TYPE_PERMISSION = 30, // Displays a permission request to the user. | 33 BUBBLE_TYPE_PERMISSION = 30, // Displays a permission request to the user. |
34 BUBBLE_TYPE_CHOOSER_PERMISSION = 31, // For chooser permissions. | |
34 | 35 |
35 // Upper boundary for metrics. | 36 // Upper boundary for metrics. |
36 BUBBLE_TYPE_MAX, | 37 BUBBLE_TYPE_MAX, |
37 }; | 38 }; |
38 | 39 |
39 // Convert from bubble name to ID. The bubble ID will allow collecting the | 40 // Convert from bubble name to ID. The bubble ID will allow collecting the |
40 // close reason for each bubble type. | 41 // close reason for each bubble type. |
41 static int GetBubbleId(BubbleReference bubble) { | 42 static int GetBubbleId(BubbleReference bubble) { |
42 BubbleType bubble_type = BUBBLE_TYPE_UNKNOWN; | 43 BubbleType bubble_type = BUBBLE_TYPE_UNKNOWN; |
43 | 44 |
44 // Translate from bubble name to enum. | 45 // Translate from bubble name to enum. |
45 if (bubble->GetName().compare("MockBubble") == 0) | 46 if (bubble->GetName().compare("MockBubble") == 0) |
46 bubble_type = BUBBLE_TYPE_MOCK; | 47 bubble_type = BUBBLE_TYPE_MOCK; |
47 else if (bubble->GetName().compare("ExtensionInstalled") == 0) | 48 else if (bubble->GetName().compare("ExtensionInstalled") == 0) |
48 bubble_type = BUBBLE_TYPE_EXTENSION_INSTALLED; | 49 bubble_type = BUBBLE_TYPE_EXTENSION_INSTALLED; |
49 else if (bubble->GetName().compare("TranslateBubble") == 0) | 50 else if (bubble->GetName().compare("TranslateBubble") == 0) |
50 bubble_type = BUBBLE_TYPE_TRANSLATE; | 51 bubble_type = BUBBLE_TYPE_TRANSLATE; |
51 else if (bubble->GetName().compare("PermissionBubble") == 0) | 52 else if (bubble->GetName().compare("PermissionBubble") == 0) |
52 bubble_type = BUBBLE_TYPE_PERMISSION; | 53 bubble_type = BUBBLE_TYPE_PERMISSION; |
54 else if (bubble->GetName().compare("ChooserBubble") == 0) | |
sky
2015/12/10 00:32:47
I'm not familiar with this code. Where are the raw
juncai
2015/12/10 00:38:38
https://codereview.chromium.org/1408193003/diff/59
sky
2015/12/10 00:59:15
Problem with strings is it's easy to change the st
juncai
2015/12/10 01:06:54
Quoting from email from hcarmona@:
"The reason we
| |
55 bubble_type = BUBBLE_TYPE_CHOOSER_PERMISSION; | |
53 | 56 |
54 DCHECK_NE(bubble_type, BUBBLE_TYPE_UNKNOWN); | 57 DCHECK_NE(bubble_type, BUBBLE_TYPE_UNKNOWN); |
55 DCHECK_NE(bubble_type, BUBBLE_TYPE_MAX); | 58 DCHECK_NE(bubble_type, BUBBLE_TYPE_MAX); |
56 | 59 |
57 return bubble_type; | 60 return bubble_type; |
58 } | 61 } |
59 | 62 |
60 // Log the reason for closing this bubble. | 63 // Log the reason for closing this bubble. |
61 // Each reason is its own metric. Each histogram call MUST have a runtime | 64 // Each reason is its own metric. Each histogram call MUST have a runtime |
62 // constant value passed in for the title. | 65 // constant value passed in for the title. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 } | 154 } |
152 | 155 |
153 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleClosed( | 156 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleClosed( |
154 BubbleReference bubble, BubbleCloseReason reason) { | 157 BubbleReference bubble, BubbleCloseReason reason) { |
155 // Log the amount of time the bubble was visible. | 158 // Log the amount of time the bubble was visible. |
156 base::TimeDelta visible_time = bubble->GetVisibleTime(); | 159 base::TimeDelta visible_time = bubble->GetVisibleTime(); |
157 UMA_HISTOGRAM_LONG_TIMES("Bubbles.DisplayTime.All", visible_time); | 160 UMA_HISTOGRAM_LONG_TIMES("Bubbles.DisplayTime.All", visible_time); |
158 | 161 |
159 LogBubbleCloseReason(bubble, reason); | 162 LogBubbleCloseReason(bubble, reason); |
160 } | 163 } |
OLD | NEW |