OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 default: | 324 default: |
325 NOTREACHED(); | 325 NOTREACHED(); |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { | 329 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { |
330 // CreateAppInfo and ClearPageIndex can change the extension prefs. | 330 // CreateAppInfo and ClearPageIndex can change the extension prefs. |
331 AutoReset<bool> auto_reset(&ignore_changes_, true); | 331 AutoReset<bool> auto_reset(&ignore_changes_, true); |
332 | 332 |
333 ListValue* list = new ListValue(); | 333 ListValue* list = new ListValue(); |
334 const ExtensionList* extensions = extension_service_->extensions(); | 334 const ExtensionSet* extensions = extension_service_->extensions(); |
335 ExtensionList::const_iterator it; | 335 ExtensionSet::const_iterator it; |
336 for (it = extensions->begin(); it != extensions->end(); ++it) { | 336 for (it = extensions->begin(); it != extensions->end(); ++it) { |
337 if (!IsAppExcludedFromList(*it)) { | 337 const Extension* extension = *it; |
338 DictionaryValue* app_info = GetAppInfo(*it); | 338 if (!IsAppExcludedFromList(extension)) { |
| 339 DictionaryValue* app_info = GetAppInfo(extension); |
339 list->Append(app_info); | 340 list->Append(app_info); |
340 } else { | 341 } else { |
341 // This is necessary because in some previous versions of chrome, we set a | 342 // This is necessary because in some previous versions of chrome, we set a |
342 // page index for non-app extensions. Old profiles can persist this error, | 343 // page index for non-app extensions. Old profiles can persist this error, |
343 // and this fixes it. If we don't fix it, GetNaturalAppPageIndex() doesn't | 344 // and this fixes it. If we don't fix it, GetNaturalAppPageIndex() doesn't |
344 // work. See http://crbug.com/98325 | 345 // work. See http://crbug.com/98325 |
345 ExtensionPrefs* prefs = extension_service_->extension_prefs(); | 346 ExtensionPrefs* prefs = extension_service_->extension_prefs(); |
346 if (prefs->GetPageIndex((*it)->id()) != -1) | 347 if (prefs->GetPageIndex(extension->id()) != -1) |
347 prefs->ClearPageIndex((*it)->id()); | 348 prefs->ClearPageIndex(extension->id()); |
348 } | 349 } |
349 } | 350 } |
350 | 351 |
351 extensions = extension_service_->disabled_extensions(); | 352 extensions = extension_service_->disabled_extensions(); |
352 for (it = extensions->begin(); it != extensions->end(); ++it) { | 353 for (it = extensions->begin(); it != extensions->end(); ++it) { |
353 if (!IsAppExcludedFromList(*it)) { | 354 if (!IsAppExcludedFromList(*it)) { |
354 DictionaryValue* app_info = new DictionaryValue(); | 355 DictionaryValue* app_info = new DictionaryValue(); |
355 CreateAppInfo(*it, | 356 CreateAppInfo(*it, |
356 NULL, | 357 NULL, |
357 extension_service_, | 358 extension_service_, |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 | 954 |
954 void AppLauncherHandler::UninstallDefaultApps() { | 955 void AppLauncherHandler::UninstallDefaultApps() { |
955 AppsPromo* apps_promo = extension_service_->apps_promo(); | 956 AppsPromo* apps_promo = extension_service_->apps_promo(); |
956 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 957 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
957 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 958 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
958 iter != app_ids.end(); ++iter) { | 959 iter != app_ids.end(); ++iter) { |
959 if (extension_service_->GetExtensionById(*iter, true)) | 960 if (extension_service_->GetExtensionById(*iter, true)) |
960 extension_service_->UninstallExtension(*iter, false, NULL); | 961 extension_service_->UninstallExtension(*iter, false, NULL); |
961 } | 962 } |
962 } | 963 } |
OLD | NEW |