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

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

Issue 93883004: Sync the launch type pref for apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test for invalid value, make tests actually check things Created 6 years, 11 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
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/extension_system.h" 8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/extensions/launch_util.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/extensions_helper.h" 11 #include "chrome/browser/sync/test/integration/extensions_helper.h"
11 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 12 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
12 #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/extensions/extension_constants.h"
13 #include "chrome/common/extensions/sync_helper.h" 15 #include "chrome/common/extensions/sync_helper.h"
14 #include "extensions/browser/app_sorting.h" 16 #include "extensions/browser/app_sorting.h"
15 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
16 #include "extensions/common/extension_set.h" 18 #include "extensions/common/extension_set.h"
17 #include "extensions/common/id_util.h" 19 #include "extensions/common/id_util.h"
18 20
19 namespace { 21 namespace {
20 22
21 struct AppState { 23 struct AppState {
22 AppState(); 24 AppState();
23 ~AppState(); 25 ~AppState();
24 bool IsValid() const; 26 bool IsValid() const;
25 bool Equals(const AppState& other) const; 27 bool Equals(const AppState& other) const;
26 28
27 syncer::StringOrdinal app_launch_ordinal; 29 syncer::StringOrdinal app_launch_ordinal;
28 syncer::StringOrdinal page_ordinal; 30 syncer::StringOrdinal page_ordinal;
31 extensions::LaunchType launch_type;
29 }; 32 };
30 33
31 typedef std::map<std::string, AppState> AppStateMap; 34 typedef std::map<std::string, AppState> AppStateMap;
32 35
33 AppState::AppState() {} 36 AppState::AppState() : launch_type(extensions::LAUNCH_TYPE_INVALID) {}
34 37
35 AppState::~AppState() {} 38 AppState::~AppState() {}
36 39
37 bool AppState::IsValid() const { 40 bool AppState::IsValid() const {
38 return page_ordinal.IsValid() && app_launch_ordinal.IsValid(); 41 return page_ordinal.IsValid() && app_launch_ordinal.IsValid();
39 } 42 }
40 43
41 bool AppState::Equals(const AppState& other) const { 44 bool AppState::Equals(const AppState& other) const {
42 return app_launch_ordinal.Equals(other.app_launch_ordinal) && 45 return app_launch_ordinal.Equals(other.app_launch_ordinal) &&
43 page_ordinal.Equals(other.page_ordinal); 46 page_ordinal.Equals(other.page_ordinal) &&
47 launch_type == other.launch_type;
44 } 48 }
45 49
46 // Load all the app specific values for |id| into |app_state|. 50 // Load all the app specific values for |id| into |app_state|.
47 void LoadApp(ExtensionService* extension_service, 51 void LoadApp(ExtensionService* extension_service,
48 const std::string& id, 52 const std::string& id,
49 AppState* app_state) { 53 AppState* app_state) {
50 app_state->app_launch_ordinal = extension_service->extension_prefs()-> 54 app_state->app_launch_ordinal = extension_service->extension_prefs()->
51 app_sorting()->GetAppLaunchOrdinal(id); 55 app_sorting()->GetAppLaunchOrdinal(id);
52 app_state->page_ordinal = extension_service->extension_prefs()-> 56 app_state->page_ordinal = extension_service->extension_prefs()->
53 app_sorting()->GetPageOrdinal(id); 57 app_sorting()->GetPageOrdinal(id);
58 app_state->launch_type =
59 extensions::GetLaunchTypePrefValue(extension_service->extension_prefs(),
60 id);
54 } 61 }
55 62
56 // Returns a map from |profile|'s installed extensions to their state. 63 // Returns a map from |profile|'s installed extensions to their state.
57 AppStateMap GetAppStates(Profile* profile) { 64 AppStateMap GetAppStates(Profile* profile) {
58 AppStateMap app_state_map; 65 AppStateMap app_state_map;
59 66
60 ExtensionService* extension_service = profile->GetExtensionService(); 67 ExtensionService* extension_service = profile->GetExtensionService();
61 68
62 scoped_ptr<const extensions::ExtensionSet> extensions( 69 scoped_ptr<const extensions::ExtensionSet> extensions(
63 extension_service->GenerateInstalledExtensionsSet()); 70 extension_service->GenerateInstalledExtensionsSet());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 184 }
178 185
179 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) { 186 void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) {
180 profile->GetExtensionService()->extension_prefs()->app_sorting()-> 187 profile->GetExtensionService()->extension_prefs()->app_sorting()->
181 FixNTPOrdinalCollisions(); 188 FixNTPOrdinalCollisions();
182 } 189 }
183 190
184 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {} 191 SyncAppHelper::SyncAppHelper() : setup_completed_(false) {}
185 192
186 SyncAppHelper::~SyncAppHelper() {} 193 SyncAppHelper::~SyncAppHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698