Commit 5c498d00 authored by tmdiep@chromium.org's avatar tmdiep@chromium.org

Promotion of ephemeral apps now handles permission escalation correctly

ExtensionService::PromoteEphemeralApp() now clears the permission
escalation flag as well as enabling the app.

BUG=374018
TEST=browser_tests (EphemeralAppBrowserTest.*)

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278089 0039d316-1c4b-4281-b951-d872f2087c98
parent b7176268
......@@ -554,7 +554,10 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralAppAndEnable) {
const Extension* app = InstallEphemeralApp(kNotificationsTestApp);
ASSERT_TRUE(app);
// Disable the ephemeral app.
// Disable the ephemeral app due to a permissions increase. This also involves
// setting the DidExtensionEscalatePermissions flag.
ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
prefs->SetDidExtensionEscalatePermissions(app, true);
ExtensionService* service =
ExtensionSystem::Get(profile())->extension_service();
service->DisableExtension(app->id(), Extension::DISABLE_PERMISSIONS_INCREASE);
......@@ -564,6 +567,7 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralAppAndEnable) {
// Promote to a regular installed app. It should be enabled.
PromoteEphemeralApp(app);
VerifyPromotedApp(app->id(), ExtensionRegistry::ENABLED);
EXPECT_FALSE(prefs->DidExtensionEscalatePermissions(app->id()));
scoped_ptr<AppSyncData> sync_change = GetFirstSyncChangeForApp(app->id());
VerifySyncChange(sync_change.get(), true);
......
......@@ -2026,20 +2026,10 @@ void ExtensionService::PromoteEphemeralApp(
extension->id(), syncer::StringOrdinal());
}
if (extension_prefs_->IsExtensionDisabled(extension->id()) &&
!extension_prefs_->IsExtensionBlacklisted(extension->id())) {
// If the extension is not blacklisted and was disabled due to permission
// increase or user action only, we can enable it because the user was
// prompted.
extension_prefs_->RemoveDisableReason(
extension->id(),
Extension::DISABLE_PERMISSIONS_INCREASE);
extension_prefs_->RemoveDisableReason(
extension->id(),
Extension::DISABLE_USER_ACTION);
if (!extension_prefs_->GetDisableReasons(extension->id()))
EnableExtension(extension->id());
}
// Cached ephemeral apps may be updated and disabled due to permissions
// increase. The app can be enabled as the install was user-acknowledged.
if (extension_prefs_->DidExtensionEscalatePermissions(extension->id()))
GrantPermissionsAndEnableExtension(extension);
}
// Remove the ephemeral flags from the preferences.
......
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