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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // static | 146 // static |
147 bool SessionCrashedBubble::Show(Browser* browser) { | 147 bool SessionCrashedBubble::Show(Browser* browser) { |
148 if (!IsBubbleUIEnabled()) | 148 if (!IsBubbleUIEnabled()) |
149 return false; | 149 return false; |
150 | 150 |
151 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 151 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
152 if (browser->profile()->IsOffTheRecord()) | 152 if (browser->profile()->IsOffTheRecord()) |
153 return true; | 153 return true; |
154 | 154 |
155 // Observes browser removal event and will be deallocated in ShowForReal. | 155 // Observes browser removal event and will be deallocated in ShowForReal. |
156 scoped_ptr<SessionCrashedBubbleView::BrowserRemovalObserver> browser_observer( | 156 std::unique_ptr<SessionCrashedBubbleView::BrowserRemovalObserver> |
157 new SessionCrashedBubbleView::BrowserRemovalObserver(browser)); | 157 browser_observer( |
| 158 new SessionCrashedBubbleView::BrowserRemovalObserver(browser)); |
158 | 159 |
159 // Stats collection only applies to Google Chrome builds. | 160 // Stats collection only applies to Google Chrome builds. |
160 #if defined(GOOGLE_CHROME_BUILD) | 161 #if defined(GOOGLE_CHROME_BUILD) |
161 // Schedule a task to run GoogleUpdateSettings::GetCollectStatsConsent() on | 162 // Schedule a task to run GoogleUpdateSettings::GetCollectStatsConsent() on |
162 // FILE thread, since it does IO. Then, call | 163 // FILE thread, since it does IO. Then, call |
163 // SessionCrashedBubbleView::ShowForReal with the result. | 164 // SessionCrashedBubbleView::ShowForReal with the result. |
164 content::BrowserThread::PostTaskAndReplyWithResult( | 165 content::BrowserThread::PostTaskAndReplyWithResult( |
165 content::BrowserThread::FILE, | 166 content::BrowserThread::FILE, |
166 FROM_HERE, | 167 FROM_HERE, |
167 base::Bind(&GoogleUpdateSettings::GetCollectStatsConsent), | 168 base::Bind(&GoogleUpdateSettings::GetCollectStatsConsent), |
168 base::Bind(&SessionCrashedBubbleView::ShowForReal, | 169 base::Bind(&SessionCrashedBubbleView::ShowForReal, |
169 base::Passed(&browser_observer))); | 170 base::Passed(&browser_observer))); |
170 #else | 171 #else |
171 SessionCrashedBubbleView::ShowForReal(std::move(browser_observer), false); | 172 SessionCrashedBubbleView::ShowForReal(std::move(browser_observer), false); |
172 #endif // defined(GOOGLE_CHROME_BUILD) | 173 #endif // defined(GOOGLE_CHROME_BUILD) |
173 | 174 |
174 return true; | 175 return true; |
175 } | 176 } |
176 | 177 |
177 // static | 178 // static |
178 void SessionCrashedBubbleView::ShowForReal( | 179 void SessionCrashedBubbleView::ShowForReal( |
179 scoped_ptr<BrowserRemovalObserver> browser_observer, | 180 std::unique_ptr<BrowserRemovalObserver> browser_observer, |
180 bool uma_opted_in_already) { | 181 bool uma_opted_in_already) { |
181 // Determine whether or not the UMA opt-in option should be offered. It is | 182 // Determine whether or not the UMA opt-in option should be offered. It is |
182 // offered only when it is a Google chrome build, user hasn't opted in yet, | 183 // offered only when it is a Google chrome build, user hasn't opted in yet, |
183 // and the preference is modifiable by the user. | 184 // and the preference is modifiable by the user. |
184 bool offer_uma_optin = false; | 185 bool offer_uma_optin = false; |
185 | 186 |
186 #if defined(GOOGLE_CHROME_BUILD) | 187 #if defined(GOOGLE_CHROME_BUILD) |
187 if (!uma_opted_in_already) { | 188 if (!uma_opted_in_already) { |
188 offer_uma_optin = | 189 offer_uma_optin = |
189 g_browser_process->local_state() | 190 g_browser_process->local_state() |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if (uma_option_ && uma_option_->checked()) { | 413 if (uma_option_ && uma_option_->checked()) { |
413 InitiateMetricsReportingChange(true, OnMetricsReportingCallbackType()); | 414 InitiateMetricsReportingChange(true, OnMetricsReportingCallbackType()); |
414 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_UMA_OPTIN); | 415 RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_UMA_OPTIN); |
415 } | 416 } |
416 CloseBubble(); | 417 CloseBubble(); |
417 } | 418 } |
418 | 419 |
419 void SessionCrashedBubbleView::CloseBubble() { | 420 void SessionCrashedBubbleView::CloseBubble() { |
420 GetWidget()->Close(); | 421 GetWidget()->Close(); |
421 } | 422 } |
OLD | NEW |