| 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 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/common/content_client.h" | 31 #include "content/public/common/content_client.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/http/http_request_headers.h" | 36 #include "net/http/http_request_headers.h" |
| 37 #include "net/url_request/url_fetcher.h" | 37 #include "net/url_request/url_fetcher.h" |
| 38 #include "net/url_request/url_fetcher_delegate.h" | 38 #include "net/url_request/url_fetcher_delegate.h" |
| 39 #include "net/url_request/url_request_status.h" | 39 #include "net/url_request/url_request_status.h" |
| 40 #include "third_party/icu/source/common/unicode/locid.h" | 40 #include "third_party/icu/source/common/unicode/locid.h" |
| 41 #include "third_party/zlib/google/zip.h" | |
| 42 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "url/gurl.h" | 42 #include "url/gurl.h" |
| 44 | 43 |
| 44 #if defined(OS_CHROMEOS) |
| 45 #include "third_party/zlib/google/zip.h" |
| 46 #endif |
| 47 |
| 45 using content::WebContents; | 48 using content::WebContents; |
| 46 | 49 |
| 47 namespace { | 50 namespace { |
| 48 const char kLogsFilename[] = "system_logs.txt"; | 51 const char kLogsFilename[] = "system_logs.txt"; |
| 49 } | 52 } |
| 50 | 53 |
| 51 namespace chrome { | 54 namespace chrome { |
| 52 const char kAppLauncherCategoryTag[] = "AppLauncher"; | 55 const char kAppLauncherCategoryTag[] = "AppLauncher"; |
| 53 } // namespace chrome | 56 } // namespace chrome |
| 54 | 57 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 screenshot_size = new gfx::Rect(); | 427 screenshot_size = new gfx::Rect(); |
| 425 return *screenshot_size; | 428 return *screenshot_size; |
| 426 } | 429 } |
| 427 | 430 |
| 428 // static | 431 // static |
| 429 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { | 432 void FeedbackUtil::SetScreenshotSize(const gfx::Rect& rect) { |
| 430 gfx::Rect& screen_size = GetScreenshotSize(); | 433 gfx::Rect& screen_size = GetScreenshotSize(); |
| 431 screen_size = rect; | 434 screen_size = rect; |
| 432 } | 435 } |
| 433 | 436 |
| 437 #if defined(OS_CHROMEOS) |
| 434 // static | 438 // static |
| 435 bool FeedbackUtil::ZipString(const std::string& logs, | 439 bool FeedbackUtil::ZipString(const std::string& logs, |
| 436 std::string* compressed_logs) { | 440 std::string* compressed_logs) { |
| 437 base::FilePath temp_path; | 441 base::FilePath temp_path; |
| 438 base::FilePath zip_file; | 442 base::FilePath zip_file; |
| 439 | 443 |
| 440 // Create a temporary directory, put the logs into a file in it. Create | 444 // Create a temporary directory, put the logs into a file in it. Create |
| 441 // another temporary file to receive the zip file in. | 445 // another temporary file to receive the zip file in. |
| 442 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &temp_path)) | 446 if (!file_util::CreateNewTempDirectory("", &temp_path)) |
| 443 return false; | 447 return false; |
| 444 if (file_util::WriteFile(temp_path.Append(FILE_PATH_LITERAL(kLogsFilename)), | 448 if (file_util::WriteFile( |
| 445 logs.c_str(), logs.size()) == -1) | 449 temp_path.Append(kLogsFilename), logs.c_str(), logs.size()) == -1) |
| 446 return false; | 450 return false; |
| 447 if (!file_util::CreateTemporaryFile(&zip_file)) | 451 if (!file_util::CreateTemporaryFile(&zip_file)) |
| 448 return false; | 452 return false; |
| 449 | 453 |
| 450 if (!zip::Zip(temp_path, zip_file, false)) | 454 if (!zip::Zip(temp_path, zip_file, false)) |
| 451 return false; | 455 return false; |
| 452 | 456 |
| 453 if (!file_util::ReadFileToString(zip_file, compressed_logs)) | 457 if (!file_util::ReadFileToString(zip_file, compressed_logs)) |
| 454 return false; | 458 return false; |
| 455 | 459 |
| 456 return true; | 460 return true; |
| 457 } | 461 } |
| 462 #endif // OS_CHROMEOS |
| 463 |
| OLD | NEW |