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 "chrome/browser/ui/views/session_crashed_bubble_view.h" | 5 #include "chrome/browser/ui/views/session_crashed_bubble_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; | 67 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; |
68 | 68 |
69 enum SessionCrashedBubbleHistogramValue { | 69 enum SessionCrashedBubbleHistogramValue { |
70 SESSION_CRASHED_BUBBLE_SHOWN, | 70 SESSION_CRASHED_BUBBLE_SHOWN, |
71 SESSION_CRASHED_BUBBLE_ERROR, | 71 SESSION_CRASHED_BUBBLE_ERROR, |
72 SESSION_CRASHED_BUBBLE_RESTORED, | 72 SESSION_CRASHED_BUBBLE_RESTORED, |
73 SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN, | 73 SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN, |
74 SESSION_CRASHED_BUBBLE_UMA_OPTIN, | 74 SESSION_CRASHED_BUBBLE_UMA_OPTIN, |
75 SESSION_CRASHED_BUBBLE_HELP, | 75 SESSION_CRASHED_BUBBLE_HELP, |
76 SESSION_CRASHED_BUBBLE_IGNORED, | 76 SESSION_CRASHED_BUBBLE_IGNORED, |
| 77 SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN, |
77 SESSION_CRASHED_BUBBLE_MAX, | 78 SESSION_CRASHED_BUBBLE_MAX, |
78 }; | 79 }; |
79 | 80 |
80 void RecordBubbleHistogramValue(SessionCrashedBubbleHistogramValue value) { | 81 void RecordBubbleHistogramValue(SessionCrashedBubbleHistogramValue value) { |
81 UMA_HISTOGRAM_ENUMERATION( | 82 UMA_HISTOGRAM_ENUMERATION( |
82 "SessionCrashed.Bubble", value, SESSION_CRASHED_BUBBLE_MAX); | 83 "SessionCrashed.Bubble", value, SESSION_CRASHED_BUBBLE_MAX); |
83 } | 84 } |
84 | 85 |
85 // Whether or not the bubble UI should be used. | 86 // Whether or not the bubble UI should be used. |
86 bool IsBubbleUIEnabled() { | 87 bool IsBubbleUIEnabled() { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // static | 153 // static |
153 void SessionCrashedBubbleView::ShowForReal( | 154 void SessionCrashedBubbleView::ShowForReal( |
154 scoped_ptr<BrowserRemovalObserver> browser_observer, | 155 scoped_ptr<BrowserRemovalObserver> browser_observer, |
155 bool uma_opted_in_already) { | 156 bool uma_opted_in_already) { |
156 // Determine whether or not the uma opt-in option should be offered. It is | 157 // Determine whether or not the uma opt-in option should be offered. It is |
157 // offered only when it is a Google chrome build, user hasn't opted in yet, | 158 // offered only when it is a Google chrome build, user hasn't opted in yet, |
158 // and the preference is modifiable by the user. | 159 // and the preference is modifiable by the user. |
159 bool offer_uma_optin = false; | 160 bool offer_uma_optin = false; |
160 | 161 |
161 #if defined(GOOGLE_CHROME_BUILD) | 162 #if defined(GOOGLE_CHROME_BUILD) |
162 if (uma_opted_in_already) { | 163 if (!uma_opted_in_already) { |
163 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN); | |
164 } else { | |
165 offer_uma_optin = g_browser_process->local_state()->FindPreference( | 164 offer_uma_optin = g_browser_process->local_state()->FindPreference( |
166 prefs::kMetricsReportingEnabled)->IsUserModifiable(); | 165 prefs::kMetricsReportingEnabled)->IsUserModifiable(); |
167 } | 166 } |
168 #endif // defined(GOOGLE_CHROME_BUILD) | 167 #endif // defined(GOOGLE_CHROME_BUILD) |
169 | 168 |
170 Browser* browser = browser_observer->browser(); | 169 Browser* browser = browser_observer->browser(); |
171 | 170 |
172 if (!browser) { | 171 if (!browser) { |
173 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); | 172 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); |
174 return; | 173 return; |
175 } | 174 } |
176 | 175 |
177 views::View* anchor_view = | 176 views::View* anchor_view = |
178 BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu(); | 177 BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu(); |
179 content::WebContents* web_contents = | 178 content::WebContents* web_contents = |
180 browser->tab_strip_model()->GetActiveWebContents(); | 179 browser->tab_strip_model()->GetActiveWebContents(); |
181 | 180 |
182 if (!web_contents) { | 181 if (!web_contents) { |
183 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); | 182 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); |
184 return; | 183 return; |
185 } | 184 } |
186 | 185 |
187 SessionCrashedBubbleView* crash_bubble = | 186 SessionCrashedBubbleView* crash_bubble = |
188 new SessionCrashedBubbleView(anchor_view, browser, web_contents, | 187 new SessionCrashedBubbleView(anchor_view, browser, web_contents, |
189 offer_uma_optin); | 188 offer_uma_optin); |
190 views::BubbleDelegateView::CreateBubble(crash_bubble)->Show(); | 189 views::BubbleDelegateView::CreateBubble(crash_bubble)->Show(); |
| 190 |
191 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN); | 191 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN); |
| 192 if (uma_opted_in_already) |
| 193 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN); |
192 } | 194 } |
193 | 195 |
194 SessionCrashedBubbleView::SessionCrashedBubbleView( | 196 SessionCrashedBubbleView::SessionCrashedBubbleView( |
195 views::View* anchor_view, | 197 views::View* anchor_view, |
196 Browser* browser, | 198 Browser* browser, |
197 content::WebContents* web_contents, | 199 content::WebContents* web_contents, |
198 bool offer_uma_optin) | 200 bool offer_uma_optin) |
199 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 201 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
200 content::WebContentsObserver(web_contents), | 202 content::WebContentsObserver(web_contents), |
201 browser_(browser), | 203 browser_(browser), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 277 |
276 layout->StartRow(0, kTextColumnSetId); | 278 layout->StartRow(0, kTextColumnSetId); |
277 layout->AddView(text_label); | 279 layout->AddView(text_label); |
278 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 280 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
279 | 281 |
280 layout->StartRow(0, kButtonColumnSetId); | 282 layout->StartRow(0, kButtonColumnSetId); |
281 layout->AddView(restore_button_); | 283 layout->AddView(restore_button_); |
282 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 284 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
283 | 285 |
284 // Metrics reporting option. | 286 // Metrics reporting option. |
285 if (offer_uma_optin_) | 287 if (offer_uma_optin_) { |
286 CreateUmaOptinView(layout); | 288 CreateUmaOptinView(layout); |
| 289 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN); |
| 290 } |
287 | 291 |
288 set_margins(gfx::Insets()); | 292 set_margins(gfx::Insets()); |
289 Layout(); | 293 Layout(); |
290 } | 294 } |
291 | 295 |
292 void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { | 296 void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { |
293 // Checkbox for metric reporting setting. | 297 // Checkbox for metric reporting setting. |
294 // Since the text to the right of the checkbox can't be a simple string (needs | 298 // Since the text to the right of the checkbox can't be a simple string (needs |
295 // a hyperlink in it), this checkbox contains an empty string as its label, | 299 // a hyperlink in it), this checkbox contains an empty string as its label, |
296 // and the real text will be added as a separate view. | 300 // and the real text will be added as a separate view. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 GetWidget()->Close(); | 433 GetWidget()->Close(); |
430 } | 434 } |
431 | 435 |
432 bool ShowSessionCrashedBubble(Browser* browser) { | 436 bool ShowSessionCrashedBubble(Browser* browser) { |
433 if (IsBubbleUIEnabled()) { | 437 if (IsBubbleUIEnabled()) { |
434 SessionCrashedBubbleView::Show(browser); | 438 SessionCrashedBubbleView::Show(browser); |
435 return true; | 439 return true; |
436 } | 440 } |
437 return false; | 441 return false; |
438 } | 442 } |
OLD | NEW |