Commit 5a5bf024 authored by tbarzic's avatar tbarzic Committed by Commit bot

Make Easy Unlock app have separate instance in incognito

Extension background page is only allowed for the incognito profile
on sign-in screen, so in order to run the app on sign-in, the app
must be run in split incognito mode.

To avoid having two background pages per user (for original and otr
profile) in regular user session, set split incognito mode only for the
app running on signin screen (by using different manifest than for a
regular session)

TEST=
1. Make sure easy sign-in works
2. Lock screen with an incognito window open.
   Verify that the screen can be unlocked using Smart Lock
BUG=448634,445048

Review URL: https://codereview.chromium.org/834233005

Cr-Commit-Position: refs/heads/master@{#311543}
parent a63b2ff9
......@@ -426,6 +426,7 @@
<include name="IDR_GCM_INTERNALS_CSS" file="resources\gcm_internals.css" type="BINDATA" />
<include name="IDR_GCM_INTERNALS_JS" file="resources\gcm_internals.js" type="BINDATA" />
<include name="IDR_EASY_UNLOCK_MANIFEST" file="resources\easy_unlock\manifest.json" type="BINDATA" />
<include name="IDR_EASY_UNLOCK_MANIFEST_SIGNIN" file="resources\easy_unlock\manifest_signin.json" type="BINDATA" />
<if expr="chromeos">
<include name="IDR_SET_TIME_HTML" file="resources\chromeos\set_time.html" type="BINDATA" />
<include name="IDR_SET_TIME_CSS" file="resources\chromeos\set_time.css" type="BINDATA" />
......
{
"name": "Smart Lock",
"description": "This app allows you to sign-in to a device when in proximity to your phone.",
"version": "1.1",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqOUeUl1nC6qTz6WwVUIaAJ4ukXVzgeCAumX4TZlCHFk5DLHImHLDBxakyVGaQFLS9iEQ3tDTsJLIoA+FkbWKNX7bvDW/qM89CeVNZsIZRGw898m8J78N6dJHwP9aZSI8CpoMK2KvjANpuj1tdWs1OM6v65zRUu6y4Mq876dr5AcPiuznGxl8jekagBwGu8jqMySsJxLazj/EfQ3W1E7mpyHd0Z4C1qNwJoFlUQeMjn6gfPZqa06BLU6YznzCUesiyjFK3d1vzbN54ZkVxhcA6ekwLKYLqKykBFLmIQG0gkNNePzcGXju8p34dGJgkcZw0sOXrtNaLSe1su0zfcniIwIDAQAB",
"permissions": [
// Public APIs:
"alarms",
"browser",
"gcm",
"identity",
"notifications",
"storage",
"system.display",
// Private APIs:
"bluetoothPrivate",
"chromeosInfoPrivate",
"easyUnlockPrivate",
"feedbackPrivate",
"metricsPrivate",
"preferencesPrivate",
"screenlockPrivate",
"systemPrivate"
],
"app": {
"background": {
"scripts": ["easy_unlock_background.js"]
}
},
"bluetooth": {
"socket" : true,
"low_energy" : true,
"uuids": [
"704EE561-3782-405A-A14B-2D47A2DDCDDF" // Unlock UUID
]
},
"offline_enabled": true,
"display_in_launcher": false,
"incognito": "split",
"icons": {
"32": "icons/easyunlock_app_icon_32.png",
"48": "icons/easyunlock_app_icon_48.png",
"64": "icons/easyunlock_app_icon_64.png",
"96": "icons/easyunlock_app_icon_96.png",
"128": "icons/easyunlock_app_icon_128.png",
"256": "icons/easyunlock_app_icon_256.png"
}
}
......@@ -524,8 +524,12 @@ void EasyUnlockService::LoadApp() {
if (!easy_unlock_path.empty()) {
extensions::ComponentLoader* loader = GetComponentLoader(profile_);
if (!loader->Exists(extension_misc::kEasyUnlockAppId))
loader->Add(IDR_EASY_UNLOCK_MANIFEST, easy_unlock_path);
if (!loader->Exists(extension_misc::kEasyUnlockAppId)) {
int manifest_id =
GetType() == TYPE_REGULAR ? IDR_EASY_UNLOCK_MANIFEST :
IDR_EASY_UNLOCK_MANIFEST_SIGNIN;
loader->Add(manifest_id, easy_unlock_path);
}
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
......
......@@ -50,7 +50,7 @@ KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor(
#if defined(OS_CHROMEOS)
if (chromeos::ProfileHelper::IsSigninProfile(
Profile::FromBrowserContext(context))) {
if (EasyUnlockService::IsSignInEnabled()) {
if (EasyUnlockService::IsSignInEnabled() && context->IsOffTheRecord()) {
return new EasyUnlockServiceSignin(Profile::FromBrowserContext(context));
} else {
return NULL;
......@@ -62,6 +62,12 @@ KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
#if defined(OS_CHROMEOS)
if (chromeos::ProfileHelper::IsSigninProfile(
Profile::FromBrowserContext(context))) {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
#endif
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
......
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