| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/feedback_private/feedback_private_api.h" | 5 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 SendResponse(true); | 231 SendResponse(true); |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool FeedbackPrivateSendFeedbackFunction::RunAsync() { | 234 bool FeedbackPrivateSendFeedbackFunction::RunAsync() { |
| 235 std::unique_ptr<feedback_private::SendFeedback::Params> params( | 235 std::unique_ptr<feedback_private::SendFeedback::Params> params( |
| 236 feedback_private::SendFeedback::Params::Create(*args_)); | 236 feedback_private::SendFeedback::Params::Create(*args_)); |
| 237 EXTENSION_FUNCTION_VALIDATE(params); | 237 EXTENSION_FUNCTION_VALIDATE(params); |
| 238 | 238 |
| 239 const FeedbackInfo &feedback_info = params->feedback; | 239 const FeedbackInfo &feedback_info = params->feedback; |
| 240 | 240 |
| 241 std::string attached_file_uuid; | |
| 242 if (feedback_info.attached_file_blob_uuid && | |
| 243 !feedback_info.attached_file_blob_uuid->empty()) { | |
| 244 attached_file_uuid = *feedback_info.attached_file_blob_uuid; | |
| 245 } | |
| 246 | |
| 247 std::string screenshot_uuid; | |
| 248 if (feedback_info.screenshot_blob_uuid && | |
| 249 !feedback_info.screenshot_blob_uuid->empty()) { | |
| 250 screenshot_uuid = *feedback_info.screenshot_blob_uuid; | |
| 251 } | |
| 252 | |
| 253 // Populate feedback data. | 241 // Populate feedback data. |
| 254 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); | 242 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); |
| 255 feedback_data->set_context(GetProfile()); | 243 feedback_data->set_context(GetProfile()); |
| 256 feedback_data->set_description(feedback_info.description); | 244 feedback_data->set_description(feedback_info.description); |
| 257 | 245 |
| 258 if (feedback_info.product_id) | 246 if (feedback_info.product_id) |
| 259 feedback_data->set_product_id(*feedback_info.product_id); | 247 feedback_data->set_product_id(*feedback_info.product_id); |
| 260 if (feedback_info.category_tag) | 248 if (feedback_info.category_tag) |
| 261 feedback_data->set_category_tag(*feedback_info.category_tag); | 249 feedback_data->set_category_tag(*feedback_info.category_tag); |
| 262 if (feedback_info.page_url) | 250 if (feedback_info.page_url) |
| 263 feedback_data->set_page_url(*feedback_info.page_url); | 251 feedback_data->set_page_url(*feedback_info.page_url); |
| 264 if (feedback_info.email) | 252 if (feedback_info.email) |
| 265 feedback_data->set_user_email(*feedback_info.email); | 253 feedback_data->set_user_email(*feedback_info.email); |
| 254 if (feedback_info.trace_id) |
| 255 feedback_data->set_trace_id(*feedback_info.trace_id); |
| 266 | 256 |
| 267 if (!attached_file_uuid.empty()) { | 257 if (feedback_info.attached_file_blob_uuid && |
| 258 !feedback_info.attached_file_blob_uuid->empty()) { |
| 268 feedback_data->set_attached_filename( | 259 feedback_data->set_attached_filename( |
| 269 StripFakepath((*feedback_info.attached_file).name)); | 260 StripFakepath((*feedback_info.attached_file).name)); |
| 270 feedback_data->set_attached_file_uuid(attached_file_uuid); | 261 feedback_data->set_attached_file_uuid( |
| 262 *feedback_info.attached_file_blob_uuid); |
| 271 } | 263 } |
| 272 | 264 |
| 273 if (!screenshot_uuid.empty()) | 265 if (feedback_info.screenshot_blob_uuid && |
| 274 feedback_data->set_screenshot_uuid(screenshot_uuid); | 266 !feedback_info.screenshot_blob_uuid->empty()) { |
| 275 | 267 feedback_data->set_screenshot_uuid(*feedback_info.screenshot_blob_uuid); |
| 276 if (feedback_info.trace_id) { | |
| 277 feedback_data->set_trace_id(*feedback_info.trace_id); | |
| 278 } | 268 } |
| 279 | 269 |
| 280 std::unique_ptr<FeedbackData::SystemLogsMap> sys_logs( | 270 std::unique_ptr<FeedbackData::SystemLogsMap> sys_logs( |
| 281 new FeedbackData::SystemLogsMap); | 271 new FeedbackData::SystemLogsMap); |
| 282 SystemInformationList* sys_info = feedback_info.system_information.get(); | 272 SystemInformationList* sys_info = feedback_info.system_information.get(); |
| 283 if (sys_info) { | 273 if (sys_info) { |
| 284 for (const SystemInformation& info : *sys_info) | 274 for (const SystemInformation& info : *sys_info) |
| 285 (*sys_logs)[info.key] = info.value; | 275 (*sys_logs)[info.key] = info.value; |
| 286 } | 276 } |
| 287 feedback_data->SetAndCompressSystemInfo(std::move(sys_logs)); | 277 feedback_data->SetAndCompressSystemInfo(std::move(sys_logs)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 content::RecordAction( | 324 content::RecordAction( |
| 335 base::UserMetricsAction("Feedback.SrtPromptClosed")); | 325 base::UserMetricsAction("Feedback.SrtPromptClosed")); |
| 336 break; | 326 break; |
| 337 default: | 327 default: |
| 338 return RespondNow(Error("Invalid arugment.")); | 328 return RespondNow(Error("Invalid arugment.")); |
| 339 } | 329 } |
| 340 return RespondNow(NoArguments()); | 330 return RespondNow(NoArguments()); |
| 341 } | 331 } |
| 342 | 332 |
| 343 } // namespace extensions | 333 } // namespace extensions |
| OLD | NEW |