| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/feedback_util.h" | 5 #include "chrome/browser/chromeos/feedback_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" | 10 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
| 11 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" | 11 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 | 13 |
| 14 using feedback::FeedbackData; | 14 using feedback::FeedbackData; |
| 15 | 15 |
| 16 namespace feedback_util { | 16 namespace feedback_util { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 extensions::FeedbackService* GetFeedbackService(Profile* profile) { | 20 extensions::FeedbackService* GetFeedbackService(Profile* profile) { |
| 21 return extensions::FeedbackPrivateAPI::GetFactoryInstance() | 21 return extensions::FeedbackPrivateAPI::GetFactoryInstance() |
| 22 ->Get(profile) | 22 ->Get(profile) |
| 23 ->GetService(); | 23 ->GetService(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void OnGetSystemInformation(Profile* profile, | 26 void OnGetSystemInformation( |
| 27 const std::string& description, | 27 Profile* profile, |
| 28 const SendSysLogFeedbackCallback& callback, | 28 const std::string& description, |
| 29 const extensions::SystemInformationList& sys_info) { | 29 const SendSysLogFeedbackCallback& callback, |
| 30 std::unique_ptr<system_logs::SystemLogsResponse> sys_info) { |
| 30 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); | 31 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); |
| 31 | 32 |
| 32 feedback_data->set_context(profile); | 33 feedback_data->set_context(profile); |
| 33 feedback_data->set_description(description); | 34 feedback_data->set_description(description); |
| 34 | 35 feedback_data->SetAndCompressSystemInfo(std::move(sys_info)); |
| 35 std::unique_ptr<FeedbackData::SystemLogsMap> sys_logs( | |
| 36 new FeedbackData::SystemLogsMap); | |
| 37 for (const extensions::api::feedback_private::SystemInformation& info : | |
| 38 sys_info) { | |
| 39 (*sys_logs.get())[info.key] = info.value; | |
| 40 } | |
| 41 feedback_data->SetAndCompressSystemInfo(std::move(sys_logs)); | |
| 42 | 36 |
| 43 GetFeedbackService(profile)->SendFeedback(profile, feedback_data, callback); | 37 GetFeedbackService(profile)->SendFeedback(profile, feedback_data, callback); |
| 44 } | 38 } |
| 45 | 39 |
| 46 } // namespace | 40 } // namespace |
| 47 | 41 |
| 48 void SendSysLogFeedback(Profile* profile, | 42 void SendSysLogFeedback(Profile* profile, |
| 49 const std::string& description, | 43 const std::string& description, |
| 50 const SendSysLogFeedbackCallback& callback) { | 44 const SendSysLogFeedbackCallback& callback) { |
| 51 GetFeedbackService(profile)->GetSystemInformation( | 45 GetFeedbackService(profile)->GetSystemInformation( |
| 52 base::Bind(&OnGetSystemInformation, profile, description, callback)); | 46 base::Bind(&OnGetSystemInformation, profile, description, callback)); |
| 53 } | 47 } |
| 54 | 48 |
| 55 } // namespace feedback_util | 49 } // namespace feedback_util |
| OLD | NEW |