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

Side by Side Diff: chrome/browser/ui/app_list/chrome_app_list_item.cc

Issue 1507873006: Implement base class for app_list items. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove header Created 5 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/app_list/chrome_app_list_item.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/app_list/app_list_service.h"
9 #include "chrome/browser/ui/host_desktop.h"
10 #include "extensions/browser/app_sorting.h"
11 #include "extensions/browser/extension_system.h"
12 #include "ui/gfx/color_utils.h"
13 #include "ui/gfx/image/image_skia_operations.h"
14
15 // static
16 gfx::ImageSkia ChromeAppListItem::CreateDisabledIcon(
17 const gfx::ImageSkia& icon) {
18 const color_utils::HSL shift = {-1, 0, 0.6};
19 return gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift);
20 }
21
22 ChromeAppListItem::ChromeAppListItem(Profile* profile,
23 const std::string& app_id)
24 : app_list::AppListItem(app_id),
25 profile_(profile) {
26 }
27
28 ChromeAppListItem::~ChromeAppListItem() {
29 }
30
31 extensions::AppSorting* ChromeAppListItem::GetAppSorting() {
32 return extensions::ExtensionSystem::Get(profile())->app_sorting();
33 }
34
35 void ChromeAppListItem::UpdateFromSync(
36 const app_list::AppListSyncableService::SyncItem* sync_item) {
37 if (sync_item && sync_item->item_ordinal.IsValid()) {
38 // An existing synced position exists, use that.
39 set_position(sync_item->item_ordinal);
40 // Only set the name from the sync item if it is empty.
41 if (name().empty())
42 SetName(sync_item->item_name);
43 } else {
44 GetAppSorting()->EnsureValidOrdinals(id(), syncer::StringOrdinal());
xiyuan 2015/12/10 05:21:13 EnsureValidOrdinals() has side effects of updating
khmel1 2015/12/10 09:07:31 Yes, I see that is important. Reverted to original
45 UpdatePositionFromOrdering();
46 }
47 }
48
49 void ChromeAppListItem::UpdatePositionFromOrdering() {
50 const syncer::StringOrdinal& page =
51 GetAppSorting()->GetPageOrdinal(id());
52 const syncer::StringOrdinal& launch =
53 GetAppSorting()->GetAppLaunchOrdinal(id());
54 set_position(syncer::StringOrdinal(
55 page.ToInternalValue() + launch.ToInternalValue()));
56 }
57
58 AppListControllerDelegate* ChromeAppListItem::GetController() {
59 return AppListService::Get(chrome::GetActiveDesktop())->
60 GetControllerDelegate();
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698