| OLD | NEW |
| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 35 #include "chrome/browser/chromeos/chromeos_utils.h" | 35 #include "chrome/browser/chromeos/chromeos_utils.h" |
| 36 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" | 36 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" |
| 37 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" | 37 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" |
| 38 #include "components/user_manager/user.h" | 38 #include "components/user_manager/user.h" |
| 39 #include "components/user_manager/user_manager.h" | 39 #include "components/user_manager/user_manager.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 namespace extensions { | 42 namespace extensions { |
| 43 namespace api { | 43 |
| 44 namespace easy_unlock_private = api::easy_unlock_private; |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 static base::LazyInstance<BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI> > | 48 static base::LazyInstance<BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI> > |
| 48 g_factory = LAZY_INSTANCE_INITIALIZER; | 49 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 49 | 50 |
| 50 // Utility method for getting the API's crypto delegate. | 51 // Utility method for getting the API's crypto delegate. |
| 51 EasyUnlockPrivateCryptoDelegate* GetCryptoDelegate( | 52 EasyUnlockPrivateCryptoDelegate* GetCryptoDelegate( |
| 52 content::BrowserContext* context) { | 53 content::BrowserContext* context) { |
| 53 return BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>::Get(context) | 54 return BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>::Get(context) |
| 54 ->crypto_delegate(); | 55 ->GetCryptoDelegate(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 EasyUnlockScreenlockStateHandler::State ToScreenlockStateHandlerState( | 58 EasyUnlockScreenlockStateHandler::State ToScreenlockStateHandlerState( |
| 58 easy_unlock_private::State state) { | 59 easy_unlock_private::State state) { |
| 59 switch (state) { | 60 switch (state) { |
| 60 case easy_unlock_private::STATE_NO_BLUETOOTH: | 61 case easy_unlock_private::STATE_NO_BLUETOOTH: |
| 61 return EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH; | 62 return EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH; |
| 62 case easy_unlock_private::STATE_BLUETOOTH_CONNECTING: | 63 case easy_unlock_private::STATE_BLUETOOTH_CONNECTING: |
| 63 return EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING; | 64 return EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING; |
| 64 case easy_unlock_private::STATE_NO_PHONE: | 65 case easy_unlock_private::STATE_NO_PHONE: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace | 89 } // namespace |
| 89 | 90 |
| 90 // static | 91 // static |
| 91 BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>* | 92 BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>* |
| 92 EasyUnlockPrivateAPI::GetFactoryInstance() { | 93 EasyUnlockPrivateAPI::GetFactoryInstance() { |
| 93 return g_factory.Pointer(); | 94 return g_factory.Pointer(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 EasyUnlockPrivateAPI::EasyUnlockPrivateAPI(content::BrowserContext* context) | 97 EasyUnlockPrivateAPI::EasyUnlockPrivateAPI(content::BrowserContext* context) { |
| 97 : crypto_delegate_(EasyUnlockPrivateCryptoDelegate::Create()) { | |
| 98 } | 98 } |
| 99 | 99 |
| 100 EasyUnlockPrivateAPI::~EasyUnlockPrivateAPI() {} | 100 EasyUnlockPrivateAPI::~EasyUnlockPrivateAPI() {} |
| 101 | 101 |
| 102 EasyUnlockPrivateCryptoDelegate* EasyUnlockPrivateAPI::GetCryptoDelegate() { |
| 103 if (!crypto_delegate_) |
| 104 crypto_delegate_ = EasyUnlockPrivateCryptoDelegate::Create(); |
| 105 return crypto_delegate_.get(); |
| 106 } |
| 107 |
| 102 EasyUnlockPrivateGetStringsFunction::EasyUnlockPrivateGetStringsFunction() { | 108 EasyUnlockPrivateGetStringsFunction::EasyUnlockPrivateGetStringsFunction() { |
| 103 } | 109 } |
| 104 EasyUnlockPrivateGetStringsFunction::~EasyUnlockPrivateGetStringsFunction() { | 110 EasyUnlockPrivateGetStringsFunction::~EasyUnlockPrivateGetStringsFunction() { |
| 105 } | 111 } |
| 106 | 112 |
| 107 bool EasyUnlockPrivateGetStringsFunction::RunSync() { | 113 bool EasyUnlockPrivateGetStringsFunction::RunSync() { |
| 108 scoped_ptr<base::DictionaryValue> strings(new base::DictionaryValue); | 114 scoped_ptr<base::DictionaryValue> strings(new base::DictionaryValue); |
| 109 | 115 |
| 110 #if defined(OS_CHROMEOS) | 116 #if defined(OS_CHROMEOS) |
| 111 const base::string16 device_type = chromeos::GetChromeDeviceType(); | 117 const base::string16 device_type = chromeos::GetChromeDeviceType(); |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 if (params->result.error_message) | 834 if (params->result.error_message) |
| 829 error_message = *params->result.error_message; | 835 error_message = *params->result.error_message; |
| 830 | 836 |
| 831 Profile* profile = Profile::FromBrowserContext(browser_context()); | 837 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 832 EasyUnlockService::Get(profile) | 838 EasyUnlockService::Get(profile) |
| 833 ->SetAutoPairingResult(params->result.success, error_message); | 839 ->SetAutoPairingResult(params->result.success, error_message); |
| 834 | 840 |
| 835 return true; | 841 return true; |
| 836 } | 842 } |
| 837 | 843 |
| 838 } // namespace api | |
| 839 } // namespace extensions | 844 } // namespace extensions |
| OLD | NEW |