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