| OLD | NEW |
| (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 #ifndef ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ | |
| 6 #define ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <map> | |
| 10 #include <set> | |
| 11 | |
| 12 #include "ash/launcher/launcher_delegate.h" | |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "ui/aura/window_observer.h" | |
| 15 | |
| 16 namespace ash { | |
| 17 | |
| 18 class LauncherModel; | |
| 19 | |
| 20 namespace test { | |
| 21 | |
| 22 // Test implementation of LauncherDelegate. | |
| 23 // Tests may create icons for windows by calling AddLauncherItem | |
| 24 class TestLauncherDelegate : public LauncherDelegate, | |
| 25 public aura::WindowObserver { | |
| 26 public: | |
| 27 explicit TestLauncherDelegate(LauncherModel* model); | |
| 28 ~TestLauncherDelegate(); | |
| 29 | |
| 30 void AddLauncherItem(aura::Window* window); | |
| 31 | |
| 32 static TestLauncherDelegate* instance() { return instance_; } | |
| 33 | |
| 34 // WindowObserver implementation | |
| 35 void OnWillRemoveWindow(aura::Window* window) OVERRIDE; | |
| 36 | |
| 37 // LauncherDelegate implementation. | |
| 38 virtual void CreateNewTab() OVERRIDE; | |
| 39 virtual void CreateNewWindow() OVERRIDE; | |
| 40 virtual void ItemClicked(const LauncherItem& item) OVERRIDE; | |
| 41 virtual int GetBrowserShortcutResourceId() OVERRIDE; | |
| 42 virtual string16 GetTitle(const LauncherItem& item) OVERRIDE; | |
| 43 virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item) OVERRIDE; | |
| 44 virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE; | |
| 45 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 typedef std::map<aura::Window*, ash::LauncherID> WindowToID; | |
| 49 typedef std::set<aura::Window*> ObservedWindows; | |
| 50 | |
| 51 static TestLauncherDelegate* instance_; | |
| 52 | |
| 53 aura::Window* GetWindowByID(ash::LauncherID id); | |
| 54 | |
| 55 LauncherModel* model_; | |
| 56 | |
| 57 // Maps from window to the id we gave it. | |
| 58 WindowToID window_to_id_; | |
| 59 | |
| 60 // Parent windows we are watching. | |
| 61 ObservedWindows observed_windows_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(TestLauncherDelegate); | |
| 64 }; | |
| 65 | |
| 66 } // namespace test | |
| 67 } // namespace ash | |
| 68 | |
| 69 #endif // ASH_TEST_TEST_LAUNCHER_DELEGATE | |
| OLD | NEW |