Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: chrome/browser/sync/glue/extension_change_processor.cc

Issue 2884027: Added checks to handle unsyncable extensions. (Closed)
Patch Set: Fixed comment typo Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/glue/extension_change_processor.cc
diff --git a/chrome/browser/sync/glue/extension_change_processor.cc b/chrome/browser/sync/glue/extension_change_processor.cc
index b6f4b42279f1b79b1e1884744bab30b562fca976..21d9950d532e602add4a6674614da126397e80be 100644
--- a/chrome/browser/sync/glue/extension_change_processor.cc
+++ b/chrome/browser/sync/glue/extension_change_processor.cc
@@ -9,6 +9,8 @@
#include "base/logging.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/extensions/extensions_service.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/glue/extension_model_associator.h"
#include "chrome/browser/sync/glue/extension_util.h"
@@ -51,6 +53,7 @@ void ExtensionChangeProcessor::Observe(NotificationType type,
DCHECK_EQ(Source<Profile>(source).ptr(), profile_);
Extension* extension = Details<Extension>(details).ptr();
CHECK(extension);
+ // Ignore non-syncable extensions.
if (!IsExtensionSyncable(*extension)) {
return;
}
@@ -102,23 +105,51 @@ void ExtensionChangeProcessor::ApplyChangesFromSyncModel(
error_handler()->OnUnrecoverableError(FROM_HERE, error);
return;
}
+ const std::string& id = specifics.id();
+ CHECK(profile_);
+ ExtensionsService* extensions_service =
+ profile_->GetExtensionsService();
+ CHECK(extensions_service);
+ Extension* extension =
+ extensions_service->GetExtensionById(id, true);
+ if (extension && !IsExtensionSyncable(*extension)) {
+ LOG(WARNING) << "Not updating unsyncable extension " << id;
+ return;
+ }
StopObserving();
- extension_model_associator_->OnServerUpdate(specifics);
+ extension_model_associator_->OnServerUpdate(specifics, extension);
StartObserving();
break;
}
case sync_api::SyncManager::ChangeRecord::ACTION_DELETE: {
- StopObserving();
- if (change.specifics.HasExtension(sync_pb::extension)) {
- extension_model_associator_->OnServerRemove(
- change.specifics.GetExtension(sync_pb::extension).id());
- } else {
+ if (!change.specifics.HasExtension(sync_pb::extension)) {
std::stringstream error;
- error << "Could not get extension ID for deleted node "
+ error << "Could not get extension ID for delete node "
<< change.id;
error_handler()->OnUnrecoverableError(FROM_HERE, error.str());
LOG(DFATAL) << error.str();
+ return;
}
+ const std::string& id =
+ change.specifics.GetExtension(sync_pb::extension).id();
+ CHECK(profile_);
+ ExtensionsService* extensions_service =
+ profile_->GetExtensionsService();
+ CHECK(extensions_service);
+ Extension* extension =
+ extensions_service->GetExtensionById(id, true);
+ if (!extension) {
+ LOG(ERROR) << "Trying to uninstall nonexistent extension " << id
+ << " for delete node " << change.id;
+ return;
+ }
+ if (!IsExtensionSyncable(*extension)) {
+ LOG(WARNING) << "Not uninstalling unsyncable extension " << id
+ << " for delete node " << change.id;
+ return;
+ }
+ StopObserving();
+ extensions_service->UninstallExtension(id, false);
StartObserving();
break;
}
« no previous file with comments | « chrome/browser/extensions/extensions_service_unittest.cc ('k') | chrome/browser/sync/glue/extension_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698