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

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

Issue 1419823011: app_sorting() calls should go via ExtensionSystem intsead of prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 1 month 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
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_app_helper.h" 5 #include "chrome/browser/sync/test/integration/sync_app_helper.h"
6 6
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/launch_util.h" 8 #include "chrome/browser/extensions/launch_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/extensions_helper.h" 10 #include "chrome/browser/sync/test/integration/extensions_helper.h"
11 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 11 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
12 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" 12 #include "chrome/browser/sync/test/integration/sync_extension_helper.h"
13 #include "chrome/common/extensions/extension_constants.h" 13 #include "chrome/common/extensions/extension_constants.h"
14 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 14 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
15 #include "chrome/common/extensions/sync_helper.h" 15 #include "chrome/common/extensions/sync_helper.h"
16 #include "components/crx_file/id_util.h" 16 #include "components/crx_file/id_util.h"
17 #include "extensions/browser/app_sorting.h" 17 #include "extensions/browser/app_sorting.h"
18 #include "extensions/browser/extension_prefs.h" 18 #include "extensions/browser/extension_prefs.h"
19 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
20 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
21 #include "extensions/common/extension_set.h" 21 #include "extensions/common/extension_set.h"
22 22
23 using extensions::AppSorting;
23 using extensions::ExtensionPrefs; 24 using extensions::ExtensionPrefs;
25 using extensions::ExtensionSystem;
24 26
25 namespace { 27 namespace {
26 28
27 struct AppState { 29 struct AppState {
28 AppState(); 30 AppState();
29 ~AppState(); 31 ~AppState();
30 bool IsValid() const; 32 bool IsValid() const;
31 bool Equals(const AppState& other) const; 33 bool Equals(const AppState& other) const;
32 34
33 syncer::StringOrdinal app_launch_ordinal; 35 syncer::StringOrdinal app_launch_ordinal;
(...skipping 23 matching lines...) Expand all
57 launch_web_url == other.launch_web_url && 59 launch_web_url == other.launch_web_url &&
58 description == other.description && name == other.name && 60 description == other.description && name == other.name &&
59 from_bookmark == other.from_bookmark; 61 from_bookmark == other.from_bookmark;
60 } 62 }
61 63
62 // Load all the app specific values for |id| into |app_state|. 64 // Load all the app specific values for |id| into |app_state|.
63 void LoadApp(content::BrowserContext* context, 65 void LoadApp(content::BrowserContext* context,
64 const std::string& id, 66 const std::string& id,
65 AppState* app_state) { 67 AppState* app_state) {
66 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); 68 ExtensionPrefs* prefs = ExtensionPrefs::Get(context);
67 app_state->app_launch_ordinal = prefs->app_sorting()->GetAppLaunchOrdinal(id); 69 AppSorting* app_sorting = ExtensionSystem::Get(context)->app_sorting();
68 app_state->page_ordinal = prefs->app_sorting()->GetPageOrdinal(id); 70 app_state->app_launch_ordinal = app_sorting->GetAppLaunchOrdinal(id);
71 app_state->page_ordinal = app_sorting->GetPageOrdinal(id);
69 app_state->launch_type = extensions::GetLaunchTypePrefValue(prefs, id); 72 app_state->launch_type = extensions::GetLaunchTypePrefValue(prefs, id);
70 ExtensionService* service = 73 ExtensionService* service =
71 extensions::ExtensionSystem::Get(context)->extension_service(); 74 extensions::ExtensionSystem::Get(context)->extension_service();
72 const extensions::Extension* extension = service->GetInstalledExtension(id); 75 const extensions::Extension* extension = service->GetInstalledExtension(id);
73 // GetInstalledExtension(id) returns null if |id| is for a pending extension. 76 // GetInstalledExtension(id) returns null if |id| is for a pending extension.
74 // In case of running tests against real backend servers, pending apps won't 77 // In case of running tests against real backend servers, pending apps won't
75 // be installed. 78 // be installed.
76 if (extension) { 79 if (extension) {
77 app_state->launch_web_url = 80 app_state->launch_web_url =
78 extensions::AppLaunchInfo::GetLaunchWebURL(extension); 81 extensions::AppLaunchInfo::GetLaunchWebURL(extension);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ++it1; 180 ++it1;
178 ++it2; 181 ++it2;
179 } 182 }
180 183
181 return true; 184 return true;
182 } 185 }
183 186
184 syncer::StringOrdinal SyncAppHelper::GetPageOrdinalForApp( 187 syncer::StringOrdinal SyncAppHelper::GetPageOrdinalForApp(
185 Profile* profile, 188 Profile* profile,
186 const std::string& name) { 189 const std::string& name) {
187 return ExtensionPrefs::Get(profile)->app_sorting()->GetPageOrdinal( 190 return ExtensionSystem::Get(profile)->app_sorting()->GetPageOrdinal(
188 crx_file::id_util::GenerateId(name)); 191 crx_file::id_util::GenerateId(name));
189 } 192 }
190 193
191 void SyncAppHelper::SetPageOrdinalForApp( 194 void SyncAppHelper::SetPageOrdinalForApp(
192 Profile* profile, 195 Profile* profile,
193 const std::string& name, 196 const std::string& name,
194 const syncer::StringOrdinal& page_ordinal) { 197 const syncer::StringOrdinal& page_ordinal) {
195 ExtensionPrefs::Get(profile)->app_sorting()->SetPageOrdinal( 198 ExtensionSystem::Get(profile)->app_sorting()->SetPageOrdinal(
196 crx_file::id_util::GenerateId(name), page_ordinal); 199 crx_file::id_util::GenerateId(name), page_ordinal);
197 } 200 }
198 201
199 syncer::StringOrdinal SyncAppHelper::GetAppLaunchOrdinalForApp( 202 syncer::StringOrdinal SyncAppHelper::GetAppLaunchOrdinalForApp(
200 Profile* profile, 203 Profile* profile,
201 const std::string& name) { 204 const std::string& name) {
202 return ExtensionPrefs::Get(profile)->app_sorting()->GetAppLaunchOrdinal( 205 return ExtensionSystem::Get(profile)->app_sorting()->GetAppLaunchOrdinal(
203 crx_file::id_util::GenerateId(name)); 206 crx_file::id_util::GenerateId(name));
204 } 207 }
205 208
206 void SyncAppHelper::SetAppLaunchOrdinalForApp( 209 void SyncAppHelper::SetAppLaunchOrdinalForApp(
207 Profile* profile, 210 Profile* profile,
208 const std::string& name, 211 const std::string& name,
209 const syncer::StringOrdinal& app_launch_ordinal) { 212 const syncer::StringOrdinal& app_launch_ordinal) {
210 ExtensionPrefs::Get(profile)->app_sorting()->SetAppLaunchOrdinal( 213 ExtensionSystem::Get(profile)->app_sorting()->SetAppLaunchOrdinal(
211 crx_file::id_util::GenerateId(name), app_launch_ordinal); 214 crx_file::id_util::GenerateId(name), app_launch_ordinal);
212 } 215 }
213 216
214 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) { 217 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) {
215 ExtensionPrefs::Get(profile)->app_sorting()->FixNTPOrdinalCollisions(); 218 ExtensionSystem::Get(profile)->app_sorting()->FixNTPOrdinalCollisions();
216 } 219 }
217 220
218 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {} 221 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {}
219 222
220 SyncAppHelper::~SyncAppHelper() {} 223 SyncAppHelper::~SyncAppHelper() {}
OLDNEW
« no previous file with comments | « chrome/browser/extensions/install_tracker.cc ('k') | chrome/browser/sync/test/integration/sync_app_list_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698