OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bug_report_util.h" | 5 #include "chrome/browser/bug_report_util.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/win/windows_version.h" |
16 #include "chrome/browser/browser_process_impl.h" | 17 #include "chrome/browser/browser_process_impl.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/chrome_version_info.h" | 22 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/net/url_fetcher.h" | 23 #include "chrome/common/net/url_fetcher.h" |
23 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (previous_delay_) { | 129 if (previous_delay_) { |
129 if (previous_delay_ < kRetryDelayLimit) | 130 if (previous_delay_ < kRetryDelayLimit) |
130 previous_delay_ *= kRetryDelayIncreaseFactor; | 131 previous_delay_ *= kRetryDelayIncreaseFactor; |
131 } else { | 132 } else { |
132 previous_delay_ = kInitialRetryDelay; | 133 previous_delay_ = kInitialRetryDelay; |
133 } | 134 } |
134 BugReportUtil::DispatchFeedback(profile_, post_body_, previous_delay_); | 135 BugReportUtil::DispatchFeedback(profile_, post_body_, previous_delay_); |
135 | 136 |
136 // Process the error for debug output | 137 // Process the error for debug output |
137 if (response_code == kHttpPostFailNoConnection) { | 138 if (response_code == kHttpPostFailNoConnection) { |
138 error_stream << "No connection to server."; | 139 error_stream << "No connection to server."; |
139 } else if ((response_code > kHttpPostFailClientError) && | 140 } else if ((response_code > kHttpPostFailClientError) && |
140 (response_code < kHttpPostFailServerError)) { | 141 (response_code < kHttpPostFailServerError)) { |
141 error_stream << "Client error: HTTP response code " << response_code; | 142 error_stream << "Client error: HTTP response code " << response_code; |
142 } else if (response_code > kHttpPostFailServerError) { | 143 } else if (response_code > kHttpPostFailServerError) { |
143 error_stream << "Server error: HTTP response code " << response_code; | 144 error_stream << "Server error: HTTP response code " << response_code; |
144 } else { | 145 } else { |
145 error_stream << "Unknown error: HTTP response code " << response_code; | 146 error_stream << "Unknown error: HTTP response code " << response_code; |
146 } | 147 } |
147 } | 148 } |
148 | 149 |
149 LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << url << | 150 LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << url |
150 ") status: " << error_stream.str() << std::endl; | 151 << ") status: " << error_stream.str(); |
151 | 152 |
152 // Delete the URLFetcher. | 153 // Delete the URLFetcher. |
153 delete source; | 154 delete source; |
154 // And then delete ourselves. | 155 // And then delete ourselves. |
155 delete this; | 156 delete this; |
156 } | 157 } |
157 | 158 |
158 // static | 159 // static |
159 void BugReportUtil::SetOSVersion(std::string *os_version) { | 160 void BugReportUtil::SetOSVersion(std::string* os_version) { |
160 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
161 OSVERSIONINFO osvi; | 162 base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); |
162 ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); | 163 const int* version = os_info->version_number(); |
163 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | 164 *os_version = StringPrintf("%d.%d.%d", version[0], version[1], version[2]); |
164 | 165 int service_pack = os_info->service_pack()[0]; |
165 if (GetVersionEx(&osvi)) { | 166 if (service_pack > 0) |
166 *os_version = StringPrintf("%d.%d.%d %S", | 167 os_version->append(StringPrintf("Service Pack %d", service_pack)); |
167 osvi.dwMajorVersion, | |
168 osvi.dwMinorVersion, | |
169 osvi.dwBuildNumber, | |
170 osvi.szCSDVersion); | |
171 } else { | |
172 *os_version = "unknown"; | |
173 } | |
174 #elif defined(OS_MACOSX) | 168 #elif defined(OS_MACOSX) |
175 int32 major; | 169 int32 major; |
176 int32 minor; | 170 int32 minor; |
177 int32 bugFix; | 171 int32 bugFix; |
178 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugFix); | 172 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugFix); |
179 *os_version = StringPrintf("%d.%d.%d", major, minor, bugFix); | 173 *os_version = StringPrintf("%d.%d.%d", major, minor, bugFix); |
180 #else | 174 #else |
181 *os_version = "unknown"; | 175 *os_version = "unknown"; |
182 #endif | 176 #endif |
183 } | 177 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 378 |
385 // static | 379 // static |
386 void BugReportUtil::ReportPhishing(TabContents* currentTab, | 380 void BugReportUtil::ReportPhishing(TabContents* currentTab, |
387 const std::string& phishing_url) { | 381 const std::string& phishing_url) { |
388 currentTab->controller().LoadURL( | 382 currentTab->controller().LoadURL( |
389 safe_browsing_util::GeneratePhishingReportUrl( | 383 safe_browsing_util::GeneratePhishingReportUrl( |
390 kReportPhishingUrl, phishing_url), | 384 kReportPhishingUrl, phishing_url), |
391 GURL(), | 385 GURL(), |
392 PageTransition::LINK); | 386 PageTransition::LINK); |
393 } | 387 } |
OLD | NEW |