Chromium Code Reviews| 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. Perhaps we should just delete the redundant icon? | |
|
Tim Song
2015/01/24 02:38:31
Let's wait until we're ready to remove the flag.
Ilya Sherman
2015/01/27 01:20:24
Updated the TODO text.
| |
| 28 return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT; | 32 return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT; |
| 29 case EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING: | 33 case EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING: |
| 30 return ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER; | 34 return ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER; |
| 31 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: | 35 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: |
| 32 return ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED; | 36 return ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED; |
| 33 default: | 37 default: |
| 34 return ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; | 38 return ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE; |
| 35 } | 39 } |
| 36 } | 40 } |
| 37 | 41 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 48 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: | 52 case EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED: |
| 49 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_NOT_AUTHENTICATED; | 53 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_NOT_AUTHENTICATED; |
| 50 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: | 54 case EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED: |
| 51 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED; | 55 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED; |
| 52 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: | 56 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE: |
| 53 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_UNLOCKABLE; | 57 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_UNLOCKABLE; |
| 54 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: | 58 case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW: |
| 55 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_RSSI_TOO_LOW; | 59 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_RSSI_TOO_LOW; |
| 56 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: | 60 case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH: |
| 57 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TX_POWER_TOO_HIGH; | 61 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_TX_POWER_TOO_HIGH; |
| 62 case EasyUnlockScreenlockStateHandler:: | |
| 63 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH: | |
| 64 return | |
| 65 IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; | |
| 58 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: | 66 case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED: |
| 59 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_INSTRUCTIONS; | 67 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_HARDLOCK_INSTRUCTIONS; |
| 60 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: | 68 case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED: |
| 61 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_UNSUPPORTED_ANDROID_VERSION; | 69 return IDS_EASY_UNLOCK_SCREENLOCK_TOOLTIP_UNSUPPORTED_ANDROID_VERSION; |
| 62 default: | 70 default: |
| 63 return 0; | 71 return 0; |
| 64 } | 72 } |
| 65 } | 73 } |
| 66 | 74 |
| 67 bool TooltipContainsDeviceType(EasyUnlockScreenlockStateHandler::State state) { | 75 bool TooltipContainsDeviceType(EasyUnlockScreenlockStateHandler::State state) { |
| 68 return state == EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED || | 76 return state == EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED || |
| 69 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE || | 77 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE || |
| 70 state == EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH || | 78 state == EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH || |
| 71 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED || | 79 state == EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED || |
| 72 state == EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW || | 80 state == EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH || |
| 73 state == EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH; | 81 state == EasyUnlockScreenlockStateHandler:: |
| 82 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH; | |
| 74 } | 83 } |
| 75 | 84 |
| 76 } // namespace | 85 } // namespace |
| 77 | 86 |
| 78 | 87 |
| 79 EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler( | 88 EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler( |
| 80 const std::string& user_email, | 89 const std::string& user_email, |
| 81 HardlockState initial_hardlock_state, | 90 HardlockState initial_hardlock_state, |
| 82 ScreenlockBridge* screenlock_bridge) | 91 ScreenlockBridge* screenlock_bridge) |
| 83 : state_(STATE_INACTIVE), | 92 : 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)); | 343 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE)); |
| 335 } | 344 } |
| 336 } else if (existing_auth_type != | 345 } else if (existing_auth_type != |
| 337 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) { | 346 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) { |
| 338 screenlock_bridge_->lock_handler()->SetAuthType( | 347 screenlock_bridge_->lock_handler()->SetAuthType( |
| 339 user_email_, | 348 user_email_, |
| 340 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 349 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, |
| 341 base::string16()); | 350 base::string16()); |
| 342 } | 351 } |
| 343 } | 352 } |
| OLD | NEW |