Chromium Code Reviews| 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) |
|
Alexei Svitkine (slow)
2014/07/17 15:15:36
Nit: Add {}'s.
yao
2014/07/17 15:41:22
Done.
| |
| 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 } | |
| 168 #endif // defined(GOOGLE_CHROME_BUILD) | 166 #endif // defined(GOOGLE_CHROME_BUILD) |
| 169 | 167 |
| 170 Browser* browser = browser_observer->browser(); | 168 Browser* browser = browser_observer->browser(); |
| 171 | 169 |
| 172 if (!browser) { | 170 if (!browser) { |
| 173 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); | 171 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); |
| 174 return; | 172 return; |
| 175 } | 173 } |
| 176 | 174 |
| 177 views::View* anchor_view = | 175 views::View* anchor_view = |
| 178 BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu(); | 176 BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu(); |
| 179 content::WebContents* web_contents = | 177 content::WebContents* web_contents = |
| 180 browser->tab_strip_model()->GetActiveWebContents(); | 178 browser->tab_strip_model()->GetActiveWebContents(); |
| 181 | 179 |
| 182 if (!web_contents) { | 180 if (!web_contents) { |
| 183 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); | 181 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR); |
| 184 return; | 182 return; |
| 185 } | 183 } |
| 186 | 184 |
| 187 SessionCrashedBubbleView* crash_bubble = | 185 SessionCrashedBubbleView* crash_bubble = |
| 188 new SessionCrashedBubbleView(anchor_view, browser, web_contents, | 186 new SessionCrashedBubbleView(anchor_view, browser, web_contents, |
| 189 offer_uma_optin); | 187 offer_uma_optin); |
| 190 views::BubbleDelegateView::CreateBubble(crash_bubble)->Show(); | 188 views::BubbleDelegateView::CreateBubble(crash_bubble)->Show(); |
| 189 | |
| 191 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN); | 190 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN); |
| 191 if (uma_opted_in_already) | |
| 192 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN); | |
| 192 } | 193 } |
| 193 | 194 |
| 194 SessionCrashedBubbleView::SessionCrashedBubbleView( | 195 SessionCrashedBubbleView::SessionCrashedBubbleView( |
| 195 views::View* anchor_view, | 196 views::View* anchor_view, |
| 196 Browser* browser, | 197 Browser* browser, |
| 197 content::WebContents* web_contents, | 198 content::WebContents* web_contents, |
| 198 bool offer_uma_optin) | 199 bool offer_uma_optin) |
| 199 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 200 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 200 content::WebContentsObserver(web_contents), | 201 content::WebContentsObserver(web_contents), |
| 201 browser_(browser), | 202 browser_(browser), |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 | 276 |
| 276 layout->StartRow(0, kTextColumnSetId); | 277 layout->StartRow(0, kTextColumnSetId); |
| 277 layout->AddView(text_label); | 278 layout->AddView(text_label); |
| 278 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 279 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 279 | 280 |
| 280 layout->StartRow(0, kButtonColumnSetId); | 281 layout->StartRow(0, kButtonColumnSetId); |
| 281 layout->AddView(restore_button_); | 282 layout->AddView(restore_button_); |
| 282 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 283 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 283 | 284 |
| 284 // Metrics reporting option. | 285 // Metrics reporting option. |
| 285 if (offer_uma_optin_) | 286 if (offer_uma_optin_) { |
| 286 CreateUmaOptinView(layout); | 287 CreateUmaOptinView(layout); |
| 288 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN); | |
| 289 } | |
| 287 | 290 |
| 288 set_margins(gfx::Insets()); | 291 set_margins(gfx::Insets()); |
| 289 Layout(); | 292 Layout(); |
| 290 } | 293 } |
| 291 | 294 |
| 292 void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { | 295 void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { |
| 293 // Checkbox for metric reporting setting. | 296 // Checkbox for metric reporting setting. |
| 294 // Since the text to the right of the checkbox can't be a simple string (needs | 297 // 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, | 298 // 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. | 299 // 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(); | 432 GetWidget()->Close(); |
| 430 } | 433 } |
| 431 | 434 |
| 432 bool ShowSessionCrashedBubble(Browser* browser) { | 435 bool ShowSessionCrashedBubble(Browser* browser) { |
| 433 if (IsBubbleUIEnabled()) { | 436 if (IsBubbleUIEnabled()) { |
| 434 SessionCrashedBubbleView::Show(browser); | 437 SessionCrashedBubbleView::Show(browser); |
| 435 return true; | 438 return true; |
| 436 } | 439 } |
| 437 return false; | 440 return false; |
| 438 } | 441 } |
| OLD | NEW |