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/chromeos/extensions/first_run_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/first_run_private_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/first_run/first_run.h" | 12 #include "chrome/browser/chromeos/first_run/first_run.h" |
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/grit/chromium_strings.h" | 15 #include "chrome/grit/chromium_strings.h" |
16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
17 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
18 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/webui/web_ui_util.h" | 20 #include "ui/base/webui/web_ui_util.h" |
21 | 21 |
22 bool FirstRunPrivateGetLocalizedStringsFunction::RunSync() { | 22 ExtensionFunction::ResponseAction |
| 23 FirstRunPrivateGetLocalizedStringsFunction::Run() { |
23 UMA_HISTOGRAM_COUNTS("CrosFirstRun.DialogShown", 1); | 24 UMA_HISTOGRAM_COUNTS("CrosFirstRun.DialogShown", 1); |
24 std::unique_ptr<base::DictionaryValue> localized_strings( | 25 std::unique_ptr<base::DictionaryValue> localized_strings( |
25 new base::DictionaryValue()); | 26 new base::DictionaryValue()); |
26 const user_manager::User* user = | 27 const user_manager::User* user = |
27 chromeos::ProfileHelper::Get()->GetUserByProfile(GetProfile()); | 28 chromeos::ProfileHelper::Get()->GetUserByProfile( |
| 29 Profile::FromBrowserContext(browser_context())); |
28 if (!user->GetGivenName().empty()) { | 30 if (!user->GetGivenName().empty()) { |
29 localized_strings->SetString( | 31 localized_strings->SetString( |
30 "greetingHeader", | 32 "greetingHeader", |
31 l10n_util::GetStringFUTF16(IDS_FIRST_RUN_GREETING_STEP_HEADER, | 33 l10n_util::GetStringFUTF16(IDS_FIRST_RUN_GREETING_STEP_HEADER, |
32 user->GetGivenName())); | 34 user->GetGivenName())); |
33 } else { | 35 } else { |
34 localized_strings->SetString( | 36 localized_strings->SetString( |
35 "greetingHeader", | 37 "greetingHeader", |
36 l10n_util::GetStringUTF16(IDS_FIRST_RUN_GREETING_STEP_HEADER_GENERAL)); | 38 l10n_util::GetStringUTF16(IDS_FIRST_RUN_GREETING_STEP_HEADER_GENERAL)); |
37 } | 39 } |
(...skipping 10 matching lines...) Expand all Loading... |
48 localized_strings->SetString( | 50 localized_strings->SetString( |
49 "greetingButton", | 51 "greetingButton", |
50 l10n_util::GetStringUTF16(IDS_FIRST_RUN_GREETING_STEP_BUTTON)); | 52 l10n_util::GetStringUTF16(IDS_FIRST_RUN_GREETING_STEP_BUTTON)); |
51 localized_strings->SetString( | 53 localized_strings->SetString( |
52 "closeButton", | 54 "closeButton", |
53 l10n_util::GetStringUTF16(IDS_CLOSE)); | 55 l10n_util::GetStringUTF16(IDS_CLOSE)); |
54 | 56 |
55 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 57 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
56 webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get()); | 58 webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get()); |
57 | 59 |
58 SetResult(std::move(localized_strings)); | 60 return RespondNow(OneArgument(std::move(localized_strings))); |
59 return true; | |
60 } | 61 } |
61 | 62 |
62 bool FirstRunPrivateLaunchTutorialFunction::RunSync() { | 63 ExtensionFunction::ResponseAction FirstRunPrivateLaunchTutorialFunction::Run() { |
63 chromeos::first_run::LaunchTutorial(); | 64 chromeos::first_run::LaunchTutorial(); |
64 return true; | 65 return RespondNow(NoArguments()); |
65 } | 66 } |
OLD | NEW |