Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4460)

Unified Diff: chrome/browser/signin/easy_unlock_screenlock_state_handler.cc

Issue 628193003: [Easy Unlock] Update handling of the trial easy unlock/signin run (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
diff --git a/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc b/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
index ea41fac5d1442429deb59fb7ef1768c3c6f05c74..9be483715389d61fd8b8a78c43141ce6100397c6 100644
--- a/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
+++ b/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
@@ -6,8 +6,10 @@
#include "base/bind.h"
#include "base/prefs/pref_service.h"
+#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/chromeos_utils.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
@@ -69,17 +71,21 @@ bool TooltipContainsDeviceType(EasyUnlockScreenlockStateHandler::State state) {
state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED;
}
+bool IsLocaleEnUS() {
+ return g_browser_process->GetApplicationLocale() == "en-US";
+}
+
} // namespace
EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler(
const std::string& user_email,
HardlockState initial_hardlock_state,
- PrefService* pref_service,
+ PrefService* local_state,
ScreenlockBridge* screenlock_bridge)
: state_(STATE_INACTIVE),
user_email_(user_email),
- pref_service_(pref_service),
+ local_state_(local_state),
screenlock_bridge_(screenlock_bridge),
hardlock_state_(initial_hardlock_state),
hardlock_ui_shown_(false) {
@@ -106,8 +112,9 @@ void EasyUnlockScreenlockStateHandler::ChangeState(State new_state) {
const bool trial_run = IsTrialRun();
- // No hardlock UI for trial run.
- if (!trial_run && hardlock_state_ != NO_HARDLOCK) {
+ // Ignore NO_PAIRING hardlock state for trial run.
+ if (!(trial_run && hardlock_state_ == NO_PAIRING) &&
+ hardlock_state_ != NO_HARDLOCK) {
ShowHardlockUI();
return;
}
@@ -124,7 +131,6 @@ void EasyUnlockScreenlockStateHandler::ChangeState(State new_state) {
ScreenlockBridge::UserPodCustomIconOptions icon_options;
icon_options.SetIcon(icon);
- // Don't hardlock on trial run.
if (!trial_run && HardlockOnClick(state_))
icon_options.SetHardlockOnClick();
@@ -201,17 +207,20 @@ void EasyUnlockScreenlockStateHandler::ShowHardlockUI() {
ScreenlockBridge::UserPodCustomIconOptions icon_options;
icon_options.SetIcon(ScreenlockBridge::USER_POD_CUSTOM_ICON_HARDLOCKED);
- base::string16 tooltip;
- if (hardlock_state_ == USER_HARDLOCK) {
- tooltip = l10n_util::GetStringFUTF16(
- IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_USER, GetDeviceName());
- } else if (hardlock_state_ == PAIRING_CHANGED) {
- tooltip = l10n_util::GetStringUTF16(
- IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_PAIRING_CHANGED);
- } else {
- LOG(ERROR) << "Unknown hardlock state " << hardlock_state_;
+ // TODO(tbarzic): Remove this condition for M-40.
+ if (IsLocaleEnUS()) {
+ base::string16 tooltip;
+ if (hardlock_state_ == USER_HARDLOCK) {
+ tooltip = l10n_util::GetStringFUTF16(
+ IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_USER, GetDeviceName());
+ } else if (hardlock_state_ == PAIRING_CHANGED) {
+ tooltip = l10n_util::GetStringUTF16(
+ IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_PAIRING_CHANGED);
+ } else {
+ LOG(ERROR) << "Unknown hardlock state " << hardlock_state_;
+ }
+ icon_options.SetTooltip(tooltip, false /* don't autoshow */);
}
- icon_options.SetTooltip(tooltip, false /* don't autoshow */);
screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(user_email_,
icon_options);
@@ -224,7 +233,11 @@ void EasyUnlockScreenlockStateHandler::UpdateTooltipOptions(
size_t resource_id = 0;
base::string16 device_name;
if (trial_run && state_ == STATE_AUTHENTICATED) {
- resource_id = IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TUTORIAL;
+ // TODO(tbarzic): Remove this condition for M-40 branch.
+ if (IsLocaleEnUS())
+ resource_id = IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_INITIAL_AUTHENTICATED;
+ else
+ resource_id = IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TUTORIAL;
} else {
resource_id = GetTooltipResourceId(state_);
if (TooltipContainsDeviceType(state_))
@@ -244,20 +257,27 @@ void EasyUnlockScreenlockStateHandler::UpdateTooltipOptions(
if (tooltip.empty())
return;
- icon_options->SetTooltip(
- tooltip,
- state_ == STATE_AUTHENTICATED && trial_run /* autoshow tooltip */);
+ icon_options->SetTooltip(tooltip, trial_run /* autoshow tooltip */);
}
bool EasyUnlockScreenlockStateHandler::IsTrialRun() {
- return pref_service_ &&
- pref_service_->GetBoolean(prefs::kEasyUnlockShowTutorial);
+ if (!local_state_)
+ return false;
+ const base::DictionaryValue* dict =
+ local_state_->GetDictionary(prefs::kEasyUnlockFirstRunComplete);
+ bool first_run_complete;
+ return !dict ||
+ !dict->GetBooleanWithoutPathExpansion(user_email_, &first_run_complete) ||
+ !first_run_complete;
}
void EasyUnlockScreenlockStateHandler::MarkTrialRunComplete() {
- if (!pref_service_)
+ DCHECK(!user_email_.empty());
+
+ if (!local_state_)
return;
- pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false);
+ DictionaryPrefUpdate update(local_state_, prefs::kEasyUnlockFirstRunComplete);
+ update->SetBooleanWithoutPathExpansion(user_email_, true);
}
base::string16 EasyUnlockScreenlockStateHandler::GetDeviceName() {

Powered by Google App Engine
This is Rietveld 408576698