OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/chrome_app_list_item.h" | 5 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/app_list/app_list_service.h" | 8 #include "chrome/browser/ui/app_list/app_list_service.h" |
9 #include "chrome/browser/ui/host_desktop.h" | 9 #include "chrome/browser/ui/host_desktop.h" |
10 #include "extensions/browser/app_sorting.h" | 10 #include "extensions/browser/app_sorting.h" |
11 #include "extensions/browser/extension_system.h" | 11 #include "extensions/browser/extension_system.h" |
12 #include "ui/gfx/color_utils.h" | 12 #include "ui/gfx/color_utils.h" |
13 #include "ui/gfx/image/image_skia_operations.h" | 13 #include "ui/gfx/image/image_skia_operations.h" |
14 | 14 |
| 15 namespace { |
| 16 |
| 17 AppListControllerDelegate* g_controller_for_test = nullptr; |
| 18 |
| 19 } // namespace |
| 20 |
| 21 // static |
| 22 void ChromeAppListItem::OverrideAppListControllerDelegateForTesting( |
| 23 AppListControllerDelegate* controller) { |
| 24 g_controller_for_test = controller; |
| 25 } |
| 26 |
15 // static | 27 // static |
16 gfx::ImageSkia ChromeAppListItem::CreateDisabledIcon( | 28 gfx::ImageSkia ChromeAppListItem::CreateDisabledIcon( |
17 const gfx::ImageSkia& icon) { | 29 const gfx::ImageSkia& icon) { |
18 const color_utils::HSL shift = {-1, 0, 0.6}; | 30 const color_utils::HSL shift = {-1, 0, 0.6}; |
19 return gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift); | 31 return gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift); |
20 } | 32 } |
21 | 33 |
22 ChromeAppListItem::ChromeAppListItem(Profile* profile, | 34 ChromeAppListItem::ChromeAppListItem(Profile* profile, |
23 const std::string& app_id) | 35 const std::string& app_id) |
24 : app_list::AppListItem(app_id), | 36 : app_list::AppListItem(app_id), |
(...skipping 11 matching lines...) Expand all Loading... |
36 const app_list::AppListSyncableService::SyncItem* sync_item) { | 48 const app_list::AppListSyncableService::SyncItem* sync_item) { |
37 DCHECK(sync_item && sync_item->item_ordinal.IsValid()); | 49 DCHECK(sync_item && sync_item->item_ordinal.IsValid()); |
38 // An existing synced position exists, use that. | 50 // An existing synced position exists, use that. |
39 set_position(sync_item->item_ordinal); | 51 set_position(sync_item->item_ordinal); |
40 // Only set the name from the sync item if it is empty. | 52 // Only set the name from the sync item if it is empty. |
41 if (name().empty()) | 53 if (name().empty()) |
42 SetName(sync_item->item_name); | 54 SetName(sync_item->item_name); |
43 } | 55 } |
44 | 56 |
45 AppListControllerDelegate* ChromeAppListItem::GetController() { | 57 AppListControllerDelegate* ChromeAppListItem::GetController() { |
46 return AppListService::Get(chrome::GetActiveDesktop())-> | 58 return g_controller_for_test != nullptr ? |
47 GetControllerDelegate(); | 59 g_controller_for_test : |
| 60 AppListService::Get(chrome::GetActiveDesktop())->GetControllerDelegate(); |
48 } | 61 } |
OLD | NEW |