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

Side by Side Diff: chrome/browser/ui/ash/context_menu.cc

Issue 1760743002: Add simple mash context menu support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; use test items; cleanup. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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/ash/context_menu.h"
6
7 #include "ash/shelf/shelf_item_types.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/common/pref_names.h"
11 #include "components/prefs/pref_service.h"
12 #include "mojo/common/common_type_converters.h"
13
14 ContextMenu::ContextMenu() {}
15
16 ContextMenu::~ContextMenu() {}
17
18 void ContextMenu::GetItemsAndInfo(uint32_t shelf_item_type,
19 int32_t shelf_item_id,
20 const GetItemsAndInfoCallback& callback) {
21 Profile* profile = ProfileManager::GetActiveUserProfile();
22 const bool can_user_modify_shelf_auto_hide_behavior =
23 profile->GetPrefs()
24 ->FindPreference(prefs::kShelfAutoHideBehaviorLocal)
25 ->IsUserModifiable();
26 const bool is_guest_session = profile->IsGuestSession();
27
28 // TODO(msw): Replace these test items with actual Chrome-provided items.
29 mojo::Array<mash::shelf::mojom::ContextMenuItemPtr> items;
30 if (shelf_item_id > 0) {
31 mash::shelf::mojom::ContextMenuItemPtr test_item =
32 mash::shelf::mojom::ContextMenuItem::New();
33 test_item->type = mash::shelf::mojom::ContextMenuItem::Type::ITEM;
34 test_item->command_id = 990;
sky 2016/03/18 20:30:57 I'm going to assume all this is temporary and not
35 test_item->label = mojo::String::From("CHROME TEST ITEM");
36 test_item->enabled = true;
37 items.push_back(std::move(test_item));
38
39 mash::shelf::mojom::ContextMenuItemPtr test_check =
40 mash::shelf::mojom::ContextMenuItem::New();
41 test_check->type = mash::shelf::mojom::ContextMenuItem::Type::CHECK;
42 test_check->command_id = 991;
43 test_check->label = mojo::String::From("CHROME TEST CHECK");
44 test_check->enabled = true;
45 test_check->checked = true;
46 items.push_back(std::move(test_check));
47
48 mash::shelf::mojom::ContextMenuItemPtr test_submenu =
49 mash::shelf::mojom::ContextMenuItem::New();
50 test_submenu->type = mash::shelf::mojom::ContextMenuItem::Type::SUBMENU;
51 test_submenu->command_id = 992;
52 test_submenu->label = mojo::String::From("CHROME TEST SUBMENU");
53 test_submenu->enabled = true;
54
55 mojo::Array<mash::shelf::mojom::ContextMenuItemPtr> test_submenu_items;
56 int radio_group_id = 1;
57
58 mash::shelf::mojom::ContextMenuItemPtr test_submenu_foo =
59 mash::shelf::mojom::ContextMenuItem::New();
60 test_submenu_foo->type = mash::shelf::mojom::ContextMenuItem::Type::RADIO;
61 test_submenu_foo->command_id = 993;
62 test_submenu_foo->label = mojo::String::From("CHROME TEST RADIO FOO");
63 test_submenu_foo->enabled = true;
64 test_submenu_foo->checked = true;
65 test_submenu_foo->radio_group_id = radio_group_id;
66 test_submenu_items.push_back(std::move(test_submenu_foo));
67
68 mash::shelf::mojom::ContextMenuItemPtr test_submenu_bar =
69 mash::shelf::mojom::ContextMenuItem::New();
70 test_submenu_bar->type = mash::shelf::mojom::ContextMenuItem::Type::RADIO;
71 test_submenu_bar->command_id = 994;
72 test_submenu_bar->label = mojo::String::From("CHROME TEST RADIO BAR");
73 test_submenu_bar->enabled = true;
74 test_submenu_bar->checked = false;
75 test_submenu_bar->radio_group_id = radio_group_id;
76 test_submenu_items.push_back(std::move(test_submenu_bar));
77
78 test_submenu->submenu = std::move(test_submenu_items);
79 items.push_back(std::move(test_submenu));
80
81 mash::shelf::mojom::ContextMenuItemPtr test_separator =
82 mash::shelf::mojom::ContextMenuItem::New();
83 test_separator->type = mash::shelf::mojom::ContextMenuItem::Type::SEPARATOR;
84 items.push_back(std::move(test_separator));
85 }
86
87 callback.Run(std::move(items), can_user_modify_shelf_auto_hide_behavior,
88 is_guest_session);
89 }
90
91 void ContextMenu::ExecuteCommand(int32_t command_id, int32_t event_flags) {
92 NOTIMPLEMENTED() << "Unknown command " << command_id;
93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698