Index: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
diff --git a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
index 3a5175e868c463d8340b8f8882864a264360a529..fb7c4aad2a5475bd9d42e95df07e08bf2cc3470c 100644 |
--- a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
+++ b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc |
@@ -9,6 +9,7 @@ |
#include "base/bind.h" |
#include "base/lazy_instance.h" |
#include "base/memory/linked_ptr.h" |
+#include "base/numerics/safe_conversions.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/values.h" |
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h" |
@@ -20,13 +21,17 @@ |
#include "chrome/grit/generated_resources.h" |
#include "components/proximity_auth/bluetooth_util.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/web_contents.h" |
#include "extensions/browser/browser_context_keyed_api_factory.h" |
#include "ui/base/l10n/l10n_util.h" |
+#include "ui/gfx/geometry/rect.h" |
+#include "ui/gfx/range/range.h" |
#if defined(OS_CHROMEOS) |
#include "chrome/browser/chromeos/chromeos_utils.h" |
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.h" |
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.h" |
+#include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" |
#include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" |
#include "components/user_manager/user.h" |
#include "components/user_manager/user_manager.h" |
@@ -297,6 +302,8 @@ bool EasyUnlockPrivateGetStringsFunction::RunSync() { |
l10n_util::GetStringFUTF16( |
IDS_EASY_UNLOCK_SETUP_ERROR_BLUETOOTH_CONNECTION_FAILED, |
device_type)); |
+ // TODO(isherman): Remove the setupErrorConnectionToPhoneTimeout string; it is |
+ // identical to the setupErrorConnectingToPhone string, and hence obsolete. |
strings->SetString( |
"setupErrorConnectionToPhoneTimeout", |
l10n_util::GetStringFUTF16( |
@@ -753,5 +760,48 @@ void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( |
SendResponse(true); |
} |
+EasyUnlockPrivateShowErrorBubbleFunction:: |
+ EasyUnlockPrivateShowErrorBubbleFunction() { |
+} |
+ |
+EasyUnlockPrivateShowErrorBubbleFunction:: |
+ ~EasyUnlockPrivateShowErrorBubbleFunction() { |
+} |
+ |
+bool EasyUnlockPrivateShowErrorBubbleFunction::RunSync() { |
+ content::WebContents* web_contents = GetAssociatedWebContents(); |
+ if (!web_contents) { |
+ SetError("A foreground app window is required."); |
+ return true; |
+ } |
+ |
+ scoped_ptr<easy_unlock_private::ShowErrorBubble::Params> params( |
+ easy_unlock_private::ShowErrorBubble::Params::Create(*args_)); |
+ EXTENSION_FUNCTION_VALIDATE(params.get()); |
+ |
+ if (params->link_range.start < 0 || |
+ params->link_range.end < 0 || |
+ base::checked_cast<size_t>(params->link_range.end) > |
+ params->message.size()) { |
+ SetError("Invalid link range."); |
+ return true; |
+ } |
+ |
+#if defined(OS_CHROMEOS) |
+ gfx::Rect anchor_rect( |
+ params->anchor_rect.left, params->anchor_rect.top, |
+ params->anchor_rect.width, params->anchor_rect.height); |
+ anchor_rect += |
+ web_contents->GetContainerBounds().OffsetFromOrigin(); |
+ ProximityAuthErrorBubble::ShowErrorBubble( |
+ base::UTF8ToUTF16(params->message), |
+ gfx::Range(params->link_range.start, params->link_range.end), |
+ GURL(params->link_target), anchor_rect, web_contents); |
+#else |
+ SetError("Not supported on non-ChromeOS platforms."); |
+#endif |
+ return true; |
+} |
+ |
} // namespace api |
} // namespace extensions |