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

Side by Side Diff: athena/wm/window_manager_impl.cc

Issue 391383004: Revert of athena: Add a minimized state for the home-card. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « athena/wm/public/window_manager_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/input/public/accelerator_manager.h" 7 #include "athena/input/public/accelerator_manager.h"
8 #include "athena/screen/public/screen_manager.h" 8 #include "athena/screen/public/screen_manager.h"
9 #include "athena/wm/public/window_manager_observer.h"
10 #include "athena/wm/window_overview_mode.h" 9 #include "athena/wm/window_overview_mode.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/observer_list.h"
13 #include "ui/aura/layout_manager.h" 11 #include "ui/aura/layout_manager.h"
14 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
15 #include "ui/wm/public/window_types.h" 13 #include "ui/wm/public/window_types.h"
16 14
17 namespace athena { 15 namespace athena {
18 namespace { 16 namespace {
19 17
20 class WindowManagerImpl : public WindowManager, 18 class WindowManagerImpl : public WindowManager,
21 public WindowOverviewModeDelegate, 19 public WindowOverviewModeDelegate,
22 public aura::WindowObserver, 20 public aura::WindowObserver,
23 public AcceleratorHandler { 21 public AcceleratorHandler {
24 public: 22 public:
25 WindowManagerImpl(); 23 WindowManagerImpl();
26 virtual ~WindowManagerImpl(); 24 virtual ~WindowManagerImpl();
27 25
28 void Init() { InstallAccelerators(); } 26 void Init() { InstallAccelerators(); }
29 27
30 void Layout(); 28 void Layout();
31 29
32 // WindowManager: 30 // WindowManager:
33 virtual void ToggleOverview() OVERRIDE { 31 virtual void ToggleOverview() OVERRIDE {
34 if (overview_) { 32 if (overview_)
35 overview_.reset(); 33 overview_.reset();
36 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 34 else
37 OnOverviewModeExit());
38 } else {
39 overview_ = WindowOverviewMode::Create(container_.get(), this); 35 overview_ = WindowOverviewMode::Create(container_.get(), this);
40 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
41 OnOverviewModeEnter());
42 }
43 } 36 }
44 37
45 private: 38 private:
46 enum Command { 39 enum Command {
47 COMMAND_TOGGLE_OVERVIEW, 40 COMMAND_TOGGLE_OVERVIEW,
48 }; 41 };
49 42
50 void InstallAccelerators() { 43 void InstallAccelerators() {
51 const AcceleratorData accelerator_data[] = { 44 const AcceleratorData accelerator_data[] = {
52 {TRIGGER_ON_PRESS, ui::VKEY_6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 45 {TRIGGER_ON_PRESS, ui::VKEY_6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
53 AF_NONE}, 46 AF_NONE},
54 }; 47 };
55 AcceleratorManager::Get()->RegisterAccelerators( 48 AcceleratorManager::Get()->RegisterAccelerators(
56 accelerator_data, arraysize(accelerator_data), this); 49 accelerator_data, arraysize(accelerator_data), this);
57 } 50 }
58 51
59 // WindowManager:
60 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE {
61 observers_.AddObserver(observer);
62 }
63
64 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE {
65 observers_.RemoveObserver(observer);
66 }
67
68 // WindowOverviewModeDelegate: 52 // WindowOverviewModeDelegate:
69 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { 53 virtual void OnSelectWindow(aura::Window* window) OVERRIDE {
70 CHECK_EQ(container_.get(), window->parent()); 54 CHECK_EQ(container_.get(), window->parent());
71 container_->StackChildAtTop(window); 55 container_->StackChildAtTop(window);
72 overview_.reset(); 56 overview_.reset();
73 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
74 OnOverviewModeExit());
75 } 57 }
76 58
77 // aura::WindowObserver 59 // aura::WindowObserver
78 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { 60 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
79 if (window == container_) 61 if (window == container_)
80 container_.reset(); 62 container_.reset();
81 } 63 }
82 64
83 // AcceleratorHandler: 65 // AcceleratorHandler:
84 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; } 66 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; }
85 virtual bool OnAcceleratorFired(int command_id, 67 virtual bool OnAcceleratorFired(int command_id,
86 const ui::Accelerator& accelerator) OVERRIDE { 68 const ui::Accelerator& accelerator) OVERRIDE {
87 switch (command_id) { 69 switch (command_id) {
88 case COMMAND_TOGGLE_OVERVIEW: 70 case COMMAND_TOGGLE_OVERVIEW:
89 ToggleOverview(); 71 ToggleOverview();
90 break; 72 break;
91 } 73 }
92 return true; 74 return true;
93 } 75 }
94 76
95 scoped_ptr<aura::Window> container_; 77 scoped_ptr<aura::Window> container_;
96 scoped_ptr<WindowOverviewMode> overview_; 78 scoped_ptr<WindowOverviewMode> overview_;
97 ObserverList<WindowManagerObserver> observers_;
98 79
99 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 80 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
100 }; 81 };
101 82
102 class WindowManagerImpl* instance = NULL; 83 class WindowManagerImpl* instance = NULL;
103 84
104 class AthenaContainerLayoutManager : public aura::LayoutManager { 85 class AthenaContainerLayoutManager : public aura::LayoutManager {
105 public: 86 public:
106 AthenaContainerLayoutManager() {} 87 AthenaContainerLayoutManager() {}
107 virtual ~AthenaContainerLayoutManager() {} 88 virtual ~AthenaContainerLayoutManager() {}
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return instance; 149 return instance;
169 } 150 }
170 151
171 // static 152 // static
172 void WindowManager::Shutdown() { 153 void WindowManager::Shutdown() {
173 DCHECK(instance); 154 DCHECK(instance);
174 delete instance; 155 delete instance;
175 DCHECK(!instance); 156 DCHECK(!instance);
176 } 157 }
177 158
178 // static
179 WindowManager* WindowManager::GetInstance() {
180 DCHECK(instance);
181 return instance;
182 }
183
184 } // namespace athena 159 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/public/window_manager_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698