| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sad_tab.h" | 5 #include "chrome/browser/ui/sad_tab.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "chrome/browser/net/referrer.h" | 8 #include "chrome/browser/net/referrer.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/chrome_pages.h" | 10 #include "chrome/browser/ui/chrome_pages.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void RecordEvent(bool feedback, SadTabEvent event) { | 46 void RecordEvent(bool feedback, SadTabEvent event) { |
| 47 if (feedback) { | 47 if (feedback) { |
| 48 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Feedback.Event", event, | 48 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Feedback.Event", event, |
| 49 SadTabEvent::MAX_SAD_TAB_EVENT); | 49 SadTabEvent::MAX_SAD_TAB_EVENT); |
| 50 } else { | 50 } else { |
| 51 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Reload.Event", event, | 51 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Reload.Event", event, |
| 52 SadTabEvent::MAX_SAD_TAB_EVENT); | 52 SadTabEvent::MAX_SAD_TAB_EVENT); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 const char kCategoryTagCrash[] = "Crash"; | 56 constexpr char kCategoryTagCrash[] = "Crash"; |
| 57 | 57 |
| 58 bool ShouldShowFeedbackButton() { | 58 bool ShouldShowFeedbackButton() { |
| 59 #if defined(GOOGLE_CHROME_BUILD) | 59 #if defined(GOOGLE_CHROME_BUILD) |
| 60 const int kCrashesBeforeFeedbackIsDisplayed = 1; | 60 const int kCrashesBeforeFeedbackIsDisplayed = 1; |
| 61 | 61 |
| 62 static int total_crashes = 0; | 62 static int total_crashes = 0; |
| 63 return ++total_crashes > kCrashesBeforeFeedbackIsDisplayed; | 63 return ++total_crashes > kCrashesBeforeFeedbackIsDisplayed; |
| 64 #else | 64 #else |
| 65 return false; | 65 return false; |
| 66 #endif | 66 #endif |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 RecordEvent(show_feedback_button_, SadTabEvent::DISPLAYED); | 152 RecordEvent(show_feedback_button_, SadTabEvent::DISPLAYED); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void SadTab::PerformAction(SadTab::Action action) { | 155 void SadTab::PerformAction(SadTab::Action action) { |
| 156 DCHECK(recorded_paint_); | 156 DCHECK(recorded_paint_); |
| 157 switch (action) { | 157 switch (action) { |
| 158 case Action::BUTTON: | 158 case Action::BUTTON: |
| 159 RecordEvent(show_feedback_button_, SadTabEvent::BUTTON_CLICKED); | 159 RecordEvent(show_feedback_button_, SadTabEvent::BUTTON_CLICKED); |
| 160 if (show_feedback_button_) { | 160 if (show_feedback_button_) { |
| 161 chrome::ShowFeedbackPage( | 161 ShowFeedbackPage( |
| 162 chrome::FindBrowserWithWebContents(web_contents_), | 162 FindBrowserWithWebContents(web_contents_), |
| 163 l10n_util::GetStringUTF8(kind_ == chrome::SAD_TAB_KIND_CRASHED | 163 kFeedbackSourceSadTabPage, |
| 164 l10n_util::GetStringUTF8(kind_ == SAD_TAB_KIND_CRASHED |
| 164 ? IDS_CRASHED_TAB_FEEDBACK_MESSAGE | 165 ? IDS_CRASHED_TAB_FEEDBACK_MESSAGE |
| 165 : IDS_KILLED_TAB_FEEDBACK_MESSAGE), | 166 : IDS_KILLED_TAB_FEEDBACK_MESSAGE), |
| 166 std::string(kCategoryTagCrash)); | 167 std::string(kCategoryTagCrash)); |
| 167 } else { | 168 } else { |
| 168 web_contents_->GetController().Reload(content::ReloadType::NORMAL, | 169 web_contents_->GetController().Reload(content::ReloadType::NORMAL, |
| 169 true); | 170 true); |
| 170 } | 171 } |
| 171 break; | 172 break; |
| 172 case Action::HELP_LINK: | 173 case Action::HELP_LINK: |
| 173 RecordEvent(show_feedback_button_, SadTabEvent::HELP_LINK_CLICKED); | 174 RecordEvent(show_feedback_button_, SadTabEvent::HELP_LINK_CLICKED); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 203 // Fall through | 204 // Fall through |
| 204 case chrome::SAD_TAB_KIND_KILLED: | 205 case chrome::SAD_TAB_KIND_KILLED: |
| 205 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated"); | 206 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated"); |
| 206 LOG(WARNING) << "Tab Killed: " | 207 LOG(WARNING) << "Tab Killed: " |
| 207 << web_contents->GetURL().GetOrigin().spec(); | 208 << web_contents->GetURL().GetOrigin().spec(); |
| 208 break; | 209 break; |
| 209 } | 210 } |
| 210 } | 211 } |
| 211 | 212 |
| 212 } // namespace chrome | 213 } // namespace chrome |
| OLD | NEW |