diff options
12 files changed, 42 insertions, 4 deletions
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc index e2dce03..c1eb2d7 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_client.cc +++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc @@ -50,6 +50,7 @@ #include "chrome/browser/extensions/updater/chromeos_extension_cache_delegate.h" #include "chrome/browser/extensions/updater/extension_cache_impl.h" #include "chromeos/chromeos_switches.h" +#include "components/user_manager/user_manager.h" #else #include "extensions/browser/updater/null_extension_cache.h" #endif @@ -225,6 +226,14 @@ bool ChromeExtensionsBrowserClient::IsRunningInForcedAppMode() { return chrome::IsRunningInForcedAppMode(); } +bool ChromeExtensionsBrowserClient::IsLoggedInAsPublicAccount() { +#if defined(OS_CHROMEOS) + return user_manager::UserManager::Get()->IsLoggedInAsPublicAccount(); +#else + return false; +#endif +} + ApiActivityMonitor* ChromeExtensionsBrowserClient::GetApiActivityMonitor( content::BrowserContext* context) { // The ActivityLog monitors and records function calls and events. diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.h b/chrome/browser/extensions/chrome_extensions_browser_client.h index 852a27c..c9d41a3 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_client.h +++ b/chrome/browser/extensions/chrome_extensions_browser_client.h @@ -83,6 +83,7 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient { bool DidVersionUpdate(content::BrowserContext* context) override; void PermitExternalProtocolHandler() override; bool IsRunningInForcedAppMode() override; + bool IsLoggedInAsPublicAccount() override; ApiActivityMonitor* GetApiActivityMonitor( content::BrowserContext* context) override; ExtensionSystemProvider* GetExtensionSystemFactory() override; diff --git a/chrome/test/data/extensions/platform_apps/launch_file/test.js b/chrome/test/data/extensions/platform_apps/launch_file/test.js index b4ff0c8..90eb6de 100644 --- a/chrome/test/data/extensions/platform_apps/launch_file/test.js +++ b/chrome/test/data/extensions/platform_apps/launch_file/test.js @@ -3,13 +3,15 @@ // found in the LICENSE file. chrome.app.runtime.onLaunched.addListener(function (launchData) { - // Test that the isKioskSession field is |false| and the id and items fields - // can be read in the launch data. + // Test that the isKioskSession field and isPublicSession are |false| and the + // id and items fields can be read in the launch data. chrome.test.runTests([ function testFileHandler() { chrome.test.assertFalse(!launchData, "No launchData"); chrome.test.assertFalse(launchData.isKioskSession, "launchData.isKioskSession incorrect"); + chrome.test.assertFalse(launchData.isPublicSession, + "launchData.isPublicSesion incorrect"); chrome.test.assertEq(launchData.id, "text", "launchData.id incorrect"); chrome.test.assertEq(launchData.items.length, 1); diff --git a/chrome/test/data/extensions/platform_apps/launch_whitelisted_ext_with_file/test.js b/chrome/test/data/extensions/platform_apps/launch_whitelisted_ext_with_file/test.js index 82fc079..45d7955 100644 --- a/chrome/test/data/extensions/platform_apps/launch_whitelisted_ext_with_file/test.js +++ b/chrome/test/data/extensions/platform_apps/launch_whitelisted_ext_with_file/test.js @@ -3,8 +3,8 @@ // found in the LICENSE file. chrome.app.runtime.onLaunched.addListener(function (launchData) { - // Test that the isKioskSession field is |false| and the id and items fields - // can be read in the launch data. + // Test that the isKioskSession field and isPublicSession fields are |false| + // and the id and items fields can be read in the launch data. chrome.test.runTests([ function checkNoChromeApp() { chrome.test.assertEq(undefined, chrome.app.getIsInstalled); @@ -15,6 +15,8 @@ chrome.app.runtime.onLaunched.addListener(function (launchData) { chrome.test.assertFalse(!launchData, "No launchData"); chrome.test.assertFalse(launchData.isKioskSession, "launchData.isKioskSession incorrect"); + chrome.test.assertFalse(launchData.isPublicSession, + "launchData.isPublicSession incorrect"); chrome.test.assertEq(launchData.id, "text", "launchData.id incorrect"); chrome.test.assertEq(launchData.items.length, 1); diff --git a/extensions/browser/api/app_runtime/app_runtime_api.cc b/extensions/browser/api/app_runtime/app_runtime_api.cc index 39356c3..60c2c0d 100644 --- a/extensions/browser/api/app_runtime/app_runtime_api.cc +++ b/extensions/browser/api/app_runtime/app_runtime_api.cc @@ -52,6 +52,11 @@ void DispatchOnLaunchedEventImpl(const std::string& extension_id, launch_data->SetBoolean( "isKioskSession", ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); + + launch_data->SetBoolean( + "isPublicSession", + ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount()); + scoped_ptr<base::ListValue> args(new base::ListValue()); args->Append(launch_data.release()); scoped_ptr<Event> event(new Event(events::APP_RUNTIME_ON_LAUNCHED, diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h index 8b66051..89763d9 100644 --- a/extensions/browser/extensions_browser_client.h +++ b/extensions/browser/extensions_browser_client.h @@ -164,6 +164,9 @@ class ExtensionsBrowserClient { // Return true if the system is run in forced app mode. virtual bool IsRunningInForcedAppMode() = 0; + // Return true if the user is logged in as a public session. + virtual bool IsLoggedInAsPublicAccount() = 0; + // Returns the embedder's ApiActivityMonitor for |context|. Returns NULL if // the embedder does not monitor extension API activity. virtual ApiActivityMonitor* GetApiActivityMonitor( diff --git a/extensions/browser/test_extensions_browser_client.cc b/extensions/browser/test_extensions_browser_client.cc index be9e4b5..d98f7af 100644 --- a/extensions/browser/test_extensions_browser_client.cc +++ b/extensions/browser/test_extensions_browser_client.cc @@ -142,6 +142,10 @@ void TestExtensionsBrowserClient::PermitExternalProtocolHandler() { bool TestExtensionsBrowserClient::IsRunningInForcedAppMode() { return false; } +bool TestExtensionsBrowserClient::IsLoggedInAsPublicAccount() { + return false; +} + ApiActivityMonitor* TestExtensionsBrowserClient::GetApiActivityMonitor( BrowserContext* context) { return NULL; diff --git a/extensions/browser/test_extensions_browser_client.h b/extensions/browser/test_extensions_browser_client.h index 86f0576..274a8a9 100644 --- a/extensions/browser/test_extensions_browser_client.h +++ b/extensions/browser/test_extensions_browser_client.h @@ -76,6 +76,7 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient { bool DidVersionUpdate(content::BrowserContext* context) override; void PermitExternalProtocolHandler() override; bool IsRunningInForcedAppMode() override; + bool IsLoggedInAsPublicAccount() override; ApiActivityMonitor* GetApiActivityMonitor( content::BrowserContext* context) override; ExtensionSystemProvider* GetExtensionSystemFactory() override; diff --git a/extensions/common/api/app_runtime.idl b/extensions/common/api/app_runtime.idl index 0f8cb9c..e3339bd 100644 --- a/extensions/common/api/app_runtime.idl +++ b/extensions/common/api/app_runtime.idl @@ -63,6 +63,11 @@ namespace app.runtime { // kiosk session</a>. boolean? isKioskSession; + // Whether the app is being launched in a <a + // href="https://support.google.com/chrome/a/answer/3017014">Chrome OS + // public session</a>. + boolean? isPublicSession; + // Where the app is launched from. LaunchSource? source; }; diff --git a/extensions/renderer/resources/app_runtime_custom_bindings.js b/extensions/renderer/resources/app_runtime_custom_bindings.js index 309d4af..2b492c5 100644 --- a/extensions/renderer/resources/app_runtime_custom_bindings.js +++ b/extensions/renderer/resources/app_runtime_custom_bindings.js @@ -45,6 +45,7 @@ eventBindings.registerArgumentMassager('app.runtime.onLaunched', if (--numItems === 0) { var data = { isKioskSession: launchData.isKioskSession, + isPublicSession: launchData.isPublicSession, source: launchData.source }; if (items.length !== 0) { diff --git a/extensions/shell/browser/shell_extensions_browser_client.cc b/extensions/shell/browser/shell_extensions_browser_client.cc index 62b2a5f..a3ec44a 100644 --- a/extensions/shell/browser/shell_extensions_browser_client.cc +++ b/extensions/shell/browser/shell_extensions_browser_client.cc @@ -159,6 +159,10 @@ bool ShellExtensionsBrowserClient::IsRunningInForcedAppMode() { return false; } +bool ShellExtensionsBrowserClient::IsLoggedInAsPublicAccount() { + return false; +} + ApiActivityMonitor* ShellExtensionsBrowserClient::GetApiActivityMonitor( BrowserContext* context) { // app_shell doesn't monitor API function calls or events. diff --git a/extensions/shell/browser/shell_extensions_browser_client.h b/extensions/shell/browser/shell_extensions_browser_client.h index 8b65ccf..8c449ee 100644 --- a/extensions/shell/browser/shell_extensions_browser_client.h +++ b/extensions/shell/browser/shell_extensions_browser_client.h @@ -67,6 +67,7 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { bool DidVersionUpdate(content::BrowserContext* context) override; void PermitExternalProtocolHandler() override; bool IsRunningInForcedAppMode() override; + bool IsLoggedInAsPublicAccount() override; ApiActivityMonitor* GetApiActivityMonitor( content::BrowserContext* context) override; ExtensionSystemProvider* GetExtensionSystemFactory() override; |