| 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/recommended_apps.h" | 5 #include "chrome/browser/ui/app_list/recommended_apps.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "chrome/browser/extensions/extension_ui_util.h" |
| 11 #include "chrome/browser/extensions/install_tracker.h" | 12 #include "chrome/browser/extensions/install_tracker.h" |
| 12 #include "chrome/browser/extensions/install_tracker_factory.h" | 13 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" | 15 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
| 17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 18 #include "extensions/browser/pref_names.h" | 19 #include "extensions/browser/pref_names.h" |
| 19 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 20 #include "extensions/common/extension_set.h" | 21 #include "extensions/common/extension_set.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 67 |
| 67 void RecommendedApps::Update() { | 68 void RecommendedApps::Update() { |
| 68 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); | 69 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); |
| 69 | 70 |
| 70 std::vector<AppSortInfo> sorted_apps; | 71 std::vector<AppSortInfo> sorted_apps; |
| 71 const extensions::ExtensionSet& extensions = | 72 const extensions::ExtensionSet& extensions = |
| 72 extensions::ExtensionRegistry::Get(profile_)->enabled_extensions(); | 73 extensions::ExtensionRegistry::Get(profile_)->enabled_extensions(); |
| 73 for (extensions::ExtensionSet::const_iterator app = extensions.begin(); | 74 for (extensions::ExtensionSet::const_iterator app = extensions.begin(); |
| 74 app != extensions.end(); | 75 app != extensions.end(); |
| 75 ++app) { | 76 ++app) { |
| 76 if (!(*app)->ShouldDisplayInAppLauncher()) | 77 if (!extensions::ui_util::ShouldDisplayInAppLauncher(*app, profile_)) |
| 77 continue; | 78 continue; |
| 78 | 79 |
| 79 sorted_apps.push_back( | 80 sorted_apps.push_back( |
| 80 AppSortInfo(app->get(), prefs->GetLastLaunchTime((*app)->id()))); | 81 AppSortInfo(app->get(), prefs->GetLastLaunchTime((*app)->id()))); |
| 81 } | 82 } |
| 82 | 83 |
| 83 std::sort(sorted_apps.begin(), sorted_apps.end(), &AppLaunchedMoreRecent); | 84 std::sort(sorted_apps.begin(), sorted_apps.end(), &AppLaunchedMoreRecent); |
| 84 | 85 |
| 85 const size_t kMaxRecommendedApps = 4; | 86 const size_t kMaxRecommendedApps = 4; |
| 86 sorted_apps.resize(std::min(kMaxRecommendedApps, sorted_apps.size())); | 87 sorted_apps.resize(std::min(kMaxRecommendedApps, sorted_apps.size())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 112 const extensions::Extension* extension) { | 113 const extensions::Extension* extension) { |
| 113 Update(); | 114 Update(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void RecommendedApps::OnExtensionUninstalled( | 117 void RecommendedApps::OnExtensionUninstalled( |
| 117 const extensions::Extension* extension) { | 118 const extensions::Extension* extension) { |
| 118 Update(); | 119 Update(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace app_list | 122 } // namespace app_list |
| OLD | NEW |