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

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

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add LauncherItemDelegateManager Created 7 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_launcher_delegate.h" 5 #include "ash/test/test_launcher_delegate.h"
6 6
7 #include "ash/launcher/launcher_item_delegate_manager.h"
7 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
8 #include "ash/launcher/launcher_util.h" 9 #include "ash/launcher/launcher_util.h"
10 #include "ash/shell.h"
9 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
10 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
12 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
13 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
14 16
15 namespace ash { 17 namespace ash {
16 namespace test { 18 namespace test {
17 19
18 TestLauncherDelegate* TestLauncherDelegate::instance_ = NULL; 20 TestLauncherDelegate* TestLauncherDelegate::instance_ = NULL;
19 21
20 TestLauncherDelegate::TestLauncherDelegate(LauncherModel* model) 22 TestLauncherDelegate::TestLauncherDelegate(LauncherModel* model)
21 : model_(model) { 23 : model_(model) {
22 CHECK(!instance_); 24 CHECK(!instance_);
23 instance_ = this; 25 instance_ = this;
26
27 if (Shell::HasInstance()) {
28 ash::LauncherItemDelegateManager* manager =
29 ash::Shell::GetInstance()->launcher_item_delegate_manager();
30 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this);
31 manager->RegisterLauncherItemDelegate(ash::TYPE_TABBED, this);
32 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this);
33 manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this);
34 manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this);
35 manager->RegisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP, this);
36 }
24 } 37 }
25 38
26 TestLauncherDelegate::~TestLauncherDelegate() { 39 TestLauncherDelegate::~TestLauncherDelegate() {
40 if (Shell::HasInstance()) {
41 ash::LauncherItemDelegateManager* manager =
42 ash::Shell::GetInstance()->launcher_item_delegate_manager();
43 manager->UnregisterLauncherItemDelegate(ash::TYPE_APP_PANEL);
44 manager->UnregisterLauncherItemDelegate(ash::TYPE_TABBED);
45 manager->UnregisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT);
46 manager->UnregisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT);
47 manager->UnregisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP);
48 manager->UnregisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP);
49 }
50
27 instance_ = NULL; 51 instance_ = NULL;
28 } 52 }
29 53
30 void TestLauncherDelegate::AddLauncherItem(aura::Window* window) { 54 void TestLauncherDelegate::AddLauncherItem(aura::Window* window) {
31 AddLauncherItem(window, STATUS_CLOSED); 55 AddLauncherItem(window, STATUS_CLOSED);
32 } 56 }
33 57
34 void TestLauncherDelegate::AddLauncherItem( 58 void TestLauncherDelegate::AddLauncherItem(
35 aura::Window* window, 59 aura::Window* window,
36 LauncherItemStatus status) { 60 LauncherItemStatus status) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 165
142 bool TestLauncherDelegate::IsAppPinned(const std::string& app_id) { 166 bool TestLauncherDelegate::IsAppPinned(const std::string& app_id) {
143 return false; 167 return false;
144 } 168 }
145 169
146 void TestLauncherDelegate::UnpinAppWithID(const std::string& app_id) { 170 void TestLauncherDelegate::UnpinAppWithID(const std::string& app_id) {
147 } 171 }
148 172
149 } // namespace test 173 } // namespace test
150 } // namespace ash 174 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698