| 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/ui/app_list/apps_model_builder.h" |    5 #include "chrome/browser/ui/app_list/apps_model_builder.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/auto_reset.h" |   10 #include "base/auto_reset.h" | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   50   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |   50   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 
|   51       content::Source<Profile>(profile_)); |   51       content::Source<Profile>(profile_)); | 
|   52   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |   52   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 
|   53       content::Source<Profile>(profile_)); |   53       content::Source<Profile>(profile_)); | 
|   54   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |   54   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 
|   55       content::Source<ExtensionSorting>(extension_prefs->extension_sorting())); |   55       content::Source<ExtensionSorting>(extension_prefs->extension_sorting())); | 
|   56   registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, |   56   registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, | 
|   57       content::Source<Profile>(profile_)); |   57       content::Source<Profile>(profile_)); | 
|   58  |   58  | 
|   59   pref_change_registrar_.Init(extension_prefs->pref_service()); |   59   pref_change_registrar_.Init(extension_prefs->pref_service()); | 
|   60   pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, this); |   60   pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, | 
 |   61                              base::Bind(&AppsModelBuilder::ResortApps, | 
 |   62                                         base::Unretained(this))); | 
|   61  |   63  | 
|   62   model_->AddObserver(this); |   64   model_->AddObserver(this); | 
|   63 } |   65 } | 
|   64  |   66  | 
|   65 AppsModelBuilder::~AppsModelBuilder() { |   67 AppsModelBuilder::~AppsModelBuilder() { | 
|   66   model_->RemoveObserver(this); |   68   model_->RemoveObserver(this); | 
|   67 } |   69 } | 
|   68  |   70  | 
|   69 void AppsModelBuilder::Build() { |   71 void AppsModelBuilder::Build() { | 
|   70   DCHECK(model_ && model_->item_count() == 0); |   72   DCHECK(model_ && model_->item_count() == 0); | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  206     case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { |  208     case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { | 
|  207       highlight_app_id_ = *content::Details<const std::string>(details).ptr(); |  209       highlight_app_id_ = *content::Details<const std::string>(details).ptr(); | 
|  208       HighlightApp(); |  210       HighlightApp(); | 
|  209       break; |  211       break; | 
|  210     } |  212     } | 
|  211     default: |  213     default: | 
|  212       NOTREACHED(); |  214       NOTREACHED(); | 
|  213   } |  215   } | 
|  214 } |  216 } | 
|  215  |  217  | 
|  216 void AppsModelBuilder::OnPreferenceChanged(PrefServiceBase* service, |  | 
|  217                                            const std::string& pref_name) { |  | 
|  218   ResortApps(); |  | 
|  219 } |  | 
|  220  |  | 
|  221 void AppsModelBuilder::ListItemsAdded(size_t start, size_t count) { |  218 void AppsModelBuilder::ListItemsAdded(size_t start, size_t count) { | 
|  222 } |  219 } | 
|  223  |  220  | 
|  224 void AppsModelBuilder::ListItemsRemoved(size_t start, size_t count) { |  221 void AppsModelBuilder::ListItemsRemoved(size_t start, size_t count) { | 
|  225 } |  222 } | 
|  226  |  223  | 
|  227 void AppsModelBuilder::ListItemMoved(size_t index, size_t target_index) { |  224 void AppsModelBuilder::ListItemMoved(size_t index, size_t target_index) { | 
|  228   if (ignore_changes_) |  225   if (ignore_changes_) | 
|  229     return; |  226     return; | 
|  230  |  227  | 
|  231   ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; |  228   ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; | 
|  232   ExtensionAppItem* next = target_index + 1 < model_->item_count() ? |  229   ExtensionAppItem* next = target_index + 1 < model_->item_count() ? | 
|  233       GetAppAt(target_index + 1) : NULL; |  230       GetAppAt(target_index + 1) : NULL; | 
|  234   GetAppAt(target_index)->Move(prev, next); |  231   GetAppAt(target_index)->Move(prev, next); | 
|  235 } |  232 } | 
|  236  |  233  | 
|  237 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { |  234 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { | 
|  238   NOTREACHED(); |  235   NOTREACHED(); | 
|  239 } |  236 } | 
| OLD | NEW |