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

Side by Side Diff: chrome/browser/sync/test/integration/sync_extension_helper.cc

Issue 25366003: Moved some functions off ExtensionService into a new file extension_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile failures Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/pending_extension_info.h" 14 #include "chrome/browser/extensions/pending_extension_info.h"
14 #include "chrome/browser/extensions/pending_extension_manager.h" 15 #include "chrome/browser/extensions/pending_extension_manager.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 17 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
17 #include "chrome/browser/sync/test/integration/sync_test.h" 18 #include "chrome/browser/sync/test/integration/sync_test.h"
18 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
19 #include "extensions/common/id_util.h" 20 #include "extensions/common/id_util.h"
20 #include "extensions/common/manifest_constants.h" 21 #include "extensions/common/manifest_constants.h"
21 #include "sync/api/string_ordinal.h" 22 #include "sync/api/string_ordinal.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 110 }
110 111
111 bool SyncExtensionHelper::IsExtensionEnabled( 112 bool SyncExtensionHelper::IsExtensionEnabled(
112 Profile* profile, const std::string& name) const { 113 Profile* profile, const std::string& name) const {
113 return profile->GetExtensionService()->IsExtensionEnabled( 114 return profile->GetExtensionService()->IsExtensionEnabled(
114 extensions::id_util::GenerateId(name)); 115 extensions::id_util::GenerateId(name));
115 } 116 }
116 117
117 void SyncExtensionHelper::IncognitoEnableExtension( 118 void SyncExtensionHelper::IncognitoEnableExtension(
118 Profile* profile, const std::string& name) { 119 Profile* profile, const std::string& name) {
119 profile->GetExtensionService()->SetIsIncognitoEnabled( 120 extension_util::SetIsIncognitoEnabled(extensions::id_util::GenerateId(name),
120 extensions::id_util::GenerateId(name), true); 121 profile->GetExtensionService(), true);
121 } 122 }
122 123
123 void SyncExtensionHelper::IncognitoDisableExtension( 124 void SyncExtensionHelper::IncognitoDisableExtension(
124 Profile* profile, const std::string& name) { 125 Profile* profile, const std::string& name) {
125 profile->GetExtensionService()->SetIsIncognitoEnabled( 126 extension_util::SetIsIncognitoEnabled(extensions::id_util::GenerateId(name),
126 extensions::id_util::GenerateId(name), false); 127 profile->GetExtensionService(), false);
127 } 128 }
128 129
129 bool SyncExtensionHelper::IsIncognitoEnabled( 130 bool SyncExtensionHelper::IsIncognitoEnabled(
130 Profile* profile, const std::string& name) const { 131 Profile* profile, const std::string& name) const {
131 return profile->GetExtensionService()->IsIncognitoEnabled( 132 return extension_util::IsIncognitoEnabled(
132 extensions::id_util::GenerateId(name)); 133 extensions::id_util::GenerateId(name), profile->GetExtensionService());
133 } 134 }
134 135
135 136
136 bool SyncExtensionHelper::IsExtensionPendingInstallForSync( 137 bool SyncExtensionHelper::IsExtensionPendingInstallForSync(
137 Profile* profile, const std::string& id) const { 138 Profile* profile, const std::string& id) const {
138 const extensions::PendingExtensionManager* pending_extension_manager = 139 const extensions::PendingExtensionManager* pending_extension_manager =
139 profile->GetExtensionService()->pending_extension_manager(); 140 profile->GetExtensionService()->pending_extension_manager();
140 const extensions::PendingExtensionInfo* info = 141 const extensions::PendingExtensionInfo* info =
141 pending_extension_manager->GetById(id); 142 pending_extension_manager->GetById(id);
142 if (!info) 143 if (!info)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 scoped_ptr<const ExtensionSet> extensions( 191 scoped_ptr<const ExtensionSet> extensions(
191 extension_service->GenerateInstalledExtensionsSet()); 192 extension_service->GenerateInstalledExtensionsSet());
192 for (ExtensionSet::const_iterator it = extensions->begin(); 193 for (ExtensionSet::const_iterator it = extensions->begin();
193 it != extensions->end(); ++it) { 194 it != extensions->end(); ++it) {
194 const std::string& id = (*it)->id(); 195 const std::string& id = (*it)->id();
195 extension_state_map[id].enabled_state = 196 extension_state_map[id].enabled_state =
196 extension_service->IsExtensionEnabled(id) ? 197 extension_service->IsExtensionEnabled(id) ?
197 ExtensionState::ENABLED : 198 ExtensionState::ENABLED :
198 ExtensionState::DISABLED; 199 ExtensionState::DISABLED;
199 extension_state_map[id].incognito_enabled = 200 extension_state_map[id].incognito_enabled =
200 extension_service->IsIncognitoEnabled(id); 201 extension_util::IsIncognitoEnabled(id, extension_service);
201 202
202 DVLOG(2) << "Extension " << (*it)->id() << " in profile " 203 DVLOG(2) << "Extension " << (*it)->id() << " in profile "
203 << profile_debug_name << " is " 204 << profile_debug_name << " is "
204 << (extension_service->IsExtensionEnabled(id) ? 205 << (extension_service->IsExtensionEnabled(id) ?
205 "enabled" : "disabled"); 206 "enabled" : "disabled");
206 } 207 }
207 208
208 const extensions::PendingExtensionManager* pending_extension_manager = 209 const extensions::PendingExtensionManager* pending_extension_manager =
209 extension_service->pending_extension_manager(); 210 extension_service->pending_extension_manager();
210 211
211 std::list<std::string> pending_crx_ids; 212 std::list<std::string> pending_crx_ids;
212 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); 213 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids);
213 214
214 std::list<std::string>::const_iterator id; 215 std::list<std::string>::const_iterator id;
215 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) { 216 for (id = pending_crx_ids.begin(); id != pending_crx_ids.end(); ++id) {
216 extension_state_map[*id].enabled_state = ExtensionState::PENDING; 217 extension_state_map[*id].enabled_state = ExtensionState::PENDING;
217 extension_state_map[*id].incognito_enabled = 218 extension_state_map[*id].incognito_enabled =
218 extension_service->IsIncognitoEnabled(*id); 219 extension_util::IsIncognitoEnabled(*id, extension_service);
219 DVLOG(2) << "Extension " << *id << " in profile " 220 DVLOG(2) << "Extension " << *id << " in profile "
220 << profile_debug_name << " is pending"; 221 << profile_debug_name << " is pending";
221 } 222 }
222 223
223 return extension_state_map; 224 return extension_state_map;
224 } 225 }
225 226
226 bool SyncExtensionHelper::ExtensionStatesMatch( 227 bool SyncExtensionHelper::ExtensionStatesMatch(
227 Profile* profile1, Profile* profile2) { 228 Profile* profile1, Profile* profile2) {
228 const ExtensionStateMap& state_map1 = GetExtensionStates(profile1); 229 const ExtensionStateMap& state_map1 = GetExtensionStates(profile1);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 EXPECT_EQ(expected_id, extension->id()); 370 EXPECT_EQ(expected_id, extension->id());
370 return NULL; 371 return NULL;
371 } 372 }
372 DVLOG(2) << "created extension with name = " 373 DVLOG(2) << "created extension with name = "
373 << name << ", id = " << expected_id; 374 << name << ", id = " << expected_id;
374 (it->second)[name] = extension; 375 (it->second)[name] = extension;
375 id_to_name_[expected_id] = name; 376 id_to_name_[expected_id] = name;
376 id_to_type_[expected_id] = type; 377 id_to_type_[expected_id] = type;
377 return extension; 378 return extension;
378 } 379 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/user_script_master.cc ('k') | chrome/browser/ui/app_list/search/app_search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698