Commit 878a6bb6 authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

Extension API: Move easyUnlockPrivate API to be CrOS-only.

This is true in practice and is the next step in making SmartLock
CrOS-only.

Bug: 817115
Test: Existing tests
Change-Id: I38560b7d35859f65148a6a6cbbb9e4a66e7955a5
Reviewed-on: https://chromium-review.googlesource.com/940538Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539965}
parent afd88852
...@@ -2852,6 +2852,8 @@ jumbo_split_static_library("browser") { ...@@ -2852,6 +2852,8 @@ jumbo_split_static_library("browser") {
"notifications/web_page_notifier_controller.h", "notifications/web_page_notifier_controller.h",
"policy/default_geolocation_policy_handler.cc", "policy/default_geolocation_policy_handler.cc",
"policy/default_geolocation_policy_handler.h", "policy/default_geolocation_policy_handler.h",
"signin/easy_unlock_app_manager.cc",
"signin/easy_unlock_app_manager.h",
"signin/signin_error_notifier_ash.cc", "signin/signin_error_notifier_ash.cc",
"signin/signin_error_notifier_ash.h", "signin/signin_error_notifier_ash.h",
"signin/signin_error_notifier_factory_ash.cc", "signin/signin_error_notifier_factory_ash.cc",
...@@ -3478,8 +3480,6 @@ jumbo_split_static_library("browser") { ...@@ -3478,8 +3480,6 @@ jumbo_split_static_library("browser") {
"renderer_host/chrome_extension_message_filter.h", "renderer_host/chrome_extension_message_filter.h",
"signin/chrome_proximity_auth_client.cc", "signin/chrome_proximity_auth_client.cc",
"signin/chrome_proximity_auth_client.h", "signin/chrome_proximity_auth_client.h",
"signin/easy_unlock_app_manager.cc",
"signin/easy_unlock_app_manager.h",
"signin/easy_unlock_auth_attempt.cc", "signin/easy_unlock_auth_attempt.cc",
"signin/easy_unlock_auth_attempt.h", "signin/easy_unlock_auth_attempt.h",
"signin/easy_unlock_metrics.cc", "signin/easy_unlock_metrics.cc",
......
...@@ -171,14 +171,6 @@ static_library("extensions") { ...@@ -171,14 +171,6 @@ static_library("extensions") {
"api/downloads/downloads_api.h", "api/downloads/downloads_api.h",
"api/downloads_internal/downloads_internal_api.cc", "api/downloads_internal/downloads_internal_api.cc",
"api/downloads_internal/downloads_internal_api.h", "api/downloads_internal/downloads_internal_api.h",
"api/easy_unlock_private/easy_unlock_private_api.cc",
"api/easy_unlock_private/easy_unlock_private_api.h",
"api/easy_unlock_private/easy_unlock_private_connection.cc",
"api/easy_unlock_private/easy_unlock_private_connection.h",
"api/easy_unlock_private/easy_unlock_private_connection_manager.cc",
"api/easy_unlock_private/easy_unlock_private_connection_manager.h",
"api/easy_unlock_private/easy_unlock_private_crypto_delegate.h",
"api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc",
"api/extension_action/extension_action_api.cc", "api/extension_action/extension_action_api.cc",
"api/extension_action/extension_action_api.h", "api/extension_action/extension_action_api.h",
"api/extension_action/extension_page_actions_api_constants.cc", "api/extension_action/extension_page_actions_api_constants.cc",
...@@ -920,6 +912,14 @@ static_library("extensions") { ...@@ -920,6 +912,14 @@ static_library("extensions") {
sources += [ sources += [
"api/certificate_provider/certificate_provider_api.cc", "api/certificate_provider/certificate_provider_api.cc",
"api/certificate_provider/certificate_provider_api.h", "api/certificate_provider/certificate_provider_api.h",
"api/easy_unlock_private/easy_unlock_private_api.cc",
"api/easy_unlock_private/easy_unlock_private_api.h",
"api/easy_unlock_private/easy_unlock_private_connection.cc",
"api/easy_unlock_private/easy_unlock_private_connection.h",
"api/easy_unlock_private/easy_unlock_private_connection_manager.cc",
"api/easy_unlock_private/easy_unlock_private_connection_manager.h",
"api/easy_unlock_private/easy_unlock_private_crypto_delegate.h",
"api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc",
"api/enterprise_device_attributes/enterprise_device_attributes_api.cc", "api/enterprise_device_attributes/enterprise_device_attributes_api.cc",
"api/enterprise_device_attributes/enterprise_device_attributes_api.h", "api/enterprise_device_attributes/enterprise_device_attributes_api.h",
"api/enterprise_platform_keys/enterprise_platform_keys_api.cc", "api/enterprise_platform_keys/enterprise_platform_keys_api.cc",
......
...@@ -85,7 +85,9 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() { ...@@ -85,7 +85,9 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
extensions::CookiesAPI::GetFactoryInstance(); extensions::CookiesAPI::GetFactoryInstance();
extensions::DeveloperPrivateAPI::GetFactoryInstance(); extensions::DeveloperPrivateAPI::GetFactoryInstance();
extensions::DialAPIFactory::GetInstance(); extensions::DialAPIFactory::GetInstance();
#if defined(OS_CHROMEOS)
extensions::EasyUnlockPrivateAPI::GetFactoryInstance(); extensions::EasyUnlockPrivateAPI::GetFactoryInstance();
#endif
extensions::ExtensionActionAPI::GetFactoryInstance(); extensions::ExtensionActionAPI::GetFactoryInstance();
extensions::ExtensionGarbageCollectorFactory::GetInstance(); extensions::ExtensionGarbageCollectorFactory::GetInstance();
extensions::ExtensionStorageMonitorFactory::GetInstance(); extensions::ExtensionStorageMonitorFactory::GetInstance();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/location.h" #include "base/location.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/sys_info.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h" #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h"
#include "chrome/browser/extensions/component_loader.h" #include "chrome/browser/extensions/component_loader.h"
...@@ -23,10 +24,6 @@ ...@@ -23,10 +24,6 @@
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/common/one_shot_event.h" #include "extensions/common/one_shot_event.h"
#if defined(OS_CHROMEOS)
#include "base/sys_info.h"
#endif
namespace { namespace {
class EasyUnlockAppManagerImpl : public EasyUnlockAppManager { class EasyUnlockAppManagerImpl : public EasyUnlockAppManager {
...@@ -101,14 +98,12 @@ void EasyUnlockAppManagerImpl::LoadApp() { ...@@ -101,14 +98,12 @@ void EasyUnlockAppManagerImpl::LoadApp() {
if (!extension_service) if (!extension_service)
return; return;
#if defined(OS_CHROMEOS)
// TODO(xiyuan): Remove this when the app is bundled with chrome. // TODO(xiyuan): Remove this when the app is bundled with chrome.
if (!base::SysInfo::IsRunningOnChromeOS() && if (!base::SysInfo::IsRunningOnChromeOS() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch( !base::CommandLine::ForCurrentProcess()->HasSwitch(
proximity_auth::switches::kForceLoadEasyUnlockAppInTests)) { proximity_auth::switches::kForceLoadEasyUnlockAppInTests)) {
return; return;
} }
#endif
if (app_path_.empty()) if (app_path_.empty())
return; return;
...@@ -184,15 +179,11 @@ bool EasyUnlockAppManagerImpl::SendAuthAttemptEvent() { ...@@ -184,15 +179,11 @@ bool EasyUnlockAppManagerImpl::SendAuthAttemptEvent() {
return false; return false;
// TODO(tbarzic): Restrict this to EasyUnlock app. // TODO(tbarzic): Restrict this to EasyUnlock app.
#if defined(OS_CHROMEOS)
extensions::ScreenlockPrivateEventRouter* screenlock_router = extensions::ScreenlockPrivateEventRouter* screenlock_router =
extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
extension_service->profile()); extension_service->profile());
return screenlock_router->OnAuthAttempted( return screenlock_router->OnAuthAttempted(
proximity_auth::mojom::AuthType::USER_CLICK, std::string()); proximity_auth::mojom::AuthType::USER_CLICK, std::string());
#else
return false;
#endif // defined(OS_CHROMEOS)
} }
} // namespace } // namespace
......
...@@ -9,27 +9,22 @@ ...@@ -9,27 +9,22 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
#include "chrome/browser/signin/easy_unlock_app_manager.h" #include "chrome/browser/signin/easy_unlock_app_manager.h"
#include "components/proximity_auth/screenlock_bridge.h" #include "components/proximity_auth/screenlock_bridge.h"
#include "components/proximity_auth/switches.h" #include "components/proximity_auth/switches.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
#endif
namespace { namespace {
// Fake user ids used in tests. // Fake user ids used in tests.
const char kTestUser1[] = "user1"; const char kTestUser1[] = "user1";
const char kTestUser2[] = "user2"; const char kTestUser2[] = "user2";
#if defined(OS_CHROMEOS)
const unsigned char kSecret[] = { const unsigned char kSecret[] = {
0x7c, 0x85, 0x82, 0x7d, 0x00, 0x1f, 0x6a, 0x29, 0x2f, 0xc4, 0xb5, 0x60, 0x7c, 0x85, 0x82, 0x7d, 0x00, 0x1f, 0x6a, 0x29, 0x2f, 0xc4, 0xb5, 0x60,
0x08, 0x9b, 0xb0, 0x5b 0x08, 0x9b, 0xb0, 0x5b
}; };
#endif
const unsigned char kSessionKey[] = { const unsigned char kSessionKey[] = {
0xc3, 0xd9, 0x83, 0x16, 0x52, 0xde, 0x99, 0xd7, 0x4e, 0x60, 0xf9, 0xec, 0xc3, 0xd9, 0x83, 0x16, 0x52, 0xde, 0x99, 0xd7, 0x4e, 0x60, 0xf9, 0xec,
...@@ -42,12 +37,10 @@ const unsigned char kWrappedSecret[] = { ...@@ -42,12 +37,10 @@ const unsigned char kWrappedSecret[] = {
0xfc, 0x40, 0x1f, 0xeb, 0x75, 0x64, 0x52, 0xd8 0xfc, 0x40, 0x1f, 0xeb, 0x75, 0x64, 0x52, 0xd8
}; };
#if defined(OS_CHROMEOS)
std::string GetSecret() { std::string GetSecret() {
return std::string(reinterpret_cast<const char*>(kSecret), return std::string(reinterpret_cast<const char*>(kSecret),
arraysize(kSecret)); arraysize(kSecret));
} }
#endif
std::string GetWrappedSecret() { std::string GetWrappedSecret() {
return std::string(reinterpret_cast<const char*>(kWrappedSecret), return std::string(reinterpret_cast<const char*>(kWrappedSecret),
...@@ -186,7 +179,6 @@ class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler { ...@@ -186,7 +179,6 @@ class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler {
void AttemptEasySignin(const AccountId& account_id, void AttemptEasySignin(const AccountId& account_id,
const std::string& secret, const std::string& secret,
const std::string& key_label) override { const std::string& key_label) override {
#if defined(OS_CHROMEOS)
ASSERT_TRUE(account_id_ == account_id) ASSERT_TRUE(account_id_ == account_id)
<< "account_id_=" << account_id_.Serialize() << "account_id_=" << account_id_.Serialize()
<< " != " << account_id.Serialize(); << " != " << account_id.Serialize();
...@@ -199,9 +191,6 @@ class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler { ...@@ -199,9 +191,6 @@ class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler {
ASSERT_EQ(chromeos::EasyUnlockKeyManager::GetKeyLabel(0u), key_label); ASSERT_EQ(chromeos::EasyUnlockKeyManager::GetKeyLabel(0u), key_label);
state_ = STATE_SIGNIN_DONE; state_ = STATE_SIGNIN_DONE;
} }
#else // if !defined(OS_CHROMEOS)
ADD_FAILURE() << "Should not be reached.";
#endif
} }
private: private:
...@@ -372,7 +361,6 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeUnlockCalledForWrongUser) { ...@@ -372,7 +361,6 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeUnlockCalledForWrongUser) {
ASSERT_EQ(TestLockHandler::STATE_UNLOCK_DONE, lock_handler_->state()); ASSERT_EQ(TestLockHandler::STATE_UNLOCK_DONE, lock_handler_->state());
} }
#if defined(OS_CHROMEOS)
class EasyUnlockAuthAttemptSigninTest : public testing::Test { class EasyUnlockAuthAttemptSigninTest : public testing::Test {
public: public:
EasyUnlockAuthAttemptSigninTest() {} EasyUnlockAuthAttemptSigninTest() {}
...@@ -578,6 +566,5 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninCalledForWrongUser) { ...@@ -578,6 +566,5 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninCalledForWrongUser) {
EXPECT_EQ(TestLockHandler::STATE_SIGNIN_DONE, lock_handler_->state()); EXPECT_EQ(TestLockHandler::STATE_SIGNIN_DONE, lock_handler_->state());
} }
#endif // defined(OS_CHROMEOS)
} // namespace } // namespace
...@@ -108,8 +108,10 @@ KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( ...@@ -108,8 +108,10 @@ KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor(
? GetEasyUnlockAppPath() ? GetEasyUnlockAppPath()
: app_path_for_testing_; : app_path_for_testing_;
#if defined(OS_CHROMEOS)
service->Initialize(EasyUnlockAppManager::Create( service->Initialize(EasyUnlockAppManager::Create(
extensions::ExtensionSystem::Get(context), manifest_id, app_path)); extensions::ExtensionSystem::Get(context), manifest_id, app_path));
#endif
return service; return service;
} }
......
...@@ -469,6 +469,7 @@ void EasyUnlockServiceRegular::StartAutoPairing( ...@@ -469,6 +469,7 @@ void EasyUnlockServiceRegular::StartAutoPairing(
auto_pairing_callback_ = callback; auto_pairing_callback_ = callback;
#if defined(OS_CHROMEOS)
std::unique_ptr<base::ListValue> args(new base::ListValue()); std::unique_ptr<base::ListValue> args(new base::ListValue());
std::unique_ptr<extensions::Event> event(new extensions::Event( std::unique_ptr<extensions::Event> event(new extensions::Event(
extensions::events::EASY_UNLOCK_PRIVATE_ON_START_AUTO_PAIRING, extensions::events::EASY_UNLOCK_PRIVATE_ON_START_AUTO_PAIRING,
...@@ -476,6 +477,7 @@ void EasyUnlockServiceRegular::StartAutoPairing( ...@@ -476,6 +477,7 @@ void EasyUnlockServiceRegular::StartAutoPairing(
std::move(args))); std::move(args)));
extensions::EventRouter::Get(profile())->DispatchEventWithLazyListener( extensions::EventRouter::Get(profile())->DispatchEventWithLazyListener(
extension_misc::kEasyUnlockAppId, std::move(event)); extension_misc::kEasyUnlockAppId, std::move(event));
#endif
} }
void EasyUnlockServiceRegular::SetAutoPairingResult( void EasyUnlockServiceRegular::SetAutoPairingResult(
......
...@@ -39,7 +39,6 @@ schema_sources = [ ...@@ -39,7 +39,6 @@ schema_sources = [
"dial.idl", "dial.idl",
"downloads.idl", "downloads.idl",
"downloads_internal.idl", "downloads_internal.idl",
"easy_unlock_private.idl",
"font_settings.json", "font_settings.json",
"gcm.json", "gcm.json",
"history.json", "history.json",
...@@ -92,6 +91,7 @@ if (is_chromeos) { ...@@ -92,6 +91,7 @@ if (is_chromeos) {
schema_sources += [ schema_sources += [
"certificate_provider.idl", "certificate_provider.idl",
"certificate_provider_internal.idl", "certificate_provider_internal.idl",
"easy_unlock_private.idl",
"echo_private.json", "echo_private.json",
"enterprise_device_attributes.idl", "enterprise_device_attributes.idl",
"enterprise_platform_keys.idl", "enterprise_platform_keys.idl",
......
...@@ -267,7 +267,8 @@ ...@@ -267,7 +267,8 @@
"easyUnlockPrivate": { "easyUnlockPrivate": {
"channel": "stable", "channel": "stable",
"extension_types": ["platform_app"], "extension_types": ["platform_app"],
"location": "component" "location": "component",
"platforms": ["chromeos"]
}, },
"embeddedExtensionOptions": { "embeddedExtensionOptions": {
"channel": "trunk", "channel": "trunk",
......
...@@ -3129,6 +3129,8 @@ test("unit_tests") { ...@@ -3129,6 +3129,8 @@ test("unit_tests") {
"../browser/notifications/chrome_ash_message_center_client_unittest.cc", "../browser/notifications/chrome_ash_message_center_client_unittest.cc",
"../browser/renderer_context_menu/mock_render_view_context_menu.cc", "../browser/renderer_context_menu/mock_render_view_context_menu.cc",
"../browser/renderer_context_menu/mock_render_view_context_menu.h", "../browser/renderer_context_menu/mock_render_view_context_menu.h",
"../browser/signin/easy_unlock_app_manager_unittest.cc",
"../browser/signin/easy_unlock_auth_attempt_unittest.cc",
"../browser/signin/signin_error_notifier_ash_unittest.cc", "../browser/signin/signin_error_notifier_ash_unittest.cc",
"../browser/sync/sync_error_notifier_ash_unittest.cc", "../browser/sync/sync_error_notifier_ash_unittest.cc",
"../browser/ui/ash/accessibility/accessibility_controller_client_unittest.cc", "../browser/ui/ash/accessibility/accessibility_controller_client_unittest.cc",
...@@ -3248,7 +3250,6 @@ test("unit_tests") { ...@@ -3248,7 +3250,6 @@ test("unit_tests") {
"../browser/extensions/api/developer_private/extension_info_generator_unittest.cc", "../browser/extensions/api/developer_private/extension_info_generator_unittest.cc",
"../browser/extensions/api/device_permissions_manager_unittest.cc", "../browser/extensions/api/device_permissions_manager_unittest.cc",
"../browser/extensions/api/downloads/downloads_api_unittest.cc", "../browser/extensions/api/downloads/downloads_api_unittest.cc",
"../browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc",
"../browser/extensions/api/extension_action/browser_action_unittest.cc", "../browser/extensions/api/extension_action/browser_action_unittest.cc",
"../browser/extensions/api/extension_action/extension_action_prefs_unittest.cc", "../browser/extensions/api/extension_action/extension_action_prefs_unittest.cc",
"../browser/extensions/api/file_system/file_system_api_unittest.cc", "../browser/extensions/api/file_system/file_system_api_unittest.cc",
...@@ -3384,7 +3385,6 @@ test("unit_tests") { ...@@ -3384,7 +3385,6 @@ test("unit_tests") {
"../browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_test_utils.cc", "../browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_test_utils.cc",
"../browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_test_utils.h", "../browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_test_utils.h",
"../browser/safe_search_api/safe_search_url_checker_unittest.cc", "../browser/safe_search_api/safe_search_url_checker_unittest.cc",
"../browser/signin/easy_unlock_auth_attempt_unittest.cc",
"../browser/signin/easy_unlock_notification_controller_chromeos_unittest.cc", "../browser/signin/easy_unlock_notification_controller_chromeos_unittest.cc",
"../browser/signin/easy_unlock_screenlock_state_handler_unittest.cc", "../browser/signin/easy_unlock_screenlock_state_handler_unittest.cc",
"../browser/signin/easy_unlock_service_unittest_chromeos.cc", "../browser/signin/easy_unlock_service_unittest_chromeos.cc",
...@@ -3533,8 +3533,8 @@ test("unit_tests") { ...@@ -3533,8 +3533,8 @@ test("unit_tests") {
} }
if (is_chromeos) { if (is_chromeos) {
sources += [ sources += [
"../browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc",
"../browser/extensions/api/file_system/consent_provider_unittest.cc", "../browser/extensions/api/file_system/consent_provider_unittest.cc",
"../browser/signin/easy_unlock_app_manager_unittest.cc",
] ]
} else { } else {
sources += [ sources += [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment