OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/test_shelf_delegate.h" | 5 #include "ash/common/test/test_shelf_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ShelfID shelf_id = window->aura_window()->GetProperty(kShelfIDKey); | 68 ShelfID shelf_id = window->aura_window()->GetProperty(kShelfIDKey); |
69 AddShelfIDToAppIDMapping(shelf_id, app_id); | 69 AddShelfIDToAppIDMapping(shelf_id, app_id); |
70 } | 70 } |
71 | 71 |
72 void TestShelfDelegate::AddShelfItem(WmWindow* window, ShelfItemStatus status) { | 72 void TestShelfDelegate::AddShelfItem(WmWindow* window, ShelfItemStatus status) { |
73 ShelfItem item; | 73 ShelfItem item; |
74 if (window->GetType() == ui::wm::WINDOW_TYPE_PANEL) | 74 if (window->GetType() == ui::wm::WINDOW_TYPE_PANEL) |
75 item.type = TYPE_APP_PANEL; | 75 item.type = TYPE_APP_PANEL; |
76 else | 76 else |
77 item.type = TYPE_APP; | 77 item.type = TYPE_APP; |
78 ShelfModel* model = WmShell::Get()->shelf_model(); | 78 ShelfModel* model = Shell::Get()->shelf_model(); |
79 ShelfID id = model->next_id(); | 79 ShelfID id = model->next_id(); |
80 item.status = status; | 80 item.status = status; |
81 model->Add(item); | 81 model->Add(item); |
82 window->aura_window()->AddObserver(this); | 82 window->aura_window()->AddObserver(this); |
83 | 83 |
84 model->SetShelfItemDelegate(id, | 84 model->SetShelfItemDelegate(id, |
85 base::MakeUnique<TestShelfItemDelegate>(window)); | 85 base::MakeUnique<TestShelfItemDelegate>(window)); |
86 window->aura_window()->SetProperty(kShelfIDKey, id); | 86 window->aura_window()->SetProperty(kShelfIDKey, id); |
87 } | 87 } |
88 | 88 |
89 void TestShelfDelegate::RemoveShelfItemForWindow(WmWindow* window) { | 89 void TestShelfDelegate::RemoveShelfItemForWindow(WmWindow* window) { |
90 ShelfID shelf_id = window->aura_window()->GetProperty(kShelfIDKey); | 90 ShelfID shelf_id = window->aura_window()->GetProperty(kShelfIDKey); |
91 if (shelf_id == 0) | 91 if (shelf_id == 0) |
92 return; | 92 return; |
93 ShelfModel* model = WmShell::Get()->shelf_model(); | 93 ShelfModel* model = Shell::Get()->shelf_model(); |
94 int index = model->ItemIndexByID(shelf_id); | 94 int index = model->ItemIndexByID(shelf_id); |
95 DCHECK_NE(-1, index); | 95 DCHECK_NE(-1, index); |
96 model->RemoveItemAt(index); | 96 model->RemoveItemAt(index); |
97 window->aura_window()->RemoveObserver(this); | 97 window->aura_window()->RemoveObserver(this); |
98 if (HasShelfIDToAppIDMapping(shelf_id)) { | 98 if (HasShelfIDToAppIDMapping(shelf_id)) { |
99 const std::string& app_id = GetAppIDForShelfID(shelf_id); | 99 const std::string& app_id = GetAppIDForShelfID(shelf_id); |
100 if (IsAppPinned(app_id)) | 100 if (IsAppPinned(app_id)) |
101 UnpinAppWithID(app_id); | 101 UnpinAppWithID(app_id); |
102 if (HasShelfIDToAppIDMapping(shelf_id)) | 102 if (HasShelfIDToAppIDMapping(shelf_id)) |
103 RemoveShelfIDToAppIDMapping(shelf_id); | 103 RemoveShelfIDToAppIDMapping(shelf_id); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 const std::string& app_id) { | 156 const std::string& app_id) { |
157 shelf_id_to_app_id_map_[shelf_id] = app_id; | 157 shelf_id_to_app_id_map_[shelf_id] = app_id; |
158 } | 158 } |
159 | 159 |
160 void TestShelfDelegate::RemoveShelfIDToAppIDMapping(ShelfID shelf_id) { | 160 void TestShelfDelegate::RemoveShelfIDToAppIDMapping(ShelfID shelf_id) { |
161 shelf_id_to_app_id_map_.erase(shelf_id); | 161 shelf_id_to_app_id_map_.erase(shelf_id); |
162 } | 162 } |
163 | 163 |
164 } // namespace test | 164 } // namespace test |
165 } // namespace ash | 165 } // namespace ash |
OLD | NEW |