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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 EventRouter::Get(browser_context_) | 147 EventRouter::Get(browser_context_) |
148 ->DispatchEventToExtension(extension_misc::kFeedbackExtensionId, | 148 ->DispatchEventToExtension(extension_misc::kFeedbackExtensionId, |
149 std::move(event)); | 149 std::move(event)); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 // static | 153 // static |
154 base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL; | 154 base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL; |
155 | 155 |
156 bool FeedbackPrivateGetStringsFunction::RunSync() { | 156 ExtensionFunction::ResponseAction FeedbackPrivateGetStringsFunction::Run() { |
157 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 157 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
158 | 158 |
159 #define SET_STRING(id, idr) \ | 159 #define SET_STRING(id, idr) \ |
160 dict->SetString(id, l10n_util::GetStringUTF16(idr)) | 160 dict->SetString(id, l10n_util::GetStringUTF16(idr)) |
161 SET_STRING("page-title", IDS_FEEDBACK_REPORT_PAGE_TITLE); | 161 SET_STRING("page-title", IDS_FEEDBACK_REPORT_PAGE_TITLE); |
162 SET_STRING("additionalInfo", IDS_FEEDBACK_ADDITIONAL_INFO_LABEL); | 162 SET_STRING("additionalInfo", IDS_FEEDBACK_ADDITIONAL_INFO_LABEL); |
163 SET_STRING("page-url", IDS_FEEDBACK_REPORT_URL_LABEL); | 163 SET_STRING("page-url", IDS_FEEDBACK_REPORT_URL_LABEL); |
164 SET_STRING("screenshot", IDS_FEEDBACK_SCREENSHOT_LABEL); | 164 SET_STRING("screenshot", IDS_FEEDBACK_SCREENSHOT_LABEL); |
165 SET_STRING("user-email", IDS_FEEDBACK_USER_EMAIL_LABEL); | 165 SET_STRING("user-email", IDS_FEEDBACK_USER_EMAIL_LABEL); |
166 #if defined(OS_CHROMEOS) | 166 #if defined(OS_CHROMEOS) |
(...skipping 30 matching lines...) Expand all Loading... |
197 // And the localized strings needed for the SRT Download Prompt. | 197 // And the localized strings needed for the SRT Download Prompt. |
198 SET_STRING("srtPromptBody", IDS_FEEDBACK_SRT_PROMPT_BODY); | 198 SET_STRING("srtPromptBody", IDS_FEEDBACK_SRT_PROMPT_BODY); |
199 SET_STRING("srtPromptAcceptButton", IDS_FEEDBACK_SRT_PROMPT_ACCEPT_BUTTON); | 199 SET_STRING("srtPromptAcceptButton", IDS_FEEDBACK_SRT_PROMPT_ACCEPT_BUTTON); |
200 SET_STRING("srtPromptDeclineButton", | 200 SET_STRING("srtPromptDeclineButton", |
201 IDS_FEEDBACK_SRT_PROMPT_DECLINE_BUTTON); | 201 IDS_FEEDBACK_SRT_PROMPT_DECLINE_BUTTON); |
202 #undef SET_STRING | 202 #undef SET_STRING |
203 | 203 |
204 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 204 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
205 webui::SetLoadTimeDataDefaults(app_locale, dict.get()); | 205 webui::SetLoadTimeDataDefaults(app_locale, dict.get()); |
206 | 206 |
207 SetResult(std::move(dict)); | |
208 | 207 |
209 if (test_callback_ && !test_callback_->is_null()) | 208 if (test_callback_ && !test_callback_->is_null()) |
210 test_callback_->Run(); | 209 test_callback_->Run(); |
211 | 210 |
212 return true; | 211 return RespondNow(OneArgument(std::move(dict))); |
213 } | 212 } |
214 | 213 |
215 bool FeedbackPrivateGetUserEmailFunction::RunSync() { | 214 ExtensionFunction::ResponseAction FeedbackPrivateGetUserEmailFunction::Run() { |
216 SigninManagerBase* signin_manager = | 215 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( |
217 SigninManagerFactory::GetForProfile(GetProfile()); | 216 Profile::FromBrowserContext(browser_context())); |
218 SetResult(base::MakeUnique<base::StringValue>( | 217 return RespondNow(OneArgument(base::MakeUnique<base::StringValue>( |
219 signin_manager ? signin_manager->GetAuthenticatedAccountInfo().email | 218 signin_manager ? signin_manager->GetAuthenticatedAccountInfo().email |
220 : std::string())); | 219 : std::string()))); |
221 return true; | |
222 } | 220 } |
223 | 221 |
224 bool FeedbackPrivateGetSystemInformationFunction::RunAsync() { | 222 bool FeedbackPrivateGetSystemInformationFunction::RunAsync() { |
225 FeedbackService* service = | 223 FeedbackService* service = |
226 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); | 224 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); |
227 DCHECK(service); | 225 DCHECK(service); |
228 service->GetSystemInformation( | 226 service->GetSystemInformation( |
229 base::Bind( | 227 base::Bind( |
230 &FeedbackPrivateGetSystemInformationFunction::OnCompleted, this)); | 228 &FeedbackPrivateGetSystemInformationFunction::OnCompleted, this)); |
231 return true; | 229 return true; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 content::RecordAction( | 337 content::RecordAction( |
340 base::UserMetricsAction("Feedback.SrtPromptClosed")); | 338 base::UserMetricsAction("Feedback.SrtPromptClosed")); |
341 break; | 339 break; |
342 default: | 340 default: |
343 return RespondNow(Error("Invalid arugment.")); | 341 return RespondNow(Error("Invalid arugment.")); |
344 } | 342 } |
345 return RespondNow(NoArguments()); | 343 return RespondNow(NoArguments()); |
346 } | 344 } |
347 | 345 |
348 } // namespace extensions | 346 } // namespace extensions |
OLD | NEW |