| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/common/system/chromeos/palette/palette_tool_manager.h" | 5 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/system/chromeos/palette/palette_tool.h" | 9 #include "ash/common/system/chromeos/palette/palette_tool.h" |
| 10 #include "ash/resources/vector_icons/vector_icons.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "ui/gfx/vector_icons_public.h" | |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 PaletteToolManager::PaletteToolManager(Delegate* delegate) | 15 PaletteToolManager::PaletteToolManager(Delegate* delegate) |
| 16 : delegate_(delegate) { | 16 : delegate_(delegate) { |
| 17 DCHECK(delegate_); | 17 DCHECK(delegate_); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PaletteToolManager::~PaletteToolManager() {} | 20 PaletteToolManager::~PaletteToolManager() {} |
| 21 | 21 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 DCHECK(tool); | 62 DCHECK(tool); |
| 63 | 63 |
| 64 return active_tools_[tool->GetGroup()] == tool; | 64 return active_tools_[tool->GetGroup()] == tool; |
| 65 } | 65 } |
| 66 | 66 |
| 67 PaletteToolId PaletteToolManager::GetActiveTool(PaletteGroup group) { | 67 PaletteToolId PaletteToolManager::GetActiveTool(PaletteGroup group) { |
| 68 PaletteTool* active_tool = active_tools_[group]; | 68 PaletteTool* active_tool = active_tools_[group]; |
| 69 return active_tool ? active_tool->GetToolId() : PaletteToolId::NONE; | 69 return active_tool ? active_tool->GetToolId() : PaletteToolId::NONE; |
| 70 } | 70 } |
| 71 | 71 |
| 72 gfx::VectorIconId PaletteToolManager::GetActiveTrayIcon(PaletteToolId tool_id) { | 72 const gfx::VectorIcon& PaletteToolManager::GetActiveTrayIcon( |
| 73 PaletteToolId tool_id) const { |
| 73 PaletteTool* tool = FindToolById(tool_id); | 74 PaletteTool* tool = FindToolById(tool_id); |
| 74 if (!tool) | 75 if (!tool) |
| 75 return gfx::VectorIconId::PALETTE_TRAY_ICON_DEFAULT; | 76 return kPaletteTrayIconDefaultIcon; |
| 76 | 77 |
| 77 return tool->GetActiveTrayIcon(); | 78 return tool->GetActiveTrayIcon(); |
| 78 } | 79 } |
| 79 | 80 |
| 80 std::vector<PaletteToolView> PaletteToolManager::CreateViews() { | 81 std::vector<PaletteToolView> PaletteToolManager::CreateViews() { |
| 81 std::vector<PaletteToolView> views; | 82 std::vector<PaletteToolView> views; |
| 82 views.reserve(tools_.size()); | 83 views.reserve(tools_.size()); |
| 83 | 84 |
| 84 for (size_t i = 0; i < tools_.size(); ++i) { | 85 for (size_t i = 0; i < tools_.size(); ++i) { |
| 85 views::View* tool_view = tools_[i]->CreateView(); | 86 views::View* tool_view = tools_[i]->CreateView(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 110 } | 111 } |
| 111 | 112 |
| 112 void PaletteToolManager::HidePalette() { | 113 void PaletteToolManager::HidePalette() { |
| 113 delegate_->HidePalette(); | 114 delegate_->HidePalette(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 WmWindow* PaletteToolManager::GetWindow() { | 117 WmWindow* PaletteToolManager::GetWindow() { |
| 117 return delegate_->GetWindow(); | 118 return delegate_->GetWindow(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 PaletteTool* PaletteToolManager::FindToolById(PaletteToolId tool_id) { | 121 PaletteTool* PaletteToolManager::FindToolById(PaletteToolId tool_id) const { |
| 121 for (std::unique_ptr<PaletteTool>& tool : tools_) { | 122 for (const std::unique_ptr<PaletteTool>& tool : tools_) { |
| 122 if (tool->GetToolId() == tool_id) | 123 if (tool->GetToolId() == tool_id) |
| 123 return tool.get(); | 124 return tool.get(); |
| 124 } | 125 } |
| 125 | 126 |
| 126 return nullptr; | 127 return nullptr; |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace ash | 130 } // namespace ash |
| OLD | NEW |