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

Unified Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc

Issue 475483003: Wire easy unlock settings UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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 a7f1ce612bd5baa88d9da56f050c474165e529de..67fa839fe022953dce8a3ddafcf573199b8611a1 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
@@ -10,8 +10,11 @@
#include "base/values.h"
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util.h"
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/easy_unlock_service.h"
#include "chrome/common/extensions/api/easy_unlock_private.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
+#include "extensions/browser/event_router.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -43,11 +46,22 @@ BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>*
}
EasyUnlockPrivateAPI::EasyUnlockPrivateAPI(content::BrowserContext* context)
- : crypto_delegate_(EasyUnlockPrivateCryptoDelegate::Create()) {
+ : browser_context_(context),
+ crypto_delegate_(EasyUnlockPrivateCryptoDelegate::Create()) {
}
EasyUnlockPrivateAPI::~EasyUnlockPrivateAPI() {}
+void EasyUnlockPrivateAPI::SendTurnOffFlowFinished() {
+ using easy_unlock_private::OnTurnOffFlowFinished::kEventName;
+ EventRouter* router = EventRouter::Get(browser_context_);
+ if (!router || !router->HasEventListener(kEventName))
+ return;
+ scoped_ptr<base::ListValue> args(new base::ListValue());
+ scoped_ptr<Event> event(new Event(kEventName, args.Pass()));
+ router->BroadcastEvent(event.Pass());
+}
+
EasyUnlockPrivateGetStringsFunction::EasyUnlockPrivateGetStringsFunction() {
}
EasyUnlockPrivateGetStringsFunction::~EasyUnlockPrivateGetStringsFunction() {
@@ -368,5 +382,103 @@ void EasyUnlockPrivateSeekBluetoothDeviceByAddressFunction::OnSeekCompleted(
}
}
+EasyUnlockPrivateSetPermitAccessFunction::
+ EasyUnlockPrivateSetPermitAccessFunction() {
+}
+
+EasyUnlockPrivateSetPermitAccessFunction::
+ ~EasyUnlockPrivateSetPermitAccessFunction() {
+}
+
+bool EasyUnlockPrivateSetPermitAccessFunction::RunSync() {
+ scoped_ptr<easy_unlock_private::SetPermitAccess::Params> params(
+ easy_unlock_private::SetPermitAccess::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ Profile* profile = Profile::FromBrowserContext(browser_context());
+ EasyUnlockService::Get(profile)
+ ->SetPermitAccess(*params->permit_access.ToValue());
+
+ return true;
+}
+
+EasyUnlockPrivateGetPermitAccessFunction::
+ EasyUnlockPrivateGetPermitAccessFunction() {
+}
+
+EasyUnlockPrivateGetPermitAccessFunction::
+ ~EasyUnlockPrivateGetPermitAccessFunction() {
+}
+
+bool EasyUnlockPrivateGetPermitAccessFunction::RunSync() {
+ Profile* profile = Profile::FromBrowserContext(browser_context());
+ const base::DictionaryValue* permit_value =
+ EasyUnlockService::Get(profile)->GetPermitAccess();
+ if (permit_value) {
+ scoped_ptr<easy_unlock_private::PermitRecord> permit =
+ easy_unlock_private::PermitRecord::FromValue(*permit_value);
+ results_ = easy_unlock_private::GetPermitAccess::Results::Create(*permit);
+ }
+
+ return true;
+}
+
+EasyUnlockPrivateClearPermitAccessFunction::
+ EasyUnlockPrivateClearPermitAccessFunction() {
+}
+
+EasyUnlockPrivateClearPermitAccessFunction::
+ ~EasyUnlockPrivateClearPermitAccessFunction() {
+}
+
+bool EasyUnlockPrivateClearPermitAccessFunction::RunSync() {
+ Profile* profile = Profile::FromBrowserContext(browser_context());
+ EasyUnlockService::Get(profile)->ClearPermitAccess();
+ return true;
+}
+
+EasyUnlockPrivateSetRemoteDevicesFunction::
+ EasyUnlockPrivateSetRemoteDevicesFunction() {
+}
+
+EasyUnlockPrivateSetRemoteDevicesFunction::
+ ~EasyUnlockPrivateSetRemoteDevicesFunction() {
+}
+
+bool EasyUnlockPrivateSetRemoteDevicesFunction::RunSync() {
+ scoped_ptr<easy_unlock_private::SetRemoteDevices::Params> params(
+ easy_unlock_private::SetRemoteDevices::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ Profile* profile = Profile::FromBrowserContext(browser_context());
+ if (params->devices.empty()) {
+ EasyUnlockService::Get(profile)->ClearRemoteDevices();
+ } else {
+ base::ListValue devices;
+ for (size_t i = 0; i < params->devices.size(); ++i) {
+ devices.Append(params->devices[i]->ToValue().release());
+ }
+ EasyUnlockService::Get(profile)->SetRemoteDevices(devices);
+ }
+
+ return true;
+}
+
+EasyUnlockPrivateGetRemoteDevicesFunction::
+ EasyUnlockPrivateGetRemoteDevicesFunction() {
+}
+
+EasyUnlockPrivateGetRemoteDevicesFunction::
+ ~EasyUnlockPrivateGetRemoteDevicesFunction() {
+}
+
+bool EasyUnlockPrivateGetRemoteDevicesFunction::RunSync() {
+ Profile* profile = Profile::FromBrowserContext(browser_context());
+ const base::ListValue* devices =
+ EasyUnlockService::Get(profile)->GetRemoteDevices();
+ SetResult(devices ? devices->DeepCopy() : new base::ListValue());
+ return true;
+}
+
} // namespace api
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698