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 "ash/shelf/app_list_shelf_item_delegate.h" | 5 #include "ash/shelf/app_list_shelf_item_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/strings/grit/ash_strings.h" | |
12 #include "base/memory/ptr_util.h" | |
13 #include "ui/app_list/app_list_switches.h" | |
14 #include "ui/base/l10n/l10n_util.h" | |
15 | 11 |
16 namespace ash { | 12 namespace ash { |
17 | 13 |
18 namespace { | |
19 | |
20 // An app id for the app list, used to identify the shelf item. | |
21 // Generated as crx_file::id_util::GenerateId("org.chromium.applist") | |
22 static constexpr char kAppListId[] = "jlfapfmkapbjlfbpjedlinehodkccjee"; | |
23 | |
24 } // namespace | |
25 | |
26 // static | |
27 void AppListShelfItemDelegate::CreateAppListItemAndDelegate(ShelfModel* model) { | |
28 // Add the app list item to the shelf model. | |
29 ShelfItem item; | |
30 item.type = TYPE_APP_LIST; | |
31 item.id = ShelfID(kAppListId); | |
32 item.title = l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); | |
33 int index = model->Add(item); | |
34 DCHECK_GE(index, 0); | |
35 | |
36 // Create an AppListShelfItemDelegate for that item. | |
37 model->SetShelfItemDelegate(item.id, | |
38 base::MakeUnique<AppListShelfItemDelegate>()); | |
39 } | |
40 | |
41 AppListShelfItemDelegate::AppListShelfItemDelegate() | 14 AppListShelfItemDelegate::AppListShelfItemDelegate() |
42 : ShelfItemDelegate(ShelfID(kAppListId)) {} | 15 : ShelfItemDelegate(ShelfID(kAppListId)) {} |
43 | 16 |
44 AppListShelfItemDelegate::~AppListShelfItemDelegate() {} | 17 AppListShelfItemDelegate::~AppListShelfItemDelegate() {} |
45 | 18 |
46 void AppListShelfItemDelegate::ItemSelected(std::unique_ptr<ui::Event> event, | 19 void AppListShelfItemDelegate::ItemSelected(std::unique_ptr<ui::Event> event, |
47 int64_t display_id, | 20 int64_t display_id, |
48 ShelfLaunchSource source, | 21 ShelfLaunchSource source, |
49 ItemSelectedCallback callback) { | 22 ItemSelectedCallback callback) { |
50 Shell::Get()->ToggleAppList(); | 23 Shell::Get()->ToggleAppList(); |
51 std::move(callback).Run(SHELF_ACTION_APP_LIST_SHOWN, base::nullopt); | 24 std::move(callback).Run(SHELF_ACTION_APP_LIST_SHOWN, base::nullopt); |
52 } | 25 } |
53 | 26 |
54 void AppListShelfItemDelegate::ExecuteCommand(uint32_t command_id, | 27 void AppListShelfItemDelegate::ExecuteCommand(uint32_t command_id, |
55 int32_t event_flags) { | 28 int32_t event_flags) { |
56 // This delegate does not support showing an application menu. | 29 // This delegate does not support showing an application menu. |
57 NOTIMPLEMENTED(); | 30 NOTIMPLEMENTED(); |
58 } | 31 } |
59 | 32 |
60 void AppListShelfItemDelegate::Close() {} | 33 void AppListShelfItemDelegate::Close() {} |
61 | 34 |
62 } // namespace ash | 35 } // namespace ash |
OLD | NEW |