| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | |
| 14 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
| 15 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 16 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 19 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 20 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| 21 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 24 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
| 26 #include "chrome/common/metrics/metrics_log_manager.h" |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/navigation_controller.h" | 28 #include "content/public/browser/navigation_controller.h" |
| 29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
| 31 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "grit/locale_settings.h" | 33 #include "grit/locale_settings.h" |
| 34 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 35 #include "net/base/load_flags.h" | 35 #include "net/base/load_flags.h" |
| 36 #include "net/url_request/url_fetcher.h" | 36 #include "net/url_request/url_fetcher.h" |
| 37 #include "net/url_request/url_fetcher_delegate.h" | 37 #include "net/url_request/url_fetcher_delegate.h" |
| 38 #include "net/url_request/url_request_status.h" | 38 #include "net/url_request/url_request_status.h" |
| 39 #include "third_party/icu/public/common/unicode/locid.h" | 39 #include "third_party/icu/public/common/unicode/locid.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
| 41 | 41 |
| 42 #if defined(USE_ASH) | 42 #if defined(OS_CHROMEOS) |
| 43 #include "ash/shell.h" | 43 #if defined(USE_SYSTEM_LIBBZ2) |
| 44 #include "ash/shell_delegate.h" | 44 #include <bzlib.h> |
| 45 #endif | 45 #else |
| 46 #include "third_party/bzip2/bzlib.h" |
| 47 #endif // USE_SYSTEM_LIBBZ2 |
| 48 #endif // OS_CHROMEOS |
| 46 | 49 |
| 47 using content::WebContents; | 50 using content::WebContents; |
| 48 | 51 |
| 49 const char kSyncDataKey[] = "about_sync_data"; | |
| 50 | |
| 51 #if defined(OS_CHROMEOS) | |
| 52 const char kHUDLogDataKey[] = "hud_log"; | |
| 53 #endif | |
| 54 | |
| 55 namespace { | |
| 56 | |
| 57 const int kFeedbackVersion = 1; | 52 const int kFeedbackVersion = 1; |
| 58 | 53 |
| 59 const char kReportPhishingUrl[] = | 54 const char kReportPhishingUrl[] = |
| 60 "http://www.google.com/safebrowsing/report_phish/"; | 55 "http://www.google.com/safebrowsing/report_phish/"; |
| 61 | 56 |
| 62 // URL to post bug reports to. | 57 // URL to post bug reports to. |
| 63 const char kFeedbackPostUrl[] = | 58 const char kFeedbackPostUrl[] = |
| 64 "https://www.google.com/tools/feedback/chrome/__submit"; | 59 "https://www.google.com/tools/feedback/chrome/__submit"; |
| 65 | 60 |
| 66 const char kProtBufMimeType[] = "application/x-protobuf"; | 61 const char kProtBufMimeType[] = "application/x-protobuf"; |
| 67 const char kPngMimeType[] = "image/png"; | 62 const char kPngMimeType[] = "image/png"; |
| 68 | 63 |
| 69 // Tags we use in product specific data | 64 // Tags we use in product specific data |
| 70 const char kChromeVersionTag[] = "CHROME VERSION"; | 65 const char kChromeVersionTag[] = "CHROME VERSION"; |
| 71 const char kOsVersionTag[] = "OS VERSION"; | 66 const char kOsVersionTag[] = "OS VERSION"; |
| 72 #if defined(OS_CHROMEOS) | |
| 73 const char kTimestampTag[] = "TIMESTAMP"; | |
| 74 #endif | |
| 75 | 67 |
| 76 const int kHttpPostSuccessNoContent = 204; | 68 const int kHttpPostSuccessNoContent = 204; |
| 77 const int kHttpPostFailNoConnection = -1; | 69 const int kHttpPostFailNoConnection = -1; |
| 78 const int kHttpPostFailClientError = 400; | 70 const int kHttpPostFailClientError = 400; |
| 79 const int kHttpPostFailServerError = 500; | 71 const int kHttpPostFailServerError = 500; |
| 80 | 72 |
| 81 #if defined(OS_CHROMEOS) | |
| 82 const char kBZip2MimeType[] = "application/x-bzip2"; | |
| 83 const char kLogsAttachmentName[] = "system_logs.bz2"; | |
| 84 const char kArbitraryMimeType[] = "application/octet-stream"; | |
| 85 #endif | |
| 86 | |
| 87 const int64 kInitialRetryDelay = 900000; // 15 minutes | 73 const int64 kInitialRetryDelay = 900000; // 15 minutes |
| 88 const int64 kRetryDelayIncreaseFactor = 2; | 74 const int64 kRetryDelayIncreaseFactor = 2; |
| 89 const int64 kRetryDelayLimit = 14400000; // 4 hours | 75 const int64 kRetryDelayLimit = 14400000; // 4 hours |
| 90 | 76 |
| 91 void ReadFileToStringNoResult(const base::FilePath& path, | 77 #if defined(OS_CHROMEOS) |
| 92 std::string* contents) { | 78 const size_t kFeedbackMaxLength = 4 * 1024; |
| 93 if (!file_util::ReadFileToString(path, contents)) | 79 const size_t kFeedbackMaxLineCount = 40; |
| 94 if (contents) | 80 |
| 95 contents->clear(); | 81 const char kBZip2MimeType[] = "application/x-bzip2"; |
| 82 const char kLogsAttachmentName[] = "system_logs.bz2"; |
| 83 const char kArbitraryMimeType[] = "application/octet-stream"; |
| 84 |
| 85 const char kMultilineIndicatorString[] = "<multiline>\n"; |
| 86 const char kMultilineStartString[] = "---------- START ----------\n"; |
| 87 const char kMultilineEndString[] = "---------- END ----------\n\n"; |
| 88 |
| 89 const char kTimestampTag[] = "TIMESTAMP"; |
| 90 #endif |
| 91 |
| 92 #if defined(OS_CHROMEOS) |
| 93 namespace { |
| 94 |
| 95 // This implementation is based on the Firefox MetricsService implementation. |
| 96 bool Bzip2Compress(const std::string& input, std::string* output) { |
| 97 bz_stream stream = {0}; |
| 98 // As long as our input is smaller than the bzip2 block size, we should get |
| 99 // the best compression. For example, if your input was 250k, using a block |
| 100 // size of 300k or 500k should result in the same compression ratio. Since |
| 101 // our data should be under 100k, using the minimum block size of 100k should |
| 102 // allocate less temporary memory, but result in the same compression ratio. |
| 103 int result = BZ2_bzCompressInit(&stream, |
| 104 1, // 100k (min) block size |
| 105 0, // quiet |
| 106 0); // default "work factor" |
| 107 if (result != BZ_OK) { // out of memory? |
| 108 return false; |
| 109 } |
| 110 |
| 111 output->clear(); |
| 112 |
| 113 stream.next_in = const_cast<char*>(input.data()); |
| 114 stream.avail_in = static_cast<int>(input.size()); |
| 115 // NOTE: we don't need a BZ_RUN phase since our input buffer contains |
| 116 // the entire input |
| 117 do { |
| 118 output->resize(output->size() + 1024); |
| 119 stream.next_out = &((*output)[stream.total_out_lo32]); |
| 120 stream.avail_out = static_cast<int>(output->size()) - stream.total_out_lo32; |
| 121 result = BZ2_bzCompress(&stream, BZ_FINISH); |
| 122 } while (result == BZ_FINISH_OK); |
| 123 if (result != BZ_STREAM_END) { // unknown failure? |
| 124 output->clear(); |
| 125 // TODO(jar): See if it would be better to do a CHECK() here. |
| 126 return false; |
| 127 } |
| 128 result = BZ2_bzCompressEnd(&stream); |
| 129 DCHECK(result == BZ_OK); |
| 130 |
| 131 output->resize(stream.total_out_lo32); |
| 132 |
| 133 return true; |
| 134 } |
| 135 |
| 136 std::string ZipLogs(chromeos::SystemLogsResponse* sys_info) { |
| 137 std::string syslogs_string; |
| 138 for (chromeos::SystemLogsResponse::const_iterator it = sys_info->begin(); |
| 139 it != sys_info->end(); ++it) { |
| 140 std::string key = it->first; |
| 141 std::string value = it->second; |
| 142 |
| 143 TrimString(key, "\n ", &key); |
| 144 TrimString(value, "\n ", &value); |
| 145 |
| 146 if (value.find("\n") != std::string::npos) { |
| 147 syslogs_string.append( |
| 148 key + "=" + kMultilineIndicatorString + |
| 149 kMultilineStartString + |
| 150 value + "\n" + |
| 151 kMultilineEndString); |
| 152 } else { |
| 153 syslogs_string.append(key + "=" + value + "\n"); |
| 154 } |
| 155 } |
| 156 std::string compressed_logs; |
| 157 if (Bzip2Compress(syslogs_string, &compressed_logs)) |
| 158 return compressed_logs; |
| 159 else |
| 160 return std::string(); |
| 96 } | 161 } |
| 97 | 162 |
| 98 } // namespace | 163 } // namespace |
| 99 | 164 #endif |
| 100 | 165 |
| 101 // Simple net::URLFetcherDelegate to clean up URLFetcher on completion. | 166 // Simple net::URLFetcherDelegate to clean up URLFetcher on completion. |
| 102 class FeedbackUtil::PostCleanup : public net::URLFetcherDelegate { | 167 class FeedbackUtil::PostCleanup : public net::URLFetcherDelegate { |
| 103 public: | 168 public: |
| 104 PostCleanup(Profile* profile, | 169 PostCleanup(Profile* profile, |
| 105 std::string* post_body, | 170 std::string* post_body, |
| 106 int64 previous_delay) : profile_(profile), | 171 int64 previous_delay) : profile_(profile), |
| 107 post_body_(post_body), | 172 post_body_(post_body), |
| 108 previous_delay_(previous_delay) { } | 173 previous_delay_(previous_delay) { } |
| 109 // Overridden from net::URLFetcherDelegate. | 174 // Overridden from net::URLFetcherDelegate. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Create log_value object and add it to the web_data object | 294 // Create log_value object and add it to the web_data object |
| 230 userfeedback::ProductSpecificData log_value; | 295 userfeedback::ProductSpecificData log_value; |
| 231 log_value.set_key(key); | 296 log_value.set_key(key); |
| 232 log_value.set_value(value); | 297 log_value.set_value(value); |
| 233 userfeedback::WebData* web_data = feedback_data->mutable_web_data(); | 298 userfeedback::WebData* web_data = feedback_data->mutable_web_data(); |
| 234 *(web_data->add_product_specific_data()) = log_value; | 299 *(web_data->add_product_specific_data()) = log_value; |
| 235 } | 300 } |
| 236 | 301 |
| 237 #if defined(OS_CHROMEOS) | 302 #if defined(OS_CHROMEOS) |
| 238 bool FeedbackUtil::ValidFeedbackSize(const std::string& content) { | 303 bool FeedbackUtil::ValidFeedbackSize(const std::string& content) { |
| 239 if (content.length() > chromeos::system::kFeedbackMaxLength) | 304 if (content.length() > kFeedbackMaxLength) |
| 240 return false; | 305 return false; |
| 241 const size_t line_count = std::count(content.begin(), content.end(), '\n'); | 306 const size_t line_count = std::count(content.begin(), content.end(), '\n'); |
| 242 if (line_count > chromeos::system::kFeedbackMaxLineCount) | 307 if (line_count > kFeedbackMaxLineCount) |
| 243 return false; | 308 return false; |
| 244 return true; | 309 return true; |
| 245 } | 310 } |
| 246 #endif | 311 #endif |
| 247 | 312 |
| 248 // static | 313 // static |
| 249 void FeedbackUtil::SendReport(const FeedbackData& data) { | 314 void FeedbackUtil::SendReport(scoped_refptr<FeedbackData> data) { |
| 250 #if defined(OS_CHROMEOS) | 315 if (!data) { |
| 251 if (data.attached_filename().size() && | 316 LOG(ERROR) << "FeedbackUtil::SendReport called with NULL data!"; |
| 252 base::FilePath::IsSeparator(data.attached_filename()[0]) && | 317 NOTREACHED(); |
| 253 !data.attached_filedata()) { | |
| 254 // Read the attached file and then send this report. | |
| 255 std::string* file_data = new std::string; | |
| 256 | |
| 257 base::FilePath root = | |
| 258 ash::Shell::GetInstance()->delegate()-> | |
| 259 GetCurrentBrowserContext()->GetPath(); | |
| 260 base::FilePath filepath = root.Append(data.attached_filename().substr(1)); | |
| 261 std::string stripped_filename = filepath.BaseName().value(); | |
| 262 | |
| 263 // Read the file into file_data, then call send report again with the | |
| 264 // stripped filename and file data (which will skip this code path). | |
| 265 content::BrowserThread::PostTaskAndReply( | |
| 266 content::BrowserThread::FILE, FROM_HERE, | |
| 267 base::Bind(&ReadFileToStringNoResult, | |
| 268 filepath, | |
| 269 file_data), | |
| 270 base::Bind(&FeedbackUtil::SendReport, | |
| 271 FeedbackData(data.profile(), | |
| 272 data.category_tag(), | |
| 273 data.page_url(), | |
| 274 data.description(), | |
| 275 data.user_email(), | |
| 276 data.image(), | |
| 277 data.sys_info(), | |
| 278 data.zip_content(), | |
| 279 data.timestamp(), | |
| 280 stripped_filename, | |
| 281 file_data))); | |
| 282 return; | 318 return; |
| 283 } | 319 } |
| 284 #endif | |
| 285 | 320 |
| 286 // Create google feedback protocol buffer objects | 321 // Create google feedback protocol buffer objects |
| 287 userfeedback::ExtensionSubmit feedback_data; | 322 userfeedback::ExtensionSubmit feedback_data; |
| 288 // type id set to 0, unused field but needs to be initialized to 0 | 323 // type id set to 0, unused field but needs to be initialized to 0 |
| 289 feedback_data.set_type_id(0); | 324 feedback_data.set_type_id(0); |
| 290 | 325 |
| 291 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); | 326 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); |
| 292 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); | 327 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); |
| 293 | 328 |
| 294 // Set our user agent. | 329 // Set our user agent. |
| 295 userfeedback::Navigator* navigator = web_data->mutable_navigator(); | 330 userfeedback::Navigator* navigator = web_data->mutable_navigator(); |
| 296 navigator->set_user_agent(content::GetUserAgent(GURL())); | 331 navigator->set_user_agent(content::GetUserAgent(GURL())); |
| 297 | 332 |
| 298 // Set GAIA id to 0. We're not using gaia id's for recording | 333 // Set GAIA id to 0. We're not using gaia id's for recording |
| 299 // use feedback - we're using the e-mail field, allows users to | 334 // use feedback - we're using the e-mail field, allows users to |
| 300 // submit feedback from incognito mode and specify any mail id | 335 // submit feedback from incognito mode and specify any mail id |
| 301 // they wish | 336 // they wish |
| 302 common_data->set_gaia_id(0); | 337 common_data->set_gaia_id(0); |
| 303 | 338 |
| 304 // Add the user e-mail to the feedback object | 339 // Add the user e-mail to the feedback object |
| 305 common_data->set_user_email(data.user_email()); | 340 common_data->set_user_email(data->user_email()); |
| 306 | 341 |
| 307 // Add the description to the feedback object | 342 // Add the description to the feedback object |
| 308 common_data->set_description(data.description()); | 343 common_data->set_description(data->description()); |
| 309 | 344 |
| 310 // Add the language | 345 // Add the language |
| 311 std::string chrome_locale = g_browser_process->GetApplicationLocale(); | 346 std::string chrome_locale = g_browser_process->GetApplicationLocale(); |
| 312 common_data->set_source_description_language(chrome_locale); | 347 common_data->set_source_description_language(chrome_locale); |
| 313 | 348 |
| 314 // Set the url | 349 // Set the url |
| 315 web_data->set_url(data.page_url()); | 350 web_data->set_url(data->page_url()); |
| 316 | 351 |
| 317 // Add the Chrome version | 352 // Add the Chrome version |
| 318 chrome::VersionInfo version_info; | 353 chrome::VersionInfo version_info; |
| 319 if (version_info.is_valid()) { | 354 if (version_info.is_valid()) { |
| 320 std::string chrome_version = version_info.Name() + " - " + | 355 std::string chrome_version = version_info.Name() + " - " + |
| 321 version_info.Version() + | 356 version_info.Version() + |
| 322 " (" + version_info.LastChange() + ")"; | 357 " (" + version_info.LastChange() + ")"; |
| 323 AddFeedbackData(&feedback_data, std::string(kChromeVersionTag), | 358 AddFeedbackData(&feedback_data, std::string(kChromeVersionTag), |
| 324 chrome_version); | 359 chrome_version); |
| 325 } | 360 } |
| 326 | 361 |
| 327 // We don't need the OS version for ChromeOS since we get it in | 362 // We don't need the OS version for ChromeOS since we get it in |
| 328 // CHROMEOS_RELEASE_VERSION from /etc/lsb-release | 363 // CHROMEOS_RELEASE_VERSION from /etc/lsb-release |
| 329 #if !defined(OS_CHROMEOS) | 364 #if !defined(OS_CHROMEOS) |
| 330 // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). | 365 // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). |
| 331 std::string os_version = ""; | 366 std::string os_version = ""; |
| 332 SetOSVersion(&os_version); | 367 SetOSVersion(&os_version); |
| 333 AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); | 368 AddFeedbackData(&feedback_data, std::string(kOsVersionTag), os_version); |
| 334 #endif | 369 #endif |
| 335 | 370 |
| 336 // Include the page image if we have one. | 371 // Include the page image if we have one. |
| 337 if (data.image().get() && data.image()->size()) { | 372 if (data->image().get() && data->image()->size()) { |
| 338 userfeedback::PostedScreenshot screenshot; | 373 userfeedback::PostedScreenshot screenshot; |
| 339 screenshot.set_mime_type(kPngMimeType); | 374 screenshot.set_mime_type(kPngMimeType); |
| 340 // Set the dimensions of the screenshot | 375 // Set the dimensions of the screenshot |
| 341 userfeedback::Dimensions dimensions; | 376 userfeedback::Dimensions dimensions; |
| 342 gfx::Rect& screen_size = GetScreenshotSize(); | 377 gfx::Rect& screen_size = GetScreenshotSize(); |
| 343 dimensions.set_width(static_cast<float>(screen_size.width())); | 378 dimensions.set_width(static_cast<float>(screen_size.width())); |
| 344 dimensions.set_height(static_cast<float>(screen_size.height())); | 379 dimensions.set_height(static_cast<float>(screen_size.height())); |
| 345 *(screenshot.mutable_dimensions()) = dimensions; | 380 *(screenshot.mutable_dimensions()) = dimensions; |
| 346 | 381 |
| 347 int image_data_size = data.image()->size(); | 382 int image_data_size = data->image()->size(); |
| 348 char* image_data = reinterpret_cast<char*>(&(data.image()->front())); | 383 char* image_data = reinterpret_cast<char*>(&(data->image()->front())); |
| 349 screenshot.set_binary_content(std::string(image_data, image_data_size)); | 384 screenshot.set_binary_content(std::string(image_data, image_data_size)); |
| 350 | 385 |
| 351 // Set the screenshot object in feedback | 386 // Set the screenshot object in feedback |
| 352 *(feedback_data.mutable_screenshot()) = screenshot; | 387 *(feedback_data.mutable_screenshot()) = screenshot; |
| 353 } | 388 } |
| 354 | 389 |
| 355 #if defined(OS_CHROMEOS) | 390 #if defined(OS_CHROMEOS) |
| 356 if (data.sys_info()) { | 391 if (data->sys_info()) { |
| 357 // Add the product specific data | 392 // Add the product specific data |
| 358 for (chromeos::system::LogDictionaryType::const_iterator i = | 393 for (chromeos::SystemLogsResponse::const_iterator i = |
| 359 data.sys_info()->begin(); i != data.sys_info()->end(); ++i) { | 394 data->sys_info()->begin(); i != data->sys_info()->end(); ++i) { |
| 360 if (i->first == kSyncDataKey || | 395 if (ValidFeedbackSize(i->second)) { |
| 361 i->first == kHUDLogDataKey || | |
| 362 ValidFeedbackSize(i->second)) { | |
| 363 AddFeedbackData(&feedback_data, i->first, i->second); | 396 AddFeedbackData(&feedback_data, i->first, i->second); |
| 364 } | 397 } |
| 365 } | 398 } |
| 366 | 399 |
| 367 // If we have zipped logs, add them here | 400 std::string compressed_logs = ZipLogs(data->sys_info()); |
| 368 if (data.zip_content()) { | 401 if (compressed_logs.size()) { |
| 369 userfeedback::ProductSpecificBinaryData attachment; | 402 userfeedback::ProductSpecificBinaryData attachment; |
| 370 attachment.set_mime_type(kBZip2MimeType); | 403 attachment.set_mime_type(kBZip2MimeType); |
| 371 attachment.set_name(kLogsAttachmentName); | 404 attachment.set_name(kLogsAttachmentName); |
| 372 attachment.set_data(*data.zip_content()); | 405 attachment.set_data(compressed_logs); |
| 373 delete data.zip_content(); | |
| 374 *(feedback_data.add_product_specific_binary_data()) = attachment; | 406 *(feedback_data.add_product_specific_binary_data()) = attachment; |
| 375 } | 407 } |
| 376 } | 408 } |
| 377 delete data.sys_info(); | |
| 378 | 409 |
| 379 if (data.timestamp() != "") | 410 if (data->timestamp() != "") |
| 380 AddFeedbackData(&feedback_data, std::string(kTimestampTag), | 411 AddFeedbackData(&feedback_data, std::string(kTimestampTag), |
| 381 data.timestamp()); | 412 data->timestamp()); |
| 382 | 413 |
| 383 if (data.attached_filename() != "" && data.attached_filedata() && | 414 if (data->attached_filename() != "" && |
| 384 data.attached_filedata()->size()) { | 415 data->attached_filedata() && |
| 416 data->attached_filedata()->size()) { |
| 385 userfeedback::ProductSpecificBinaryData attached_file; | 417 userfeedback::ProductSpecificBinaryData attached_file; |
| 386 attached_file.set_mime_type(kArbitraryMimeType); | 418 attached_file.set_mime_type(kArbitraryMimeType); |
| 387 attached_file.set_name(data.attached_filename()); | 419 attached_file.set_name(data->attached_filename()); |
| 388 attached_file.set_data(*data.attached_filedata()); | 420 attached_file.set_data(*data->attached_filedata()); |
| 389 delete data.attached_filedata(); | 421 delete data->attached_filedata(); |
| 390 *(feedback_data.add_product_specific_binary_data()) = attached_file; | 422 *(feedback_data.add_product_specific_binary_data()) = attached_file; |
| 391 } | 423 } |
| 392 #endif | 424 #endif |
| 393 | 425 |
| 394 // Set our category tag if we have one | 426 // Set our category tag if we have one |
| 395 if (data.category_tag().size()) | 427 if (data->category_tag().size()) |
| 396 feedback_data.set_category_tag(data.category_tag()); | 428 feedback_data.set_category_tag(data->category_tag()); |
| 397 | 429 |
| 398 // Set our Chrome specific data | 430 // Set our Chrome specific data |
| 399 userfeedback::ChromeData chrome_data; | 431 userfeedback::ChromeData chrome_data; |
| 400 chrome_data.set_chrome_platform( | 432 chrome_data.set_chrome_platform( |
| 401 #if defined(OS_CHROMEOS) | 433 #if defined(OS_CHROMEOS) |
| 402 userfeedback::ChromeData_ChromePlatform_CHROME_OS); | 434 userfeedback::ChromeData_ChromePlatform_CHROME_OS); |
| 403 userfeedback::ChromeOsData chrome_os_data; | 435 userfeedback::ChromeOsData chrome_os_data; |
| 404 chrome_os_data.set_category( | 436 chrome_os_data.set_category( |
| 405 userfeedback::ChromeOsData_ChromeOsCategory_OTHER); | 437 userfeedback::ChromeOsData_ChromeOsCategory_OTHER); |
| 406 *(chrome_data.mutable_chrome_os_data()) = chrome_os_data; | 438 *(chrome_data.mutable_chrome_os_data()) = chrome_os_data; |
| 407 #else | 439 #else |
| 408 userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER); | 440 userfeedback::ChromeData_ChromePlatform_CHROME_BROWSER); |
| 409 userfeedback::ChromeBrowserData chrome_browser_data; | 441 userfeedback::ChromeBrowserData chrome_browser_data; |
| 410 chrome_browser_data.set_category( | 442 chrome_browser_data.set_category( |
| 411 userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER); | 443 userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER); |
| 412 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; | 444 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; |
| 413 #endif | 445 #endif |
| 414 | 446 |
| 415 *(feedback_data.mutable_chrome_data()) = chrome_data; | 447 *(feedback_data.mutable_chrome_data()) = chrome_data; |
| 416 | 448 |
| 417 // Serialize our report to a string pointer we can pass around | 449 // Serialize our report to a string pointer we can pass around |
| 418 std::string* post_body = new std::string; | 450 std::string* post_body = new std::string; |
| 419 feedback_data.SerializeToString(post_body); | 451 feedback_data.SerializeToString(post_body); |
| 420 | 452 |
| 421 // We have the body of our POST, so send it off to the server with 0 delay | 453 // We have the body of our POST, so send it off to the server with 0 delay |
| 422 DispatchFeedback(data.profile(), post_body, 0); | 454 DispatchFeedback(data->profile(), post_body, 0); |
| 423 } | 455 } |
| 424 | 456 |
| 425 #if defined(FULL_SAFE_BROWSING) | 457 #if defined(FULL_SAFE_BROWSING) |
| 426 // static | 458 // static |
| 427 void FeedbackUtil::ReportPhishing(WebContents* current_tab, | 459 void FeedbackUtil::ReportPhishing(WebContents* current_tab, |
| 428 const std::string& phishing_url) { | 460 const std::string& phishing_url) { |
| 429 current_tab->GetController().LoadURL( | 461 current_tab->GetController().LoadURL( |
| 430 safe_browsing_util::GeneratePhishingReportUrl( | 462 safe_browsing_util::GeneratePhishingReportUrl( |
| 431 kReportPhishingUrl, phishing_url, | 463 kReportPhishingUrl, phishing_url, |
| 432 false /* not client-side detection */), | 464 false /* not client-side detection */), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 457 if (screenshot_size == NULL) | 489 if (screenshot_size == NULL) |
| 458 screenshot_size = new gfx::Rect(); | 490 screenshot_size = new gfx::Rect(); |
| 459 return *screenshot_size; | 491 return *screenshot_size; |
| 460 } | 492 } |
| 461 | 493 |
| 462 // static | 494 // static |
| 463 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { | 495 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { |
| 464 gfx::Rect& screen_size = GetScreenshotSize(); | 496 gfx::Rect& screen_size = GetScreenshotSize(); |
| 465 screen_size = rect; | 497 screen_size = rect; |
| 466 } | 498 } |
| OLD | NEW |