| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/easy_unlock_screenlock_state_handler.h" | 5 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/chromeos_utils.h" | 10 #include "chrome/browser/chromeos/chromeos_utils.h" |
| 11 #include "chrome/browser/signin/easy_unlock_metrics.h" | 11 #include "chrome/browser/signin/easy_unlock_metrics.h" |
| 12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 | 14 |
| 15 using proximity_auth::ScreenlockState; |
| 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 proximity_auth::ScreenlockBridge::UserPodCustomIcon GetIconForState( | 19 proximity_auth::ScreenlockBridge::UserPodCustomIcon GetIconForState( |
| 18 EasyUnlockScreenlockStateHandler::State state) { | 20 ScreenlockState state) { |
| 19 switch (state) { | 21 switch (state) { |
| 20 case EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH: | 22 case ScreenlockState::NO_BLUETOOTH: |
| 21 case EasyUnlockScreenlockStateHandler::STATE_NO_PHONE: | 23 case ScreenlockState::NO_PHONE: |
| 22 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: | 24 case ScreenlockState::PHONE_NOT_AUTHENTICATED: |
| 23 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: | 25 case ScreenlockState::PHONE_LOCKED: |
| 24 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: | 26 case ScreenlockState::PHONE_NOT_LOCKABLE: |
| 25 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: | 27 case ScreenlockState::PHONE_UNSUPPORTED: |
| 26 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: | 28 case ScreenlockState::RSSI_TOO_LOW: |
| 27 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED; | 29 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED; |
| 28 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: | 30 case ScreenlockState::TX_POWER_TOO_HIGH: |
| 29 case EasyUnlockScreenlockStateHandler:: | 31 case ScreenlockState::PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: |
| 30 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: | |
| 31 // TODO(isherman): This icon is currently identical to the regular locked | 32 // TODO(isherman): This icon is currently identical to the regular locked |
| 32 // icon. Once the reduced proximity range flag is removed, consider | 33 // icon. Once the reduced proximity range flag is removed, consider |
| 33 // deleting the redundant icon. | 34 // deleting the redundant icon. |
| 34 return proximity_auth::ScreenlockBridge:: | 35 return proximity_auth::ScreenlockBridge:: |
| 35 USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT; | 36 USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT; |
| 36 case EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING: | 37 case ScreenlockState::BLUETOOTH_CONNECTING: |
| 37 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER; | 38 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER; |
| 38 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: | 39 case ScreenlockState::AUTHENTICATED: |
| 39 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED; | 40 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED; |
| 40 default: | 41 case ScreenlockState::INACTIVE: |
| 41 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; | 42 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; |
| 42 } | 43 } |
| 44 |
| 45 NOTREACHED(); |
| 46 return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; |
| 43 } | 47 } |
| 44 | 48 |
| 45 bool HardlockOnClick(EasyUnlockScreenlockStateHandler::State state) { | 49 bool HardlockOnClick(ScreenlockState state) { |
| 46 return state != EasyUnlockScreenlockStateHandler::STATE_INACTIVE; | 50 return state != ScreenlockState::INACTIVE; |
| 47 } | 51 } |
| 48 | 52 |
| 49 size_t GetTooltipResourceId(EasyUnlockScreenlockStateHandler::State state) { | 53 size_t GetTooltipResourceId(ScreenlockState state) { |
| 50 switch (state) { | 54 switch (state) { |
| 51 case EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH: | 55 case ScreenlockState::INACTIVE: |
| 56 case ScreenlockState::BLUETOOTH_CONNECTING: |
| 57 return 0; |
| 58 case ScreenlockState::NO_BLUETOOTH: |
| 52 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_NO_BLUETOOTH; | 59 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_NO_BLUETOOTH; |
| 53 case EasyUnlockScreenlockStateHandler::STATE_NO_PHONE: | 60 case ScreenlockState::NO_PHONE: |
| 54 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_NO_PHONE; | 61 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_NO_PHONE; |
| 55 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: | 62 case ScreenlockState::PHONE_NOT_AUTHENTICATED: |
| 56 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_NOT_AUTHENTICATED; | 63 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_NOT_AUTHENTICATED; |
| 57 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: | 64 case ScreenlockState::PHONE_LOCKED: |
| 58 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED; | 65 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED; |
| 59 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: | 66 case ScreenlockState::PHONE_NOT_LOCKABLE: |
| 60 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_UNLOCKABLE; | 67 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_UNLOCKABLE; |
| 61 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: | 68 case ScreenlockState::PHONE_UNSUPPORTED: |
| 69 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_UNSUPPORTED_ANDROID_VERSION; |
| 70 case ScreenlockState::RSSI_TOO_LOW: |
| 62 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_RSSI_TOO_LOW; | 71 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_RSSI_TOO_LOW; |
| 63 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: | 72 case ScreenlockState::TX_POWER_TOO_HIGH: |
| 64 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TX_POWER_TOO_HIGH; | 73 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TX_POWER_TOO_HIGH; |
| 65 case EasyUnlockScreenlockStateHandler:: | 74 case ScreenlockState::PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: |
| 66 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: | |
| 67 return | 75 return |
| 68 IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; | 76 IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; |
| 69 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: | 77 case ScreenlockState::AUTHENTICATED: |
| 70 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_INSTRUCTIONS; | 78 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_INSTRUCTIONS; |
| 71 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: | |
| 72 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_UNSUPPORTED_ANDROID_VERSION; | |
| 73 default: | |
| 74 return 0; | |
| 75 } | 79 } |
| 80 |
| 81 NOTREACHED(); |
| 82 return 0; |
| 76 } | 83 } |
| 77 | 84 |
| 78 bool TooltipContainsDeviceType(EasyUnlockScreenlockStateHandler::State state) { | 85 bool TooltipContainsDeviceType(ScreenlockState state) { |
| 79 return state == EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED || | 86 return (state == ScreenlockState::AUTHENTICATED || |
| 80 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE || | 87 state == ScreenlockState::PHONE_NOT_LOCKABLE || |
| 81 state == EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH || | 88 state == ScreenlockState::NO_BLUETOOTH || |
| 82 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED || | 89 state == ScreenlockState::PHONE_UNSUPPORTED || |
| 83 state == EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH || | 90 state == ScreenlockState::TX_POWER_TOO_HIGH || |
| 84 state == EasyUnlockScreenlockStateHandler:: | 91 state == ScreenlockState::PHONE_LOCKED_AND_TX_POWER_TOO_HIGH); |
| 85 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; | |
| 86 } | 92 } |
| 87 | 93 |
| 88 // Returns true iff the |state| corresponds to a locked remote device. | 94 // Returns true iff the |state| corresponds to a locked remote device. |
| 89 bool IsLockedState(EasyUnlockScreenlockStateHandler::State state) { | 95 bool IsLockedState(ScreenlockState state) { |
| 90 return (state == EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED || | 96 return (state == ScreenlockState::PHONE_LOCKED || |
| 91 state == EasyUnlockScreenlockStateHandler:: | 97 state == ScreenlockState::PHONE_LOCKED_AND_TX_POWER_TOO_HIGH); |
| 92 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH); | |
| 93 } | 98 } |
| 94 | 99 |
| 95 } // namespace | 100 } // namespace |
| 96 | 101 |
| 97 EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler( | 102 EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler( |
| 98 const std::string& user_email, | 103 const std::string& user_email, |
| 99 HardlockState initial_hardlock_state, | 104 HardlockState initial_hardlock_state, |
| 100 proximity_auth::ScreenlockBridge* screenlock_bridge) | 105 proximity_auth::ScreenlockBridge* screenlock_bridge) |
| 101 : state_(STATE_INACTIVE), | 106 : state_(ScreenlockState::INACTIVE), |
| 102 user_email_(user_email), | 107 user_email_(user_email), |
| 103 screenlock_bridge_(screenlock_bridge), | 108 screenlock_bridge_(screenlock_bridge), |
| 104 hardlock_state_(initial_hardlock_state), | 109 hardlock_state_(initial_hardlock_state), |
| 105 hardlock_ui_shown_(false), | 110 hardlock_ui_shown_(false), |
| 106 is_trial_run_(false), | 111 is_trial_run_(false), |
| 107 did_see_locked_phone_(false) { | 112 did_see_locked_phone_(false) { |
| 108 DCHECK(screenlock_bridge_); | 113 DCHECK(screenlock_bridge_); |
| 109 screenlock_bridge_->AddObserver(this); | 114 screenlock_bridge_->AddObserver(this); |
| 110 } | 115 } |
| 111 | 116 |
| 112 EasyUnlockScreenlockStateHandler::~EasyUnlockScreenlockStateHandler() { | 117 EasyUnlockScreenlockStateHandler::~EasyUnlockScreenlockStateHandler() { |
| 113 screenlock_bridge_->RemoveObserver(this); | 118 screenlock_bridge_->RemoveObserver(this); |
| 114 // Make sure the screenlock state set by this gets cleared. | 119 // Make sure the screenlock state set by this gets cleared. |
| 115 ChangeState(STATE_INACTIVE); | 120 ChangeState(ScreenlockState::INACTIVE); |
| 116 } | 121 } |
| 117 | 122 |
| 118 bool EasyUnlockScreenlockStateHandler::IsActive() const { | 123 bool EasyUnlockScreenlockStateHandler::IsActive() const { |
| 119 return state_ != STATE_INACTIVE; | 124 return state_ != ScreenlockState::INACTIVE; |
| 120 } | 125 } |
| 121 | 126 |
| 122 bool EasyUnlockScreenlockStateHandler::InStateValidOnRemoteAuthFailure() const { | 127 bool EasyUnlockScreenlockStateHandler::InStateValidOnRemoteAuthFailure() const { |
| 123 // Note that NO_PHONE is not valid in this case because the phone may close | 128 // Note that NO_PHONE is not valid in this case because the phone may close |
| 124 // the connection if the auth challenge sent to it is invalid. This case | 129 // the connection if the auth challenge sent to it is invalid. This case |
| 125 // should be handled as authentication failure. | 130 // should be handled as authentication failure. |
| 126 return state_ == EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH || | 131 return (state_ == ScreenlockState::NO_BLUETOOTH || |
| 127 state_ == EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED; | 132 state_ == ScreenlockState::PHONE_LOCKED); |
| 128 } | 133 } |
| 129 | 134 |
| 130 void EasyUnlockScreenlockStateHandler::ChangeState(State new_state) { | 135 void EasyUnlockScreenlockStateHandler::ChangeState(ScreenlockState new_state) { |
| 131 if (state_ == new_state) | 136 if (state_ == new_state) |
| 132 return; | 137 return; |
| 133 | 138 |
| 134 state_ = new_state; | 139 state_ = new_state; |
| 135 | 140 |
| 136 // If lock screen is not active or it forces offline password, just cache the | 141 // If lock screen is not active or it forces offline password, just cache the |
| 137 // current state. The screenlock state will get refreshed in |ScreenDidLock|. | 142 // current state. The screenlock state will get refreshed in |ScreenDidLock|. |
| 138 if (!screenlock_bridge_->IsLocked()) | 143 if (!screenlock_bridge_->IsLocked()) |
| 139 return; | 144 return; |
| 140 | 145 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 168 | 173 |
| 169 // Don't hardlock on trial run. | 174 // Don't hardlock on trial run. |
| 170 if (is_trial_run_) | 175 if (is_trial_run_) |
| 171 icon_options.SetTrialRun(); | 176 icon_options.SetTrialRun(); |
| 172 else if (HardlockOnClick(state_)) | 177 else if (HardlockOnClick(state_)) |
| 173 icon_options.SetHardlockOnClick(); | 178 icon_options.SetHardlockOnClick(); |
| 174 | 179 |
| 175 UpdateTooltipOptions(&icon_options); | 180 UpdateTooltipOptions(&icon_options); |
| 176 | 181 |
| 177 // For states without tooltips, we still need to set an accessibility label. | 182 // For states without tooltips, we still need to set an accessibility label. |
| 178 if (state_ == EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING) { | 183 if (state_ == ScreenlockState::BLUETOOTH_CONNECTING) { |
| 179 icon_options.SetAriaLabel( | 184 icon_options.SetAriaLabel( |
| 180 l10n_util::GetStringUTF16(IDS_SMART_LOCK_SPINNER_ACCESSIBILITY_LABEL)); | 185 l10n_util::GetStringUTF16(IDS_SMART_LOCK_SPINNER_ACCESSIBILITY_LABEL)); |
| 181 } | 186 } |
| 182 | 187 |
| 183 screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(user_email_, | 188 screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(user_email_, |
| 184 icon_options); | 189 icon_options); |
| 185 } | 190 } |
| 186 | 191 |
| 187 void EasyUnlockScreenlockStateHandler::SetHardlockState( | 192 void EasyUnlockScreenlockStateHandler::SetHardlockState( |
| 188 HardlockState new_state) { | 193 HardlockState new_state) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 235 |
| 231 void EasyUnlockScreenlockStateHandler::OnScreenDidUnlock( | 236 void EasyUnlockScreenlockStateHandler::OnScreenDidUnlock( |
| 232 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { | 237 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 233 if (hardlock_state_ == LOGIN_FAILED) | 238 if (hardlock_state_ == LOGIN_FAILED) |
| 234 hardlock_state_ = NO_HARDLOCK; | 239 hardlock_state_ = NO_HARDLOCK; |
| 235 hardlock_ui_shown_ = false; | 240 hardlock_ui_shown_ = false; |
| 236 is_trial_run_ = false; | 241 is_trial_run_ = false; |
| 237 | 242 |
| 238 // Upon a successful unlock event, record whether the user's phone was locked | 243 // Upon a successful unlock event, record whether the user's phone was locked |
| 239 // at any point while the lock screen was up. | 244 // at any point while the lock screen was up. |
| 240 if (state_ == STATE_AUTHENTICATED) | 245 if (state_ == ScreenlockState::AUTHENTICATED) |
| 241 RecordEasyUnlockDidUserManuallyUnlockPhone(did_see_locked_phone_); | 246 RecordEasyUnlockDidUserManuallyUnlockPhone(did_see_locked_phone_); |
| 242 did_see_locked_phone_ = false; | 247 did_see_locked_phone_ = false; |
| 243 } | 248 } |
| 244 | 249 |
| 245 void EasyUnlockScreenlockStateHandler::OnFocusedUserChanged( | 250 void EasyUnlockScreenlockStateHandler::OnFocusedUserChanged( |
| 246 const std::string& user_id) { | 251 const std::string& user_id) { |
| 247 } | 252 } |
| 248 | 253 |
| 249 void EasyUnlockScreenlockStateHandler::RefreshScreenlockState() { | 254 void EasyUnlockScreenlockStateHandler::RefreshScreenlockState() { |
| 250 State last_state = state_; | 255 ScreenlockState last_state = state_; |
| 251 // This should force updating screenlock state. | 256 // This should force updating screenlock state. |
| 252 state_ = STATE_INACTIVE; | 257 state_ = ScreenlockState::INACTIVE; |
| 253 ChangeState(last_state); | 258 ChangeState(last_state); |
| 254 } | 259 } |
| 255 | 260 |
| 256 void EasyUnlockScreenlockStateHandler::ShowHardlockUI() { | 261 void EasyUnlockScreenlockStateHandler::ShowHardlockUI() { |
| 257 DCHECK(hardlock_state_ != NO_HARDLOCK); | 262 DCHECK(hardlock_state_ != NO_HARDLOCK); |
| 258 | 263 |
| 259 if (!screenlock_bridge_->IsLocked()) | 264 if (!screenlock_bridge_->IsLocked()) |
| 260 return; | 265 return; |
| 261 | 266 |
| 262 // Do not override online signin. | 267 // Do not override online signin. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 324 |
| 320 screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(user_email_, | 325 screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(user_email_, |
| 321 icon_options); | 326 icon_options); |
| 322 hardlock_ui_shown_ = true; | 327 hardlock_ui_shown_ = true; |
| 323 } | 328 } |
| 324 | 329 |
| 325 void EasyUnlockScreenlockStateHandler::UpdateTooltipOptions( | 330 void EasyUnlockScreenlockStateHandler::UpdateTooltipOptions( |
| 326 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options) { | 331 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options) { |
| 327 size_t resource_id = 0; | 332 size_t resource_id = 0; |
| 328 base::string16 device_name; | 333 base::string16 device_name; |
| 329 if (is_trial_run_ && state_ == STATE_AUTHENTICATED) { | 334 if (is_trial_run_ && state_ == ScreenlockState::AUTHENTICATED) { |
| 330 resource_id = IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_INITIAL_AUTHENTICATED; | 335 resource_id = IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_INITIAL_AUTHENTICATED; |
| 331 } else { | 336 } else { |
| 332 resource_id = GetTooltipResourceId(state_); | 337 resource_id = GetTooltipResourceId(state_); |
| 333 if (TooltipContainsDeviceType(state_)) | 338 if (TooltipContainsDeviceType(state_)) |
| 334 device_name = GetDeviceName(); | 339 device_name = GetDeviceName(); |
| 335 } | 340 } |
| 336 | 341 |
| 337 if (!resource_id) | 342 if (!resource_id) |
| 338 return; | 343 return; |
| 339 | 344 |
| 340 base::string16 tooltip; | 345 base::string16 tooltip; |
| 341 if (device_name.empty()) { | 346 if (device_name.empty()) { |
| 342 tooltip = l10n_util::GetStringUTF16(resource_id); | 347 tooltip = l10n_util::GetStringUTF16(resource_id); |
| 343 } else { | 348 } else { |
| 344 tooltip = l10n_util::GetStringFUTF16(resource_id, device_name); | 349 tooltip = l10n_util::GetStringFUTF16(resource_id, device_name); |
| 345 } | 350 } |
| 346 | 351 |
| 347 if (tooltip.empty()) | 352 if (tooltip.empty()) |
| 348 return; | 353 return; |
| 349 | 354 |
| 350 icon_options->SetTooltip( | 355 bool autoshow_tooltip = |
| 351 tooltip, | 356 is_trial_run_ || state_ != ScreenlockState::AUTHENTICATED; |
| 352 is_trial_run_ || (state_ != STATE_AUTHENTICATED) /* autoshow tooltip */); | 357 icon_options->SetTooltip(tooltip, autoshow_tooltip); |
| 353 } | 358 } |
| 354 | 359 |
| 355 base::string16 EasyUnlockScreenlockStateHandler::GetDeviceName() { | 360 base::string16 EasyUnlockScreenlockStateHandler::GetDeviceName() { |
| 356 #if defined(OS_CHROMEOS) | 361 #if defined(OS_CHROMEOS) |
| 357 return chromeos::GetChromeDeviceType(); | 362 return chromeos::GetChromeDeviceType(); |
| 358 #else | 363 #else |
| 359 // TODO(tbarzic): Figure out the name for non Chrome OS case. | 364 // TODO(tbarzic): Figure out the name for non Chrome OS case. |
| 360 return base::ASCIIToUTF16("Chrome"); | 365 return base::ASCIIToUTF16("Chrome"); |
| 361 #endif | 366 #endif |
| 362 } | 367 } |
| 363 | 368 |
| 364 void EasyUnlockScreenlockStateHandler::UpdateScreenlockAuthType() { | 369 void EasyUnlockScreenlockStateHandler::UpdateScreenlockAuthType() { |
| 365 if (!is_trial_run_ && hardlock_state_ != NO_HARDLOCK) | 370 if (!is_trial_run_ && hardlock_state_ != NO_HARDLOCK) |
| 366 return; | 371 return; |
| 367 | 372 |
| 368 // Do not override online signin. | 373 // Do not override online signin. |
| 369 const proximity_auth::ScreenlockBridge::LockHandler::AuthType | 374 const proximity_auth::ScreenlockBridge::LockHandler::AuthType |
| 370 existing_auth_type = | 375 existing_auth_type = |
| 371 screenlock_bridge_->lock_handler()->GetAuthType(user_email_); | 376 screenlock_bridge_->lock_handler()->GetAuthType(user_email_); |
| 372 DCHECK_NE(proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN, | 377 DCHECK_NE(proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN, |
| 373 existing_auth_type); | 378 existing_auth_type); |
| 374 | 379 |
| 375 if (state_ == STATE_AUTHENTICATED) { | 380 if (state_ == ScreenlockState::AUTHENTICATED) { |
| 376 if (existing_auth_type != | 381 if (existing_auth_type != |
| 377 proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK) { | 382 proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK) { |
| 378 screenlock_bridge_->lock_handler()->SetAuthType( | 383 screenlock_bridge_->lock_handler()->SetAuthType( |
| 379 user_email_, | 384 user_email_, |
| 380 proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK, | 385 proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK, |
| 381 l10n_util::GetStringUTF16( | 386 l10n_util::GetStringUTF16( |
| 382 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE)); | 387 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE)); |
| 383 } | 388 } |
| 384 } else if (existing_auth_type != | 389 } else if (existing_auth_type != |
| 385 proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) { | 390 proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) { |
| 386 screenlock_bridge_->lock_handler()->SetAuthType( | 391 screenlock_bridge_->lock_handler()->SetAuthType( |
| 387 user_email_, | 392 user_email_, |
| 388 proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 393 proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, |
| 389 base::string16()); | 394 base::string16()); |
| 390 } | 395 } |
| 391 } | 396 } |
| OLD | NEW |