Chromium Code Reviews| Index: chrome/browser/ui/ash/context_menu.cc |
| diff --git a/chrome/browser/ui/ash/context_menu.cc b/chrome/browser/ui/ash/context_menu.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4edd3ec9d7aa2730c217c54fb825f31d86195dd |
| --- /dev/null |
| +++ b/chrome/browser/ui/ash/context_menu.cc |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2016 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/ash/context_menu.h" |
| + |
| +#include "ash/shelf/shelf_item_types.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/common/pref_names.h" |
| +#include "components/prefs/pref_service.h" |
| +#include "mojo/common/common_type_converters.h" |
| + |
| +ContextMenu::ContextMenu() {} |
| + |
| +ContextMenu::~ContextMenu() {} |
| + |
| +void ContextMenu::GetItemsAndInfo(uint32_t shelf_item_type, |
| + int32_t shelf_item_id, |
| + const GetItemsAndInfoCallback& callback) { |
| + Profile* profile = ProfileManager::GetActiveUserProfile(); |
| + const bool can_user_modify_shelf_auto_hide_behavior = |
| + profile->GetPrefs() |
| + ->FindPreference(prefs::kShelfAutoHideBehaviorLocal) |
| + ->IsUserModifiable(); |
| + const bool is_guest_session = profile->IsGuestSession(); |
| + |
| + // TODO(msw): Replace these test items with actual Chrome-provided items. |
| + mojo::Array<mash::shelf::mojom::ContextMenuItemPtr> items; |
| + if (shelf_item_id > 0) { |
| + mash::shelf::mojom::ContextMenuItemPtr test_item = |
| + mash::shelf::mojom::ContextMenuItem::New(); |
| + test_item->type = mash::shelf::mojom::ContextMenuItem::Type::ITEM; |
| + test_item->command_id = 990; |
|
sky
2016/03/18 20:30:57
I'm going to assume all this is temporary and not
|
| + test_item->label = mojo::String::From("CHROME TEST ITEM"); |
| + test_item->enabled = true; |
| + items.push_back(std::move(test_item)); |
| + |
| + mash::shelf::mojom::ContextMenuItemPtr test_check = |
| + mash::shelf::mojom::ContextMenuItem::New(); |
| + test_check->type = mash::shelf::mojom::ContextMenuItem::Type::CHECK; |
| + test_check->command_id = 991; |
| + test_check->label = mojo::String::From("CHROME TEST CHECK"); |
| + test_check->enabled = true; |
| + test_check->checked = true; |
| + items.push_back(std::move(test_check)); |
| + |
| + mash::shelf::mojom::ContextMenuItemPtr test_submenu = |
| + mash::shelf::mojom::ContextMenuItem::New(); |
| + test_submenu->type = mash::shelf::mojom::ContextMenuItem::Type::SUBMENU; |
| + test_submenu->command_id = 992; |
| + test_submenu->label = mojo::String::From("CHROME TEST SUBMENU"); |
| + test_submenu->enabled = true; |
| + |
| + mojo::Array<mash::shelf::mojom::ContextMenuItemPtr> test_submenu_items; |
| + int radio_group_id = 1; |
| + |
| + mash::shelf::mojom::ContextMenuItemPtr test_submenu_foo = |
| + mash::shelf::mojom::ContextMenuItem::New(); |
| + test_submenu_foo->type = mash::shelf::mojom::ContextMenuItem::Type::RADIO; |
| + test_submenu_foo->command_id = 993; |
| + test_submenu_foo->label = mojo::String::From("CHROME TEST RADIO FOO"); |
| + test_submenu_foo->enabled = true; |
| + test_submenu_foo->checked = true; |
| + test_submenu_foo->radio_group_id = radio_group_id; |
| + test_submenu_items.push_back(std::move(test_submenu_foo)); |
| + |
| + mash::shelf::mojom::ContextMenuItemPtr test_submenu_bar = |
| + mash::shelf::mojom::ContextMenuItem::New(); |
| + test_submenu_bar->type = mash::shelf::mojom::ContextMenuItem::Type::RADIO; |
| + test_submenu_bar->command_id = 994; |
| + test_submenu_bar->label = mojo::String::From("CHROME TEST RADIO BAR"); |
| + test_submenu_bar->enabled = true; |
| + test_submenu_bar->checked = false; |
| + test_submenu_bar->radio_group_id = radio_group_id; |
| + test_submenu_items.push_back(std::move(test_submenu_bar)); |
| + |
| + test_submenu->submenu = std::move(test_submenu_items); |
| + items.push_back(std::move(test_submenu)); |
| + |
| + mash::shelf::mojom::ContextMenuItemPtr test_separator = |
| + mash::shelf::mojom::ContextMenuItem::New(); |
| + test_separator->type = mash::shelf::mojom::ContextMenuItem::Type::SEPARATOR; |
| + items.push_back(std::move(test_separator)); |
| + } |
| + |
| + callback.Run(std::move(items), can_user_modify_shelf_auto_hide_behavior, |
| + is_guest_session); |
| +} |
| + |
| +void ContextMenu::ExecuteCommand(int32_t command_id, int32_t event_flags) { |
| + NOTIMPLEMENTED() << "Unknown command " << command_id; |
| +} |