| 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/extensions/api/easy_unlock_private/easy_unlock_private_
api.h" | 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/numerics/safe_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
crypto_delegate.h" | 16 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
crypto_delegate.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" | 18 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
| 18 #include "chrome/browser/signin/easy_unlock_service.h" | 19 #include "chrome/browser/signin/easy_unlock_service.h" |
| 19 #include "chrome/browser/signin/screenlock_bridge.h" | 20 #include "chrome/browser/signin/screenlock_bridge.h" |
| 21 #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" |
| 20 #include "chrome/common/extensions/api/easy_unlock_private.h" | 22 #include "chrome/common/extensions/api/easy_unlock_private.h" |
| 21 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 22 #include "components/proximity_auth/bluetooth_util.h" | 24 #include "components/proximity_auth/bluetooth_util.h" |
| 23 #include "components/proximity_auth/switches.h" | 25 #include "components/proximity_auth/switches.h" |
| 24 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/web_contents.h" |
| 25 #include "extensions/browser/browser_context_keyed_api_factory.h" | 28 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/gfx/geometry/rect.h" |
| 31 #include "ui/gfx/range/range.h" |
| 27 | 32 |
| 28 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
| 29 #include "chrome/browser/chromeos/chromeos_utils.h" | 34 #include "chrome/browser/chromeos/chromeos_utils.h" |
| 30 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" | 35 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" |
| 31 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" | 36 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" |
| 32 #include "components/user_manager/user.h" | 37 #include "components/user_manager/user.h" |
| 33 #include "components/user_manager/user_manager.h" | 38 #include "components/user_manager/user_manager.h" |
| 34 #endif | 39 #endif |
| 35 | 40 |
| 36 namespace extensions { | 41 namespace extensions { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 "setupErrorBluetoothUnavailable", | 297 "setupErrorBluetoothUnavailable", |
| 293 l10n_util::GetStringFUTF16( | 298 l10n_util::GetStringFUTF16( |
| 294 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_UNAVAILBLE, device_type)); | 299 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_UNAVAILBLE, device_type)); |
| 295 strings->SetString( | 300 strings->SetString( |
| 296 "setupErrorOffline", | 301 "setupErrorOffline", |
| 297 l10n_util::GetStringFUTF16( | 302 l10n_util::GetStringFUTF16( |
| 298 IDS_EASY_UNLOCK_SETUP_ERROR_OFFLINE, device_type)); | 303 IDS_EASY_UNLOCK_SETUP_ERROR_OFFLINE, device_type)); |
| 299 strings->SetString( | 304 strings->SetString( |
| 300 "setupErrorFindingPhone", | 305 "setupErrorFindingPhone", |
| 301 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_ERROR_FINDING_PHONE)); | 306 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_ERROR_FINDING_PHONE)); |
| 307 // TODO(isherman): Remove the setupErrorBluetoothConnectionFailed string; it |
| 308 // is unused. |
| 302 strings->SetString( | 309 strings->SetString( |
| 303 "setupErrorBluetoothConnectionFailed", | 310 "setupErrorBluetoothConnectionFailed", |
| 304 l10n_util::GetStringFUTF16( | 311 l10n_util::GetStringFUTF16( |
| 305 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED, | 312 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED, |
| 306 device_type)); | 313 device_type)); |
| 314 // TODO(isherman): Remove the setupErrorConnectionToPhoneTimeout string; it is |
| 315 // identical to the setupErrorConnectingToPhone string, and hence obsolete. |
| 307 strings->SetString( | 316 strings->SetString( |
| 308 "setupErrorConnectionToPhoneTimeout", | 317 "setupErrorConnectionToPhoneTimeout", |
| 309 l10n_util::GetStringFUTF16( | 318 l10n_util::GetStringFUTF16( |
| 310 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECT_TO_PHONE_TIMEOUT, | 319 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECT_TO_PHONE_TIMEOUT, |
| 311 device_type)); | 320 device_type)); |
| 312 strings->SetString( | 321 strings->SetString( |
| 313 "setupErrorSyncPhoneState", | 322 "setupErrorSyncPhoneState", |
| 314 l10n_util::GetStringUTF16( | 323 l10n_util::GetStringUTF16( |
| 315 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); | 324 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); |
| 316 strings->SetString( | 325 strings->SetString( |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( | 744 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( |
| 736 const device::BluetoothDevice::ConnectionInfo& connection_info) { | 745 const device::BluetoothDevice::ConnectionInfo& connection_info) { |
| 737 scoped_ptr<base::ListValue> results(new base::ListValue()); | 746 scoped_ptr<base::ListValue> results(new base::ListValue()); |
| 738 results->AppendInteger(connection_info.rssi); | 747 results->AppendInteger(connection_info.rssi); |
| 739 results->AppendInteger(connection_info.transmit_power); | 748 results->AppendInteger(connection_info.transmit_power); |
| 740 results->AppendInteger(connection_info.max_transmit_power); | 749 results->AppendInteger(connection_info.max_transmit_power); |
| 741 SetResultList(results.Pass()); | 750 SetResultList(results.Pass()); |
| 742 SendResponse(true); | 751 SendResponse(true); |
| 743 } | 752 } |
| 744 | 753 |
| 754 EasyUnlockPrivateShowErrorBubbleFunction:: |
| 755 EasyUnlockPrivateShowErrorBubbleFunction() { |
| 756 } |
| 757 |
| 758 EasyUnlockPrivateShowErrorBubbleFunction:: |
| 759 ~EasyUnlockPrivateShowErrorBubbleFunction() { |
| 760 } |
| 761 |
| 762 bool EasyUnlockPrivateShowErrorBubbleFunction::RunSync() { |
| 763 content::WebContents* web_contents = GetAssociatedWebContents(); |
| 764 if (!web_contents) { |
| 765 SetError("A foreground app window is required."); |
| 766 return true; |
| 767 } |
| 768 |
| 769 scoped_ptr<easy_unlock_private::ShowErrorBubble::Params> params( |
| 770 easy_unlock_private::ShowErrorBubble::Params::Create(*args_)); |
| 771 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 772 |
| 773 if (params->link_range.start < 0 || |
| 774 params->link_range.end < 0 || |
| 775 base::saturated_cast<size_t>(params->link_range.end) > |
| 776 params->message.size()) { |
| 777 SetError("Invalid link range."); |
| 778 return true; |
| 779 } |
| 780 |
| 781 #if defined(TOOLKIT_VIEWS) |
| 782 gfx::Rect anchor_rect( |
| 783 params->anchor_rect.left, params->anchor_rect.top, |
| 784 params->anchor_rect.width, params->anchor_rect.height); |
| 785 anchor_rect += |
| 786 web_contents->GetContainerBounds().OffsetFromOrigin(); |
| 787 ShowProximityAuthErrorBubble( |
| 788 base::UTF8ToUTF16(params->message), |
| 789 gfx::Range(params->link_range.start, params->link_range.end), |
| 790 GURL(params->link_target), anchor_rect, web_contents); |
| 791 #else |
| 792 SetError("Not supported on non-Views platforms."); |
| 793 #endif |
| 794 return true; |
| 795 } |
| 796 |
| 745 } // namespace api | 797 } // namespace api |
| 746 } // namespace extensions | 798 } // namespace extensions |
| OLD | NEW |