| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/bug_report_data.h" | |
| 6 | |
| 7 #include "chrome/browser/bug_report_util.h" | |
| 8 #include "content/public/browser/browser_thread.h" | |
| 9 | |
| 10 #if defined(OS_CHROMEOS) | |
| 11 #include "chrome/browser/chromeos/notifications/system_notification.h" | |
| 12 #endif | |
| 13 | |
| 14 using content::BrowserThread; | |
| 15 | |
| 16 BugReportData::BugReportData() | |
| 17 : profile_(NULL), | |
| 18 problem_type_(0) | |
| 19 #if defined(OS_CHROMEOS) | |
| 20 , sys_info_(NULL) | |
| 21 , zip_content_(NULL) | |
| 22 , sent_report_(false) | |
| 23 , send_sys_info_(false) | |
| 24 #endif | |
| 25 { | |
| 26 } | |
| 27 | |
| 28 BugReportData::~BugReportData() {} | |
| 29 | |
| 30 void BugReportData::UpdateData(Profile* profile, | |
| 31 const std::string& target_tab_url, | |
| 32 const int problem_type, | |
| 33 const std::string& page_url, | |
| 34 const std::string& description, | |
| 35 ScreenshotDataPtr image | |
| 36 #if defined(OS_CHROMEOS) | |
| 37 , const std::string& user_email | |
| 38 , const bool send_sys_info | |
| 39 , const bool sent_report | |
| 40 #endif | |
| 41 ) { | |
| 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 43 profile_ = profile; | |
| 44 target_tab_url_ = target_tab_url; | |
| 45 problem_type_ = problem_type; | |
| 46 page_url_ = page_url; | |
| 47 description_ = description; | |
| 48 image_ = image; | |
| 49 #if defined(OS_CHROMEOS) | |
| 50 user_email_ = user_email; | |
| 51 send_sys_info_ = send_sys_info; | |
| 52 sent_report_ = sent_report; | |
| 53 #endif | |
| 54 } | |
| 55 | |
| 56 void BugReportData::SendReport() { | |
| 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 58 #if defined(OS_CHROMEOS) | |
| 59 if (sent_report_) | |
| 60 return; // We already received the syslogs and sent the report. | |
| 61 | |
| 62 // Set send_report_ to ensure that we only send one report. | |
| 63 sent_report_ = true; | |
| 64 #endif | |
| 65 | |
| 66 gfx::Rect& screen_size = BugReportUtil::GetScreenshotSize(); | |
| 67 BugReportUtil::SendReport(profile_ | |
| 68 , problem_type_ | |
| 69 , page_url_ | |
| 70 , description_ | |
| 71 , image_ | |
| 72 , screen_size.width() | |
| 73 , screen_size.height() | |
| 74 #if defined(OS_CHROMEOS) | |
| 75 , user_email_ | |
| 76 , zip_content_ ? zip_content_->c_str() : NULL | |
| 77 , zip_content_ ? zip_content_->length() : 0 | |
| 78 , send_sys_info_ ? sys_info_ : NULL | |
| 79 #endif | |
| 80 ); | |
| 81 | |
| 82 #if defined(OS_CHROMEOS) | |
| 83 if (sys_info_) { | |
| 84 delete sys_info_; | |
| 85 sys_info_ = NULL; | |
| 86 } | |
| 87 if (zip_content_) { | |
| 88 delete zip_content_; | |
| 89 zip_content_ = NULL; | |
| 90 } | |
| 91 #endif | |
| 92 | |
| 93 // Delete this object once the report has been sent. | |
| 94 delete this; | |
| 95 } | |
| 96 | |
| 97 #if defined(OS_CHROMEOS) | |
| 98 // SyslogsComplete may be called before UpdateData, in which case, we do not | |
| 99 // want to delete the logs that were gathered, and we do not want to send the | |
| 100 // report either. Instead simply populate |sys_info_| and |zip_content_|. | |
| 101 void BugReportData::SyslogsComplete(chromeos::system::LogDictionaryType* logs, | |
| 102 std::string* zip_content) { | |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 104 if (sent_report_) { | |
| 105 // We already sent the report, just delete the data. | |
| 106 if (logs) | |
| 107 delete logs; | |
| 108 if (zip_content) | |
| 109 delete zip_content; | |
| 110 } else { | |
| 111 zip_content_ = zip_content; | |
| 112 sys_info_ = logs; // Will get deleted when SendReport() is called. | |
| 113 if (send_sys_info_) { | |
| 114 // We already prepared the report, send it now. | |
| 115 this->SendReport(); | |
| 116 } | |
| 117 } | |
| 118 } | |
| 119 #endif | |
| OLD | NEW |