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_sorting.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/string_ordinal.h" | 13 #include "chrome/common/string_ordinal.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 struct AppState { | 17 struct AppState { |
18 AppState(); | 18 AppState(); |
19 ~AppState(); | 19 ~AppState(); |
| 20 bool IsValid() const; |
20 bool Equals(const AppState& other) const; | 21 bool Equals(const AppState& other) const; |
21 | 22 |
22 StringOrdinal app_launch_ordinal; | 23 StringOrdinal app_launch_ordinal; |
23 StringOrdinal page_ordinal; | 24 StringOrdinal page_ordinal; |
24 }; | 25 }; |
25 | 26 |
26 typedef std::map<std::string, AppState> AppStateMap; | 27 typedef std::map<std::string, AppState> AppStateMap; |
27 | 28 |
28 AppState::AppState() {} | 29 AppState::AppState() {} |
29 | 30 |
30 AppState::~AppState() {} | 31 AppState::~AppState() {} |
31 | 32 |
| 33 bool AppState::IsValid() const { |
| 34 return page_ordinal.IsValid() && app_launch_ordinal.IsValid(); |
| 35 } |
| 36 |
32 bool AppState::Equals(const AppState& other) const { | 37 bool AppState::Equals(const AppState& other) const { |
33 return app_launch_ordinal.Equal(other.app_launch_ordinal) && | 38 return app_launch_ordinal.Equal(other.app_launch_ordinal) && |
34 page_ordinal.Equal(other.page_ordinal); | 39 page_ordinal.Equal(other.page_ordinal); |
35 } | 40 } |
36 | 41 |
37 // Load all the app specific values for |id| into |app_state|. | 42 // Load all the app specific values for |id| into |app_state|. |
38 void LoadApp(ExtensionService* extension_service, | 43 void LoadApp(ExtensionService* extension_service, |
39 const std::string& id, | 44 const std::string& id, |
40 AppState* app_state) { | 45 AppState* app_state) { |
41 app_state->app_launch_ordinal = extension_service->GetAppLaunchOrdinal(id); | 46 app_state->app_launch_ordinal = extension_service->GetAppLaunchOrdinal(id); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return false; | 110 return false; |
106 } | 111 } |
107 | 112 |
108 AppStateMap::const_iterator it1 = state_map1.begin(); | 113 AppStateMap::const_iterator it1 = state_map1.begin(); |
109 AppStateMap::const_iterator it2 = state_map2.begin(); | 114 AppStateMap::const_iterator it2 = state_map2.begin(); |
110 while (it1 != state_map1.end()) { | 115 while (it1 != state_map1.end()) { |
111 if (it1->first != it2->first) { | 116 if (it1->first != it2->first) { |
112 DVLOG(2) << "Apps for profile " << profile1->GetDebugName() | 117 DVLOG(2) << "Apps for profile " << profile1->GetDebugName() |
113 << " do not match profile " << profile2->GetDebugName(); | 118 << " do not match profile " << profile2->GetDebugName(); |
114 return false; | 119 return false; |
| 120 } else if (!it1->second.IsValid()) { |
| 121 DVLOG(2) << "Apps for profile " << profile1->GetDebugName() |
| 122 << " are not valid."; |
| 123 return false; |
| 124 } else if (!it2->second.IsValid()) { |
| 125 DVLOG(2) << "Apps for profile " << profile2->GetDebugName() |
| 126 << " are not valid."; |
| 127 return false; |
115 } else if (!it1->second.Equals(it2->second)) { | 128 } else if (!it1->second.Equals(it2->second)) { |
116 DVLOG(2) << "App states for profile " << profile1->GetDebugName() | 129 DVLOG(2) << "App states for profile " << profile1->GetDebugName() |
117 << " do not match profile " << profile2->GetDebugName(); | 130 << " do not match profile " << profile2->GetDebugName(); |
118 return false; | 131 return false; |
119 } | 132 } |
120 ++it1; | 133 ++it1; |
121 ++it2; | 134 ++it2; |
122 } | 135 } |
123 | 136 |
124 return true; | 137 return true; |
(...skipping 29 matching lines...) Expand all Loading... |
154 } | 167 } |
155 | 168 |
156 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) { | 169 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) { |
157 profile->GetExtensionService()->extension_prefs()-> | 170 profile->GetExtensionService()->extension_prefs()-> |
158 extension_sorting()->FixNTPOrdinalCollisions(); | 171 extension_sorting()->FixNTPOrdinalCollisions(); |
159 } | 172 } |
160 | 173 |
161 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {} | 174 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {} |
162 | 175 |
163 SyncAppHelper::~SyncAppHelper() {} | 176 SyncAppHelper::~SyncAppHelper() {} |
OLD | NEW |