| 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_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/extension_sorting.h" |
| 8 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/browser/extensions/extension_sorting.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/sync/test/integration/extensions_helper.h" | 11 #include "chrome/browser/sync/test/integration/extensions_helper.h" |
| 12 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 12 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 13 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" | 13 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" |
| 14 #include "chrome/common/string_ordinal.h" | |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 struct AppState { | 17 struct AppState { |
| 19 AppState(); | 18 AppState(); |
| 20 ~AppState(); | 19 ~AppState(); |
| 21 bool IsValid() const; | 20 bool IsValid() const; |
| 22 bool Equals(const AppState& other) const; | 21 bool Equals(const AppState& other) const; |
| 23 | 22 |
| 24 StringOrdinal app_launch_ordinal; | 23 syncer::StringOrdinal app_launch_ordinal; |
| 25 StringOrdinal page_ordinal; | 24 syncer::StringOrdinal page_ordinal; |
| 26 }; | 25 }; |
| 27 | 26 |
| 28 typedef std::map<std::string, AppState> AppStateMap; | 27 typedef std::map<std::string, AppState> AppStateMap; |
| 29 | 28 |
| 30 AppState::AppState() {} | 29 AppState::AppState() {} |
| 31 | 30 |
| 32 AppState::~AppState() {} | 31 AppState::~AppState() {} |
| 33 | 32 |
| 34 bool AppState::IsValid() const { | 33 bool AppState::IsValid() const { |
| 35 return page_ordinal.IsValid() && app_launch_ordinal.IsValid(); | 34 return page_ordinal.IsValid() && app_launch_ordinal.IsValid(); |
| 36 } | 35 } |
| 37 | 36 |
| 38 bool AppState::Equals(const AppState& other) const { | 37 bool AppState::Equals(const AppState& other) const { |
| 39 return app_launch_ordinal.Equal(other.app_launch_ordinal) && | 38 return app_launch_ordinal.Equals(other.app_launch_ordinal) && |
| 40 page_ordinal.Equal(other.page_ordinal); | 39 page_ordinal.Equals(other.page_ordinal); |
| 41 } | 40 } |
| 42 | 41 |
| 43 // Load all the app specific values for |id| into |app_state|. | 42 // Load all the app specific values for |id| into |app_state|. |
| 44 void LoadApp(ExtensionService* extension_service, | 43 void LoadApp(ExtensionService* extension_service, |
| 45 const std::string& id, | 44 const std::string& id, |
| 46 AppState* app_state) { | 45 AppState* app_state) { |
| 47 app_state->app_launch_ordinal = extension_service->extension_prefs()-> | 46 app_state->app_launch_ordinal = extension_service->extension_prefs()-> |
| 48 extension_sorting()->GetAppLaunchOrdinal(id); | 47 extension_sorting()->GetAppLaunchOrdinal(id); |
| 49 app_state->page_ordinal = extension_service->extension_prefs()-> | 48 app_state->page_ordinal = extension_service->extension_prefs()-> |
| 50 extension_sorting()->GetPageOrdinal(id); | 49 extension_sorting()->GetPageOrdinal(id); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 << " do not match profile " << profile2->GetDebugName(); | 134 << " do not match profile " << profile2->GetDebugName(); |
| 136 return false; | 135 return false; |
| 137 } | 136 } |
| 138 ++it1; | 137 ++it1; |
| 139 ++it2; | 138 ++it2; |
| 140 } | 139 } |
| 141 | 140 |
| 142 return true; | 141 return true; |
| 143 } | 142 } |
| 144 | 143 |
| 145 StringOrdinal SyncAppHelper::GetPageOrdinalForApp(Profile* profile, | 144 syncer::StringOrdinal SyncAppHelper::GetPageOrdinalForApp( |
| 146 const std::string& name) { | 145 Profile* profile, |
| 146 const std::string& name) { |
| 147 return profile->GetExtensionService()->extension_prefs()-> | 147 return profile->GetExtensionService()->extension_prefs()-> |
| 148 extension_sorting()->GetPageOrdinal(SyncExtensionHelper::NameToId(name)); | 148 extension_sorting()->GetPageOrdinal(SyncExtensionHelper::NameToId(name)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void SyncAppHelper::SetPageOrdinalForApp(Profile* profile, | 151 void SyncAppHelper::SetPageOrdinalForApp( |
| 152 const std::string& name, | 152 Profile* profile, |
| 153 const StringOrdinal& page_ordinal) { | 153 const std::string& name, |
| 154 const syncer::StringOrdinal& page_ordinal) { |
| 154 profile->GetExtensionService()->extension_prefs()->extension_sorting()-> | 155 profile->GetExtensionService()->extension_prefs()->extension_sorting()-> |
| 155 SetPageOrdinal(SyncExtensionHelper::NameToId(name), page_ordinal); | 156 SetPageOrdinal(SyncExtensionHelper::NameToId(name), page_ordinal); |
| 156 } | 157 } |
| 157 | 158 |
| 158 StringOrdinal SyncAppHelper::GetAppLaunchOrdinalForApp( | 159 syncer::StringOrdinal SyncAppHelper::GetAppLaunchOrdinalForApp( |
| 159 Profile* profile, | 160 Profile* profile, |
| 160 const std::string& name) { | 161 const std::string& name) { |
| 161 return profile->GetExtensionService()->extension_prefs()-> | 162 return profile->GetExtensionService()->extension_prefs()-> |
| 162 extension_sorting()->GetAppLaunchOrdinal( | 163 extension_sorting()->GetAppLaunchOrdinal( |
| 163 SyncExtensionHelper::NameToId(name)); | 164 SyncExtensionHelper::NameToId(name)); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void SyncAppHelper::SetAppLaunchOrdinalForApp( | 167 void SyncAppHelper::SetAppLaunchOrdinalForApp( |
| 167 Profile* profile, | 168 Profile* profile, |
| 168 const std::string& name, | 169 const std::string& name, |
| 169 const StringOrdinal& app_launch_ordinal) { | 170 const syncer::StringOrdinal& app_launch_ordinal) { |
| 170 profile->GetExtensionService()->extension_prefs()->extension_sorting()-> | 171 profile->GetExtensionService()->extension_prefs()->extension_sorting()-> |
| 171 SetAppLaunchOrdinal(SyncExtensionHelper::NameToId(name), | 172 SetAppLaunchOrdinal(SyncExtensionHelper::NameToId(name), |
| 172 app_launch_ordinal); | 173 app_launch_ordinal); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) { | 176 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) { |
| 176 profile->GetExtensionService()->extension_prefs()->extension_sorting()-> | 177 profile->GetExtensionService()->extension_prefs()->extension_sorting()-> |
| 177 FixNTPOrdinalCollisions(); | 178 FixNTPOrdinalCollisions(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {} | 181 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {} |
| 181 | 182 |
| 182 SyncAppHelper::~SyncAppHelper() {} | 183 SyncAppHelper::~SyncAppHelper() {} |
| OLD | NEW |