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