OLD | NEW |
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_model.h" | 7 #include "ash/launcher/launcher_model.h" |
8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 TestLauncherDelegate* TestLauncherDelegate::instance_ = NULL; | 16 TestLauncherDelegate* TestLauncherDelegate::instance_ = NULL; |
17 | 17 |
18 TestLauncherDelegate::TestLauncherDelegate(LauncherModel* model) | 18 TestLauncherDelegate::TestLauncherDelegate(LauncherModel* model) |
19 : model_(model) { | 19 : model_(model) { |
20 CHECK(!instance_); | 20 CHECK(!instance_); |
21 instance_ = this; | 21 instance_ = this; |
22 } | 22 } |
23 | 23 |
24 TestLauncherDelegate::~TestLauncherDelegate() { | 24 TestLauncherDelegate::~TestLauncherDelegate() { |
25 instance_ = NULL; | 25 instance_ = NULL; |
26 } | 26 } |
27 | 27 |
28 void TestLauncherDelegate::AddLauncherItem(aura::Window* window) { | 28 void TestLauncherDelegate::AddLauncherItem(aura::Window* window) { |
29 AddLauncherItem(window, STATUS_CLOSED); | |
30 } | |
31 | |
32 void TestLauncherDelegate::AddLauncherItem( | |
33 aura::Window* window, | |
34 LauncherItemStatus status) { | |
35 ash::LauncherItem item; | 29 ash::LauncherItem item; |
36 item.type = ash::TYPE_TABBED; | 30 item.type = ash::TYPE_TABBED; |
37 DCHECK(window_to_id_.find(window) == window_to_id_.end()); | 31 DCHECK(window_to_id_.find(window) == window_to_id_.end()); |
38 window_to_id_[window] = model_->next_id(); | 32 window_to_id_[window] = model_->next_id(); |
39 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | 33 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); |
40 item.image.allocPixels(); | 34 item.image.allocPixels(); |
41 item.status = status; | |
42 model_->Add(item); | 35 model_->Add(item); |
43 if (observed_windows_.find(window->parent()) == observed_windows_.end()) { | 36 if (observed_windows_.find(window->parent()) == observed_windows_.end()) { |
44 window->parent()->AddObserver(this); | 37 window->parent()->AddObserver(this); |
45 observed_windows_.insert(window->parent()); | 38 observed_windows_.insert(window->parent()); |
46 } | 39 } |
47 } | 40 } |
48 | 41 |
49 void TestLauncherDelegate::OnWillRemoveWindow(aura::Window* window) { | 42 void TestLauncherDelegate::OnWillRemoveWindow(aura::Window* window) { |
50 ash::LauncherID id = GetIDByWindow(window); | 43 ash::LauncherID id = GetIDByWindow(window); |
51 if (id == 0) | 44 if (id == 0) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 100 } |
108 return NULL; | 101 return NULL; |
109 } | 102 } |
110 | 103 |
111 bool TestLauncherDelegate::IsDraggable(const ash::LauncherItem& item) { | 104 bool TestLauncherDelegate::IsDraggable(const ash::LauncherItem& item) { |
112 return true; | 105 return true; |
113 } | 106 } |
114 | 107 |
115 } // namespace test | 108 } // namespace test |
116 } // namespace ash | 109 } // namespace ash |
OLD | NEW |