| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 void FeedbackPrivateGetSystemInformationFunction::OnCompleted( | 227 void FeedbackPrivateGetSystemInformationFunction::OnCompleted( |
| 228 const SystemInformationList& sys_info) { | 228 const SystemInformationList& sys_info) { |
| 229 results_ = feedback_private::GetSystemInformation::Results::Create( | 229 results_ = feedback_private::GetSystemInformation::Results::Create( |
| 230 sys_info); | 230 sys_info); |
| 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.get()); | 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; | 241 std::string attached_file_uuid; |
| 242 if (feedback_info.attached_file_blob_uuid.get() && | 242 if (feedback_info.attached_file_blob_uuid && |
| 243 !feedback_info.attached_file_blob_uuid->empty()) | 243 !feedback_info.attached_file_blob_uuid->empty()) { |
| 244 attached_file_uuid = *feedback_info.attached_file_blob_uuid; | 244 attached_file_uuid = *feedback_info.attached_file_blob_uuid; |
| 245 } |
| 245 | 246 |
| 246 std::string screenshot_uuid; | 247 std::string screenshot_uuid; |
| 247 if (feedback_info.screenshot_blob_uuid.get() && | 248 if (feedback_info.screenshot_blob_uuid && |
| 248 !feedback_info.screenshot_blob_uuid->empty()) | 249 !feedback_info.screenshot_blob_uuid->empty()) { |
| 249 screenshot_uuid = *feedback_info.screenshot_blob_uuid; | 250 screenshot_uuid = *feedback_info.screenshot_blob_uuid; |
| 251 } |
| 250 | 252 |
| 251 // Populate feedback data. | 253 // Populate feedback data. |
| 252 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); | 254 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); |
| 253 feedback_data->set_context(GetProfile()); | 255 feedback_data->set_context(GetProfile()); |
| 254 feedback_data->set_description(feedback_info.description); | 256 feedback_data->set_description(feedback_info.description); |
| 255 | 257 |
| 256 if (feedback_info.category_tag.get()) | 258 if (feedback_info.product_id) |
| 259 feedback_data->set_product_id(*feedback_info.product_id); |
| 260 if (feedback_info.category_tag) |
| 257 feedback_data->set_category_tag(*feedback_info.category_tag); | 261 feedback_data->set_category_tag(*feedback_info.category_tag); |
| 258 if (feedback_info.page_url.get()) | 262 if (feedback_info.page_url) |
| 259 feedback_data->set_page_url(*feedback_info.page_url); | 263 feedback_data->set_page_url(*feedback_info.page_url); |
| 260 if (feedback_info.email.get()) | 264 if (feedback_info.email) |
| 261 feedback_data->set_user_email(*feedback_info.email); | 265 feedback_data->set_user_email(*feedback_info.email); |
| 262 | 266 |
| 263 if (!attached_file_uuid.empty()) { | 267 if (!attached_file_uuid.empty()) { |
| 264 feedback_data->set_attached_filename( | 268 feedback_data->set_attached_filename( |
| 265 StripFakepath((*feedback_info.attached_file).name)); | 269 StripFakepath((*feedback_info.attached_file).name)); |
| 266 feedback_data->set_attached_file_uuid(attached_file_uuid); | 270 feedback_data->set_attached_file_uuid(attached_file_uuid); |
| 267 } | 271 } |
| 268 | 272 |
| 269 if (!screenshot_uuid.empty()) | 273 if (!screenshot_uuid.empty()) |
| 270 feedback_data->set_screenshot_uuid(screenshot_uuid); | 274 feedback_data->set_screenshot_uuid(screenshot_uuid); |
| 271 | 275 |
| 272 if (feedback_info.trace_id.get()) { | 276 if (feedback_info.trace_id) { |
| 273 feedback_data->set_trace_id(*feedback_info.trace_id); | 277 feedback_data->set_trace_id(*feedback_info.trace_id); |
| 274 } | 278 } |
| 275 | 279 |
| 276 std::unique_ptr<FeedbackData::SystemLogsMap> sys_logs( | 280 std::unique_ptr<FeedbackData::SystemLogsMap> sys_logs( |
| 277 new FeedbackData::SystemLogsMap); | 281 new FeedbackData::SystemLogsMap); |
| 278 SystemInformationList* sys_info = feedback_info.system_information.get(); | 282 SystemInformationList* sys_info = feedback_info.system_information.get(); |
| 279 if (sys_info) { | 283 if (sys_info) { |
| 280 for (const SystemInformation& info : *sys_info) | 284 for (const SystemInformation& info : *sys_info) |
| 281 (*sys_logs)[info.key] = info.value; | 285 (*sys_logs)[info.key] = info.value; |
| 282 } | 286 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 content::RecordAction( | 334 content::RecordAction( |
| 331 base::UserMetricsAction("Feedback.SrtPromptClosed")); | 335 base::UserMetricsAction("Feedback.SrtPromptClosed")); |
| 332 break; | 336 break; |
| 333 default: | 337 default: |
| 334 return RespondNow(Error("Invalid arugment.")); | 338 return RespondNow(Error("Invalid arugment.")); |
| 335 } | 339 } |
| 336 return RespondNow(NoArguments()); | 340 return RespondNow(NoArguments()); |
| 337 } | 341 } |
| 338 | 342 |
| 339 } // namespace extensions | 343 } // namespace extensions |
| OLD | NEW |