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/command_line.h" | |
| 10 #include "base/metrics/field_trial.h" | |
| 9 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/sessions/session_restore.h" | 14 #include "chrome/browser/sessions/session_restore.h" |
| 13 #include "chrome/browser/ui/options/options_util.h" | 15 #include "chrome/browser/ui/options/options_util.h" |
| 14 #include "chrome/browser/ui/startup/session_crashed_bubble.h" | 16 #include "chrome/browser/ui/startup/session_crashed_bubble.h" |
| 15 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 17 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 21 #include "chrome/common/chrome_switches.h" | |
| 19 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 21 #include "chrome/installer/util/google_update_settings.h" | 24 #include "chrome/installer/util/google_update_settings.h" |
| 22 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
| 23 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 24 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 25 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 26 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 27 #include "grit/google_chrome_strings.h" | 30 #include "grit/google_chrome_strings.h" |
| 28 #include "grit/ui_resources.h" | 31 #include "grit/ui_resources.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 49 | 52 |
| 50 // Margins width for the top rows to compensate for the bottom panel for which | 53 // Margins width for the top rows to compensate for the bottom panel for which |
| 51 // we don't want any margin. | 54 // we don't want any margin. |
| 52 const int kMarginWidth = 12; | 55 const int kMarginWidth = 12; |
| 53 const int kMarginHeight = kMarginWidth; | 56 const int kMarginHeight = kMarginWidth; |
| 54 | 57 |
| 55 // The color of the background of the sub panel to offer UMA optin. | 58 // The color of the background of the sub panel to offer UMA optin. |
| 56 const SkColor kLightGrayBackgroundColor = 0xFFF0F0F0; | 59 const SkColor kLightGrayBackgroundColor = 0xFFF0F0F0; |
| 57 const SkColor kWhiteBackgroundColor = 0xFFFFFFFF; | 60 const SkColor kWhiteBackgroundColor = 0xFFFFFFFF; |
| 58 | 61 |
| 62 // The Finch study name and group name that enables session crashed bubble UI. | |
| 63 const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI"; | |
| 64 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; | |
| 65 | |
| 59 bool ShouldOfferMetricsReporting() { | 66 bool ShouldOfferMetricsReporting() { |
| 60 // Stats collection only applies to Google Chrome builds. | 67 // Stats collection only applies to Google Chrome builds. |
| 61 #if defined(GOOGLE_CHROME_BUILD) | 68 #if defined(GOOGLE_CHROME_BUILD) |
| 62 // Only show metrics reporting option if user didn't already consent to it. | 69 // Only show metrics reporting option if user didn't already consent to it. |
| 63 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 70 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
| 64 return false; | 71 return false; |
| 65 return g_browser_process->local_state()->FindPreference( | 72 return g_browser_process->local_state()->FindPreference( |
| 66 prefs::kMetricsReportingEnabled)->IsUserModifiable(); | 73 prefs::kMetricsReportingEnabled)->IsUserModifiable(); |
| 67 #else | 74 #else |
| 68 return false; | 75 return false; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 g_browser_process->local_state()->SetBoolean( | 344 g_browser_process->local_state()->SetBoolean( |
| 338 prefs::kMetricsReportingEnabled, true); | 345 prefs::kMetricsReportingEnabled, true); |
| 339 } | 346 } |
| 340 CloseBubble(); | 347 CloseBubble(); |
| 341 } | 348 } |
| 342 | 349 |
| 343 void SessionCrashedBubbleView::CloseBubble() { | 350 void SessionCrashedBubbleView::CloseBubble() { |
| 344 GetWidget()->Close(); | 351 GetWidget()->Close(); |
| 345 } | 352 } |
| 346 | 353 |
| 347 bool ShowSessionCrashedBubble(Browser* browser) { | 354 bool ShowSessionCrashedBubble(Browser* browser, |
| 348 SessionCrashedBubbleView::Show(browser); | 355 const base::CommandLine& command_line) { |
|
Alexei Svitkine (slow)
2014/05/15 22:52:27
I don't think you need this param. You can just do
yao
2014/05/16 00:48:25
I can't until the other CL (with posttask schedule
Alexei Svitkine (slow)
2014/05/16 19:01:40
I think you can just wait for the other CL to land
yao
2014/05/26 21:36:50
Done.
| |
| 349 return true; | 356 // If user disables the bubble UI explicitly, don't show it. If not, the |
| 357 // bubble UI can be enabled by Finch experiment or by flag. | |
| 358 if (command_line.HasSwitch(switches::kDisableSessionCrashedBubble)) { | |
| 359 return false; | |
|
Alexei Svitkine (slow)
2014/05/16 19:01:40
No need for else or {}'s if you're doing a return
yao
2014/05/26 21:36:50
Done.
| |
| 360 } else if (base::FieldTrialList::FindFullName(kEnableBubbleUIFinchName) == | |
|
Alexei Svitkine (slow)
2014/05/16 19:01:40
The best practice for this is to get the group fir
yao
2014/05/26 21:36:50
Done.
| |
| 361 kEnableBubbleUIGroupEnabled || | |
| 362 command_line.HasSwitch(switches::kEnableSessionCrashedBubble)) { | |
| 363 SessionCrashedBubbleView::Show(browser); | |
| 364 return true; | |
| 365 } | |
| 366 return false; | |
| 350 } | 367 } |
| OLD | NEW |