Chromium Code Reviews| Index: chrome/test/live_sync/live_sync_extension_helper.cc |
| diff --git a/chrome/test/live_sync/live_sync_extension_helper.cc b/chrome/test/live_sync/live_sync_extension_helper.cc |
| index dc260adee85c1b8a4bc97746b3f49397f2f7850a..bd924503d80eceaa6467a8ed847a538c23d5ac41 100644 |
| --- a/chrome/test/live_sync/live_sync_extension_helper.cc |
| +++ b/chrome/test/live_sync/live_sync_extension_helper.cc |
| @@ -16,6 +16,17 @@ |
| #include "chrome/test/live_sync/live_sync_test.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +LiveSyncExtensionHelper::ExtensionState::ExtensionState() |
| + : enabled_state(ENABLED), incognito_enabled(false) {} |
| + |
| +LiveSyncExtensionHelper::ExtensionState::~ExtensionState() {} |
| + |
| +bool LiveSyncExtensionHelper::ExtensionState::Equals( |
| + const LiveSyncExtensionHelper::ExtensionState &other) const { |
| + return ((enabled_state == other.enabled_state) && |
| + (incognito_enabled == other.incognito_enabled)); |
| +} |
| + |
| LiveSyncExtensionHelper::LiveSyncExtensionHelper() {} |
| LiveSyncExtensionHelper::~LiveSyncExtensionHelper() {} |
| @@ -48,6 +59,26 @@ void LiveSyncExtensionHelper::UninstallExtension( |
| NameToId(name)); |
| } |
| +void LiveSyncExtensionHelper::EnableExtension(Profile* profile, |
| + const std::string& name) { |
| + profile->GetExtensionService()->EnableExtension(NameToId(name)); |
| +} |
| + |
| +void LiveSyncExtensionHelper::DisableExtension(Profile* profile, |
| + const std::string& name) { |
| + profile->GetExtensionService()->DisableExtension(NameToId(name)); |
| +} |
| + |
| +void LiveSyncExtensionHelper::IncognitoEnableExtension( |
| + Profile* profile, const std::string& name) { |
| + profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), true); |
| +} |
| + |
| +void LiveSyncExtensionHelper::IncognitoDisableExtension( |
| + Profile* profile, const std::string& name) { |
| + profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), false); |
| +} |
| + |
| bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync( |
| Profile* profile, const std::string& id) const { |
| const PendingExtensionManager* pending_extension_manager = |
| @@ -100,7 +131,10 @@ LiveSyncExtensionHelper::ExtensionStateMap |
| const ExtensionList* extensions = extension_service->extensions(); |
| for (ExtensionList::const_iterator it = extensions->begin(); |
| it != extensions->end(); ++it) { |
| - extension_state_map[(*it)->id()] = ENABLED; |
| + const std::string& id = (*it)->id(); |
| + extension_state_map[id].enabled_state = ExtensionState::ENABLED; |
| + extension_state_map[id].incognito_enabled = |
| + extension_service->IsIncognitoEnabled(id); |
| VLOG(2) << "Extension " << (*it)->id() << " in profile " |
| << profile_debug_name << " is enabled"; |
| } |
| @@ -109,7 +143,10 @@ LiveSyncExtensionHelper::ExtensionStateMap |
| extension_service->disabled_extensions(); |
| for (ExtensionList::const_iterator it = disabled_extensions->begin(); |
| it != disabled_extensions->end(); ++it) { |
| - extension_state_map[(*it)->id()] = DISABLED; |
| + const std::string& id = (*it)->id(); |
| + extension_state_map[id].enabled_state = ExtensionState::DISABLED; |
| + extension_state_map[id].incognito_enabled = |
| + extension_service->IsIncognitoEnabled(id); |
| VLOG(2) << "Extension " << (*it)->id() << " in profile " |
| << profile_debug_name << " is disabled"; |
| } |
| @@ -119,7 +156,10 @@ LiveSyncExtensionHelper::ExtensionStateMap |
| PendingExtensionManager::const_iterator it; |
| for (it = pending_extension_manager->begin(); |
| it != pending_extension_manager->end(); ++it) { |
| - extension_state_map[it->first] = PENDING; |
| + const std::string& id = it->first; |
| + extension_state_map[id].enabled_state = ExtensionState::PENDING; |
| + extension_state_map[id].incognito_enabled = |
| + extension_service->IsIncognitoEnabled(id); |
| VLOG(2) << "Extension " << it->first << " in profile " |
| << profile_debug_name << " is pending"; |
| } |
| @@ -127,6 +167,34 @@ LiveSyncExtensionHelper::ExtensionStateMap |
| return extension_state_map; |
| } |
| +bool LiveSyncExtensionHelper::ExtensionStatesMatch( |
| + Profile* profile1, Profile* profile2) const { |
| + const ExtensionStateMap& state_map1 = GetExtensionStates(profile1); |
| + const ExtensionStateMap& state_map2 = GetExtensionStates(profile2); |
| + if (state_map1.size() != state_map2.size()) { |
| + VLOG(1) << "Number of extensions for profile " << profile1->GetDebugName() |
| + << " does not match profile " << profile2->GetDebugName(); |
| + return false; |
| + } |
| + |
| + ExtensionStateMap::const_iterator it1 = state_map1.begin(); |
| + ExtensionStateMap::const_iterator it2 = state_map2.begin(); |
| + while (it1 != state_map1.end()) { |
| + if (it1->first != it2->first) { |
| + VLOG(1) << "Extensions for profile " << profile1->GetDebugName() |
| + << " do not match profile " << profile2->GetDebugName(); |
| + return false; |
| + } else if (!(it1->second.Equals(it2->second))) { |
|
akalin
2011/06/10 01:56:44
usual Google/Chrome style is to not have parenthes
|
| + VLOG(1) << "Extension states for profile " << profile1->GetDebugName() |
|
braffert
2011/06/10 16:49:17
Done. I had thought that without the parentheses
|
| + << " do not match profile " << profile2->GetDebugName(); |
| + return false; |
| + } |
| + ++it1; |
| + ++it2; |
| + } |
| + return true; |
| +} |
| + |
| void LiveSyncExtensionHelper::SetupProfile(Profile* profile) { |
| profile->InitExtensions(true); |
| profile_extensions_.insert(make_pair(profile, ExtensionNameMap())); |