| 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_prefs.h" | 11 #include "chrome/browser/extensions/extension_prefs.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_system_factory.h" | 13 #include "chrome/browser/extensions/extension_system_factory.h" |
| 14 #include "chrome/browser/extensions/install_tracker.h" | 14 #include "chrome/browser/extensions/install_tracker.h" |
| 15 #include "chrome/browser/extensions/install_tracker_factory.h" | 15 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 16 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" | 16 #include "chrome/browser/ui/app_list/recommended_apps_observer.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
| 19 #include "extensions/common/extension_set.h" |
| 19 | 20 |
| 20 namespace app_list { | 21 namespace app_list { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 struct AppSortInfo { | 25 struct AppSortInfo { |
| 25 AppSortInfo() : app(NULL) {} | 26 AppSortInfo() : app(NULL) {} |
| 26 AppSortInfo(const extensions::Extension* app, | 27 AppSortInfo(const extensions::Extension* app, |
| 27 const base::Time& last_launch_time) | 28 const base::Time& last_launch_time) |
| 28 : app(app), last_launch_time(last_launch_time) {} | 29 : app(app), last_launch_time(last_launch_time) {} |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void RecommendedApps::RemoveObserver(RecommendedAppsObserver* observer) { | 64 void RecommendedApps::RemoveObserver(RecommendedAppsObserver* observer) { |
| 64 observers_.RemoveObserver(observer); | 65 observers_.RemoveObserver(observer); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void RecommendedApps::Update() { | 68 void RecommendedApps::Update() { |
| 68 ExtensionService* service = | 69 ExtensionService* service = |
| 69 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 70 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 70 extensions::ExtensionPrefs* prefs = service->extension_prefs(); | 71 extensions::ExtensionPrefs* prefs = service->extension_prefs(); |
| 71 | 72 |
| 72 std::vector<AppSortInfo> sorted_apps; | 73 std::vector<AppSortInfo> sorted_apps; |
| 73 const ExtensionSet* extensions = service->extensions(); | 74 const extensions::ExtensionSet* extensions = service->extensions(); |
| 74 for (ExtensionSet::const_iterator app = extensions->begin(); | 75 for (extensions::ExtensionSet::const_iterator app = extensions->begin(); |
| 75 app != extensions->end(); ++app) { | 76 app != extensions->end(); ++app) { |
| 76 if (!(*app)->ShouldDisplayInAppLauncher()) | 77 if (!(*app)->ShouldDisplayInAppLauncher()) |
| 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 128 } |
| 128 | 129 |
| 129 void RecommendedApps::OnAppsReordered() {} | 130 void RecommendedApps::OnAppsReordered() {} |
| 130 | 131 |
| 131 void RecommendedApps::OnAppInstalledToAppList( | 132 void RecommendedApps::OnAppInstalledToAppList( |
| 132 const std::string& extension_id) {} | 133 const std::string& extension_id) {} |
| 133 | 134 |
| 134 void RecommendedApps::OnShutdown() {} | 135 void RecommendedApps::OnShutdown() {} |
| 135 | 136 |
| 136 } // namespace app_list | 137 } // namespace app_list |
| OLD | NEW |