| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" | 5 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/extensions/extension_util.h" | 13 #include "chrome/browser/extensions/extension_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 15 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 16 #include "chrome/browser/sync/test/integration/sync_test.h" | 16 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 17 #include "extensions/browser/pending_extension_info.h" | 17 #include "extensions/browser/pending_extension_info.h" |
| 18 #include "extensions/browser/pending_extension_manager.h" | 18 #include "extensions/browser/pending_extension_manager.h" |
| 19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 20 #include "extensions/common/extension_set.h" |
| 20 #include "extensions/common/id_util.h" | 21 #include "extensions/common/id_util.h" |
| 21 #include "extensions/common/manifest_constants.h" | 22 #include "extensions/common/manifest_constants.h" |
| 22 #include "sync/api/string_ordinal.h" | 23 #include "sync/api/string_ordinal.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| 25 using extensions::Extension; | 26 using extensions::Extension; |
| 26 using extensions::Manifest; | 27 using extensions::Manifest; |
| 27 | 28 |
| 28 SyncExtensionHelper::ExtensionState::ExtensionState() | 29 SyncExtensionHelper::ExtensionState::ExtensionState() |
| 29 : enabled_state(ENABLED), incognito_enabled(false) {} | 30 : enabled_state(ENABLED), incognito_enabled(false) {} |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ExtensionService::UninstallExtensionHelper( | 81 ExtensionService::UninstallExtensionHelper( |
| 81 profile->GetExtensionService(), | 82 profile->GetExtensionService(), |
| 82 extensions::id_util::GenerateId(name)); | 83 extensions::id_util::GenerateId(name)); |
| 83 } | 84 } |
| 84 | 85 |
| 85 std::vector<std::string> SyncExtensionHelper::GetInstalledExtensionNames( | 86 std::vector<std::string> SyncExtensionHelper::GetInstalledExtensionNames( |
| 86 Profile* profile) const { | 87 Profile* profile) const { |
| 87 std::vector<std::string> names; | 88 std::vector<std::string> names; |
| 88 ExtensionService* extension_service = profile->GetExtensionService(); | 89 ExtensionService* extension_service = profile->GetExtensionService(); |
| 89 | 90 |
| 90 scoped_ptr<const ExtensionSet> extensions( | 91 scoped_ptr<const extensions::ExtensionSet> extensions( |
| 91 extension_service->GenerateInstalledExtensionsSet()); | 92 extension_service->GenerateInstalledExtensionsSet()); |
| 92 for (ExtensionSet::const_iterator it = extensions->begin(); | 93 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); |
| 93 it != extensions->end(); ++it) { | 94 it != extensions->end(); ++it) { |
| 94 names.push_back((*it)->name()); | 95 names.push_back((*it)->name()); |
| 95 } | 96 } |
| 96 | 97 |
| 97 return names; | 98 return names; |
| 98 } | 99 } |
| 99 | 100 |
| 100 void SyncExtensionHelper::EnableExtension(Profile* profile, | 101 void SyncExtensionHelper::EnableExtension(Profile* profile, |
| 101 const std::string& name) { | 102 const std::string& name) { |
| 102 profile->GetExtensionService()->EnableExtension( | 103 profile->GetExtensionService()->EnableExtension( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 182 } |
| 182 | 183 |
| 183 SyncExtensionHelper::ExtensionStateMap | 184 SyncExtensionHelper::ExtensionStateMap |
| 184 SyncExtensionHelper::GetExtensionStates(Profile* profile) { | 185 SyncExtensionHelper::GetExtensionStates(Profile* profile) { |
| 185 const std::string& profile_debug_name = profile->GetDebugName(); | 186 const std::string& profile_debug_name = profile->GetDebugName(); |
| 186 | 187 |
| 187 ExtensionStateMap extension_state_map; | 188 ExtensionStateMap extension_state_map; |
| 188 | 189 |
| 189 ExtensionService* extension_service = profile->GetExtensionService(); | 190 ExtensionService* extension_service = profile->GetExtensionService(); |
| 190 | 191 |
| 191 scoped_ptr<const ExtensionSet> extensions( | 192 scoped_ptr<const extensions::ExtensionSet> extensions( |
| 192 extension_service->GenerateInstalledExtensionsSet()); | 193 extension_service->GenerateInstalledExtensionsSet()); |
| 193 for (ExtensionSet::const_iterator it = extensions->begin(); | 194 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); |
| 194 it != extensions->end(); ++it) { | 195 it != extensions->end(); ++it) { |
| 195 const std::string& id = (*it)->id(); | 196 const std::string& id = (*it)->id(); |
| 196 extension_state_map[id].enabled_state = | 197 extension_state_map[id].enabled_state = |
| 197 extension_service->IsExtensionEnabled(id) ? | 198 extension_service->IsExtensionEnabled(id) ? |
| 198 ExtensionState::ENABLED : | 199 ExtensionState::ENABLED : |
| 199 ExtensionState::DISABLED; | 200 ExtensionState::DISABLED; |
| 200 extension_state_map[id].incognito_enabled = | 201 extension_state_map[id].incognito_enabled = |
| 201 extension_util::IsIncognitoEnabled(id, extension_service); | 202 extension_util::IsIncognitoEnabled(id, extension_service); |
| 202 | 203 |
| 203 DVLOG(2) << "Extension " << (*it)->id() << " in profile " | 204 DVLOG(2) << "Extension " << (*it)->id() << " in profile " |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 EXPECT_EQ(expected_id, extension->id()); | 371 EXPECT_EQ(expected_id, extension->id()); |
| 371 return NULL; | 372 return NULL; |
| 372 } | 373 } |
| 373 DVLOG(2) << "created extension with name = " | 374 DVLOG(2) << "created extension with name = " |
| 374 << name << ", id = " << expected_id; | 375 << name << ", id = " << expected_id; |
| 375 (it->second)[name] = extension; | 376 (it->second)[name] = extension; |
| 376 id_to_name_[expected_id] = name; | 377 id_to_name_[expected_id] = name; |
| 377 id_to_type_[expected_id] = type; | 378 id_to_type_[expected_id] = type; |
| 378 return extension; | 379 return extension; |
| 379 } | 380 } |
| OLD | NEW |