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

Unified Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 576343002: [Easy signin] Add method to get user info to easyUnlockPrivate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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/signin/easy_unlock_service.cc
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc
index 68ffa44cb8aafd74bbf6292ebc5828aa37da6478..109f895ecd136be27693b77e26c186cc82d5ab37 100644
--- a/chrome/browser/signin/easy_unlock_service.cc
+++ b/chrome/browser/signin/easy_unlock_service.cc
@@ -18,11 +18,13 @@
#include "chrome/browser/signin/easy_unlock_service_observer.h"
#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/api/easy_unlock_private.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
+#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/one_shot_event.h"
@@ -231,13 +233,15 @@ void EasyUnlockService::LoadApp() {
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
extension_service->EnableExtension(extension_misc::kEasyUnlockAppId);
+
+ NotifyUserUpdated();
}
#endif // defined(GOOGLE_CHROME_BUILD)
}
void EasyUnlockService::DisableAppIfLoaded() {
// Make sure lock screen state set by the extension gets reset.
- screenlock_state_handler_.reset();
+ ResetScreenlockStateHandler();
extensions::ComponentLoader* loader = GetComponentLoader(profile_);
if (!loader->Exists(extension_misc::kEasyUnlockAppId))
@@ -249,16 +253,21 @@ void EasyUnlockService::DisableAppIfLoaded() {
extensions::Extension::DISABLE_RELOAD);
}
+void EasyUnlockService::UnloadApp() {
+ GetComponentLoader(profile_)->Remove(extension_misc::kEasyUnlockAppId);
+}
+
void EasyUnlockService::ReloadApp() {
// Make sure lock screen state set by the extension gets reset.
- screenlock_state_handler_.reset();
+ ResetScreenlockStateHandler();
- if (GetComponentLoader(profile_)->Exists(extension_misc::kEasyUnlockAppId)) {
- extensions::ExtensionSystem* extension_system =
- extensions::ExtensionSystem::Get(profile_);
- extension_system->extension_service()->ReloadExtension(
- extension_misc::kEasyUnlockAppId);
- }
+ if (!GetComponentLoader(profile_)->Exists(extension_misc::kEasyUnlockAppId))
+ return;
+ extensions::ExtensionSystem* extension_system =
+ extensions::ExtensionSystem::Get(profile_);
+ extension_system->extension_service()->ReloadExtension(
+ extension_misc::kEasyUnlockAppId);
+ NotifyUserUpdated();
}
void EasyUnlockService::UpdateAppState() {
@@ -277,11 +286,37 @@ void EasyUnlockService::UpdateAppState() {
}
}
+void EasyUnlockService::NotifyUserUpdated() {
+ std::string user_id = GetUserEmail();
+ if (user_id.empty())
+ return;
+
+ // Notify the easy unlock app that the user info changed.
+ extensions::api::easy_unlock_private::UserInfo info;
+ info.user_id = user_id;
+ info.logged_in = GetType() == TYPE_REGULAR;
+ info.data_ready = GetRemoteDevices();
+
+ scoped_ptr<base::ListValue> args(new base::ListValue());
+ args->Append(info.ToValue().release());
+
+ scoped_ptr<extensions::Event> event(new extensions::Event(
+ extensions::api::easy_unlock_private::OnUserInfoUpdated::kEventName,
+ args.Pass()));
+
+ extensions::EventRouter::Get(profile_)->DispatchEventToExtension(
+ extension_misc::kEasyUnlockAppId, event.Pass());
+}
+
void EasyUnlockService::NotifyTurnOffOperationStatusChanged() {
FOR_EACH_OBSERVER(
EasyUnlockServiceObserver, observers_, OnTurnOffOperationStatusChanged());
}
+void EasyUnlockService::ResetScreenlockStateHandler() {
+ screenlock_state_handler_.reset();
+}
+
void EasyUnlockService::Initialize() {
InitializeInternal();

Powered by Google App Engine
This is Rietveld 408576698