| 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/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 ScreenlockBridge::UserPodCustomIcon GetIconForState( | 16 ScreenlockBridge::UserPodCustomIcon GetIconForState( |
| 17 EasyUnlockScreenlockStateHandler::State state) { | 17 EasyUnlockScreenlockStateHandler::State state) { |
| 18 switch (state) { | 18 switch (state) { |
| 19 case EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH: | 19 case EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH: |
| 20 case EasyUnlockScreenlockStateHandler::STATE_NO_PHONE: | 20 case EasyUnlockScreenlockStateHandler::STATE_NO_PHONE: |
| 21 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: | 21 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: |
| 22 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: | 22 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: |
| 23 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: | 23 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: |
| 24 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: | 24 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: |
| 25 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: | 25 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: |
| 26 return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED; | 26 return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED; |
| 27 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: | 27 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: |
| 28 case EasyUnlockScreenlockStateHandler:: |
| 29 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: |
| 30 // TODO(isherman): This icon is currently identical to the regular locked |
| 31 // icon. Once the reduced proximity range flag is removed, consider |
| 32 // deleting the redundant icon. |
| 28 return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT; | 33 return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT; |
| 29 case EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING: | 34 case EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING: |
| 30 return ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER; | 35 return ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER; |
| 31 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: | 36 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: |
| 32 return ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED; | 37 return ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED; |
| 33 default: | 38 default: |
| 34 return ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; | 39 return ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; |
| 35 } | 40 } |
| 36 } | 41 } |
| 37 | 42 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 48 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: | 53 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: |
| 49 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_NOT_AUTHENTICATED; | 54 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_NOT_AUTHENTICATED; |
| 50 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: | 55 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: |
| 51 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED; | 56 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED; |
| 52 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: | 57 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: |
| 53 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_UNLOCKABLE; | 58 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_UNLOCKABLE; |
| 54 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: | 59 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: |
| 55 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_RSSI_TOO_LOW; | 60 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_RSSI_TOO_LOW; |
| 56 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: | 61 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: |
| 57 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TX_POWER_TOO_HIGH; | 62 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TX_POWER_TOO_HIGH; |
| 63 case EasyUnlockScreenlockStateHandler:: |
| 64 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: |
| 65 return |
| 66 IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; |
| 58 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: | 67 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: |
| 59 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_INSTRUCTIONS; | 68 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_INSTRUCTIONS; |
| 60 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: | 69 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: |
| 61 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_UNSUPPORTED_ANDROID_VERSION; | 70 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_UNSUPPORTED_ANDROID_VERSION; |
| 62 default: | 71 default: |
| 63 return 0; | 72 return 0; |
| 64 } | 73 } |
| 65 } | 74 } |
| 66 | 75 |
| 67 bool TooltipContainsDeviceType(EasyUnlockScreenlockStateHandler::State state) { | 76 bool TooltipContainsDeviceType(EasyUnlockScreenlockStateHandler::State state) { |
| 68 return state == EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED || | 77 return state == EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED || |
| 69 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE || | 78 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE || |
| 70 state == EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH || | 79 state == EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH || |
| 71 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED || | 80 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED || |
| 72 state == EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW || | 81 state == EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH || |
| 73 state == EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH; | 82 state == EasyUnlockScreenlockStateHandler:: |
| 83 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; |
| 74 } | 84 } |
| 75 | 85 |
| 76 } // namespace | 86 } // namespace |
| 77 | 87 |
| 78 | 88 |
| 79 EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler( | 89 EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler( |
| 80 const std::string& user_email, | 90 const std::string& user_email, |
| 81 HardlockState initial_hardlock_state, | 91 HardlockState initial_hardlock_state, |
| 82 ScreenlockBridge* screenlock_bridge) | 92 ScreenlockBridge* screenlock_bridge) |
| 83 : state_(STATE_INACTIVE), | 93 : state_(STATE_INACTIVE), |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE)); | 344 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE)); |
| 335 } | 345 } |
| 336 } else if (existing_auth_type != | 346 } else if (existing_auth_type != |
| 337 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) { | 347 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) { |
| 338 screenlock_bridge_->lock_handler()->SetAuthType( | 348 screenlock_bridge_->lock_handler()->SetAuthType( |
| 339 user_email_, | 349 user_email_, |
| 340 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 350 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, |
| 341 base::string16()); | 351 base::string16()); |
| 342 } | 352 } |
| 343 } | 353 } |
| OLD | NEW |