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 "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 gfx::VectorIconId PaletteToolManager::GetActiveTrayIcon(PaletteToolId tool_id) { | 72 gfx::VectorIconId PaletteToolManager::GetActiveTrayIcon(PaletteToolId tool_id) { |
73 PaletteTool* tool = FindToolById(tool_id); | 73 PaletteTool* tool = FindToolById(tool_id); |
74 if (!tool) | 74 if (!tool) |
75 return gfx::VectorIconId::PALETTE_TRAY_ICON_DEFAULT; | 75 return gfx::VectorIconId::PALETTE_TRAY_ICON_DEFAULT; |
76 | 76 |
77 return tool->GetActiveTrayIcon(); | 77 return tool->GetActiveTrayIcon(); |
78 } | 78 } |
79 | 79 |
80 std::vector<PaletteToolView> PaletteToolManager::CreateViews() { | 80 std::vector<PaletteToolView> PaletteToolManager::CreateViews() { |
81 std::vector<PaletteToolView> views(tools_.size()); | 81 std::vector<PaletteToolView> views; |
82 views.reserve(tools_.size()); | |
James Cook
2016/08/12 23:58:55
nice attention to detail
jdufault
2016/08/16 21:38:18
:)
| |
82 | 83 |
83 for (size_t i = 0; i < tools_.size(); ++i) { | 84 for (size_t i = 0; i < tools_.size(); ++i) { |
84 PaletteToolView* view = &views[i]; | 85 views::View* tool_view = tools_[i]->CreateView(); |
85 view->group = tools_[i]->GetGroup(); | 86 if (!tool_view) |
86 view->tool_id = tools_[i]->GetToolId(); | 87 continue; |
87 view->view = tools_[i]->CreateView(); | 88 |
89 PaletteToolView view; | |
90 view.group = tools_[i]->GetGroup(); | |
91 view.tool_id = tools_[i]->GetToolId(); | |
92 view.view = tool_view; | |
93 views.push_back(view); | |
88 } | 94 } |
89 | 95 |
90 return views; | 96 return views; |
91 } | 97 } |
92 | 98 |
93 void PaletteToolManager::NotifyViewsDestroyed() { | 99 void PaletteToolManager::NotifyViewsDestroyed() { |
94 for (std::unique_ptr<PaletteTool>& tool : tools_) | 100 for (std::unique_ptr<PaletteTool>& tool : tools_) |
95 tool->OnViewDestroyed(); | 101 tool->OnViewDestroyed(); |
96 } | 102 } |
97 | 103 |
(...skipping 16 matching lines...) Expand all Loading... | |
114 PaletteTool* PaletteToolManager::FindToolById(PaletteToolId tool_id) { | 120 PaletteTool* PaletteToolManager::FindToolById(PaletteToolId tool_id) { |
115 for (std::unique_ptr<PaletteTool>& tool : tools_) { | 121 for (std::unique_ptr<PaletteTool>& tool : tools_) { |
116 if (tool->GetToolId() == tool_id) | 122 if (tool->GetToolId() == tool_id) |
117 return tool.get(); | 123 return tool.get(); |
118 } | 124 } |
119 | 125 |
120 return nullptr; | 126 return nullptr; |
121 } | 127 } |
122 | 128 |
123 } // namespace ash | 129 } // namespace ash |
OLD | NEW |