Commit c794eae3 authored by James Cook's avatar James Cook Committed by Commit Bot

Add new Chrome OS OOBE sync consent dialog for SplitSettingsSync

As part of go/cros-sync and go/split-settings-sync we're creating a new
OOBE sync consent dialog. The main new feature is that the user can turn
OS sync off in the dialog and the OS sync system will never start.
OS sync is tied to a user profile pref that is set only when the user
closes the dialog.

This version of the dialog has placeholder strings and layout. Strings
won't be available until M81 and I suspect the layout might change.

See bug for screenshot and link to mocks.

Bug: 1023854
Test: added to browser_tests
Change-Id: I3e86a827eae1d80b8784b89b433d9aebb92eb5d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1912899Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714719}
parent 277d49de
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/consent_auditor/consent_auditor.h" #include "components/consent_auditor/consent_auditor.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "components/sync/base/pref_names.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
namespace chromeos { namespace chromeos {
...@@ -127,7 +129,7 @@ void SyncConsentScreen::OnStateChanged(syncer::SyncService* sync) { ...@@ -127,7 +129,7 @@ void SyncConsentScreen::OnStateChanged(syncer::SyncService* sync) {
void SyncConsentScreen::OnContinueAndReview( void SyncConsentScreen::OnContinueAndReview(
const std::vector<int>& consent_description, const std::vector<int>& consent_description,
const int consent_confirmation) { const int consent_confirmation) {
RecordConsent(consent_description, consent_confirmation); RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation);
profile_->GetPrefs()->SetBoolean(prefs::kShowSyncSettingsOnSessionStart, profile_->GetPrefs()->SetBoolean(prefs::kShowSyncSettingsOnSessionStart,
true); true);
exit_callback_.Run(); exit_callback_.Run();
...@@ -136,7 +138,20 @@ void SyncConsentScreen::OnContinueAndReview( ...@@ -136,7 +138,20 @@ void SyncConsentScreen::OnContinueAndReview(
void SyncConsentScreen::OnContinueWithDefaults( void SyncConsentScreen::OnContinueWithDefaults(
const std::vector<int>& consent_description, const std::vector<int>& consent_description,
const int consent_confirmation) { const int consent_confirmation) {
RecordConsent(consent_description, consent_confirmation); RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation);
exit_callback_.Run();
}
void SyncConsentScreen::OnAcceptAndContinue(
const std::vector<int>& consent_description,
int consent_confirmation,
bool enable_os_sync) {
DCHECK(chromeos::features::IsSplitSettingsSyncEnabled());
// The user only consented to the feature if they left the toggle on.
RecordConsent(enable_os_sync ? CONSENT_GIVEN : CONSENT_NOT_GIVEN,
consent_description, consent_confirmation);
profile_->GetPrefs()->SetBoolean(syncer::prefs::kOsSyncFeatureEnabled,
enable_os_sync);
exit_callback_.Run(); exit_callback_.Run();
} }
...@@ -205,8 +220,9 @@ void SyncConsentScreen::UpdateScreen() { ...@@ -205,8 +220,9 @@ void SyncConsentScreen::UpdateScreen() {
} }
void SyncConsentScreen::RecordConsent( void SyncConsentScreen::RecordConsent(
ConsentGiven consent_given,
const std::vector<int>& consent_description, const std::vector<int>& consent_description,
const int consent_confirmation) { int consent_confirmation) {
consent_auditor::ConsentAuditor* consent_auditor = consent_auditor::ConsentAuditor* consent_auditor =
ConsentAuditorFactory::GetForProfile(profile_); ConsentAuditorFactory::GetForProfile(profile_);
const std::string& google_account_id = const std::string& google_account_id =
...@@ -217,12 +233,13 @@ void SyncConsentScreen::RecordConsent( ...@@ -217,12 +233,13 @@ void SyncConsentScreen::RecordConsent(
for (int id : consent_description) { for (int id : consent_description) {
sync_consent.add_description_grd_ids(id); sync_consent.add_description_grd_ids(id);
} }
sync_consent.set_status(sync_pb::UserConsentTypes::ConsentStatus:: sync_consent.set_status(consent_given == CONSENT_GIVEN
UserConsentTypes_ConsentStatus_GIVEN); ? sync_pb::UserConsentTypes::GIVEN
: sync_pb::UserConsentTypes::NOT_GIVEN);
consent_auditor->RecordSyncConsent(google_account_id, sync_consent); consent_auditor->RecordSyncConsent(google_account_id, sync_consent);
if (test_delegate_) { if (test_delegate_) {
test_delegate_->OnConsentRecordedIds(consent_description, test_delegate_->OnConsentRecordedIds(consent_given, consent_description,
consent_confirmation); consent_confirmation);
} }
} }
......
...@@ -33,6 +33,8 @@ class SyncConsentScreen : public BaseScreen, ...@@ -33,6 +33,8 @@ class SyncConsentScreen : public BaseScreen,
}; };
public: public:
enum ConsentGiven { CONSENT_NOT_GIVEN, CONSENT_GIVEN };
class SyncConsentScreenTestDelegate { class SyncConsentScreenTestDelegate {
public: public:
SyncConsentScreenTestDelegate() = default; SyncConsentScreenTestDelegate() = default;
...@@ -40,8 +42,9 @@ class SyncConsentScreen : public BaseScreen, ...@@ -40,8 +42,9 @@ class SyncConsentScreen : public BaseScreen,
// This is called from SyncConsentScreen when user consent is passed to // This is called from SyncConsentScreen when user consent is passed to
// consent auditor with resource ids recorder as consent. // consent auditor with resource ids recorder as consent.
virtual void OnConsentRecordedIds( virtual void OnConsentRecordedIds(
ConsentGiven consent_given,
const std::vector<int>& consent_description, const std::vector<int>& consent_description,
const int consent_confirmation) = 0; int consent_confirmation) = 0;
// This is called from SyncConsentScreenHandler when user consent is passed // This is called from SyncConsentScreenHandler when user consent is passed
// to consent auditor with resource strings recorder as consent. // to consent auditor with resource strings recorder as consent.
...@@ -77,6 +80,11 @@ class SyncConsentScreen : public BaseScreen, ...@@ -77,6 +80,11 @@ class SyncConsentScreen : public BaseScreen,
void OnContinueWithDefaults(const std::vector<int>& consent_description, void OnContinueWithDefaults(const std::vector<int>& consent_description,
const int consent_confirmation); const int consent_confirmation);
// Reacts to "Accept and Continue".
void OnAcceptAndContinue(const std::vector<int>& consent_description,
int consent_confirmation,
bool enable_os_sync);
// Sets internal condition "Sync disabled by policy" for tests. // Sets internal condition "Sync disabled by policy" for tests.
void SetProfileSyncDisabledByPolicyForTesting(bool value); void SetProfileSyncDisabledByPolicyForTesting(bool value);
...@@ -96,8 +104,9 @@ class SyncConsentScreen : public BaseScreen, ...@@ -96,8 +104,9 @@ class SyncConsentScreen : public BaseScreen,
void UpdateScreen(); void UpdateScreen();
// Records user Sync consent. // Records user Sync consent.
void RecordConsent(const std::vector<int>& consent_description, void RecordConsent(ConsentGiven consent_given,
const int consent_confirmation); const std::vector<int>& consent_description,
int consent_confirmation);
// Returns true if profile sync is disabled by policy. // Returns true if profile sync is disabled by policy.
bool IsProfileSyncDisabledByPolicy() const; bool IsProfileSyncDisabledByPolicy() const;
......
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h" #include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h"
#include "chrome/browser/chromeos/login/screens/sync_consent_screen.h" #include "chrome/browser/chromeos/login/screens/sync_consent_screen.h"
#include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h" #include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
...@@ -19,12 +18,14 @@ ...@@ -19,12 +18,14 @@
#include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "content/public/browser/notification_service.h" #include "components/prefs/pref_service.h"
#include "components/sync/base/pref_names.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -44,8 +45,10 @@ class ConsentRecordedWaiter ...@@ -44,8 +45,10 @@ class ConsentRecordedWaiter
} }
// SyncConsentScreen::SyncConsentScreenTestDelegate // SyncConsentScreen::SyncConsentScreenTestDelegate
void OnConsentRecordedIds(const std::vector<int>& consent_description, void OnConsentRecordedIds(SyncConsentScreen::ConsentGiven consent_given,
const int consent_confirmation) override { const std::vector<int>& consent_description,
int consent_confirmation) override {
consent_given_ = consent_given;
consent_description_ids_ = consent_description; consent_description_ids_ = consent_description;
consent_confirmation_id_ = consent_confirmation; consent_confirmation_id_ = consent_confirmation;
} }
...@@ -62,18 +65,7 @@ class ConsentRecordedWaiter ...@@ -62,18 +65,7 @@ class ConsentRecordedWaiter
run_loop_.Quit(); run_loop_.Quit();
} }
const std::vector<int>& get_consent_description_ids() const { SyncConsentScreen::ConsentGiven consent_given_;
return consent_description_ids_;
}
int get_consent_confirmation_id() const { return consent_confirmation_id_; }
const ::login::StringList& get_consent_description_strings() const {
return consent_description_strings_;
}
const std::string& get_consent_confirmation_string() const {
return consent_confirmation_string_;
}
private:
std::vector<int> consent_description_ids_; std::vector<int> consent_description_ids_;
int consent_confirmation_id_; int consent_confirmation_id_;
...@@ -91,8 +83,6 @@ std::string GetLocalizedConsentString(const int id) { ...@@ -91,8 +83,6 @@ std::string GetLocalizedConsentString(const int id) {
return sanitized_string; return sanitized_string;
} }
} // anonymous namespace
class SyncConsentTest : public OobeBaseTest { class SyncConsentTest : public OobeBaseTest {
public: public:
SyncConsentTest() = default; SyncConsentTest() = default;
...@@ -145,12 +135,16 @@ class SyncConsentTest : public OobeBaseTest { ...@@ -145,12 +135,16 @@ class SyncConsentTest : public OobeBaseTest {
} }
protected: protected:
static SyncConsentScreen* GetSyncConsentScreen() {
return static_cast<SyncConsentScreen*>(
WizardController::default_controller()->GetScreen(
SyncConsentScreenView::kScreenId));
}
void SyncConsentRecorderTestImpl( void SyncConsentRecorderTestImpl(
const std::vector<std::string>& expected_consent_strings, const std::vector<std::string>& expected_consent_strings,
const std::string expected_consent_confirmation_string) { const std::string expected_consent_confirmation_string) {
SyncConsentScreen* screen = static_cast<SyncConsentScreen*>( SyncConsentScreen* screen = GetSyncConsentScreen();
WizardController::default_controller()->GetScreen(
SyncConsentScreenView::kScreenId));
ConsentRecordedWaiter consent_recorded_waiter; ConsentRecordedWaiter consent_recorded_waiter;
screen->SetDelegateForTesting(&consent_recorded_waiter); screen->SetDelegateForTesting(&consent_recorded_waiter);
...@@ -169,14 +163,16 @@ class SyncConsentTest : public OobeBaseTest { ...@@ -169,14 +163,16 @@ class SyncConsentTest : public OobeBaseTest {
const int expected_consent_confirmation_id = const int expected_consent_confirmation_id =
IDS_LOGIN_SYNC_CONSENT_SCREEN_ACCEPT_AND_CONTINUE; IDS_LOGIN_SYNC_CONSENT_SCREEN_ACCEPT_AND_CONTINUE;
EXPECT_EQ(SyncConsentScreen::CONSENT_GIVEN,
consent_recorded_waiter.consent_given_);
EXPECT_EQ(expected_consent_strings, EXPECT_EQ(expected_consent_strings,
consent_recorded_waiter.get_consent_description_strings()); consent_recorded_waiter.consent_description_strings_);
EXPECT_EQ(expected_consent_confirmation_string, EXPECT_EQ(expected_consent_confirmation_string,
consent_recorded_waiter.get_consent_confirmation_string()); consent_recorded_waiter.consent_confirmation_string_);
EXPECT_EQ(expected_consent_ids, EXPECT_EQ(expected_consent_ids,
consent_recorded_waiter.get_consent_description_ids()); consent_recorded_waiter.consent_description_ids_);
EXPECT_EQ(expected_consent_confirmation_id, EXPECT_EQ(expected_consent_confirmation_id,
consent_recorded_waiter.get_consent_confirmation_id()); consent_recorded_waiter.consent_confirmation_id_);
} }
std::vector<std::string> GetLocalizedExpectedConsentStrings() const { std::vector<std::string> GetLocalizedExpectedConsentStrings() const {
...@@ -228,7 +224,7 @@ class SyncConsentTestWithParams ...@@ -228,7 +224,7 @@ class SyncConsentTestWithParams
public ::testing::WithParamInterface<std::string> { public ::testing::WithParamInterface<std::string> {
public: public:
SyncConsentTestWithParams() = default; SyncConsentTestWithParams() = default;
~SyncConsentTestWithParams() = default; ~SyncConsentTestWithParams() override = default;
private: private:
DISALLOW_COPY_AND_ASSIGN(SyncConsentTestWithParams); DISALLOW_COPY_AND_ASSIGN(SyncConsentTestWithParams);
...@@ -268,9 +264,7 @@ IN_PROC_BROWSER_TEST_P(SyncConsentPolicyDisabledTest, ...@@ -268,9 +264,7 @@ IN_PROC_BROWSER_TEST_P(SyncConsentPolicyDisabledTest,
SyncConsentPolicyDisabled) { SyncConsentPolicyDisabled) {
LoginToSyncConsentScreen(); LoginToSyncConsentScreen();
SyncConsentScreen* screen = static_cast<SyncConsentScreen*>( SyncConsentScreen* screen = GetSyncConsentScreen();
WizardController::default_controller()->GetScreen(
SyncConsentScreenView::kScreenId));
screen->SetProfileSyncDisabledByPolicyForTesting(true); screen->SetProfileSyncDisabledByPolicyForTesting(true);
screen->SetProfileSyncEngineInitializedForTesting(GetParam()); screen->SetProfileSyncEngineInitializedForTesting(GetParam());
...@@ -284,4 +278,98 @@ INSTANTIATE_TEST_SUITE_P(/* no prefix */, ...@@ -284,4 +278,98 @@ INSTANTIATE_TEST_SUITE_P(/* no prefix */,
SyncConsentPolicyDisabledTest, SyncConsentPolicyDisabledTest,
testing::Bool()); testing::Bool());
// Tests of the consent dialog with the SplitSettingsSync flag enabled.
class SyncConsentSplitSettingsSyncTest : public SyncConsentTest {
public:
SyncConsentSplitSettingsSyncTest() {
sync_feature_list_.InitAndEnableFeature(
chromeos::features::kSplitSettingsSync);
}
~SyncConsentSplitSettingsSyncTest() override = default;
private:
base::test::ScopedFeatureList sync_feature_list_;
};
IN_PROC_BROWSER_TEST_F(SyncConsentSplitSettingsSyncTest, DefaultFlow) {
LoginToSyncConsentScreen();
// OS sync is disabled by default.
PrefService* prefs = ProfileManager::GetPrimaryUserProfile()->GetPrefs();
EXPECT_FALSE(prefs->GetBoolean(syncer::prefs::kOsSyncFeatureEnabled));
// Wait for content to load.
SyncConsentScreen* screen = GetSyncConsentScreen();
ConsentRecordedWaiter consent_recorded_waiter;
screen->SetDelegateForTesting(&consent_recorded_waiter);
screen->SetProfileSyncDisabledByPolicyForTesting(false);
screen->SetProfileSyncEngineInitializedForTesting(true);
screen->OnStateChanged(nullptr);
test::OobeJS().CreateVisibilityWaiter(true, {"sync-consent-impl"})->Wait();
// Dialog is visible.
test::OobeJS().ExpectVisiblePath(
{"sync-consent-impl", "osSyncConsentDialog"});
// Click the continue button and wait for the JS to C++ callback.
test::OobeJS().ClickOnPath(
{"sync-consent-impl", "osSyncAcceptAndContinueButton"});
consent_recorded_waiter.Wait();
screen->SetDelegateForTesting(nullptr);
// Consent was recorded for the confirmation button.
EXPECT_EQ(SyncConsentScreen::CONSENT_GIVEN,
consent_recorded_waiter.consent_given_);
EXPECT_EQ("Accept and continue",
consent_recorded_waiter.consent_confirmation_string_);
EXPECT_EQ(IDS_LOGIN_SYNC_CONSENT_SCREEN_ACCEPT_AND_CONTINUE,
consent_recorded_waiter.consent_confirmation_id_);
// Consent was recorded for all descriptions, including the confirmation
// button label.
// TODO(jamescook): When PLACEHOLDER strings are replaced, add checks for the
// correct text and IDs here.
std::vector<std::string> expected_desc_strings = {"Accept and continue"};
std::vector<int> expected_desc_ids = {
IDS_LOGIN_SYNC_CONSENT_SCREEN_ACCEPT_AND_CONTINUE};
EXPECT_EQ(expected_desc_strings,
consent_recorded_waiter.consent_description_strings_);
EXPECT_EQ(expected_desc_ids,
consent_recorded_waiter.consent_description_ids_);
// Toggle button is on-by-default, so OS sync should be on.
EXPECT_TRUE(prefs->GetBoolean(syncer::prefs::kOsSyncFeatureEnabled));
}
IN_PROC_BROWSER_TEST_F(SyncConsentSplitSettingsSyncTest, UserCanDisable) {
LoginToSyncConsentScreen();
// Wait for content to load.
SyncConsentScreen* screen = GetSyncConsentScreen();
ConsentRecordedWaiter consent_recorded_waiter;
screen->SetDelegateForTesting(&consent_recorded_waiter);
screen->SetProfileSyncDisabledByPolicyForTesting(false);
screen->SetProfileSyncEngineInitializedForTesting(true);
screen->OnStateChanged(nullptr);
test::OobeJS().CreateVisibilityWaiter(true, {"sync-consent-impl"})->Wait();
// Turn off the toggle.
test::OobeJS().ClickOnPath({"sync-consent-impl", "enableOsSyncToggle"});
// Click the continue button and wait for the JS to C++ callback.
test::OobeJS().ClickOnPath(
{"sync-consent-impl", "osSyncAcceptAndContinueButton"});
consent_recorded_waiter.Wait();
screen->SetDelegateForTesting(nullptr);
// User did not consent.
EXPECT_EQ(SyncConsentScreen::CONSENT_NOT_GIVEN,
consent_recorded_waiter.consent_given_);
// OS sync is off.
PrefService* prefs = ProfileManager::GetPrimaryUserProfile()->GetPrefs();
EXPECT_FALSE(prefs->GetBoolean(syncer::prefs::kOsSyncFeatureEnabled));
}
} // namespace
} // namespace chromeos } // namespace chromeos
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> <link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html"> <link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<if expr="_google_chrome"> <if expr="_google_chrome">
<link rel="import" href="chrome://oobe/sync-consent-icons.html"> <link rel="import" href="chrome://oobe/sync-consent-icons.html">
...@@ -218,5 +219,51 @@ ...@@ -218,5 +219,51 @@
</oobe-text-button> </oobe-text-button>
</div> </div>
</oobe-dialog> </oobe-dialog>
<!-- Dialog used with SplitSettingsSync. -->
<oobe-dialog id="osSyncConsentDialog" role="dialog" has-buttons
aria-label$="Sync and personalization options PLACEHOLDER"
hidden>
<hd-iron-icon slot="oobe-icon"
icon1x="sync-consent-32:googleg" icon2x="sync-consent-64:googleg">
</hd-iron-icon>
<!-- TODO(jamescook): When replacing the PLACEHOLDER strings add the
consent-description attribute to the h1 and the divs. The consent
auditor system requires real string IDs so it won't work with the
placeholders. -->
<h1 slot="title">
Sync and personalization options PLACEHOLDER
</h1>
<div slot="subtitle">
Speedy, secure, stateless... feature description PLACEHOLDER
</div>
<div slot="footer" class="layout vertical">
<div class="overview-list-item flex layout horizontal center">
<div class="overview-list-item-text flex layout vertical
center-justified">
<div role="heading" aria-level="2" class="overview-list-item-title"
id="enableOsSyncLabel">
Keep my Chromebook synced PLACEHOLDER
</div>
<div class="overview-list-item-description">
Chrome OS will sync your apps, settings, and Wi-Fi preferences to
keep your transition seamless. PLACEHOLDER
</div>
</div>
<cr-toggle id="enableOsSyncToggle" checked
aria-labelledby="enableOsSyncLabel">
</cr-toggle>
</div>
</div>
<div slot="bottom-buttons" class="layout horizontal end-justified">
<oobe-text-button id="osSyncAcceptAndContinueButton"
on-click="onOsSyncAcceptAndContinue_" class="focus-on-show" inverse>
<div consent-description consent-confirmation>
[[i18nDynamic(locale, 'syncConsentAcceptAndContinue')]]
</div>
</oobe-text-button>
</div>
</oobe-dialog>
</template> </template>
</dom-module> </dom-module>
...@@ -65,11 +65,15 @@ Polymer({ ...@@ -65,11 +65,15 @@ Polymer({
* Reacts to changes in loadTimeData. * Reacts to changes in loadTimeData.
*/ */
updateLocalizedContent: function() { updateLocalizedContent: function() {
let useMakeBetterScreen = loadTimeData.getBoolean('syncConsentMakeBetter'); if (loadTimeData.getBoolean('splitSettingsSync')) {
if (useMakeBetterScreen) { // SplitSettingsSync version.
this.showScreen_('osSyncConsentDialog');
} else if (loadTimeData.getBoolean('syncConsentMakeBetter')) {
// Unified Consent version.
if (this.$.syncConsentMakeChromeSyncOptionsDialog.hidden) if (this.$.syncConsentMakeChromeSyncOptionsDialog.hidden)
this.showScreen_('syncConsentNewDialog'); this.showScreen_('syncConsentNewDialog');
} else { } else {
// Regular version.
this.showScreen_('syncConsentOverviewDialog'); this.showScreen_('syncConsentOverviewDialog');
} }
this.i18nUpdateLocale(); this.i18nUpdateLocale();
...@@ -91,6 +95,20 @@ Polymer({ ...@@ -91,6 +95,20 @@ Polymer({
} }
}, },
/**
* @param {!Event} event
* @private
*/
onOsSyncAcceptAndContinue_: function(event) {
assert(loadTimeData.getBoolean('splitSettingsSync'));
assert(event.path);
let enableOsSync = !!this.$.enableOsSyncToggle.checked;
chrome.send('login.SyncConsentScreen.osSyncAcceptAndContinue', [
this.getConsentDescription_(), this.getConsentConfirmation_(event.path),
enableOsSync
]);
},
/** /**
* @param {!Array<!HTMLElement>} path Path of the click event. Must contain * @param {!Array<!HTMLElement>} path Path of the click event. Must contain
* a consent confirmation element. * a consent confirmation element.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/login/screens/sync_consent_screen.h" #include "chrome/browser/chromeos/login/screens/sync_consent_screen.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/login/localized_values_builder.h" #include "components/login/localized_values_builder.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -161,10 +162,14 @@ void SyncConsentScreenHandler::RegisterMessages() { ...@@ -161,10 +162,14 @@ void SyncConsentScreenHandler::RegisterMessages() {
&SyncConsentScreenHandler::HandleContinueAndReview); &SyncConsentScreenHandler::HandleContinueAndReview);
AddCallback("login.SyncConsentScreen.continueWithDefaults", AddCallback("login.SyncConsentScreen.continueWithDefaults",
&SyncConsentScreenHandler::HandleContinueWithDefaults); &SyncConsentScreenHandler::HandleContinueWithDefaults);
AddCallback("login.SyncConsentScreen.osSyncAcceptAndContinue",
&SyncConsentScreenHandler::HandleOsSyncAcceptAndContinue);
} }
void SyncConsentScreenHandler::GetAdditionalParameters( void SyncConsentScreenHandler::GetAdditionalParameters(
base::DictionaryValue* parameters) { base::DictionaryValue* parameters) {
parameters->SetBoolean("splitSettingsSync",
chromeos::features::IsSplitSettingsSyncEnabled());
parameters->Set("syncConsentMakeBetter", parameters->Set("syncConsentMakeBetter",
std::make_unique<base::Value>(false)); std::make_unique<base::Value>(false));
BaseScreenHandler::GetAdditionalParameters(parameters); BaseScreenHandler::GetAdditionalParameters(parameters);
...@@ -173,6 +178,7 @@ void SyncConsentScreenHandler::GetAdditionalParameters( ...@@ -173,6 +178,7 @@ void SyncConsentScreenHandler::GetAdditionalParameters(
void SyncConsentScreenHandler::HandleContinueAndReview( void SyncConsentScreenHandler::HandleContinueAndReview(
const login::StringList& consent_description, const login::StringList& consent_description,
const std::string& consent_confirmation) { const std::string& consent_confirmation) {
DCHECK(!chromeos::features::IsSplitSettingsSyncEnabled());
std::vector<int> consent_description_ids; std::vector<int> consent_description_ids;
int consent_confirmation_id; int consent_confirmation_id;
GetConsentIDs(known_string_ids_, consent_description, consent_confirmation, GetConsentIDs(known_string_ids_, consent_description, consent_confirmation,
...@@ -191,6 +197,7 @@ void SyncConsentScreenHandler::HandleContinueAndReview( ...@@ -191,6 +197,7 @@ void SyncConsentScreenHandler::HandleContinueAndReview(
void SyncConsentScreenHandler::HandleContinueWithDefaults( void SyncConsentScreenHandler::HandleContinueWithDefaults(
const login::StringList& consent_description, const login::StringList& consent_description,
const std::string& consent_confirmation) { const std::string& consent_confirmation) {
DCHECK(!chromeos::features::IsSplitSettingsSyncEnabled());
std::vector<int> consent_description_ids; std::vector<int> consent_description_ids;
int consent_confirmation_id; int consent_confirmation_id;
GetConsentIDs(known_string_ids_, consent_description, consent_confirmation, GetConsentIDs(known_string_ids_, consent_description, consent_confirmation,
...@@ -206,4 +213,24 @@ void SyncConsentScreenHandler::HandleContinueWithDefaults( ...@@ -206,4 +213,24 @@ void SyncConsentScreenHandler::HandleContinueWithDefaults(
} }
} }
void SyncConsentScreenHandler::HandleOsSyncAcceptAndContinue(
const login::StringList& consent_description,
const std::string& consent_confirmation,
bool enable_os_sync) {
DCHECK(chromeos::features::IsSplitSettingsSyncEnabled());
std::vector<int> consent_description_ids;
int consent_confirmation_id;
GetConsentIDs(known_string_ids_, consent_description, consent_confirmation,
&consent_description_ids, &consent_confirmation_id);
screen_->OnAcceptAndContinue(consent_description_ids, consent_confirmation_id,
enable_os_sync);
SyncConsentScreen::SyncConsentScreenTestDelegate* test_delegate =
screen_->GetDelegateForTesting();
if (test_delegate) {
test_delegate->OnConsentRecordedStrings(consent_description,
consent_confirmation);
}
}
} // namespace chromeos } // namespace chromeos
...@@ -67,6 +67,10 @@ class SyncConsentScreenHandler : public BaseScreenHandler, ...@@ -67,6 +67,10 @@ class SyncConsentScreenHandler : public BaseScreenHandler,
void HandleContinueWithDefaults( void HandleContinueWithDefaults(
const ::login::StringList& consent_description, const ::login::StringList& consent_description,
const std::string& consent_confirmation); const std::string& consent_confirmation);
void HandleOsSyncAcceptAndContinue(
const ::login::StringList& consent_description,
const std::string& consent_confirmation,
bool enable_os_sync);
// Adds resource |resource_id| both to |builder| and to |known_string_ids_|. // Adds resource |resource_id| both to |builder| and to |known_string_ids_|.
void RememberLocalizedValue(const std::string& name, void RememberLocalizedValue(const std::string& name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment