Chromium Code Reviews| Index: ash/mus/sysui/shelf_delegate_mus.cc |
| diff --git a/ash/mus/sysui/shelf_delegate_mus.cc b/ash/mus/sysui/shelf_delegate_mus.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..07621554bc30be76ed8869599c4effe5bf3b0743 |
| --- /dev/null |
| +++ b/ash/mus/sysui/shelf_delegate_mus.cc |
| @@ -0,0 +1,174 @@ |
| +// 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 "ash/mus/sysui/shelf_delegate_mus.h" |
| + |
| +#include "ash/shelf/shelf_item_delegate.h" |
| +#include "ash/shelf/shelf_item_delegate_manager.h" |
| +#include "ash/shelf/shelf_model.h" |
| +#include "ash/shell.h" |
| +#include "base/strings/string_util.h" |
| +#include "mojo/common/common_type_converters.h" |
| +#include "mojo/shell/public/cpp/shell.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/resources/grit/ui_resources.h" |
| +#include "ui/views/mus/window_manager_connection.h" |
| + |
| +using mash::wm::mojom::UserWindowController; |
| + |
| +namespace ash { |
| +namespace sysui { |
| + |
| +namespace { |
| + |
| +class ShelfItemDelegateMus : public ShelfItemDelegate { |
| + public: |
| + ShelfItemDelegateMus(uint32_t window_id, |
| + const base::string16& title, |
| + UserWindowController* user_window_controller) |
| + : window_id_(window_id), |
| + title_(title), |
| + user_window_controller_(user_window_controller) {} |
| + ~ShelfItemDelegateMus() override {} |
| + |
| + private: |
| + // ShelfItemDelegate: |
| + ShelfItemDelegate::PerformedAction ItemSelected( |
| + const ui::Event& event) override { |
| + user_window_controller_->FocusUserWindow(window_id_); |
| + return kExistingWindowActivated; |
| + } |
| + |
| + base::string16 GetTitle() override { return title_; } |
| + |
| + ui::MenuModel* CreateContextMenu(aura::Window* root_window) override { |
| + NOTIMPLEMENTED(); |
| + return nullptr; |
| + } |
| + |
| + 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.
|
| + NOTIMPLEMENTED(); |
| + return nullptr; |
| + } |
| + |
| + bool IsDraggable() override { |
| + NOTIMPLEMENTED(); |
| + return false; |
| + } |
| + |
| + bool CanPin() const override { |
| + NOTIMPLEMENTED(); |
| + return false; |
| + } |
| + |
| + bool ShouldShowTooltip() override { |
| + // NOTIMPLEMENTED(); very noisy |
| + return false; |
| + } |
| + |
| + void Close() override { NOTIMPLEMENTED(); } |
| + |
| + // TODO(msw): Support multiple open windows per button. |
| + uint32_t window_id_; |
| + base::string16 title_; |
| + UserWindowController* user_window_controller_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegateMus); |
| +}; |
| + |
| +} // namespace |
| + |
| +ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) |
| + : model_(model), binding_(this) { |
| + mojo::Shell* shell = views::WindowManagerConnection::Get()->shell(); |
| + shell->ConnectToService("mojo:desktop_wm", &user_window_controller_); |
| + user_window_controller_->AddUserWindowObserver( |
| + binding_.CreateInterfacePtrAndBind()); |
| +} |
| + |
| +ShelfDelegateMus::~ShelfDelegateMus() {} |
| + |
| +void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { |
| + NOTIMPLEMENTED(); |
| + return 0; |
| +} |
| + |
| +bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +const std::string& ShelfDelegateMus::GetAppIDForShelfID(ShelfID id) { |
| + NOTIMPLEMENTED(); |
| + return base::EmptyString(); |
| +} |
| + |
| +void ShelfDelegateMus::PinAppWithID(const std::string& app_id) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +bool ShelfDelegateMus::IsAppPinned(const std::string& app_id) { |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +void ShelfDelegateMus::UnpinAppWithID(const std::string& app_id) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void ShelfDelegateMus::OnUserWindowObserverAdded( |
| + mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) { |
| + for (size_t i = 0; i < user_windows.size(); ++i) |
| + OnUserWindowAdded(std::move(user_windows[i])); |
| +} |
| + |
| +void ShelfDelegateMus::OnUserWindowAdded( |
| + mash::wm::mojom::UserWindowPtr user_window) { |
| + ShelfItem item; |
| + item.type = TYPE_PLATFORM_APP; |
| + item.status = user_window->window_has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
| + // TODO(msw): Support actual window icons. |
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| + item.image = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); |
| + |
| + ShelfID shelf_id = model_->next_id(); |
| + window_id_to_shelf_id_.insert( |
| + std::make_pair(user_window->window_id, shelf_id)); |
| + model_->Add(item); |
| + |
| + ShelfItemDelegateManager* manager = |
| + Shell::GetInstance()->shelf_item_delegate_manager(); |
| + scoped_ptr<ShelfItemDelegate> delegate(new ShelfItemDelegateMus( |
| + user_window->window_id, user_window->window_title.To<base::string16>(), |
| + user_window_controller_.get())); |
| + manager->SetShelfItemDelegate(shelf_id, std::move(delegate)); |
| +} |
| + |
| +void ShelfDelegateMus::OnUserWindowRemoved(uint32_t window_id) { |
| + DCHECK(window_id_to_shelf_id_.count(window_id)); |
| + model_->RemoveItemAt( |
| + model_->ItemIndexByID(window_id_to_shelf_id_[window_id])); |
| +} |
| + |
| +void ShelfDelegateMus::OnUserWindowTitleChanged( |
| + uint32_t window_id, |
| + const mojo::String& window_title) { |
| + 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
|
| +} |
| + |
| +void ShelfDelegateMus::OnUserWindowFocusChanged(uint32_t window_id, |
| + bool has_focus) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +} // namespace sysui |
| +} // namespace ash |