| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/signin/easy_unlock_app_manager.h" | 5 #include "chrome/browser/signin/easy_unlock_app_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "chrome/browser/extensions/component_loader.h" | 9 #include "chrome/browser/extensions/component_loader.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/ui/extensions/application_launch.h" | 11 #include "chrome/browser/ui/extensions/application_launch.h" |
| 12 #include "chrome/common/extensions/api/easy_unlock_private.h" | 12 #include "chrome/common/extensions/api/easy_unlock_private.h" |
| 13 #include "chrome/common/extensions/api/screenlock_private.h" | 13 #include "chrome/common/extensions/api/screenlock_private.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "components/proximity_auth/switches.h" | 15 #include "components/proximity_auth/switches.h" |
| 16 #include "components/user_manager/user_id.h" |
| 16 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 17 #include "extensions/browser/extension_system.h" | 18 #include "extensions/browser/extension_system.h" |
| 18 #include "extensions/common/one_shot_event.h" | 19 #include "extensions/common/one_shot_event.h" |
| 19 | 20 |
| 20 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 21 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 class EasyUnlockAppManagerImpl : public EasyUnlockAppManager { | 27 class EasyUnlockAppManagerImpl : public EasyUnlockAppManager { |
| 27 public: | 28 public: |
| 28 EasyUnlockAppManagerImpl(extensions::ExtensionSystem* extension_system, | 29 EasyUnlockAppManagerImpl(extensions::ExtensionSystem* extension_system, |
| 29 int manifest_id, | 30 int manifest_id, |
| 30 const base::FilePath& app_path); | 31 const base::FilePath& app_path); |
| 31 ~EasyUnlockAppManagerImpl() override; | 32 ~EasyUnlockAppManagerImpl() override; |
| 32 | 33 |
| 33 // EasyUnlockAppManager overrides. | 34 // EasyUnlockAppManager overrides. |
| 34 void EnsureReady(const base::Closure& ready_callback) override; | 35 void EnsureReady(const base::Closure& ready_callback) override; |
| 35 void LaunchSetup() override; | 36 void LaunchSetup() override; |
| 36 void LoadApp() override; | 37 void LoadApp() override; |
| 37 void DisableAppIfLoaded() override; | 38 void DisableAppIfLoaded() override; |
| 38 void ReloadApp() override; | 39 void ReloadApp() override; |
| 39 bool SendUserUpdatedEvent(const std::string& user_id, | 40 bool SendUserUpdatedEvent(const user_manager::UserID& user_id, |
| 40 bool is_logged_in, | 41 bool is_logged_in, |
| 41 bool data_ready) override; | 42 bool data_ready) override; |
| 42 bool SendAuthAttemptEvent() override; | 43 bool SendAuthAttemptEvent() override; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 extensions::ExtensionSystem* extension_system_; | 46 extensions::ExtensionSystem* extension_system_; |
| 46 | 47 |
| 47 // The Easy Unlock app id. | 48 // The Easy Unlock app id. |
| 48 std::string app_id_; | 49 std::string app_id_; |
| 49 int manifest_id_; | 50 int manifest_id_; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ExtensionService* extension_service = extension_system_->extension_service(); | 129 ExtensionService* extension_service = extension_system_->extension_service(); |
| 129 if (!extension_service) | 130 if (!extension_service) |
| 130 return; | 131 return; |
| 131 | 132 |
| 132 if (!extension_service->component_loader()->Exists(app_id_)) | 133 if (!extension_service->component_loader()->Exists(app_id_)) |
| 133 return; | 134 return; |
| 134 | 135 |
| 135 extension_service->ReloadExtension(app_id_); | 136 extension_service->ReloadExtension(app_id_); |
| 136 } | 137 } |
| 137 | 138 |
| 138 bool EasyUnlockAppManagerImpl::SendUserUpdatedEvent(const std::string& user_id, | 139 bool EasyUnlockAppManagerImpl::SendUserUpdatedEvent(const user_manager::UserID&
user_id, |
| 139 bool is_logged_in, | 140 bool is_logged_in, |
| 140 bool data_ready) { | 141 bool data_ready) { |
| 141 extensions::EventRouter* event_router = extension_system_->event_router(); | 142 extensions::EventRouter* event_router = extension_system_->event_router(); |
| 142 if (!event_router) | 143 if (!event_router) |
| 143 return false; | 144 return false; |
| 144 | 145 |
| 145 std::string event_name = | 146 std::string event_name = |
| 146 extensions::api::easy_unlock_private::OnUserInfoUpdated::kEventName; | 147 extensions::api::easy_unlock_private::OnUserInfoUpdated::kEventName; |
| 147 | 148 |
| 148 if (!event_router->ExtensionHasEventListener(app_id_, event_name)) | 149 if (!event_router->ExtensionHasEventListener(app_id_, event_name)) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 194 } |
| 194 | 195 |
| 195 // static | 196 // static |
| 196 scoped_ptr<EasyUnlockAppManager> EasyUnlockAppManager::Create( | 197 scoped_ptr<EasyUnlockAppManager> EasyUnlockAppManager::Create( |
| 197 extensions::ExtensionSystem* extension_system, | 198 extensions::ExtensionSystem* extension_system, |
| 198 int manifest_id, | 199 int manifest_id, |
| 199 const base::FilePath& app_path) { | 200 const base::FilePath& app_path) { |
| 200 return scoped_ptr<EasyUnlockAppManager>( | 201 return scoped_ptr<EasyUnlockAppManager>( |
| 201 new EasyUnlockAppManagerImpl(extension_system, manifest_id, app_path)); | 202 new EasyUnlockAppManagerImpl(extension_system, manifest_id, app_path)); |
| 202 } | 203 } |
| OLD | NEW |