Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7166)

Unified Diff: chrome/browser/ui/app_list/recommended_apps.cc

Issue 874563003: Remove old HTML app list start page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/recommended_apps.cc
diff --git a/chrome/browser/ui/app_list/recommended_apps.cc b/chrome/browser/ui/app_list/recommended_apps.cc
deleted file mode 100644
index bc8e93734989c2300e157d9e88df42b88e5e7b8c..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/app_list/recommended_apps.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/app_list/recommended_apps.h"
-
-#include <algorithm>
-#include <vector>
-
-#include "base/bind.h"
-#include "chrome/browser/extensions/extension_ui_util.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/app_list/recommended_apps_observer.h"
-#include "extensions/browser/extension_prefs.h"
-#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/pref_names.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/extension_set.h"
-
-namespace app_list {
-
-namespace {
-
-struct AppSortInfo {
- AppSortInfo() : app(NULL) {}
- AppSortInfo(const extensions::Extension* app,
- const base::Time& last_launch_time)
- : app(app), last_launch_time(last_launch_time) {}
-
- const extensions::Extension* app;
- base::Time last_launch_time;
-};
-
-bool AppLaunchedMoreRecent(const AppSortInfo& app1, const AppSortInfo& app2) {
- return app1.last_launch_time > app2.last_launch_time;
-}
-
-} // namespace
-
-RecommendedApps::RecommendedApps(Profile* profile)
- : profile_(profile), extension_registry_observer_(this) {
- extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_);
- pref_change_registrar_.Init(prefs->pref_service());
- pref_change_registrar_.Add(extensions::pref_names::kExtensions,
- base::Bind(&RecommendedApps::Update,
- base::Unretained(this)));
- extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile));
- Update();
-}
-
-RecommendedApps::~RecommendedApps() {
-}
-
-void RecommendedApps::AddObserver(RecommendedAppsObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void RecommendedApps::RemoveObserver(RecommendedAppsObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void RecommendedApps::Update() {
- extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_);
-
- std::vector<AppSortInfo> sorted_apps;
- const extensions::ExtensionSet& extensions =
- extensions::ExtensionRegistry::Get(profile_)->enabled_extensions();
- for (extensions::ExtensionSet::const_iterator app = extensions.begin();
- app != extensions.end();
- ++app) {
- if (!extensions::ui_util::ShouldDisplayInAppLauncher(app->get(), profile_))
- continue;
-
- sorted_apps.push_back(
- AppSortInfo(app->get(), prefs->GetLastLaunchTime((*app)->id())));
- }
-
- std::sort(sorted_apps.begin(), sorted_apps.end(), &AppLaunchedMoreRecent);
-
- const size_t kMaxRecommendedApps = 4;
- sorted_apps.resize(std::min(kMaxRecommendedApps, sorted_apps.size()));
-
- Apps new_recommends;
- for (size_t i = 0; i < sorted_apps.size(); ++i)
- new_recommends.push_back(sorted_apps[i].app);
-
- const bool changed = apps_.size() != new_recommends.size() ||
- !std::equal(apps_.begin(), apps_.end(), new_recommends.begin());
- if (changed) {
- apps_.swap(new_recommends);
- FOR_EACH_OBSERVER(
- RecommendedAppsObserver, observers_, OnRecommendedAppsChanged());
- }
-}
-
-void RecommendedApps::OnExtensionWillBeInstalled(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension,
- bool is_update,
- bool from_ephemeral,
- const std::string& old_name) {
- Update();
-}
-
-void RecommendedApps::OnExtensionLoaded(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension) {
- Update();
-}
-
-void RecommendedApps::OnExtensionUnloaded(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension,
- extensions::UnloadedExtensionInfo::Reason reason) {
- Update();
-}
-
-void RecommendedApps::OnExtensionUninstalled(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension,
- extensions::UninstallReason reason) {
- Update();
-}
-
-} // namespace app_list
« no previous file with comments | « chrome/browser/ui/app_list/recommended_apps.h ('k') | chrome/browser/ui/app_list/recommended_apps_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698