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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return; | 90 return; |
91 case BUBBLE_CLOSE_FULLSCREEN_TOGGLED: | 91 case BUBBLE_CLOSE_FULLSCREEN_TOGGLED: |
92 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.FullscreenToggled", bubble_id); | 92 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.FullscreenToggled", bubble_id); |
93 return; | 93 return; |
94 case BUBBLE_CLOSE_ACCEPTED: | 94 case BUBBLE_CLOSE_ACCEPTED: |
95 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.Accepted", bubble_id); | 95 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.Accepted", bubble_id); |
96 return; | 96 return; |
97 case BUBBLE_CLOSE_CANCELED: | 97 case BUBBLE_CLOSE_CANCELED: |
98 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.Canceled", bubble_id); | 98 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.Canceled", bubble_id); |
99 return; | 99 return; |
| 100 case BUBBLE_CLOSE_FRAME_DESTROYED: |
| 101 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.Close.FrameDestroyed", bubble_id); |
| 102 return; |
100 } | 103 } |
101 | 104 |
102 NOTREACHED(); | 105 NOTREACHED(); |
103 } | 106 } |
104 | 107 |
105 } // namespace | 108 } // namespace |
106 | 109 |
107 ChromeBubbleManager::ChromeBubbleManager(TabStripModel* tab_strip_model) | 110 ChromeBubbleManager::ChromeBubbleManager(TabStripModel* tab_strip_model) |
108 : tab_strip_model_(tab_strip_model) { | 111 : tab_strip_model_(tab_strip_model) { |
109 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 112 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
(...skipping 22 matching lines...) Expand all Loading... |
132 CloseAllBubbles(BUBBLE_CLOSE_TABSWITCHED); | 135 CloseAllBubbles(BUBBLE_CLOSE_TABSWITCHED); |
133 } | 136 } |
134 | 137 |
135 void ChromeBubbleManager::ActiveTabChanged(content::WebContents* old_contents, | 138 void ChromeBubbleManager::ActiveTabChanged(content::WebContents* old_contents, |
136 content::WebContents* new_contents, | 139 content::WebContents* new_contents, |
137 int index, | 140 int index, |
138 int reason) { | 141 int reason) { |
139 Observe(new_contents); | 142 Observe(new_contents); |
140 } | 143 } |
141 | 144 |
| 145 void ChromeBubbleManager::FrameDeleted( |
| 146 content::RenderFrameHost* render_frame_host) { |
| 147 // When a frame is destroyed, bubbles spawned by that frame should default to |
| 148 // being closed, so that they can't traverse any references they hold to the |
| 149 // destroyed frame. |
| 150 CloseAllBubbles(BUBBLE_CLOSE_FRAME_DESTROYED); |
| 151 } |
| 152 |
142 void ChromeBubbleManager::DidToggleFullscreenModeForTab( | 153 void ChromeBubbleManager::DidToggleFullscreenModeForTab( |
143 bool entered_fullscreen) { | 154 bool entered_fullscreen) { |
144 CloseAllBubbles(BUBBLE_CLOSE_FULLSCREEN_TOGGLED); | 155 CloseAllBubbles(BUBBLE_CLOSE_FULLSCREEN_TOGGLED); |
145 // Any bubble that didn't close should update its anchor position. | 156 // Any bubble that didn't close should update its anchor position. |
146 UpdateAllBubbleAnchors(); | 157 UpdateAllBubbleAnchors(); |
147 } | 158 } |
148 | 159 |
149 void ChromeBubbleManager::NavigationEntryCommitted( | 160 void ChromeBubbleManager::NavigationEntryCommitted( |
150 const content::LoadCommittedDetails& load_details) { | 161 const content::LoadCommittedDetails& load_details) { |
151 CloseAllBubbles(BUBBLE_CLOSE_NAVIGATED); | 162 CloseAllBubbles(BUBBLE_CLOSE_NAVIGATED); |
152 } | 163 } |
153 | 164 |
154 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleNeverShown( | 165 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleNeverShown( |
155 BubbleReference bubble) { | 166 BubbleReference bubble) { |
156 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.NeverShown", GetBubbleId(bubble)); | 167 UMA_HISTOGRAM_SPARSE_SLOWLY("Bubbles.NeverShown", GetBubbleId(bubble)); |
157 } | 168 } |
158 | 169 |
159 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleClosed( | 170 void ChromeBubbleManager::ChromeBubbleMetrics::OnBubbleClosed( |
160 BubbleReference bubble, BubbleCloseReason reason) { | 171 BubbleReference bubble, BubbleCloseReason reason) { |
161 // Log the amount of time the bubble was visible. | 172 // Log the amount of time the bubble was visible. |
162 base::TimeDelta visible_time = bubble->GetVisibleTime(); | 173 base::TimeDelta visible_time = bubble->GetVisibleTime(); |
163 UMA_HISTOGRAM_LONG_TIMES("Bubbles.DisplayTime.All", visible_time); | 174 UMA_HISTOGRAM_LONG_TIMES("Bubbles.DisplayTime.All", visible_time); |
164 | 175 |
165 LogBubbleCloseReason(bubble, reason); | 176 LogBubbleCloseReason(bubble, reason); |
166 } | 177 } |
OLD | NEW |