OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/ui/app_list/app_list_syncable_service.h" | 5 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "chrome/browser/apps/drive/drive_app_provider.h" | 9 #include "chrome/browser/apps/drive/drive_app_provider.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 class AppListSyncableService::ModelObserver : public AppListModelObserver { | 178 class AppListSyncableService::ModelObserver : public AppListModelObserver { |
179 public: | 179 public: |
180 explicit ModelObserver(AppListSyncableService* owner) | 180 explicit ModelObserver(AppListSyncableService* owner) |
181 : owner_(owner), | 181 : owner_(owner), |
182 adding_item_(NULL) { | 182 adding_item_(NULL) { |
183 DVLOG(2) << owner_ << ": ModelObserver Added"; | 183 DVLOG(2) << owner_ << ": ModelObserver Added"; |
184 owner_->model()->AddObserver(this); | 184 owner_->model()->AddObserver(this); |
185 } | 185 } |
186 | 186 |
187 virtual ~ModelObserver() { | 187 ~ModelObserver() override { |
188 owner_->model()->RemoveObserver(this); | 188 owner_->model()->RemoveObserver(this); |
189 DVLOG(2) << owner_ << ": ModelObserver Removed"; | 189 DVLOG(2) << owner_ << ": ModelObserver Removed"; |
190 } | 190 } |
191 | 191 |
192 private: | 192 private: |
193 // AppListModelObserver | 193 // AppListModelObserver |
194 virtual void OnAppListItemAdded(AppListItem* item) override { | 194 void OnAppListItemAdded(AppListItem* item) override { |
195 DCHECK(!adding_item_); | 195 DCHECK(!adding_item_); |
196 adding_item_ = item; // Ignore updates while adding an item. | 196 adding_item_ = item; // Ignore updates while adding an item. |
197 VLOG(2) << owner_ << " OnAppListItemAdded: " << item->ToDebugString(); | 197 VLOG(2) << owner_ << " OnAppListItemAdded: " << item->ToDebugString(); |
198 owner_->AddOrUpdateFromSyncItem(item); | 198 owner_->AddOrUpdateFromSyncItem(item); |
199 adding_item_ = NULL; | 199 adding_item_ = NULL; |
200 } | 200 } |
201 | 201 |
202 virtual void OnAppListItemWillBeDeleted(AppListItem* item) override { | 202 void OnAppListItemWillBeDeleted(AppListItem* item) override { |
203 DCHECK(!adding_item_); | 203 DCHECK(!adding_item_); |
204 VLOG(2) << owner_ << " OnAppListItemDeleted: " << item->ToDebugString(); | 204 VLOG(2) << owner_ << " OnAppListItemDeleted: " << item->ToDebugString(); |
205 // Don't sync folder removal in case the folder still exists on another | 205 // Don't sync folder removal in case the folder still exists on another |
206 // device (e.g. with device specific items in it). Empty folders will be | 206 // device (e.g. with device specific items in it). Empty folders will be |
207 // deleted when the last item is removed (in PruneEmptySyncFolders()). | 207 // deleted when the last item is removed (in PruneEmptySyncFolders()). |
208 if (item->GetItemType() == AppListFolderItem::kItemType) | 208 if (item->GetItemType() == AppListFolderItem::kItemType) |
209 return; | 209 return; |
210 owner_->RemoveSyncItem(item->id()); | 210 owner_->RemoveSyncItem(item->id()); |
211 } | 211 } |
212 | 212 |
213 virtual void OnAppListItemUpdated(AppListItem* item) override { | 213 void OnAppListItemUpdated(AppListItem* item) override { |
214 if (adding_item_) { | 214 if (adding_item_) { |
215 // Adding an item may trigger update notifications which should be | 215 // Adding an item may trigger update notifications which should be |
216 // ignored. | 216 // ignored. |
217 DCHECK_EQ(adding_item_, item); | 217 DCHECK_EQ(adding_item_, item); |
218 return; | 218 return; |
219 } | 219 } |
220 VLOG(2) << owner_ << " OnAppListItemUpdated: " << item->ToDebugString(); | 220 VLOG(2) << owner_ << " OnAppListItemUpdated: " << item->ToDebugString(); |
221 owner_->UpdateSyncItem(item); | 221 owner_->UpdateSyncItem(item); |
222 } | 222 } |
223 | 223 |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 } else { | 993 } else { |
994 res += " { " + item_name + " }"; | 994 res += " { " + item_name + " }"; |
995 res += " [" + item_ordinal.ToDebugString() + "]"; | 995 res += " [" + item_ordinal.ToDebugString() + "]"; |
996 if (!parent_id.empty()) | 996 if (!parent_id.empty()) |
997 res += " <" + parent_id.substr(0, 8) + ">"; | 997 res += " <" + parent_id.substr(0, 8) + ">"; |
998 } | 998 } |
999 return res; | 999 return res; |
1000 } | 1000 } |
1001 | 1001 |
1002 } // namespace app_list | 1002 } // namespace app_list |
OLD | NEW |