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

Side by Side Diff: chrome/browser/ui/app_list/model_pref_updater.cc

Issue 2430753002: Discard unused AppListPrefs code. (Closed)
Patch Set: update Created 4 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
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/app_list/model_pref_updater.h"
6
7 #include "build/build_config.h"
8 #include "chrome/browser/ui/app_list/app_list_prefs.h"
9 #include "chrome/browser/ui/app_list/extension_app_item.h"
10 #include "ui/app_list/app_list_folder_item.h"
11 #include "ui/app_list/app_list_item.h"
12 #include "ui/app_list/app_list_model.h"
13
14 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/ui/app_list/arc/arc_app_item.h"
16 #endif
17
18 namespace app_list {
19
20 ModelPrefUpdater::ModelPrefUpdater(AppListPrefs* app_list_prefs,
21 AppListModel* model)
22 : app_list_prefs_(app_list_prefs), model_(model) {
23 model_->AddObserver(this);
24 }
25
26 ModelPrefUpdater::~ModelPrefUpdater() {
27 model_->RemoveObserver(this);
28 }
29
30 void ModelPrefUpdater::OnAppListItemAdded(AppListItem* item) {
31 UpdatePrefsFromAppListItem(item);
32 }
33
34 void ModelPrefUpdater::OnAppListItemWillBeDeleted(AppListItem* item) {
35 app_list_prefs_->DeleteAppListInfo(item->id());
36 }
37
38 void ModelPrefUpdater::OnAppListItemUpdated(AppListItem* item) {
39 UpdatePrefsFromAppListItem(item);
40 }
41
42 void ModelPrefUpdater::UpdatePrefsFromAppListItem(AppListItem* item) {
43 // Write synced data to local pref.
44 AppListPrefs::AppListInfo info;
45 if (item->GetItemType() == AppListFolderItem::kItemType)
46 info.item_type = AppListPrefs::AppListInfo::FOLDER_ITEM;
47 else if (item->GetItemType() == ExtensionAppItem::kItemType)
48 info.item_type = AppListPrefs::AppListInfo::APP_ITEM;
49 #if defined(OS_CHROMEOS)
50 else if (item->GetItemType() == ArcAppItem::kItemType)
51 info.item_type = AppListPrefs::AppListInfo::APP_ITEM;
52 #endif
53 else
54 NOTREACHED();
55
56 info.parent_id = item->folder_id();
57 info.position = item->position();
58 info.name = item->name();
59
60 app_list_prefs_->SetAppListInfo(item->id(), info);
61 }
62
63 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/model_pref_updater.h ('k') | chrome/browser/ui/app_list/model_pref_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698