Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_support_host.cc |
| diff --git a/chrome/browser/chromeos/arc/arc_support_host.cc b/chrome/browser/chromeos/arc/arc_support_host.cc |
| index 3713eb058dab9ea26329320fbb9e032a40d6dcb9..bdc78c67af0dba74adf47f1b12f14cf0d9d9d446 100644 |
| --- a/chrome/browser/chromeos/arc/arc_support_host.cc |
| +++ b/chrome/browser/chromeos/arc/arc_support_host.cc |
| @@ -19,6 +19,7 @@ |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| #include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "components/metrics/metrics_pref_names.h" |
| #include "components/prefs/pref_service.h" |
| @@ -28,13 +29,15 @@ |
| namespace { |
| const char kAction[] = "action"; |
| -const char kCode[] = "code"; |
| +const char kBackupRestoreEnabled[] = "backupRestoreEnabled"; |
| const char kCanEnable[] = "canEnable"; |
| -const char kStatus[] = "status"; |
| +const char kCode[] = "code"; |
| const char kData[] = "data"; |
| const char kDeviceId[] = "deviceId"; |
| +const char kEnabled[] = "enabled"; |
| const char kOn[] = "on"; |
| const char kPage[] = "page"; |
| +const char kStatus[] = "status"; |
| const char kText[] = "text"; |
| const char kActionInitialize[] = "initialize"; |
| const char kActionSetMetricsMode[] = "setMetricsMode"; |
| @@ -43,6 +46,7 @@ const char kActionCancelAuthCode[] = "cancelAuthCode"; |
| const char kActionSetAuthCode[] = "setAuthCode"; |
| const char kActionEnableMetrics[] = "enableMetrics"; |
| const char kActionSendFeedback[] = "sendFeedback"; |
| +const char kActionSetBackupRestore[] = "setBackupRestore"; |
| const char kActionCloseUI[] = "closeUI"; |
| const char kActionShowPage[] = "showPage"; |
| } // namespace |
| @@ -98,7 +102,6 @@ void ArcSupportHost::Start(Client* client) { |
| void ArcSupportHost::Initialize() { |
| DCHECK(client_); |
| - |
| std::unique_ptr<base::DictionaryValue> localized_strings( |
| new base::DictionaryValue()); |
| base::string16 device_name = ash::GetChromeOSDeviceName(); |
| @@ -133,14 +136,23 @@ void ArcSupportHost::Initialize() { |
| localized_strings->SetString( |
| "termsOfService", |
| l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_TERMS_OF_SERVICE)); |
| + localized_strings->SetString( |
| + "textBackupRestore", |
| + l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE)); |
| const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| const std::string& country_code = base::CountryCodeForCurrentTimezone(); |
| localized_strings->SetString("countryCode", country_code); |
| - webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get()); |
| arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); |
| + |
| + localized_strings->SetBoolean( |
|
elijahtaylor1
2016/06/30 01:59:06
We want the default to be checked, and set the pre
malaykeshav
2016/06/30 02:46:19
What about the case where the opt-in fails. Do we
elijahtaylor1
2016/06/30 04:52:34
That's a good point, and I do think it's the right
malaykeshav
2016/06/30 18:25:46
This is already set when defining the boolean pref
khmel
2016/06/30 18:30:11
BTW, if OptIn fails, 'Get Started' page is not sho
xiyuan
2016/06/30 18:34:22
What about user disables ARC then re-enables it in
malaykeshav
2016/06/30 18:50:59
The user's choice persists across the disable-rena
khmel
2016/06/30 19:00:43
I also still think that
pref_change_registrar_.A
|
| + kBackupRestoreEnabled, |
| + arc_auth_service->profile()->GetPrefs()->GetBoolean( |
| + prefs::kArcBackupRestoreEnabled)); |
| + |
| + webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get()); |
| DCHECK(arc_auth_service); |
| const std::string device_id = user_manager::known_user::GetDeviceId( |
| multi_user_util::GetAccountIdFromProfile(arc_auth_service->profile())); |
| @@ -215,8 +227,13 @@ void ArcSupportHost::OnOptInUIShowPage(arc::ArcAuthService::UIPage page, |
| client_->PostMessageFromNativeHost(response_string); |
| } |
| -void ArcSupportHost::EnableMetrics() { |
| - InitiateMetricsReportingChange(true, OnMetricsReportingCallbackType()); |
| +void ArcSupportHost::EnableMetrics(bool is_enabled) { |
| + InitiateMetricsReportingChange(is_enabled, OnMetricsReportingCallbackType()); |
| +} |
| + |
| +void ArcSupportHost::EnableBackupRestore(bool is_enabled) { |
| + PrefService* pref_service = arc::ArcAuthService::Get()->profile()->GetPrefs(); |
| + pref_service->SetBoolean(prefs::kArcBackupRestoreEnabled, is_enabled); |
| } |
| void ArcSupportHost::OnMessage(const std::string& request_string) { |
| @@ -249,9 +266,21 @@ void ArcSupportHost::OnMessage(const std::string& request_string) { |
| } else if (action == kActionCancelAuthCode) { |
| arc_auth_service->CancelAuthCode(); |
| } else if (action == kActionEnableMetrics) { |
| - EnableMetrics(); |
| + bool is_enabled; |
| + if (!request->GetBoolean(kEnabled, &is_enabled)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + EnableMetrics(is_enabled); |
| } else if (action == kActionSendFeedback) { |
| chrome::OpenFeedbackDialog(nullptr); |
| + } else if (action == kActionSetBackupRestore) { |
| + bool is_enabled; |
| + if (!request->GetBoolean(kEnabled, &is_enabled)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + EnableBackupRestore(is_enabled); |
| } else { |
| NOTREACHED(); |
| } |