| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
crypto_delegate.h" | 14 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
crypto_delegate.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" | 16 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
| 17 #include "chrome/browser/signin/easy_unlock_service.h" | 17 #include "chrome/browser/signin/easy_unlock_service.h" |
| 18 #include "chrome/common/extensions/api/easy_unlock_private.h" | 18 #include "chrome/common/extensions/api/easy_unlock_private.h" |
| 19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 20 #include "components/proximity_auth/bluetooth_util.h" | 20 #include "components/proximity_auth/bluetooth_util.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "extensions/browser/browser_context_keyed_api_factory.h" | 22 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 | 24 |
| 25 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/chromeos/chromeos_utils.h" | 26 #include "chrome/browser/chromeos/chromeos_utils.h" |
| 27 #include "components/user_manager/user.h" |
| 28 #include "components/user_manager/user_manager.h" |
| 27 #endif | 29 #endif |
| 28 | 30 |
| 29 namespace extensions { | 31 namespace extensions { |
| 30 namespace api { | 32 namespace api { |
| 31 | 33 |
| 32 namespace { | 34 namespace { |
| 33 | 35 |
| 34 static base::LazyInstance<BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI> > | 36 static base::LazyInstance<BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI> > |
| 35 g_factory = LAZY_INSTANCE_INITIALIZER; | 37 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 36 | 38 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 bool EasyUnlockPrivateGetStringsFunction::RunSync() { | 97 bool EasyUnlockPrivateGetStringsFunction::RunSync() { |
| 96 scoped_ptr<base::DictionaryValue> strings(new base::DictionaryValue); | 98 scoped_ptr<base::DictionaryValue> strings(new base::DictionaryValue); |
| 97 | 99 |
| 98 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
| 99 const base::string16 device_type = chromeos::GetChromeDeviceType(); | 101 const base::string16 device_type = chromeos::GetChromeDeviceType(); |
| 100 #else | 102 #else |
| 101 // TODO(isherman): Set an appropriate device name for non-ChromeOS devices. | 103 // TODO(isherman): Set an appropriate device name for non-ChromeOS devices. |
| 102 const base::string16 device_type = base::ASCIIToUTF16("Chromeschnozzle"); | 104 const base::string16 device_type = base::ASCIIToUTF16("Chromeschnozzle"); |
| 103 #endif // defined(OS_CHROMEOS) | 105 #endif // defined(OS_CHROMEOS) |
| 104 | 106 |
| 107 #if defined(OS_CHROMEOS) |
| 108 const user_manager::UserManager* manager = user_manager::UserManager::Get(); |
| 109 const user_manager::User* user = manager ? manager->GetActiveUser() : NULL; |
| 110 const std::string user_email_utf8 = |
| 111 user ? user->display_email() : std::string(); |
| 112 const base::string16 user_email = base::UTF8ToUTF16(user_email_utf8); |
| 113 #else |
| 114 // TODO(isherman): Set an appropriate user display email for non-ChromeOS |
| 115 // platforms. |
| 116 const base::string16 user_email = base::UTF8ToUTF16("superman@example.com"); |
| 117 #endif // defined(OS_CHROMEOS) |
| 118 |
| 105 // Common strings. | 119 // Common strings. |
| 106 strings->SetString( | 120 strings->SetString( |
| 107 "learnMoreLinkTitle", | 121 "learnMoreLinkTitle", |
| 108 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_LEARN_MORE_LINK_TITLE)); | 122 l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_LEARN_MORE_LINK_TITLE)); |
| 109 | 123 |
| 110 // Setup notification strings. | 124 // Setup notification strings. |
| 111 strings->SetString( | 125 strings->SetString( |
| 112 "setupNotificationTitle", | 126 "setupNotificationTitle", |
| 113 l10n_util::GetStringFUTF16(IDS_EASY_UNLOCK_SETUP_NOTIFICATION_TITLE, | 127 l10n_util::GetStringFUTF16(IDS_EASY_UNLOCK_SETUP_NOTIFICATION_TITLE, |
| 114 device_type)); | 128 device_type)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 142 device_type)); | 156 device_type)); |
| 143 | 157 |
| 144 // Setup dialog strings. | 158 // Setup dialog strings. |
| 145 // Step 1: Intro. | 159 // Step 1: Intro. |
| 146 strings->SetString( | 160 strings->SetString( |
| 147 "setupIntroHeaderTitle", | 161 "setupIntroHeaderTitle", |
| 148 l10n_util::GetStringFUTF16( | 162 l10n_util::GetStringFUTF16( |
| 149 IDS_EASY_UNLOCK_SETUP_INTRO_HEADER_TITLE, device_type)); | 163 IDS_EASY_UNLOCK_SETUP_INTRO_HEADER_TITLE, device_type)); |
| 150 strings->SetString( | 164 strings->SetString( |
| 151 "setupIntroHeaderText", | 165 "setupIntroHeaderText", |
| 152 l10n_util::GetStringFUTF16( | 166 l10n_util::GetStringFUTF16(IDS_EASY_UNLOCK_SETUP_INTRO_HEADER_TEXT, |
| 153 IDS_EASY_UNLOCK_SETUP_INTRO_HEADER_TEXT, device_type)); | 167 device_type, |
| 154 strings->SetString( | 168 user_email)); |
| 155 "setupIntroHeaderFootnote", | |
| 156 l10n_util::GetStringUTF16( | |
| 157 IDS_EASY_UNLOCK_SETUP_INTRO_HEADER_FOOTNOTE)); | |
| 158 strings->SetString( | 169 strings->SetString( |
| 159 "setupIntroFindPhoneButtonLabel", | 170 "setupIntroFindPhoneButtonLabel", |
| 160 l10n_util::GetStringUTF16( | 171 l10n_util::GetStringUTF16( |
| 161 IDS_EASY_UNLOCK_SETUP_INTRO_FIND_PHONE_BUTTON_LABEL)); | 172 IDS_EASY_UNLOCK_SETUP_INTRO_FIND_PHONE_BUTTON_LABEL)); |
| 162 strings->SetString( | 173 strings->SetString( |
| 163 "setupIntroFindingPhoneButtonLabel", | 174 "setupIntroFindingPhoneButtonLabel", |
| 164 l10n_util::GetStringUTF16( | 175 l10n_util::GetStringUTF16( |
| 165 IDS_EASY_UNLOCK_SETUP_INTRO_FINDING_PHONE_BUTTON_LABEL)); | 176 IDS_EASY_UNLOCK_SETUP_INTRO_FINDING_PHONE_BUTTON_LABEL)); |
| 166 strings->SetString( | 177 strings->SetString( |
| 167 "setupIntroRetryFindPhoneButtonLabel", | 178 "setupIntroRetryFindPhoneButtonLabel", |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 device_type)); | 241 device_type)); |
| 231 strings->SetString( | 242 strings->SetString( |
| 232 "setupErrorSyncPhoneState", | 243 "setupErrorSyncPhoneState", |
| 233 l10n_util::GetStringUTF16( | 244 l10n_util::GetStringUTF16( |
| 234 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); | 245 IDS_EASY_UNLOCK_SETUP_ERROR_SYNC_PHONE_STATE_FAILED)); |
| 235 strings->SetString( | 246 strings->SetString( |
| 236 "setupErrorConnectingToPhone", | 247 "setupErrorConnectingToPhone", |
| 237 l10n_util::GetStringFUTF16( | 248 l10n_util::GetStringFUTF16( |
| 238 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECTING_TO_PHONE, device_type)); | 249 IDS_EASY_UNLOCK_SETUP_ERROR_CONNECTING_TO_PHONE, device_type)); |
| 239 | 250 |
| 240 // TODO(isherman): Remove these strings once the app has been updated. | 251 // TODO(isherman): Remove this string once the app has been updated. |
| 241 strings->SetString( | 252 strings->SetString("setupIntroHeaderFootnote", base::string16()); |
| 242 "notificationTitle", | |
| 243 l10n_util::GetStringFUTF16(IDS_EASY_UNLOCK_SETUP_NOTIFICATION_TITLE, | |
| 244 device_type)); | |
| 245 strings->SetString( | |
| 246 "notificationMessage", | |
| 247 l10n_util::GetStringFUTF16(IDS_EASY_UNLOCK_SETUP_NOTIFICATION_MESSAGE, | |
| 248 device_type)); | |
| 249 strings->SetString( | |
| 250 "notificationButtonTitle", | |
| 251 l10n_util::GetStringUTF16( | |
| 252 IDS_EASY_UNLOCK_SETUP_NOTIFICATION_BUTTON_TITLE)); | |
| 253 | 253 |
| 254 SetResult(strings.release()); | 254 SetResult(strings.release()); |
| 255 return true; | 255 return true; |
| 256 } | 256 } |
| 257 | 257 |
| 258 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: | 258 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: |
| 259 EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} | 259 EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} |
| 260 | 260 |
| 261 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: | 261 EasyUnlockPrivatePerformECDHKeyAgreementFunction:: |
| 262 ~EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} | 262 ~EasyUnlockPrivatePerformECDHKeyAgreementFunction() {} |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 users[0]->user_id = user_id; | 587 users[0]->user_id = user_id; |
| 588 users[0]->logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; | 588 users[0]->logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; |
| 589 users[0]->data_ready = service->GetRemoteDevices() != NULL; | 589 users[0]->data_ready = service->GetRemoteDevices() != NULL; |
| 590 } | 590 } |
| 591 results_ = easy_unlock_private::GetUserInfo::Results::Create(users); | 591 results_ = easy_unlock_private::GetUserInfo::Results::Create(users); |
| 592 return true; | 592 return true; |
| 593 } | 593 } |
| 594 | 594 |
| 595 } // namespace api | 595 } // namespace api |
| 596 } // namespace extensions | 596 } // namespace extensions |
| OLD | NEW |