| 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 28 matching lines...) Expand all Loading... |
| 39 #include "content/public/common/content_client.h" | 39 #include "content/public/common/content_client.h" |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "grit/locale_settings.h" | 41 #include "grit/locale_settings.h" |
| 42 #include "grit/theme_resources.h" | 42 #include "grit/theme_resources.h" |
| 43 #include "net/base/load_flags.h" | 43 #include "net/base/load_flags.h" |
| 44 #include "net/http/http_request_headers.h" | 44 #include "net/http/http_request_headers.h" |
| 45 #include "net/url_request/url_fetcher.h" | 45 #include "net/url_request/url_fetcher.h" |
| 46 #include "net/url_request/url_fetcher_delegate.h" | 46 #include "net/url_request/url_fetcher_delegate.h" |
| 47 #include "net/url_request/url_request_status.h" | 47 #include "net/url_request/url_request_status.h" |
| 48 #include "third_party/icu/source/common/unicode/locid.h" | 48 #include "third_party/icu/source/common/unicode/locid.h" |
| 49 #include "third_party/zlib/google/zip.h" | 49 #include "third_party/zlib/google/zip_writer.h" |
| 50 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
| 51 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 GURL GetTargetTabUrl(int session_id, int index) { | 55 GURL GetTargetTabUrl(int session_id, int index) { |
| 56 Browser* browser = chrome::FindBrowserWithID(session_id); | 56 Browser* browser = chrome::FindBrowserWithID(session_id); |
| 57 // Sanity checks. | 57 // Sanity checks. |
| 58 if (!browser || index >= browser->tab_strip_model()->count()) | 58 if (!browser || index >= browser->tab_strip_model()->count()) |
| 59 return GURL(); | 59 return GURL(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 scoped_ptr<std::string> post_body(new std::string); | 241 scoped_ptr<std::string> post_body(new std::string); |
| 242 feedback_data.SerializeToString(post_body.get()); | 242 feedback_data.SerializeToString(post_body.get()); |
| 243 | 243 |
| 244 feedback::FeedbackUploader *uploader = | 244 feedback::FeedbackUploader *uploader = |
| 245 feedback::FeedbackUploaderFactory::GetForBrowserContext(data->profile()); | 245 feedback::FeedbackUploaderFactory::GetForBrowserContext(data->profile()); |
| 246 uploader->QueueReport(post_body.Pass()); | 246 uploader->QueueReport(post_body.Pass()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool ZipString(const base::FilePath& filename, | 249 bool ZipString(const base::FilePath& filename, |
| 250 const std::string& data, std::string* compressed_logs) { | 250 const std::string& data, std::string* compressed_logs) { |
| 251 base::FilePath temp_path; | |
| 252 base::FilePath zip_file; | 251 base::FilePath zip_file; |
| 253 | 252 |
| 254 // Create a temporary directory, put the logs into a file in it. Create | 253 zip::ZipWriter writer; |
| 255 // another temporary file to receive the zip file in. | 254 writer.AddFile(filename, data); |
| 256 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path)) | |
| 257 return false; | |
| 258 if (file_util::WriteFile(temp_path.Append(filename), | |
| 259 data.c_str(), data.size()) == -1) | |
| 260 return false; | |
| 261 | 255 |
| 262 bool succeed = base::CreateTemporaryFile(&zip_file) && | 256 bool succeed = base::CreateTemporaryFile(&zip_file) && |
| 263 zip::Zip(temp_path, zip_file, false) && | 257 writer.Commit(zip_file, zip::ZipWriter::OverWrite) && |
| 264 base::ReadFileToString(zip_file, compressed_logs); | 258 base::ReadFileToString(zip_file, compressed_logs); |
| 265 | 259 |
| 266 base::DeleteFile(temp_path, true); | |
| 267 base::DeleteFile(zip_file, false); | 260 base::DeleteFile(zip_file, false); |
| 268 | 261 |
| 269 return succeed; | 262 return succeed; |
| 270 } | 263 } |
| 271 | 264 |
| 272 } // namespace feedback_util | 265 } // namespace feedback_util |
| OLD | NEW |