| OLD | NEW |
| 1 // Copyright (c) 2011 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/bug_report_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 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 13 #include "base/file_version_info.h" | 14 #include "base/file_version_info.h" |
| 14 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 15 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 18 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 #include "unicode/locid.h" | 35 #include "unicode/locid.h" |
| 35 | 36 |
| 36 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 37 #include "chrome/browser/chromeos/notifications/system_notification.h" | 38 #include "chrome/browser/chromeos/notifications/system_notification.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 using content::WebContents; | 41 using content::WebContents; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 const int kBugReportVersion = 1; | 45 const int kFeedbackVersion = 1; |
| 45 | 46 |
| 46 const char kReportPhishingUrl[] = | 47 const char kReportPhishingUrl[] = |
| 47 "http://www.google.com/safebrowsing/report_phish/"; | 48 "http://www.google.com/safebrowsing/report_phish/"; |
| 48 | 49 |
| 49 // URL to post bug reports to. | 50 // URL to post bug reports to. |
| 50 static char const kBugReportPostUrl[] = | 51 static char const kFeedbackPostUrl[] = |
| 51 "https://www.google.com/tools/feedback/chrome/__submit"; | 52 "https://www.google.com/tools/feedback/chrome/__submit"; |
| 52 | 53 |
| 53 static char const kProtBufMimeType[] = "application/x-protobuf"; | 54 static char const kProtBufMimeType[] = "application/x-protobuf"; |
| 54 static char const kPngMimeType[] = "image/png"; | 55 static char const kPngMimeType[] = "image/png"; |
| 55 | 56 |
| 56 // Tags we use in product specific data | 57 // Tags we use in product specific data |
| 57 static char const kChromeVersionTag[] = "CHROME VERSION"; | 58 static char const kChromeVersionTag[] = "CHROME VERSION"; |
| 58 static char const kOsVersionTag[] = "OS VERSION"; | 59 static char const kOsVersionTag[] = "OS VERSION"; |
| 59 | 60 |
| 60 static char const kNotificationId[] = "feedback.chromeos"; | |
| 61 | |
| 62 static int const kHttpPostSuccessNoContent = 204; | 61 static int const kHttpPostSuccessNoContent = 204; |
| 63 static int const kHttpPostFailNoConnection = -1; | 62 static int const kHttpPostFailNoConnection = -1; |
| 64 static int const kHttpPostFailClientError = 400; | 63 static int const kHttpPostFailClientError = 400; |
| 65 static int const kHttpPostFailServerError = 500; | 64 static int const kHttpPostFailServerError = 500; |
| 66 | 65 |
| 67 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
| 68 static char const kBZip2MimeType[] = "application/x-bzip2"; | 67 static char const kBZip2MimeType[] = "application/x-bzip2"; |
| 69 static char const kLogsAttachmentName[] = "system_logs.bz2"; | 68 static char const kLogsAttachmentName[] = "system_logs.bz2"; |
| 70 // Maximum number of lines in system info log chunk to be still included | 69 // Maximum number of lines in system info log chunk to be still included |
| 71 // in product specific data. | 70 // in product specific data. |
| 72 const size_t kMaxLineCount = 40; | 71 const size_t kMaxLineCount = 40; |
| 73 // Maximum number of bytes in system info log chunk to be still included | 72 // Maximum number of bytes in system info log chunk to be still included |
| 74 // in product specific data. | 73 // in product specific data. |
| 75 const size_t kMaxSystemLogLength = 4 * 1024; | 74 const size_t kMaxSystemLogLength = 4 * 1024; |
| 76 #endif | 75 #endif |
| 77 | 76 |
| 78 const int64 kInitialRetryDelay = 900000; // 15 minutes | 77 const int64 kInitialRetryDelay = 900000; // 15 minutes |
| 79 const int64 kRetryDelayIncreaseFactor = 2; | 78 const int64 kRetryDelayIncreaseFactor = 2; |
| 80 const int64 kRetryDelayLimit = 14400000; // 4 hours | 79 const int64 kRetryDelayLimit = 14400000; // 4 hours |
| 81 | 80 |
| 82 | 81 |
| 83 } // namespace | 82 } // namespace |
| 84 | 83 |
| 85 | 84 |
| 86 // Simple content::URLFetcherDelegate to clean up URLFetcher on completion. | 85 // Simple content::URLFetcherDelegate to clean up URLFetcher on completion. |
| 87 class BugReportUtil::PostCleanup : public content::URLFetcherDelegate { | 86 class FeedbackUtil::PostCleanup : public content::URLFetcherDelegate { |
| 88 public: | 87 public: |
| 89 PostCleanup(Profile* profile, std::string* post_body, | 88 PostCleanup(Profile* profile, std::string* post_body, |
| 90 int64 previous_delay) : profile_(profile), | 89 int64 previous_delay) : profile_(profile), |
| 91 post_body_(post_body), | 90 post_body_(post_body), |
| 92 previous_delay_(previous_delay) { } | 91 previous_delay_(previous_delay) { } |
| 93 // Overridden from content::URLFetcherDelegate. | 92 // Overridden from content::URLFetcherDelegate. |
| 94 virtual void OnURLFetchComplete(const content::URLFetcher* source); | 93 virtual void OnURLFetchComplete(const content::URLFetcher* source); |
| 95 | 94 |
| 96 protected: | 95 protected: |
| 97 virtual ~PostCleanup() {} | 96 virtual ~PostCleanup() {} |
| 98 | 97 |
| 99 private: | 98 private: |
| 100 Profile* profile_; | 99 Profile* profile_; |
| 101 std::string* post_body_; | 100 std::string* post_body_; |
| 102 int64 previous_delay_; | 101 int64 previous_delay_; |
| 103 | 102 |
| 104 DISALLOW_COPY_AND_ASSIGN(PostCleanup); | 103 DISALLOW_COPY_AND_ASSIGN(PostCleanup); |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 // Don't use the data parameter, instead use the pointer we pass into every | 106 // Don't use the data parameter, instead use the pointer we pass into every |
| 108 // post cleanup object - that pointer will be deleted and deleted only on a | 107 // post cleanup object - that pointer will be deleted and deleted only on a |
| 109 // successful post to the feedback server. | 108 // successful post to the feedback server. |
| 110 void BugReportUtil::PostCleanup::OnURLFetchComplete( | 109 void FeedbackUtil::PostCleanup::OnURLFetchComplete( |
| 111 const content::URLFetcher* source) { | 110 const content::URLFetcher* source) { |
| 112 std::stringstream error_stream; | 111 std::stringstream error_stream; |
| 113 int response_code = source->GetResponseCode(); | 112 int response_code = source->GetResponseCode(); |
| 114 if (response_code == kHttpPostSuccessNoContent) { | 113 if (response_code == kHttpPostSuccessNoContent) { |
| 115 // We've sent our report, delete the report data | 114 // We've sent our report, delete the report data |
| 116 delete post_body_; | 115 delete post_body_; |
| 117 | 116 |
| 118 error_stream << "Success"; | 117 error_stream << "Success"; |
| 119 } else { | 118 } else { |
| 120 // Uh oh, feedback failed, send it off to retry | 119 // Uh oh, feedback failed, send it off to retry |
| 121 if (previous_delay_) { | 120 if (previous_delay_) { |
| 122 if (previous_delay_ < kRetryDelayLimit) | 121 if (previous_delay_ < kRetryDelayLimit) |
| 123 previous_delay_ *= kRetryDelayIncreaseFactor; | 122 previous_delay_ *= kRetryDelayIncreaseFactor; |
| 124 } else { | 123 } else { |
| 125 previous_delay_ = kInitialRetryDelay; | 124 previous_delay_ = kInitialRetryDelay; |
| 126 } | 125 } |
| 127 BugReportUtil::DispatchFeedback(profile_, post_body_, previous_delay_); | 126 FeedbackUtil::DispatchFeedback(profile_, post_body_, previous_delay_); |
| 128 | 127 |
| 129 // Process the error for debug output | 128 // Process the error for debug output |
| 130 if (response_code == kHttpPostFailNoConnection) { | 129 if (response_code == kHttpPostFailNoConnection) { |
| 131 error_stream << "No connection to server."; | 130 error_stream << "No connection to server."; |
| 132 } else if ((response_code > kHttpPostFailClientError) && | 131 } else if ((response_code > kHttpPostFailClientError) && |
| 133 (response_code < kHttpPostFailServerError)) { | 132 (response_code < kHttpPostFailServerError)) { |
| 134 error_stream << "Client error: HTTP response code " << response_code; | 133 error_stream << "Client error: HTTP response code " << response_code; |
| 135 } else if (response_code > kHttpPostFailServerError) { | 134 } else if (response_code > kHttpPostFailServerError) { |
| 136 error_stream << "Server error: HTTP response code " << response_code; | 135 error_stream << "Server error: HTTP response code " << response_code; |
| 137 } else { | 136 } else { |
| 138 error_stream << "Unknown error: HTTP response code " << response_code; | 137 error_stream << "Unknown error: HTTP response code " << response_code; |
| 139 } | 138 } |
| 140 } | 139 } |
| 141 | 140 |
| 142 LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << | 141 LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << |
| 143 source->GetURL() << ") status: " << error_stream.str(); | 142 source->GetURL() << ") status: " << error_stream.str(); |
| 144 | 143 |
| 145 // Delete the URLFetcher. | 144 // Delete the URLFetcher. |
| 146 delete source; | 145 delete source; |
| 147 // And then delete ourselves. | 146 // And then delete ourselves. |
| 148 delete this; | 147 delete this; |
| 149 } | 148 } |
| 150 | 149 |
| 151 // static | 150 // static |
| 152 void BugReportUtil::SetOSVersion(std::string* os_version) { | 151 void FeedbackUtil::SetOSVersion(std::string* os_version) { |
| 153 #if defined(OS_WIN) | 152 #if defined(OS_WIN) |
| 154 base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); | 153 base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); |
| 155 base::win::OSInfo::VersionNumber version_number = os_info->version_number(); | 154 base::win::OSInfo::VersionNumber version_number = os_info->version_number(); |
| 156 *os_version = base::StringPrintf("%d.%d.%d", | 155 *os_version = base::StringPrintf("%d.%d.%d", |
| 157 version_number.major, | 156 version_number.major, |
| 158 version_number.minor, | 157 version_number.minor, |
| 159 version_number.build); | 158 version_number.build); |
| 160 int service_pack = os_info->service_pack().major; | 159 int service_pack = os_info->service_pack().major; |
| 161 if (service_pack > 0) | 160 if (service_pack > 0) |
| 162 os_version->append(base::StringPrintf("Service Pack %d", service_pack)); | 161 os_version->append(base::StringPrintf("Service Pack %d", service_pack)); |
| 163 #elif defined(OS_MACOSX) | 162 #elif defined(OS_MACOSX) |
| 164 *os_version = base::SysInfo::OperatingSystemVersion(); | 163 *os_version = base::SysInfo::OperatingSystemVersion(); |
| 165 #else | 164 #else |
| 166 *os_version = "unknown"; | 165 *os_version = "unknown"; |
| 167 #endif | 166 #endif |
| 168 } | 167 } |
| 169 | 168 |
| 170 // static | 169 // static |
| 171 void BugReportUtil::DispatchFeedback(Profile* profile, | 170 void FeedbackUtil::DispatchFeedback(Profile* profile, |
| 172 std::string* post_body, | 171 std::string* post_body, |
| 173 int64 delay) { | 172 int64 delay) { |
| 174 DCHECK(post_body); | 173 DCHECK(post_body); |
| 175 | 174 |
| 176 MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind( | 175 MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind( |
| 177 &BugReportUtil::SendFeedback, profile, post_body, delay), delay); | 176 &FeedbackUtil::SendFeedback, profile, post_body, delay), delay); |
| 178 } | 177 } |
| 179 | 178 |
| 180 // static | 179 // static |
| 181 void BugReportUtil::SendFeedback(Profile* profile, | 180 void FeedbackUtil::SendFeedback(Profile* profile, |
| 182 std::string* post_body, | 181 std::string* post_body, |
| 183 int64 previous_delay) { | 182 int64 previous_delay) { |
| 184 DCHECK(post_body); | 183 DCHECK(post_body); |
| 185 | 184 |
| 186 GURL post_url; | 185 GURL post_url; |
| 187 if (CommandLine::ForCurrentProcess()-> | 186 if (CommandLine::ForCurrentProcess()-> |
| 188 HasSwitch(switches::kFeedbackServer)) | 187 HasSwitch(switches::kFeedbackServer)) |
| 189 post_url = GURL(CommandLine::ForCurrentProcess()-> | 188 post_url = GURL(CommandLine::ForCurrentProcess()-> |
| 190 GetSwitchValueASCII(switches::kFeedbackServer)); | 189 GetSwitchValueASCII(switches::kFeedbackServer)); |
| 191 else | 190 else |
| 192 post_url = GURL(kBugReportPostUrl); | 191 post_url = GURL(kFeedbackPostUrl); |
| 193 | 192 |
| 194 content::URLFetcher* fetcher = content::URLFetcher::Create( | 193 content::URLFetcher* fetcher = content::URLFetcher::Create( |
| 195 post_url, content::URLFetcher::POST, | 194 post_url, content::URLFetcher::POST, |
| 196 new BugReportUtil::PostCleanup(profile, post_body, previous_delay)); | 195 new FeedbackUtil::PostCleanup(profile, post_body, previous_delay)); |
| 197 fetcher->SetRequestContext(profile->GetRequestContext()); | 196 fetcher->SetRequestContext(profile->GetRequestContext()); |
| 198 | 197 |
| 199 fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body); | 198 fetcher->SetUploadData(std::string(kProtBufMimeType), *post_body); |
| 200 fetcher->Start(); | 199 fetcher->Start(); |
| 201 } | 200 } |
| 202 | 201 |
| 203 | 202 |
| 204 // static | 203 // static |
| 205 void BugReportUtil::AddFeedbackData( | 204 void FeedbackUtil::AddFeedbackData( |
| 206 userfeedback::ExternalExtensionSubmit* feedback_data, | 205 userfeedback::ExtensionSubmit* feedback_data, |
| 207 const std::string& key, const std::string& value) { | 206 const std::string& key, const std::string& value) { |
| 208 // Don't bother with empty keys or values | 207 // Don't bother with empty keys or values |
| 209 if (key=="" || value == "") return; | 208 if (key == "" || value == "") return; |
| 210 // Create log_value object and add it to the web_data object | 209 // Create log_value object and add it to the web_data object |
| 211 userfeedback::ProductSpecificData log_value; | 210 userfeedback::ProductSpecificData log_value; |
| 212 log_value.set_key(key); | 211 log_value.set_key(key); |
| 213 log_value.set_value(value); | 212 log_value.set_value(value); |
| 214 userfeedback::WebData* web_data = feedback_data->mutable_web_data(); | 213 userfeedback::WebData* web_data = feedback_data->mutable_web_data(); |
| 215 *(web_data->add_product_specific_data()) = log_value; | 214 *(web_data->add_product_specific_data()) = log_value; |
| 216 } | 215 } |
| 217 | 216 |
| 218 #if defined(OS_CHROMEOS) | 217 #if defined(OS_CHROMEOS) |
| 219 bool BugReportUtil::ValidFeedbackSize(const std::string& content) { | 218 bool FeedbackUtil::ValidFeedbackSize(const std::string& content) { |
| 220 if (content.length() > kMaxSystemLogLength) | 219 if (content.length() > kMaxSystemLogLength) |
| 221 return false; | 220 return false; |
| 222 size_t line_count = 0; | 221 size_t line_count = 0; |
| 223 const char* text = content.c_str(); | 222 const char* text = content.c_str(); |
| 224 for (size_t i = 0; i < content.length(); i++) { | 223 for (size_t i = 0; i < content.length(); i++) { |
| 225 if (*(text + i) == '\n') { | 224 if (*(text + i) == '\n') { |
| 226 line_count++; | 225 line_count++; |
| 227 if (line_count > kMaxLineCount) | 226 if (line_count > kMaxLineCount) |
| 228 return false; | 227 return false; |
| 229 } | 228 } |
| 230 } | 229 } |
| 231 return true; | 230 return true; |
| 232 } | 231 } |
| 233 #endif | 232 #endif |
| 234 | 233 |
| 235 // static | 234 // static |
| 236 void BugReportUtil::SendReport( | 235 void FeedbackUtil::SendReport( |
| 237 Profile* profile | 236 Profile* profile |
| 238 , int problem_type | 237 , const std::string& category_tag |
| 239 , const std::string& page_url_text | 238 , const std::string& page_url_text |
| 240 , const std::string& description | 239 , const std::string& description |
| 241 , ScreenshotDataPtr image_data_ptr | 240 , ScreenshotDataPtr image_data_ptr |
| 242 , int png_width | 241 , int png_width |
| 243 , int png_height | 242 , int png_height |
| 244 #if defined(OS_CHROMEOS) | 243 #if defined(OS_CHROMEOS) |
| 245 , const std::string& user_email_text | 244 , const std::string& user_email_text |
| 246 , const char* zipped_logs_data | 245 , const char* zipped_logs_data |
| 247 , int zipped_logs_length | 246 , int zipped_logs_length |
| 248 , const chromeos::system::LogDictionaryType* const sys_info | 247 , const chromeos::system::LogDictionaryType* const sys_info |
| 249 #endif | 248 #endif |
| 250 ) { | 249 ) { |
| 251 // Create google feedback protocol buffer objects | 250 // Create google feedback protocol buffer objects |
| 252 userfeedback::ExternalExtensionSubmit feedback_data; | 251 userfeedback::ExtensionSubmit feedback_data; |
| 253 // type id set to 0, unused field but needs to be initialized to 0 | 252 // type id set to 0, unused field but needs to be initialized to 0 |
| 254 feedback_data.set_type_id(0); | 253 feedback_data.set_type_id(0); |
| 255 | 254 |
| 256 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); | 255 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); |
| 257 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); | 256 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); |
| 258 | 257 |
| 259 // Set GAIA id to 0. We're not using gaia id's for recording | 258 // Set GAIA id to 0. We're not using gaia id's for recording |
| 260 // use feedback - we're using the e-mail field, allows users to | 259 // use feedback - we're using the e-mail field, allows users to |
| 261 // submit feedback from incognito mode and specify any mail id | 260 // submit feedback from incognito mode and specify any mail id |
| 262 // they wish | 261 // they wish |
| (...skipping 17 matching lines...) Expand all Loading... |
| 280 // Add the Chrome version | 279 // Add the Chrome version |
| 281 chrome::VersionInfo version_info; | 280 chrome::VersionInfo version_info; |
| 282 if (version_info.is_valid()) { | 281 if (version_info.is_valid()) { |
| 283 std::string chrome_version = version_info.Name() + " - " + | 282 std::string chrome_version = version_info.Name() + " - " + |
| 284 version_info.Version() + | 283 version_info.Version() + |
| 285 " (" + version_info.LastChange() + ")"; | 284 " (" + version_info.LastChange() + ")"; |
| 286 AddFeedbackData(&feedback_data, std::string(kChromeVersionTag), | 285 AddFeedbackData(&feedback_data, std::string(kChromeVersionTag), |
| 287 chrome_version); | 286 chrome_version); |
| 288 } | 287 } |
| 289 | 288 |
| 289 // We don't need the OS version for ChromeOS since we get it in |
| 290 // CHROMEOS_RELEASE_VERSION from /etc/lsb-release |
| 291 #if !defined(OS_CHROMEOS) |
| 290 // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). | 292 // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). |
| 291 std::string os_version = ""; | 293 std::string os_version = ""; |
| 292 SetOSVersion(&os_version); | 294 SetOSVersion(&os_version); |
| 293 AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); | 295 AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); |
| 296 #endif |
| 294 | 297 |
| 295 // Include the page image if we have one. | 298 // Include the page image if we have one. |
| 296 if (image_data_ptr.get() && image_data_ptr->size()) { | 299 if (image_data_ptr.get() && image_data_ptr->size()) { |
| 297 userfeedback::PostedScreenshot screenshot; | 300 userfeedback::PostedScreenshot screenshot; |
| 298 screenshot.set_mime_type(kPngMimeType); | 301 screenshot.set_mime_type(kPngMimeType); |
| 299 // Set the dimensions of the screenshot | 302 // Set the dimensions of the screenshot |
| 300 userfeedback::Dimensions dimensions; | 303 userfeedback::Dimensions dimensions; |
| 301 dimensions.set_width(static_cast<float>(png_width)); | 304 dimensions.set_width(static_cast<float>(png_width)); |
| 302 dimensions.set_height(static_cast<float>(png_height)); | 305 dimensions.set_height(static_cast<float>(png_height)); |
| 303 *(screenshot.mutable_dimensions()) = dimensions; | 306 *(screenshot.mutable_dimensions()) = dimensions; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 326 switches::kCompressSystemFeedback)) { | 329 switches::kCompressSystemFeedback)) { |
| 327 userfeedback::ProductSpecificBinaryData attachment; | 330 userfeedback::ProductSpecificBinaryData attachment; |
| 328 attachment.set_mime_type(kBZip2MimeType); | 331 attachment.set_mime_type(kBZip2MimeType); |
| 329 attachment.set_name(kLogsAttachmentName); | 332 attachment.set_name(kLogsAttachmentName); |
| 330 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); | 333 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); |
| 331 *(feedback_data.add_product_specific_binary_data()) = attachment; | 334 *(feedback_data.add_product_specific_binary_data()) = attachment; |
| 332 } | 335 } |
| 333 } | 336 } |
| 334 #endif | 337 #endif |
| 335 | 338 |
| 339 // Set our category tag if we have one |
| 340 if (category_tag.size()) |
| 341 feedback_data.set_category_tag(category_tag); |
| 342 |
| 336 // Set our Chrome specific data | 343 // Set our Chrome specific data |
| 337 userfeedback::ChromeData chrome_data; | 344 userfeedback::ChromeData chrome_data; |
| 345 chrome_data.set_chrome_platform( |
| 338 #if defined(OS_CHROMEOS) | 346 #if defined(OS_CHROMEOS) |
| 339 chrome_data.set_chrome_platform( | |
| 340 userfeedback::ChromeData_ChromePlatform_CHROME_OS); | 347 userfeedback::ChromeData_ChromePlatform_CHROME_OS); |
| 341 userfeedback::ChromeOsData chrome_os_data; | 348 userfeedback::ChromeOsData chrome_os_data; |
| 342 chrome_os_data.set_category( | 349 chrome_os_data.set_category( |
| 343 (userfeedback::ChromeOsData_ChromeOsCategory) problem_type); | 350 userfeedback::ChromeOsData_ChromeOsCategory_OTHER); |
| 344 *(chrome_data.mutable_chrome_os_data()) = chrome_os_data; | 351 *(chrome_data.mutable_chrome_os_data()) = chrome_os_data; |
| 345 #else | 352 #else |
| 346 chrome_data.set_chrome_platform( | |
| 347 userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER); | 353 userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER); |
| 348 userfeedback::ChromeBrowserData chrome_browser_data; | 354 userfeedback::ChromeBrowserData chrome_browser_data; |
| 349 chrome_browser_data.set_category( | 355 chrome_browser_data.set_category( |
| 350 (userfeedback::ChromeBrowserData_ChromeBrowserCategory) problem_type); | 356 userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER); |
| 351 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; | 357 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; |
| 352 #endif | 358 #endif |
| 353 | 359 |
| 354 *(feedback_data.mutable_chrome_data()) = chrome_data; | 360 *(feedback_data.mutable_chrome_data()) = chrome_data; |
| 355 | 361 |
| 356 // Serialize our report to a string pointer we can pass around | 362 // Serialize our report to a string pointer we can pass around |
| 357 std::string* post_body = new std::string; | 363 std::string* post_body = new std::string; |
| 358 feedback_data.SerializeToString(post_body); | 364 feedback_data.SerializeToString(post_body); |
| 359 | 365 |
| 360 // We have the body of our POST, so send it off to the server with 0 delay | 366 // We have the body of our POST, so send it off to the server with 0 delay |
| 361 DispatchFeedback(profile, post_body, 0); | 367 DispatchFeedback(profile, post_body, 0); |
| 362 } | 368 } |
| 363 | 369 |
| 364 #if defined(ENABLE_SAFE_BROWSING) | 370 #if defined(ENABLE_SAFE_BROWSING) |
| 365 // static | 371 // static |
| 366 void BugReportUtil::ReportPhishing(WebContents* current_tab, | 372 void FeedbackUtil::ReportPhishing(WebContents* current_tab, |
| 367 const std::string& phishing_url) { | 373 const std::string& phishing_url) { |
| 368 current_tab->GetController().LoadURL( | 374 current_tab->GetController().LoadURL( |
| 369 safe_browsing_util::GeneratePhishingReportUrl( | 375 safe_browsing_util::GeneratePhishingReportUrl( |
| 370 kReportPhishingUrl, phishing_url, | 376 kReportPhishingUrl, phishing_url, |
| 371 false /* not client-side detection */), | 377 false /* not client-side detection */), |
| 372 content::Referrer(), | 378 content::Referrer(), |
| 373 content::PAGE_TRANSITION_LINK, | 379 content::PAGE_TRANSITION_LINK, |
| 374 std::string()); | 380 std::string()); |
| 375 } | 381 } |
| 376 #endif | 382 #endif |
| 377 | 383 |
| 378 static std::vector<unsigned char>* screenshot_png = NULL; | 384 static std::vector<unsigned char>* screenshot_png = NULL; |
| 379 static gfx::Rect* screenshot_size = NULL; | 385 static gfx::Rect* screenshot_size = NULL; |
| 380 | 386 |
| 381 // static | 387 // static |
| 382 std::vector<unsigned char>* BugReportUtil::GetScreenshotPng() { | 388 std::vector<unsigned char>* FeedbackUtil::GetScreenshotPng() { |
| 383 if (screenshot_png == NULL) | 389 if (screenshot_png == NULL) |
| 384 screenshot_png = new std::vector<unsigned char>; | 390 screenshot_png = new std::vector<unsigned char>; |
| 385 return screenshot_png; | 391 return screenshot_png; |
| 386 } | 392 } |
| 387 | 393 |
| 388 // static | 394 // static |
| 389 void BugReportUtil::ClearScreenshotPng() { | 395 void FeedbackUtil::ClearScreenshotPng() { |
| 390 if (screenshot_png) | 396 if (screenshot_png) |
| 391 screenshot_png->clear(); | 397 screenshot_png->clear(); |
| 392 } | 398 } |
| 393 | 399 |
| 394 // static | 400 // static |
| 395 gfx::Rect& BugReportUtil::GetScreenshotSize() { | 401 gfx::Rect& FeedbackUtil::GetScreenshotSize() { |
| 396 if (screenshot_size == NULL) | 402 if (screenshot_size == NULL) |
| 397 screenshot_size = new gfx::Rect(); | 403 screenshot_size = new gfx::Rect(); |
| 398 return *screenshot_size; | 404 return *screenshot_size; |
| 399 } | 405 } |
| 400 | 406 |
| 401 // static | 407 // static |
| 402 void BugReportUtil::SetScreenshotSize(const gfx::Rect& rect) { | 408 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { |
| 403 gfx::Rect& screen_size = GetScreenshotSize(); | 409 gfx::Rect& screen_size = GetScreenshotSize(); |
| 404 screen_size = rect; | 410 screen_size = rect; |
| 405 } | 411 } |
| OLD | NEW |