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

Side by Side Diff: ash/test/test_shelf_delegate.cc

Issue 2171813004: mash: Fold ShelfItemDelegateManager into ShelfModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: explicitly destroy ShelfItemDelegates Created 4 years, 5 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
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/test/test_shelf_delegate.h" 5 #include "ash/test/test_shelf_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_item_delegate_manager.h"
10 #include "ash/common/shelf/shelf_model.h" 9 #include "ash/common/shelf/shelf_model.h"
11 #include "ash/shelf/shelf_util.h" 10 #include "ash/shelf/shelf_util.h"
12 #include "ash/shell.h"
13 #include "ash/test/test_shelf_item_delegate.h" 11 #include "ash/test/test_shelf_item_delegate.h"
14 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
16 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
17 15
18 namespace ash { 16 namespace ash {
19 namespace test { 17 namespace test {
20 18
21 TestShelfDelegate* TestShelfDelegate::instance_ = NULL; 19 TestShelfDelegate* TestShelfDelegate::instance_ = NULL;
22 20
(...skipping 21 matching lines...) Expand all
44 ShelfItem item; 42 ShelfItem item;
45 if (window->type() == ui::wm::WINDOW_TYPE_PANEL) 43 if (window->type() == ui::wm::WINDOW_TYPE_PANEL)
46 item.type = TYPE_APP_PANEL; 44 item.type = TYPE_APP_PANEL;
47 else 45 else
48 item.type = TYPE_PLATFORM_APP; 46 item.type = TYPE_PLATFORM_APP;
49 ShelfID id = model_->next_id(); 47 ShelfID id = model_->next_id();
50 item.status = status; 48 item.status = status;
51 model_->Add(item); 49 model_->Add(item);
52 window->AddObserver(this); 50 window->AddObserver(this);
53 51
54 ShelfItemDelegateManager* manager =
55 Shell::GetInstance()->shelf_item_delegate_manager();
56 // |manager| owns TestShelfItemDelegate.
57 std::unique_ptr<ShelfItemDelegate> delegate( 52 std::unique_ptr<ShelfItemDelegate> delegate(
58 new TestShelfItemDelegate(window)); 53 new TestShelfItemDelegate(window));
59 manager->SetShelfItemDelegate(id, std::move(delegate)); 54 model_->SetShelfItemDelegate(id, std::move(delegate));
60 SetShelfIDForWindow(id, window); 55 SetShelfIDForWindow(id, window);
61 } 56 }
62 57
63 void TestShelfDelegate::RemoveShelfItemForWindow(aura::Window* window) { 58 void TestShelfDelegate::RemoveShelfItemForWindow(aura::Window* window) {
64 ShelfID shelf_id = GetShelfIDForWindow(window); 59 ShelfID shelf_id = GetShelfIDForWindow(window);
65 if (shelf_id == 0) 60 if (shelf_id == 0)
66 return; 61 return;
67 int index = model_->ItemIndexByID(shelf_id); 62 int index = model_->ItemIndexByID(shelf_id);
68 DCHECK_NE(-1, index); 63 DCHECK_NE(-1, index);
69 model_->RemoveItemAt(index); 64 model_->RemoveItemAt(index);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const std::string& app_id) { 130 const std::string& app_id) {
136 shelf_id_to_app_id_map_[shelf_id] = app_id; 131 shelf_id_to_app_id_map_[shelf_id] = app_id;
137 } 132 }
138 133
139 void TestShelfDelegate::RemoveShelfIDToAppIDMapping(ShelfID shelf_id) { 134 void TestShelfDelegate::RemoveShelfIDToAppIDMapping(ShelfID shelf_id) {
140 shelf_id_to_app_id_map_.erase(shelf_id); 135 shelf_id_to_app_id_map_.erase(shelf_id);
141 } 136 }
142 137
143 } // namespace test 138 } // namespace test
144 } // namespace ash 139 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/shelf_item_delegate_manager_test_api.cc ('k') | chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698