OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/feedback/feedback_util.h" | 5 #include "chrome/browser/feedback/feedback_util.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 using content::WebContents; | 42 using content::WebContents; |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 const int kFeedbackVersion = 1; | 46 const int kFeedbackVersion = 1; |
47 | 47 |
48 const char kReportPhishingUrl[] = | 48 const char kReportPhishingUrl[] = |
49 "http://www.google.com/safebrowsing/report_phish/"; | 49 "http://www.google.com/safebrowsing/report_phish/"; |
50 | 50 |
51 // URL to post bug reports to. | 51 // URL to post bug reports to. |
52 static char const kFeedbackPostUrl[] = | 52 const char kFeedbackPostUrl[] = |
53 "https://www.google.com/tools/feedback/chrome/__submit"; | 53 "https://www.google.com/tools/feedback/chrome/__submit"; |
54 | 54 |
55 static char const kProtBufMimeType[] = "application/x-protobuf"; | 55 const char kProtBufMimeType[] = "application/x-protobuf"; |
56 static char const kPngMimeType[] = "image/png"; | 56 const char kPngMimeType[] = "image/png"; |
57 | 57 |
58 // Tags we use in product specific data | 58 // Tags we use in product specific data |
59 static char const kChromeVersionTag[] = "CHROME VERSION"; | 59 const char kChromeVersionTag[] = "CHROME VERSION"; |
60 static char const kOsVersionTag[] = "OS VERSION"; | 60 const char kOsVersionTag[] = "OS VERSION"; |
| 61 #if defined(OS_CHROMEOS) |
| 62 const char kTimestampTag[] = "TIMESTAMP"; |
| 63 #endif |
61 | 64 |
62 static int const kHttpPostSuccessNoContent = 204; | 65 const int kHttpPostSuccessNoContent = 204; |
63 static int const kHttpPostFailNoConnection = -1; | 66 const int kHttpPostFailNoConnection = -1; |
64 static int const kHttpPostFailClientError = 400; | 67 const int kHttpPostFailClientError = 400; |
65 static int const kHttpPostFailServerError = 500; | 68 const int kHttpPostFailServerError = 500; |
66 | 69 |
67 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
68 static char const kBZip2MimeType[] = "application/x-bzip2"; | 71 const char kBZip2MimeType[] = "application/x-bzip2"; |
69 static char const kLogsAttachmentName[] = "system_logs.bz2"; | 72 const char kLogsAttachmentName[] = "system_logs.bz2"; |
70 // Maximum number of lines in system info log chunk to be still included | 73 // Maximum number of lines in system info log chunk to be still included |
71 // in product specific data. | 74 // in product specific data. |
72 const size_t kMaxLineCount = 40; | 75 const size_t kMaxLineCount = 40; |
73 // Maximum number of bytes in system info log chunk to be still included | 76 // Maximum number of bytes in system info log chunk to be still included |
74 // in product specific data. | 77 // in product specific data. |
75 const size_t kMaxSystemLogLength = 4 * 1024; | 78 const size_t kMaxSystemLogLength = 4 * 1024; |
76 #endif | 79 #endif |
77 | 80 |
78 const int64 kInitialRetryDelay = 900000; // 15 minutes | 81 const int64 kInitialRetryDelay = 900000; // 15 minutes |
79 const int64 kRetryDelayIncreaseFactor = 2; | 82 const int64 kRetryDelayIncreaseFactor = 2; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 , const std::string& page_url_text | 244 , const std::string& page_url_text |
242 , const std::string& description | 245 , const std::string& description |
243 , ScreenshotDataPtr image_data_ptr | 246 , ScreenshotDataPtr image_data_ptr |
244 , int png_width | 247 , int png_width |
245 , int png_height | 248 , int png_height |
246 #if defined(OS_CHROMEOS) | 249 #if defined(OS_CHROMEOS) |
247 , const std::string& user_email_text | 250 , const std::string& user_email_text |
248 , const char* zipped_logs_data | 251 , const char* zipped_logs_data |
249 , int zipped_logs_length | 252 , int zipped_logs_length |
250 , const chromeos::system::LogDictionaryType* const sys_info | 253 , const chromeos::system::LogDictionaryType* const sys_info |
| 254 , const std::string& timestamp |
251 #endif | 255 #endif |
252 ) { | 256 ) { |
253 // Create google feedback protocol buffer objects | 257 // Create google feedback protocol buffer objects |
254 userfeedback::ExtensionSubmit feedback_data; | 258 userfeedback::ExtensionSubmit feedback_data; |
255 // type id set to 0, unused field but needs to be initialized to 0 | 259 // type id set to 0, unused field but needs to be initialized to 0 |
256 feedback_data.set_type_id(0); | 260 feedback_data.set_type_id(0); |
257 | 261 |
258 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); | 262 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); |
259 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); | 263 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); |
260 | 264 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // If we have zipped logs, add them here | 334 // If we have zipped logs, add them here |
331 if (zipped_logs_data && CommandLine::ForCurrentProcess()->HasSwitch( | 335 if (zipped_logs_data && CommandLine::ForCurrentProcess()->HasSwitch( |
332 switches::kCompressSystemFeedback)) { | 336 switches::kCompressSystemFeedback)) { |
333 userfeedback::ProductSpecificBinaryData attachment; | 337 userfeedback::ProductSpecificBinaryData attachment; |
334 attachment.set_mime_type(kBZip2MimeType); | 338 attachment.set_mime_type(kBZip2MimeType); |
335 attachment.set_name(kLogsAttachmentName); | 339 attachment.set_name(kLogsAttachmentName); |
336 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); | 340 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); |
337 *(feedback_data.add_product_specific_binary_data()) = attachment; | 341 *(feedback_data.add_product_specific_binary_data()) = attachment; |
338 } | 342 } |
339 } | 343 } |
| 344 |
| 345 if (timestamp != "") |
| 346 AddFeedbackData(&feedback_data, std::string(kTimestampTag), timestamp); |
340 #endif | 347 #endif |
341 | 348 |
342 // Set our category tag if we have one | 349 // Set our category tag if we have one |
343 if (category_tag.size()) | 350 if (category_tag.size()) |
344 feedback_data.set_category_tag(category_tag); | 351 feedback_data.set_category_tag(category_tag); |
345 | 352 |
346 // Set our Chrome specific data | 353 // Set our Chrome specific data |
347 userfeedback::ChromeData chrome_data; | 354 userfeedback::ChromeData chrome_data; |
348 chrome_data.set_chrome_platform( | 355 chrome_data.set_chrome_platform( |
349 #if defined(OS_CHROMEOS) | 356 #if defined(OS_CHROMEOS) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 if (screenshot_size == NULL) | 412 if (screenshot_size == NULL) |
406 screenshot_size = new gfx::Rect(); | 413 screenshot_size = new gfx::Rect(); |
407 return *screenshot_size; | 414 return *screenshot_size; |
408 } | 415 } |
409 | 416 |
410 // static | 417 // static |
411 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { | 418 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { |
412 gfx::Rect& screen_size = GetScreenshotSize(); | 419 gfx::Rect& screen_size = GetScreenshotSize(); |
413 screen_size = rect; | 420 screen_size = rect; |
414 } | 421 } |
OLD | NEW |