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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/numerics/safe_conversions.h" | |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ crypto_delegate.h" | 15 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ crypto_delegate.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" | 17 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
17 #include "chrome/browser/signin/easy_unlock_service.h" | 18 #include "chrome/browser/signin/easy_unlock_service.h" |
18 #include "chrome/browser/signin/screenlock_bridge.h" | 19 #include "chrome/browser/signin/screenlock_bridge.h" |
19 #include "chrome/common/extensions/api/easy_unlock_private.h" | 20 #include "chrome/common/extensions/api/easy_unlock_private.h" |
20 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
21 #include "components/proximity_auth/bluetooth_util.h" | 22 #include "components/proximity_auth/bluetooth_util.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/web_contents.h" | |
23 #include "extensions/browser/browser_context_keyed_api_factory.h" | 25 #include "extensions/browser/browser_context_keyed_api_factory.h" |
24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/gfx/geometry/rect.h" | |
28 #include "ui/gfx/range/range.h" | |
25 | 29 |
26 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
27 #include "chrome/browser/chromeos/chromeos_utils.h" | 31 #include "chrome/browser/chromeos/chromeos_utils.h" |
28 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" | 32 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" |
29 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" | 33 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" |
34 #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" | |
30 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" | 35 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" |
31 #include "components/user_manager/user.h" | 36 #include "components/user_manager/user.h" |
32 #include "components/user_manager/user_manager.h" | 37 #include "components/user_manager/user_manager.h" |
33 #endif | 38 #endif |
34 | 39 |
35 namespace extensions { | 40 namespace extensions { |
36 namespace api { | 41 namespace api { |
37 | 42 |
38 namespace { | 43 namespace { |
39 | 44 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 l10n_util::GetStringFUTF16( | 301 l10n_util::GetStringFUTF16( |
297 IDS_EASY_UNLOCK_SETUP_ERROR_OFFLINE, device_type)); | 302 IDS_EASY_UNLOCK_SETUP_ERROR_OFFLINE, device_type)); |
298 strings->SetString( | 303 strings->SetString( |
299 "setupErrorFindingPhone", | 304 "setupErrorFindingPhone", |
300 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_ERROR_FINDING_PHONE)); | 305 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_ERROR_FINDING_PHONE)); |
301 strings->SetString( | 306 strings->SetString( |
302 "setupErrorBluetoothConnectionFailed", | 307 "setupErrorBluetoothConnectionFailed", |
303 l10n_util::GetStringFUTF16( | 308 l10n_util::GetStringFUTF16( |
304 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED, | 309 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED, |
305 device_type)); | 310 device_type)); |
311 // TODO(isherman): Remove the setupErrorConnectionToPhoneTimeout string; it is | |
312 // identical to the setupErrorConnectingToPhone string, and hence obsolete. | |
306 strings->SetString( | 313 strings->SetString( |
307 "setupErrorConnectionToPhoneTimeout", | 314 "setupErrorConnectionToPhoneTimeout", |
308 l10n_util::GetStringFUTF16( | 315 l10n_util::GetStringFUTF16( |
309 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECT_TO_PHONE_TIMEOUT, | 316 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECT_TO_PHONE_TIMEOUT, |
310 device_type)); | 317 device_type)); |
311 strings->SetString( | 318 strings->SetString( |
312 "setupErrorSyncPhoneState", | 319 "setupErrorSyncPhoneState", |
313 l10n_util::GetStringUTF16( | 320 l10n_util::GetStringUTF16( |
314 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); | 321 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); |
315 strings->SetString( | 322 strings->SetString( |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( | 759 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( |
753 const device::BluetoothDevice::ConnectionInfo& connection_info) { | 760 const device::BluetoothDevice::ConnectionInfo& connection_info) { |
754 scoped_ptr<base::ListValue> results(new base::ListValue()); | 761 scoped_ptr<base::ListValue> results(new base::ListValue()); |
755 results->AppendInteger(connection_info.rssi); | 762 results->AppendInteger(connection_info.rssi); |
756 results->AppendInteger(connection_info.transmit_power); | 763 results->AppendInteger(connection_info.transmit_power); |
757 results->AppendInteger(connection_info.max_transmit_power); | 764 results->AppendInteger(connection_info.max_transmit_power); |
758 SetResultList(results.Pass()); | 765 SetResultList(results.Pass()); |
759 SendResponse(true); | 766 SendResponse(true); |
760 } | 767 } |
761 | 768 |
769 EasyUnlockPrivateShowErrorBubbleFunction:: | |
770 EasyUnlockPrivateShowErrorBubbleFunction() { | |
771 } | |
772 | |
773 EasyUnlockPrivateShowErrorBubbleFunction:: | |
774 ~EasyUnlockPrivateShowErrorBubbleFunction() { | |
775 } | |
776 | |
777 bool EasyUnlockPrivateShowErrorBubbleFunction::RunSync() { | |
778 content::WebContents* web_contents = GetAssociatedWebContents(); | |
779 if (!web_contents) { | |
780 SetError("A foreground app window is required."); | |
781 return true; | |
782 } | |
783 | |
784 scoped_ptr<easy_unlock_private::ShowErrorBubble::Params> params( | |
785 easy_unlock_private::ShowErrorBubble::Params::Create(*args_)); | |
786 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
787 | |
788 if (params->link_range.start < 0 || | |
789 params->link_range.end < 0 || | |
790 base::checked_cast<size_t>(params->link_range.end) > | |
791 params->message.size()) { | |
792 SetError("Invalid link range."); | |
793 return true; | |
794 } | |
795 | |
796 #if defined(OS_CHROMEOS) | |
Tim Song
2015/01/16 22:50:36
Doesn't the bubble work on all desktop platforms b
Ilya Sherman
2015/01/17 01:03:42
Done.
| |
797 gfx::Rect anchor_rect( | |
798 params->anchor_rect.left, params->anchor_rect.top, | |
799 params->anchor_rect.width, params->anchor_rect.height); | |
800 anchor_rect += | |
801 web_contents->GetContainerBounds().OffsetFromOrigin(); | |
802 ProximityAuthErrorBubble::ShowErrorBubble( | |
803 base::UTF8ToUTF16(params->message), | |
804 gfx::Range(params->link_range.start, params->link_range.end), | |
805 GURL(params->link_target), anchor_rect, web_contents); | |
806 #else | |
807 SetError("Not supported on non-ChromeOS platforms."); | |
808 #endif | |
809 return true; | |
810 } | |
811 | |
762 } // namespace api | 812 } // namespace api |
763 } // namespace extensions | 813 } // namespace extensions |
OLD | NEW |