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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 "http://www.google.com/safebrowsing/report_phish/"; | 42 "http://www.google.com/safebrowsing/report_phish/"; |
43 | 43 |
44 // URL to post bug reports to. | 44 // URL to post bug reports to. |
45 static char const kBugReportPostUrl[] = | 45 static char const kBugReportPostUrl[] = |
46 "https://www.google.com/tools/feedback/chrome/__submit"; | 46 "https://www.google.com/tools/feedback/chrome/__submit"; |
47 | 47 |
48 static char const kProtBufMimeType[] = "application/x-protobuf"; | 48 static char const kProtBufMimeType[] = "application/x-protobuf"; |
49 static char const kPngMimeType[] = "image/png"; | 49 static char const kPngMimeType[] = "image/png"; |
50 | 50 |
51 // Tags we use in product specific data | 51 // Tags we use in product specific data |
52 static char const kPageTitleTag[] = "PAGE TITLE"; | |
53 static char const kProblemTypeIdTag[] = "PROBLEM TYPE ID"; | |
54 static char const kProblemTypeTag[] = "PROBLEM TYPE"; | |
55 static char const kChromeVersionTag[] = "CHROME VERSION"; | 52 static char const kChromeVersionTag[] = "CHROME VERSION"; |
56 static char const kOsVersionTag[] = "OS VERSION"; | 53 static char const kOsVersionTag[] = "OS VERSION"; |
57 | 54 |
58 static char const kNotificationId[] = "feedback.chromeos"; | 55 static char const kNotificationId[] = "feedback.chromeos"; |
59 | 56 |
60 static int const kHttpPostSuccessNoContent = 204; | 57 static int const kHttpPostSuccessNoContent = 204; |
61 static int const kHttpPostFailNoConnection = -1; | 58 static int const kHttpPostFailNoConnection = -1; |
62 static int const kHttpPostFailClientError = 400; | 59 static int const kHttpPostFailClientError = 400; |
63 static int const kHttpPostFailServerError = 500; | 60 static int const kHttpPostFailServerError = 500; |
64 | 61 |
65 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
66 static char const kBZip2MimeType[] = "application/x-bzip2"; | 63 static char const kBZip2MimeType[] = "application/x-bzip2"; |
67 static char const kLogsAttachmentName[] = "system_logs.bz2"; | 64 static char const kLogsAttachmentName[] = "system_logs.bz2"; |
68 // Maximum number of lines in system info log chunk to be still included | 65 // Maximum number of lines in system info log chunk to be still included |
69 // in product specific data. | 66 // in product specific data. |
70 const size_t kMaxLineCount = 10; | 67 const size_t kMaxLineCount = 40; |
71 // Maximum number of bytes in system info log chunk to be still included | 68 // Maximum number of bytes in system info log chunk to be still included |
72 // in product specific data. | 69 // in product specific data. |
73 const size_t kMaxSystemLogLength = 1024; | 70 const size_t kMaxSystemLogLength = 4 * 1024; |
74 #endif | 71 #endif |
75 | 72 |
76 const int64 kInitialRetryDelay = 900000; // 15 minutes | 73 const int64 kInitialRetryDelay = 900000; // 15 minutes |
77 const int64 kRetryDelayIncreaseFactor = 2; | 74 const int64 kRetryDelayIncreaseFactor = 2; |
78 const int64 kRetryDelayLimit = 14400000; // 4 hours | 75 const int64 kRetryDelayLimit = 14400000; // 4 hours |
79 | 76 |
80 | 77 |
81 } // namespace | 78 } // namespace |
82 | 79 |
83 | 80 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 line_count++; | 238 line_count++; |
242 if (line_count > kMaxLineCount) | 239 if (line_count > kMaxLineCount) |
243 return false; | 240 return false; |
244 } | 241 } |
245 } | 242 } |
246 return true; | 243 return true; |
247 } | 244 } |
248 #endif | 245 #endif |
249 | 246 |
250 // static | 247 // static |
251 void BugReportUtil::SendReport(Profile* profile, | 248 void BugReportUtil::SendReport( |
252 int problem_type, | 249 Profile* profile |
253 const std::string& page_url_text, | 250 , int problem_type |
254 const std::string& description, | 251 , const std::string& page_url_text |
255 const char* png_data, | 252 , const std::string& description |
256 int png_data_length, | 253 , const char* png_data |
257 int png_width, | 254 , int png_data_length |
| 255 , int png_width |
| 256 , int png_height |
258 #if defined(OS_CHROMEOS) | 257 #if defined(OS_CHROMEOS) |
259 int png_height, | 258 , const std::string& user_email_text |
260 const std::string& user_email_text, | 259 , const char* zipped_logs_data |
261 const char* zipped_logs_data, | 260 , int zipped_logs_length |
262 int zipped_logs_length, | 261 , const chromeos::system::LogDictionaryType* const sys_info |
263 const chromeos::system::LogDictionaryType* const sys_info) { | |
264 #else | |
265 int png_height) { | |
266 #endif | 262 #endif |
| 263 ) { |
267 // Create google feedback protocol buffer objects | 264 // Create google feedback protocol buffer objects |
268 userfeedback::ExternalExtensionSubmit feedback_data; | 265 userfeedback::ExternalExtensionSubmit feedback_data; |
269 // type id set to 0, unused field but needs to be initialized to 0 | 266 // type id set to 0, unused field but needs to be initialized to 0 |
270 feedback_data.set_type_id(0); | 267 feedback_data.set_type_id(0); |
271 | 268 |
272 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); | 269 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); |
273 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); | 270 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); |
274 | 271 |
275 // Set GAIA id to 0. We're not using gaia id's for recording | 272 // Set GAIA id to 0. We're not using gaia id's for recording |
276 // use feedback - we're using the e-mail field, allows users to | 273 // use feedback - we're using the e-mail field, allows users to |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 screenshot.set_binary_content(std::string(png_data, png_data_length)); | 317 screenshot.set_binary_content(std::string(png_data, png_data_length)); |
321 | 318 |
322 // Set the screenshot object in feedback | 319 // Set the screenshot object in feedback |
323 *(feedback_data.mutable_screenshot()) = screenshot; | 320 *(feedback_data.mutable_screenshot()) = screenshot; |
324 } | 321 } |
325 | 322 |
326 #if defined(OS_CHROMEOS) | 323 #if defined(OS_CHROMEOS) |
327 if (sys_info) { | 324 if (sys_info) { |
328 // Add the product specific data | 325 // Add the product specific data |
329 for (chromeos::system::LogDictionaryType::const_iterator i = | 326 for (chromeos::system::LogDictionaryType::const_iterator i = |
330 sys_info->begin(); i != sys_info->end(); ++i) | 327 sys_info->begin(); i != sys_info->end(); ++i) { |
331 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 328 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
332 switches::kCompressSystemFeedback) || ValidFeedbackSize(i->second)) { | 329 switches::kCompressSystemFeedback) || ValidFeedbackSize(i->second)) { |
333 AddFeedbackData(&feedback_data, i->first, i->second); | 330 AddFeedbackData(&feedback_data, i->first, i->second); |
334 } | 331 } |
| 332 } |
335 | 333 |
336 // If we have zipped logs, add them here | 334 // If we have zipped logs, add them here |
337 if (zipped_logs_data && CommandLine::ForCurrentProcess()->HasSwitch( | 335 if (zipped_logs_data && CommandLine::ForCurrentProcess()->HasSwitch( |
338 switches::kCompressSystemFeedback)) { | 336 switches::kCompressSystemFeedback)) { |
339 userfeedback::ProductSpecificBinaryData attachment; | 337 userfeedback::ProductSpecificBinaryData attachment; |
340 attachment.set_mime_type(kBZip2MimeType); | 338 attachment.set_mime_type(kBZip2MimeType); |
341 attachment.set_name(kLogsAttachmentName); | 339 attachment.set_name(kLogsAttachmentName); |
342 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); | 340 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); |
343 *(feedback_data.add_product_specific_binary_data()) = attachment; | 341 *(feedback_data.add_product_specific_binary_data()) = attachment; |
344 } | 342 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 void BugReportUtil::ReportPhishing(TabContents* currentTab, | 376 void BugReportUtil::ReportPhishing(TabContents* currentTab, |
379 const std::string& phishing_url) { | 377 const std::string& phishing_url) { |
380 currentTab->controller().LoadURL( | 378 currentTab->controller().LoadURL( |
381 safe_browsing_util::GeneratePhishingReportUrl( | 379 safe_browsing_util::GeneratePhishingReportUrl( |
382 kReportPhishingUrl, phishing_url, | 380 kReportPhishingUrl, phishing_url, |
383 false /* not client-side detection */), | 381 false /* not client-side detection */), |
384 GURL(), | 382 GURL(), |
385 PageTransition::LINK); | 383 PageTransition::LINK); |
386 } | 384 } |
387 #endif | 385 #endif |
| 386 |
| 387 static std::vector<unsigned char>* screenshot_png = NULL; |
| 388 static gfx::Rect* screenshot_size = NULL; |
| 389 |
| 390 // static |
| 391 std::vector<unsigned char>* BugReportUtil::GetScreenshotPng() { |
| 392 if (screenshot_png == NULL) |
| 393 screenshot_png = new std::vector<unsigned char>; |
| 394 return screenshot_png; |
| 395 } |
| 396 |
| 397 // static |
| 398 void BugReportUtil::ClearScreenshotPng() { |
| 399 if (screenshot_png) |
| 400 screenshot_png->clear(); |
| 401 } |
| 402 |
| 403 // static |
| 404 gfx::Rect& BugReportUtil::GetScreenshotSize() { |
| 405 if (screenshot_size == NULL) |
| 406 screenshot_size = new gfx::Rect(); |
| 407 return *screenshot_size; |
| 408 } |
| 409 |
| 410 // static |
| 411 void BugReportUtil::SetScreenshotSize(const gfx::Rect& rect) { |
| 412 gfx::Rect& screen_size = GetScreenshotSize(); |
| 413 screen_size = rect; |
| 414 } |
OLD | NEW |