Commit 96e989bf authored by bolms@chromium.org's avatar bolms@chromium.org

Fixing crash on sync when app becomes extension or vice versa.

BUG=94661
TEST=New unit test; also manually add a syncable app to profile, sync, then install extension with same ID: with change, no crash, without, crash on sync.


Review URL: http://codereview.chromium.org/7795011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98860 0039d316-1c4b-4281-b951-d872f2087c98
parent be41e781
......@@ -1891,6 +1891,13 @@ void ExtensionService::ProcessExtensionSyncData(
const ExtensionSyncData& extension_sync_data,
SyncBundle& bundle) {
const std::string& id = extension_sync_data.id();
const Extension* extension = GetInstalledExtension(id);
// TODO(bolms): we should really handle this better. The particularly bad
// case is where an app becomes an extension or vice versa, and we end up with
// a zombie extension that won't go away.
if (extension && !bundle.filter(*extension))
return;
// Handle uninstalls first.
if (extension_sync_data.uninstalled()) {
......@@ -1910,7 +1917,6 @@ void ExtensionService::ProcessExtensionSyncData(
}
SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled());
const Extension* extension = GetInstalledExtension(id);
if (extension) {
// If the extension is already installed, check if it's outdated.
int result = extension->version()->CompareTo(extension_sync_data.version());
......
......@@ -40,6 +40,7 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
......@@ -3612,6 +3613,48 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataUninstall) {
EXPECT_FALSE(service_->GetExtensionById(good_crx, true));
}
TEST_F(ExtensionServiceTest, ProcessSyncDataWrongType) {
InitializeEmptyExtensionService();
// Install the extension.
FilePath extension_path = data_dir_.AppendASCII("good.crx");
InstallCrx(extension_path, true);
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
sync_pb::EntitySpecifics specifics;
sync_pb::AppSpecifics* app_specifics =
specifics.MutableExtension(sync_pb::app);
sync_pb::ExtensionSpecifics* extension_specifics =
app_specifics->mutable_extension();
extension_specifics->set_id(good_crx);
extension_specifics->set_version(
service_->GetInstalledExtension(good_crx)->version()->GetString());
{
extension_specifics->set_enabled(true);
SyncData sync_data = SyncData::CreateLocalData(good_crx, "Name", specifics);
SyncChange sync_change(SyncChange::ACTION_DELETE, sync_data);
SyncChangeList list(1);
list[0] = sync_change;
// Should do nothing
service_->ProcessSyncChanges(FROM_HERE, list);
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
}
{
extension_specifics->set_enabled(false);
SyncData sync_data = SyncData::CreateLocalData(good_crx, "Name", specifics);
SyncChange sync_change(SyncChange::ACTION_UPDATE, sync_data);
SyncChangeList list(1);
list[0] = sync_change;
// Should again do nothing.
service_->ProcessSyncChanges(FROM_HERE, list);
EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
}
}
TEST_F(ExtensionServiceTest, ProcessSyncDataSettings) {
InitializeEmptyExtensionService();
TestSyncProcessorStub processor;
......
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