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

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

Issue 9808026: Layout panels on top of their launcher icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/test/test_launcher_delegate.h ('k') | ash/test/test_shell_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/test/test_launcher_delegate.h"
6
7 #include "ash/launcher/launcher_model.h"
8 #include "ash/wm/window_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "grit/ui_resources.h"
11 #include "ui/aura/window.h"
12
13 namespace ash {
14 namespace test {
15
16 TestLauncherDelegate::TestLauncherDelegate(LauncherModel* model)
17 : model_(model) {
18 }
19
20 void TestLauncherDelegate::OnWillRemoveWindow(aura::Window* window) {
21 ash::LauncherID id = GetIDByWindow(window);
22 if (id == 0)
23 return;
24 int index = model_->ItemIndexByID(id);
25 DCHECK_NE(-1, index);
26 model_->RemoveItemAt(index);
27 window_to_id_.erase(window);
28 }
29
30 void TestLauncherDelegate::CreateNewTab() {
31 }
32
33 void TestLauncherDelegate::CreateNewWindow() {
34 }
35
36 void TestLauncherDelegate::ItemClicked(const ash::LauncherItem& item) {
37 aura::Window* window = GetWindowByID(item.id);
38 window->Show();
39 ash::wm::ActivateWindow(window);
40 }
41
42 int TestLauncherDelegate::GetBrowserShortcutResourceId() {
43 return IDR_AURA_LAUNCHER_BROWSER_SHORTCUT;
44 }
45
46 string16 TestLauncherDelegate::GetTitle(const ash::LauncherItem& item) {
47 return GetWindowByID(item.id)->title();
48 }
49
50 ui::MenuModel* TestLauncherDelegate::CreateContextMenu(
51 const ash::LauncherItem& item) {
52 return NULL;
53 }
54
55 ui::MenuModel* TestLauncherDelegate::CreateContextMenuForLauncher() {
56 return NULL;
57 }
58
59 ash::LauncherID TestLauncherDelegate::GetIDByWindow(aura::Window* window) {
60 WindowToID::const_iterator found = window_to_id_.find(window);
61 if (found == window_to_id_.end())
62 return 0;
63 return found->second;
64 }
65
66 void TestLauncherDelegate::AddLauncherItem(aura::Window* window) {
67 ash::LauncherItem item;
68 item.type = ash::TYPE_TABBED;
69 window_to_id_[window] = model_->next_id();
70 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
71 item.image.allocPixels();
72 model_->Add(item);
73 if (observed_windows_.find(window->parent()) == observed_windows_.end()) {
74 window->parent()->AddObserver(this);
75 observed_windows_.insert(window->parent());
76 }
77 }
78
79 aura::Window* TestLauncherDelegate::GetWindowByID(ash::LauncherID id) {
80 for(WindowToID::const_iterator it = window_to_id_.begin();
81 it != window_to_id_.end();
82 it++) {
83 if (it->second == id)
84 return it->first;
85 }
86 return NULL;
87 }
88
89
90 } // namespace test
91 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/test_launcher_delegate.h ('k') | ash/test/test_shell_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698