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" |
| 11 #include "base/command_line.h" | |
| 12 #include "base/metrics/field_trial.h" | |
| 11 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/sessions/session_restore.h" | 16 #include "chrome/browser/sessions/session_restore.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/browser_list_observer.h" | 18 #include "chrome/browser/ui/browser_list_observer.h" |
| 17 #include "chrome/browser/ui/options/options_util.h" | 19 #include "chrome/browser/ui/options/options_util.h" |
| 18 #include "chrome/browser/ui/startup/session_crashed_bubble.h" | 20 #include "chrome/browser/ui/startup/session_crashed_bubble.h" |
| 19 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 21 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/browser/ui/views/frame/browser_view.h" | 23 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 22 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 24 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 25 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 25 #include "chrome/installer/util/google_update_settings.h" | 28 #include "chrome/installer/util/google_update_settings.h" |
| 26 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| 27 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
| 29 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 30 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 31 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 32 #include "grit/google_chrome_strings.h" | 35 #include "grit/google_chrome_strings.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 54 | 57 |
| 55 // Margins width for the top rows to compensate for the bottom panel for which | 58 // Margins width for the top rows to compensate for the bottom panel for which |
| 56 // we don't want any margin. | 59 // we don't want any margin. |
| 57 const int kMarginWidth = 12; | 60 const int kMarginWidth = 12; |
| 58 const int kMarginHeight = kMarginWidth; | 61 const int kMarginHeight = kMarginWidth; |
| 59 | 62 |
| 60 // The color of the background of the sub panel to offer UMA optin. | 63 // The color of the background of the sub panel to offer UMA optin. |
| 61 const SkColor kLightGrayBackgroundColor = 0xFFF0F0F0; | 64 const SkColor kLightGrayBackgroundColor = 0xFFF0F0F0; |
| 62 const SkColor kWhiteBackgroundColor = 0xFFFFFFFF; | 65 const SkColor kWhiteBackgroundColor = 0xFFFFFFFF; |
| 63 | 66 |
| 67 // The Finch study name and group name that enables session crashed bubble UI. | |
| 68 const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI"; | |
| 69 const char kEnableBubbleUIGroupEnabled[] = "Enabled"; | |
| 70 | |
| 64 bool ShouldOfferMetricsReporting() { | 71 bool ShouldOfferMetricsReporting() { |
| 65 // Stats collection only applies to Google Chrome builds. | 72 // Stats collection only applies to Google Chrome builds. |
| 66 #if defined(GOOGLE_CHROME_BUILD) | 73 #if defined(GOOGLE_CHROME_BUILD) |
| 67 // Only show metrics reporting option if user didn't already consent to it. | 74 // Only show metrics reporting option if user didn't already consent to it. |
| 68 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 75 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
| 69 return false; | 76 return false; |
| 70 return g_browser_process->local_state()->FindPreference( | 77 return g_browser_process->local_state()->FindPreference( |
| 71 prefs::kMetricsReportingEnabled)->IsUserModifiable(); | 78 prefs::kMetricsReportingEnabled)->IsUserModifiable(); |
| 72 #else | 79 #else |
| 73 return false; | 80 return false; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 prefs::kMetricsReportingEnabled, true); | 417 prefs::kMetricsReportingEnabled, true); |
| 411 } | 418 } |
| 412 CloseBubble(); | 419 CloseBubble(); |
| 413 } | 420 } |
| 414 | 421 |
| 415 void SessionCrashedBubbleView::CloseBubble() { | 422 void SessionCrashedBubbleView::CloseBubble() { |
| 416 GetWidget()->Close(); | 423 GetWidget()->Close(); |
| 417 } | 424 } |
| 418 | 425 |
| 419 bool ShowSessionCrashedBubble(Browser* browser) { | 426 bool ShowSessionCrashedBubble(Browser* browser) { |
| 420 SessionCrashedBubbleView::Show(browser); | 427 // If user disables the bubble UI explicitly, don't show it. If not, the |
| 421 return true; | 428 // bubble UI can be enabled by Finch experiment or by flag. |
| 429 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 430 switches::kDisableSessionCrashedBubble)) | |
| 431 return false; | |
| 432 const std::string group_name = base::FieldTrialList::FindFullName( | |
| 433 kEnableBubbleUIFinchName); | |
| 434 if (group_name == kEnableBubbleUIGroupEnabled || | |
| 435 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 436 switches::kEnableSessionCrashedBubble)) { | |
| 437 SessionCrashedBubbleView::Show(browser); | |
| 438 return true; | |
| 439 } | |
| 440 return false; | |
|
Alexei Svitkine (slow)
2014/05/27 15:42:46
Please follow the pattern suggested on the "Best P
yao
2014/05/27 16:42:01
Done.
| |
| 422 } | 441 } |
| OLD | NEW |