Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 #include "base/feature_list.h" | 43 #include "base/feature_list.h" |
| 44 #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h" | 44 #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 using extensions::api::feedback_private::SystemInformation; | 47 using extensions::api::feedback_private::SystemInformation; |
| 48 using feedback::FeedbackData; | 48 using feedback::FeedbackData; |
| 49 | 49 |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 constexpr char kExtraDiagnosticsKey[] = "EXTRA_DIAGNOSTICS"; | |
|
Peter Kasting
2017/06/14 20:41:05
Nit: I suggest declaring this locally below right
afakhry
2017/06/14 22:10:18
In that case I don't think we need it at all. I re
| |
| 53 | |
| 52 // Getting the filename of a blob prepends a "C:\fakepath" to the filename. | 54 // Getting the filename of a blob prepends a "C:\fakepath" to the filename. |
| 53 // This is undesirable, strip it if it exists. | 55 // This is undesirable, strip it if it exists. |
| 54 std::string StripFakepath(const std::string& path) { | 56 std::string StripFakepath(const std::string& path) { |
| 55 const char kFakePathStr[] = "C:\\fakepath\\"; | 57 const char kFakePathStr[] = "C:\\fakepath\\"; |
| 56 if (base::StartsWith(path, kFakePathStr, | 58 if (base::StartsWith(path, kFakePathStr, |
| 57 base::CompareCase::INSENSITIVE_ASCII)) | 59 base::CompareCase::INSENSITIVE_ASCII)) |
| 58 return path.substr(arraysize(kFakePathStr) - 1); | 60 return path.substr(arraysize(kFakePathStr) - 1); |
| 59 return path; | 61 return path; |
| 60 } | 62 } |
| 61 | 63 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 | 109 |
| 108 #if defined(OS_CHROMEOS) | 110 #if defined(OS_CHROMEOS) |
| 109 LogSourceAccessManager* FeedbackPrivateAPI::GetLogSourceAccessManager() const { | 111 LogSourceAccessManager* FeedbackPrivateAPI::GetLogSourceAccessManager() const { |
| 110 return log_source_access_manager_.get(); | 112 return log_source_access_manager_.get(); |
| 111 } | 113 } |
| 112 #endif | 114 #endif |
| 113 | 115 |
| 114 void FeedbackPrivateAPI::RequestFeedback( | 116 void FeedbackPrivateAPI::RequestFeedback( |
| 115 const std::string& description_template, | 117 const std::string& description_template, |
| 116 const std::string& category_tag, | 118 const std::string& category_tag, |
| 119 const std::string& extra_diagnostics, | |
| 117 const GURL& page_url) { | 120 const GURL& page_url) { |
| 118 #if defined(OS_WIN) | 121 #if defined(OS_WIN) |
| 119 // Show prompt for Software Removal Tool if the Reporter component has found | 122 // Show prompt for Software Removal Tool if the Reporter component has found |
| 120 // unwanted software, and the user has never run the cleaner before. | 123 // unwanted software, and the user has never run the cleaner before. |
| 121 if (base::FeatureList::IsEnabled(kSrtPromptOnFeedbackForm) && | 124 if (base::FeatureList::IsEnabled(kSrtPromptOnFeedbackForm) && |
| 122 safe_browsing::ReporterFoundUws() && | 125 safe_browsing::ReporterFoundUws() && |
| 123 !safe_browsing::UserHasRunCleaner()) { | 126 !safe_browsing::UserHasRunCleaner()) { |
| 124 RequestFeedbackForFlow(description_template, category_tag, page_url, | 127 RequestFeedbackForFlow(description_template, category_tag, |
| 128 extra_diagnostics, page_url, | |
| 125 FeedbackFlow::FEEDBACK_FLOW_SHOWSRTPROMPT); | 129 FeedbackFlow::FEEDBACK_FLOW_SHOWSRTPROMPT); |
| 126 return; | 130 return; |
| 127 } | 131 } |
| 128 #endif | 132 #endif |
| 129 RequestFeedbackForFlow(description_template, category_tag, page_url, | 133 RequestFeedbackForFlow(description_template, category_tag, extra_diagnostics, |
| 130 FeedbackFlow::FEEDBACK_FLOW_REGULAR); | 134 page_url, FeedbackFlow::FEEDBACK_FLOW_REGULAR); |
| 131 } | 135 } |
| 132 | 136 |
| 133 void FeedbackPrivateAPI::RequestFeedbackForFlow( | 137 void FeedbackPrivateAPI::RequestFeedbackForFlow( |
| 134 const std::string& description_template, | 138 const std::string& description_template, |
| 135 const std::string& category_tag, | 139 const std::string& category_tag, |
| 140 const std::string& extra_diagnostics, | |
| 136 const GURL& page_url, | 141 const GURL& page_url, |
| 137 api::feedback_private::FeedbackFlow flow) { | 142 api::feedback_private::FeedbackFlow flow) { |
| 138 if (browser_context_ && EventRouter::Get(browser_context_)) { | 143 if (browser_context_ && EventRouter::Get(browser_context_)) { |
| 139 FeedbackInfo info; | 144 FeedbackInfo info; |
| 140 info.description = description_template; | 145 info.description = description_template; |
| 141 info.category_tag = base::MakeUnique<std::string>(category_tag); | 146 info.category_tag = base::MakeUnique<std::string>(category_tag); |
| 142 info.page_url = base::MakeUnique<std::string>(page_url.spec()); | 147 info.page_url = base::MakeUnique<std::string>(page_url.spec()); |
| 143 info.system_information.reset(new SystemInformationList); | 148 info.system_information = base::MakeUnique<SystemInformationList>(); |
| 149 | |
| 150 // Any extra diagnostics information should be added to the sys info. | |
| 151 if (!extra_diagnostics.empty()) { | |
| 152 SystemInformation extra_info; | |
| 153 extra_info.key = kExtraDiagnosticsKey; | |
| 154 extra_info.value = extra_diagnostics; | |
| 155 info.system_information->emplace_back(std::move(extra_info)); | |
| 156 } | |
| 157 | |
| 144 // The manager is only available if tracing is enabled. | 158 // The manager is only available if tracing is enabled. |
| 145 if (TracingManager* manager = TracingManager::Get()) { | 159 if (TracingManager* manager = TracingManager::Get()) { |
| 146 info.trace_id.reset(new int(manager->RequestTrace())); | 160 info.trace_id = base::MakeUnique<int>(manager->RequestTrace()); |
| 147 } | 161 } |
| 148 info.flow = flow; | 162 info.flow = flow; |
| 149 #if defined(OS_MACOSX) | 163 #if defined(OS_MACOSX) |
| 150 const bool use_system_window_frame = true; | 164 const bool use_system_window_frame = true; |
| 151 #else | 165 #else |
| 152 const bool use_system_window_frame = false; | 166 const bool use_system_window_frame = false; |
| 153 #endif | 167 #endif |
| 154 info.use_system_window_frame = | 168 info.use_system_window_frame = |
| 155 base::MakeUnique<bool>(use_system_window_frame); | 169 base::MakeUnique<bool>(use_system_window_frame); |
| 156 | 170 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 case feedback_private::SRT_PROMPT_RESULT_CLOSED: | 420 case feedback_private::SRT_PROMPT_RESULT_CLOSED: |
| 407 base::RecordAction(base::UserMetricsAction("Feedback.SrtPromptClosed")); | 421 base::RecordAction(base::UserMetricsAction("Feedback.SrtPromptClosed")); |
| 408 break; | 422 break; |
| 409 default: | 423 default: |
| 410 return RespondNow(Error("Invalid arugment.")); | 424 return RespondNow(Error("Invalid arugment.")); |
| 411 } | 425 } |
| 412 return RespondNow(NoArguments()); | 426 return RespondNow(NoArguments()); |
| 413 } | 427 } |
| 414 | 428 |
| 415 } // namespace extensions | 429 } // namespace extensions |
| OLD | NEW |