Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc

Issue 843023002: [Smart Lock] Add a private API to show an error bubble anchored to the Smart Lock app window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update error message strings Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 l10n_util::GetStringFUTF16( 295 l10n_util::GetStringFUTF16(
291 IDS_EASY_UNLOCK_SETUP_ERROR_OFFLINE, device_type)); 296 IDS_EASY_UNLOCK_SETUP_ERROR_OFFLINE, device_type));
292 strings->SetString( 297 strings->SetString(
293 "setupErrorFindingPhone", 298 "setupErrorFindingPhone",
294 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_ERROR_FINDING_PHONE)); 299 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_ERROR_FINDING_PHONE));
295 strings->SetString( 300 strings->SetString(
296 "setupErrorBluetoothConnectionFailed", 301 "setupErrorBluetoothConnectionFailed",
297 l10n_util::GetStringFUTF16( 302 l10n_util::GetStringFUTF16(
298 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED, 303 IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED,
299 device_type)); 304 device_type));
305 // TODO(isherman): Remove the setupErrorConnectionToPhoneTimeout string; it is
306 // identical to the setupErrorConnectingToPhone string, and hence obsolete.
300 strings->SetString( 307 strings->SetString(
301 "setupErrorConnectionToPhoneTimeout", 308 "setupErrorConnectionToPhoneTimeout",
302 l10n_util::GetStringFUTF16( 309 l10n_util::GetStringFUTF16(
303 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECT_TO_PHONE_TIMEOUT, 310 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECT_TO_PHONE_TIMEOUT,
304 device_type)); 311 device_type));
305 strings->SetString( 312 strings->SetString(
306 "setupErrorSyncPhoneState", 313 "setupErrorSyncPhoneState",
307 l10n_util::GetStringUTF16( 314 l10n_util::GetStringUTF16(
308 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); 315 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED));
309 strings->SetString( 316 strings->SetString(
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( 753 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo(
747 const device::BluetoothDevice::ConnectionInfo& connection_info) { 754 const device::BluetoothDevice::ConnectionInfo& connection_info) {
748 scoped_ptr<base::ListValue> results(new base::ListValue()); 755 scoped_ptr<base::ListValue> results(new base::ListValue());
749 results->AppendInteger(connection_info.rssi); 756 results->AppendInteger(connection_info.rssi);
750 results->AppendInteger(connection_info.transmit_power); 757 results->AppendInteger(connection_info.transmit_power);
751 results->AppendInteger(connection_info.max_transmit_power); 758 results->AppendInteger(connection_info.max_transmit_power);
752 SetResultList(results.Pass()); 759 SetResultList(results.Pass());
753 SendResponse(true); 760 SendResponse(true);
754 } 761 }
755 762
763 EasyUnlockPrivateShowErrorBubbleFunction::
764 EasyUnlockPrivateShowErrorBubbleFunction() {
765 }
766
767 EasyUnlockPrivateShowErrorBubbleFunction::
768 ~EasyUnlockPrivateShowErrorBubbleFunction() {
769 }
770
771 bool EasyUnlockPrivateShowErrorBubbleFunction::RunSync() {
772 content::WebContents* web_contents = GetAssociatedWebContents();
773 if (!web_contents) {
774 SetError("A foreground app window is required.");
775 return true;
776 }
777
778 scoped_ptr<easy_unlock_private::ShowErrorBubble::Params> params(
779 easy_unlock_private::ShowErrorBubble::Params::Create(*args_));
780 EXTENSION_FUNCTION_VALIDATE(params.get());
781
782 if (params->link_range.start < 0 ||
783 params->link_range.end < 0 ||
784 base::checked_cast<size_t>(params->link_range.end) >
785 params->message.size()) {
786 SetError("Invalid link range.");
787 return true;
788 }
789
790 #if defined(OS_CHROMEOS)
791 gfx::Rect anchor_rect(
792 params->anchor_rect.left, params->anchor_rect.top,
793 params->anchor_rect.width, params->anchor_rect.height);
794 anchor_rect +=
795 web_contents->GetContainerBounds().OffsetFromOrigin();
796 ProximityAuthErrorBubble::ShowErrorBubble(
797 base::UTF8ToUTF16(params->message),
798 gfx::Range(params->link_range.start, params->link_range.end),
799 GURL(params->link_target), anchor_rect, web_contents);
800 #else
801 SetError("Not supported on non-ChromeOS platforms.");
802 #endif
803 return true;
804 }
805
756 } // namespace api 806 } // namespace api
757 } // namespace extensions 807 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698