| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" | 13 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" |
| 14 #include "chrome/browser/feedback/tracing_manager.h" | |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "components/feedback/tracing_manager.h" |
| 16 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/webui/web_ui_util.h" | 19 #include "ui/base/webui/web_ui_util.h" |
| 20 #include "url/url_util.h" | 20 #include "url/url_util.h" |
| 21 | 21 |
| 22 using feedback::FeedbackData; |
| 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 // Getting the filename of a blob prepends a "C:\fakepath" to the filename. | 26 // Getting the filename of a blob prepends a "C:\fakepath" to the filename. |
| 25 // This is undesirable, strip it if it exists. | 27 // This is undesirable, strip it if it exists. |
| 26 std::string StripFakepath(const std::string& path) { | 28 std::string StripFakepath(const std::string& path) { |
| 27 const char kFakePathStr[] = "C:\\fakepath\\"; | 29 const char kFakePathStr[] = "C:\\fakepath\\"; |
| 28 if (StartsWithASCII(path, kFakePathStr, false)) | 30 if (StartsWithASCII(path, kFakePathStr, false)) |
| 29 return path.substr(arraysize(kFakePathStr) - 1); | 31 return path.substr(arraysize(kFakePathStr) - 1); |
| 30 return path; | 32 return path; |
| 31 } | 33 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 !feedback_info.attached_file_blob_uuid->empty()) | 175 !feedback_info.attached_file_blob_uuid->empty()) |
| 174 attached_file_uuid = *feedback_info.attached_file_blob_uuid; | 176 attached_file_uuid = *feedback_info.attached_file_blob_uuid; |
| 175 | 177 |
| 176 std::string screenshot_uuid; | 178 std::string screenshot_uuid; |
| 177 if (feedback_info.screenshot_blob_uuid.get() && | 179 if (feedback_info.screenshot_blob_uuid.get() && |
| 178 !feedback_info.screenshot_blob_uuid->empty()) | 180 !feedback_info.screenshot_blob_uuid->empty()) |
| 179 screenshot_uuid = *feedback_info.screenshot_blob_uuid; | 181 screenshot_uuid = *feedback_info.screenshot_blob_uuid; |
| 180 | 182 |
| 181 // Populate feedback data. | 183 // Populate feedback data. |
| 182 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); | 184 scoped_refptr<FeedbackData> feedback_data(new FeedbackData()); |
| 183 feedback_data->set_profile(GetProfile()); | 185 feedback_data->set_context(GetProfile()); |
| 184 feedback_data->set_description(feedback_info.description); | 186 feedback_data->set_description(feedback_info.description); |
| 185 | 187 |
| 186 if (feedback_info.category_tag.get()) | 188 if (feedback_info.category_tag.get()) |
| 187 feedback_data->set_category_tag(*feedback_info.category_tag.get()); | 189 feedback_data->set_category_tag(*feedback_info.category_tag.get()); |
| 188 if (feedback_info.page_url.get()) | 190 if (feedback_info.page_url.get()) |
| 189 feedback_data->set_page_url(*feedback_info.page_url.get()); | 191 feedback_data->set_page_url(*feedback_info.page_url.get()); |
| 190 if (feedback_info.email.get()) | 192 if (feedback_info.email.get()) |
| 191 feedback_data->set_user_email(*feedback_info.email.get()); | 193 feedback_data->set_user_email(*feedback_info.email.get()); |
| 192 | 194 |
| 193 if (!attached_file_uuid.empty()) { | 195 if (!attached_file_uuid.empty()) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 236 |
| 235 void FeedbackPrivateSendFeedbackFunction::OnCompleted( | 237 void FeedbackPrivateSendFeedbackFunction::OnCompleted( |
| 236 bool success) { | 238 bool success) { |
| 237 results_ = feedback_private::SendFeedback::Results::Create( | 239 results_ = feedback_private::SendFeedback::Results::Create( |
| 238 success ? feedback_private::STATUS_SUCCESS : | 240 success ? feedback_private::STATUS_SUCCESS : |
| 239 feedback_private::STATUS_DELAYED); | 241 feedback_private::STATUS_DELAYED); |
| 240 SendResponse(true); | 242 SendResponse(true); |
| 241 } | 243 } |
| 242 | 244 |
| 243 } // namespace extensions | 245 } // namespace extensions |
| OLD | NEW |