1// Copyright (c) 2010 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#if defined(OS_CHROMEOS)
8#include "chrome/browser/chromeos/notifications/system_notification.h"
9#endif
10
11BugReportData::BugReportData()
12    : profile_(NULL),
13      problem_type_(0)
14#if defined(OS_CHROMEOS)
15    , sys_info_(NULL)
16    , zip_content_(NULL)
17    , sent_report_(false)
18    , send_sys_info_(false)
19#endif
20{
21}
22
23BugReportData::~BugReportData() {}
24
25void BugReportData::UpdateData(Profile* profile,
26                               const std::string& target_tab_url,
27                               const int problem_type,
28                               const std::string& page_url,
29                               const std::string& description,
30                               const std::vector<unsigned char>& image
31#if defined(OS_CHROMEOS)
32                               , const std::string& user_email
33                               , const bool send_sys_info
34                               , const bool sent_report
35#endif
36                               ) {
37  profile_ = profile;
38  target_tab_url_ = target_tab_url;
39  problem_type_ = problem_type;
40  page_url_ = page_url;
41  description_ = description;
42  image_ = image;
43#if defined(OS_CHROMEOS)
44  user_email_ = user_email;
45  send_sys_info_ = send_sys_info;
46  sent_report_ = sent_report;
47#endif
48}
49
50
51#if defined(OS_CHROMEOS)
52// Called from the same thread as HandleGetDialogDefaults, i.e. the UI thread.
53void BugReportData::SyslogsComplete(chromeos::LogDictionaryType* logs,
54                                    std::string* zip_content) {
55  if (sent_report_) {
56    // We already sent the report, just delete the data.
57    if (logs)
58      delete logs;
59    if (zip_content)
60      delete zip_content;
61  } else {
62    zip_content_ = zip_content;
63    sys_info_ = logs;  // Will get deleted when SendReport() is called.
64    if (send_sys_info_) {
65      // We already prepared the report, send it now.
66      this->SendReport();
67    }
68  }
69}
70#endif
71