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

Side by Side Diff: ash/mus/sysui/shelf_delegate_mus.cc

Issue 1684633002: ash/mash: Introduce a ShelfDelegate implementation for mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ash-sysui-window-container
Patch Set: self-nit Created 4 years, 10 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 "ash/mus/sysui/shelf_delegate_mus.h"
6
7 #include "ash/shelf/shelf_item_delegate.h"
8 #include "ash/shelf/shelf_item_delegate_manager.h"
9 #include "ash/shelf/shelf_model.h"
10 #include "ash/shell.h"
11 #include "base/strings/string_util.h"
12 #include "mojo/common/common_type_converters.h"
13 #include "mojo/shell/public/cpp/shell.h"
14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/resources/grit/ui_resources.h"
16 #include "ui/views/mus/window_manager_connection.h"
17
18 using mash::wm::mojom::UserWindowController;
19
20 namespace ash {
21 namespace sysui {
22
23 namespace {
24
25 class ShelfItemDelegateMus : public ShelfItemDelegate {
26 public:
27 ShelfItemDelegateMus(uint32_t window_id,
28 const base::string16& title,
29 UserWindowController* user_window_controller)
30 : window_id_(window_id),
31 title_(title),
32 user_window_controller_(user_window_controller) {}
33 ~ShelfItemDelegateMus() override {}
34
35 private:
36 // ShelfItemDelegate:
37 ShelfItemDelegate::PerformedAction ItemSelected(
38 const ui::Event& event) override {
39 user_window_controller_->FocusUserWindow(window_id_);
40 return kExistingWindowActivated;
41 }
42
43 base::string16 GetTitle() override { return title_; }
44
45 ui::MenuModel* CreateContextMenu(aura::Window* root_window) override {
46 NOTIMPLEMENTED();
47 return nullptr;
48 }
49
50 ShelfMenuModel* CreateApplicationMenu(int event_flags) override {
msw 2016/02/09 18:31:26 nit: follow base class ordering after CreateContex
sadrul 2016/02/10 08:04:41 Done.
51 NOTIMPLEMENTED();
52 return nullptr;
53 }
54
55 bool IsDraggable() override {
56 NOTIMPLEMENTED();
57 return false;
58 }
59
60 bool CanPin() const override {
61 NOTIMPLEMENTED();
62 return false;
63 }
64
65 bool ShouldShowTooltip() override {
66 // NOTIMPLEMENTED(); very noisy
67 return false;
68 }
69
70 void Close() override { NOTIMPLEMENTED(); }
71
72 // TODO(msw): Support multiple open windows per button.
73 uint32_t window_id_;
74 base::string16 title_;
75 UserWindowController* user_window_controller_;
76
77 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegateMus);
78 };
79
80 } // namespace
81
82 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model)
83 : model_(model), binding_(this) {
84 mojo::Shell* shell = views::WindowManagerConnection::Get()->shell();
85 shell->ConnectToService("mojo:desktop_wm", &user_window_controller_);
86 user_window_controller_->AddUserWindowObserver(
87 binding_.CreateInterfacePtrAndBind());
88 }
89
90 ShelfDelegateMus::~ShelfDelegateMus() {}
91
92 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) {
93 NOTIMPLEMENTED();
94 }
95
96 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) {
97 NOTIMPLEMENTED();
98 }
99
100 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) {
101 NOTIMPLEMENTED();
102 return 0;
103 }
104
105 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const {
106 NOTIMPLEMENTED();
107 return false;
108 }
109
110 const std::string& ShelfDelegateMus::GetAppIDForShelfID(ShelfID id) {
111 NOTIMPLEMENTED();
112 return base::EmptyString();
113 }
114
115 void ShelfDelegateMus::PinAppWithID(const std::string& app_id) {
116 NOTIMPLEMENTED();
117 }
118
119 bool ShelfDelegateMus::IsAppPinned(const std::string& app_id) {
120 NOTIMPLEMENTED();
121 return false;
122 }
123
124 void ShelfDelegateMus::UnpinAppWithID(const std::string& app_id) {
125 NOTIMPLEMENTED();
126 }
127
128 void ShelfDelegateMus::OnUserWindowObserverAdded(
129 mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) {
130 for (size_t i = 0; i < user_windows.size(); ++i)
131 OnUserWindowAdded(std::move(user_windows[i]));
132 }
133
134 void ShelfDelegateMus::OnUserWindowAdded(
135 mash::wm::mojom::UserWindowPtr user_window) {
136 ShelfItem item;
137 item.type = TYPE_PLATFORM_APP;
138 item.status = user_window->window_has_focus ? STATUS_ACTIVE : STATUS_RUNNING;
139 // TODO(msw): Support actual window icons.
140 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
141 item.image = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
142
143 ShelfID shelf_id = model_->next_id();
144 window_id_to_shelf_id_.insert(
145 std::make_pair(user_window->window_id, shelf_id));
146 model_->Add(item);
147
148 ShelfItemDelegateManager* manager =
149 Shell::GetInstance()->shelf_item_delegate_manager();
150 scoped_ptr<ShelfItemDelegate> delegate(new ShelfItemDelegateMus(
151 user_window->window_id, user_window->window_title.To<base::string16>(),
152 user_window_controller_.get()));
153 manager->SetShelfItemDelegate(shelf_id, std::move(delegate));
154 }
155
156 void ShelfDelegateMus::OnUserWindowRemoved(uint32_t window_id) {
157 DCHECK(window_id_to_shelf_id_.count(window_id));
158 model_->RemoveItemAt(
159 model_->ItemIndexByID(window_id_to_shelf_id_[window_id]));
160 }
161
162 void ShelfDelegateMus::OnUserWindowTitleChanged(
163 uint32_t window_id,
164 const mojo::String& window_title) {
165 NOTIMPLEMENTED();
msw 2016/02/09 18:31:26 Were my old title/focus change impls not easily co
sadrul 2016/02/10 08:04:41 ShelfItem in mash is slightly different from the S
166 }
167
168 void ShelfDelegateMus::OnUserWindowFocusChanged(uint32_t window_id,
169 bool has_focus) {
170 NOTIMPLEMENTED();
171 }
172
173 } // namespace sysui
174 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698