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 |
| 40 // TODO(juncai): Since LogBubbleCloseReason function adds metrics for each |
| 41 // close type, we can use only enum, and it may not be necessary to keep the |
| 42 // bubble name. |
39 // Convert from bubble name to ID. The bubble ID will allow collecting the | 43 // Convert from bubble name to ID. The bubble ID will allow collecting the |
40 // close reason for each bubble type. | 44 // close reason for each bubble type. |
41 static int GetBubbleId(BubbleReference bubble) { | 45 static int GetBubbleId(BubbleReference bubble) { |
42 BubbleType bubble_type = BUBBLE_TYPE_UNKNOWN; | 46 BubbleType bubble_type = BUBBLE_TYPE_UNKNOWN; |
43 | 47 |
44 // Translate from bubble name to enum. | 48 // Translate from bubble name to enum. |
45 if (bubble->GetName().compare("MockBubble") == 0) | 49 if (bubble->GetName().compare("MockBubble") == 0) |
46 bubble_type = BUBBLE_TYPE_MOCK; | 50 bubble_type = BUBBLE_TYPE_MOCK; |
47 else if (bubble->GetName().compare("ExtensionInstalled") == 0) | 51 else if (bubble->GetName().compare("ExtensionInstalled") == 0) |
48 bubble_type = BUBBLE_TYPE_EXTENSION_INSTALLED; | 52 bubble_type = BUBBLE_TYPE_EXTENSION_INSTALLED; |
49 else if (bubble->GetName().compare("TranslateBubble") == 0) | 53 else if (bubble->GetName().compare("TranslateBubble") == 0) |
50 bubble_type = BUBBLE_TYPE_TRANSLATE; | 54 bubble_type = BUBBLE_TYPE_TRANSLATE; |
51 else if (bubble->GetName().compare("PermissionBubble") == 0) | 55 else if (bubble->GetName().compare("PermissionBubble") == 0) |
52 bubble_type = BUBBLE_TYPE_PERMISSION; | 56 bubble_type = BUBBLE_TYPE_PERMISSION; |
| 57 else if (bubble->GetName().compare("ChooserBubble") == 0) |
| 58 bubble_type = BUBBLE_TYPE_CHOOSER_PERMISSION; |
53 | 59 |
54 DCHECK_NE(bubble_type, BUBBLE_TYPE_UNKNOWN); | 60 DCHECK_NE(bubble_type, BUBBLE_TYPE_UNKNOWN); |
55 DCHECK_NE(bubble_type, BUBBLE_TYPE_MAX); | 61 DCHECK_NE(bubble_type, BUBBLE_TYPE_MAX); |
56 | 62 |
57 return bubble_type; | 63 return bubble_type; |
58 } | 64 } |
59 | 65 |
60 // Log the reason for closing this bubble. | 66 // Log the reason for closing this bubble. |
61 // Each reason is its own metric. Each histogram call MUST have a runtime | 67 // Each reason is its own metric. Each histogram call MUST have a runtime |
62 // constant value passed in for the title. | 68 // constant value passed in for the title. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 157 } |
152 | 158 |
153 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleClosed( | 159 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleClosed( |
154 BubbleReference bubble, BubbleCloseReason reason) { | 160 BubbleReference bubble, BubbleCloseReason reason) { |
155 // Log the amount of time the bubble was visible. | 161 // Log the amount of time the bubble was visible. |
156 base::TimeDelta visible_time = bubble->GetVisibleTime(); | 162 base::TimeDelta visible_time = bubble->GetVisibleTime(); |
157 UMA_HISTOGRAM_LONG_TIMES("Bubbles.DisplayTime.All", visible_time); | 163 UMA_HISTOGRAM_LONG_TIMES("Bubbles.DisplayTime.All", visible_time); |
158 | 164 |
159 LogBubbleCloseReason(bubble, reason); | 165 LogBubbleCloseReason(bubble, reason); |
160 } | 166 } |
OLD | NEW |