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

Side by Side Diff: athena/screen/screen_manager_impl.cc

Issue 620663005: Lock screen for Chrome-Athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more nit Created 6 years, 2 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
« no previous file with comments | « athena/main/athena_launcher.cc ('k') | athena/screen_lock/chrome/DEPS » ('j') | 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/screen/public/screen_manager.h" 5 #include "athena/screen/public/screen_manager.h"
6 6
7 #include "athena/input/public/accelerator_manager.h" 7 #include "athena/input/public/accelerator_manager.h"
8 #include "athena/screen/screen_accelerator_handler.h" 8 #include "athena/screen/screen_accelerator_handler.h"
9 #include "athena/util/container_priorities.h" 9 #include "athena/util/container_priorities.h"
10 #include "athena/util/fill_layout_manager.h" 10 #include "athena/util/fill_layout_manager.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 : container_(container) { 147 : container_(container) {
148 container_->AddObserver(this); 148 container_->AddObserver(this);
149 } 149 }
150 150
151 virtual ~AthenaEventTargeter() { 151 virtual ~AthenaEventTargeter() {
152 // Removed before the container is removed. 152 // Removed before the container is removed.
153 if (container_) 153 if (container_)
154 container_->RemoveObserver(this); 154 container_->RemoveObserver(this);
155 } 155 }
156 156
157 void SetPreviousEventTargeter(scoped_ptr<ui::EventTargeter> targeter) {
158 previous_root_event_targeter_ = targeter.Pass();
159 }
160
157 private: 161 private:
158 // aura::WindowTargeter: 162 // aura::WindowTargeter:
159 virtual bool SubtreeCanAcceptEvent( 163 virtual bool SubtreeCanAcceptEvent(
160 ui::EventTarget* target, 164 ui::EventTarget* target,
161 const ui::LocatedEvent& event) const override { 165 const ui::LocatedEvent& event) const override {
162 aura::Window* window = static_cast<aura::Window*>(target); 166 aura::Window* window = static_cast<aura::Window*>(target);
163 const aura::Window::Windows& containers = 167 const aura::Window::Windows& containers =
164 container_->GetRootWindow()->children(); 168 container_->GetRootWindow()->children();
165 aura::Window::Windows::const_iterator iter = 169 aura::Window::Windows::const_iterator iter =
166 std::find(containers.begin(), containers.end(), container_); 170 std::find(containers.begin(), containers.end(), container_);
167 DCHECK(iter != containers.end()); 171 DCHECK(iter != containers.end());
168 for (; iter != containers.end(); ++iter) { 172 for (; iter != containers.end(); ++iter) {
169 if ((*iter)->Contains(window)) 173 if ((*iter)->Contains(window))
170 return true; 174 return true;
171 } 175 }
172 return false; 176 return false;
173 } 177 }
174 178
175 // aura::WindowObserver: 179 // aura::WindowObserver:
176 virtual void OnWindowDestroying(aura::Window* window) override { 180 virtual void OnWindowDestroying(aura::Window* window) override {
177 aura::Window* root_window = container_->GetRootWindow(); 181 aura::Window* root_window = container_->GetRootWindow();
178 DCHECK_EQ(window, container_); 182 DCHECK_EQ(window, container_);
179 DCHECK_EQ( 183 DCHECK_EQ(
180 this, static_cast<ui::EventTarget*>(root_window)->GetEventTargeter()); 184 this, static_cast<ui::EventTarget*>(root_window)->GetEventTargeter());
181 185
182 container_->RemoveObserver(this); 186 container_->RemoveObserver(this);
183 container_ = NULL; 187 container_ = NULL;
184 188
185 // This will remove myself. 189 // This will remove myself.
186 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); 190 root_window->SetEventTargeter(previous_root_event_targeter_.Pass());
187 } 191 }
188 192
189 aura::Window* container_; 193 aura::Window* container_;
194 scoped_ptr<ui::EventTargeter> previous_root_event_targeter_;
190 195
191 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); 196 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter);
192 }; 197 };
193 198
194 class ScreenManagerImpl : public ScreenManager { 199 class ScreenManagerImpl : public ScreenManager {
195 public: 200 public:
196 explicit ScreenManagerImpl(aura::Window* root_window); 201 explicit ScreenManagerImpl(aura::Window* root_window);
197 virtual ~ScreenManagerImpl(); 202 virtual ~ScreenManagerImpl();
198 203
199 void Init(); 204 void Init();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 container->SetProperty(kContainerParamsKey, new ContainerParams(params)); 323 container->SetProperty(kContainerParamsKey, new ContainerParams(params));
319 324
320 // If another container is already grabbing the input, SetEventTargeter 325 // If another container is already grabbing the input, SetEventTargeter
321 // implicitly release the grabbing and remove the EventTargeter instance. 326 // implicitly release the grabbing and remove the EventTargeter instance.
322 // TODO(mukai|oshima): think about the ideal behavior of multiple grabbing 327 // TODO(mukai|oshima): think about the ideal behavior of multiple grabbing
323 // and implement it. 328 // and implement it.
324 if (params.grab_inputs) { 329 if (params.grab_inputs) {
325 DCHECK(std::find_if(children.begin(), children.end(), &GrabsInput) 330 DCHECK(std::find_if(children.begin(), children.end(), &GrabsInput)
326 == children.end()) 331 == children.end())
327 << "input has already been grabbed by another container"; 332 << "input has already been grabbed by another container";
328 root_window_->SetEventTargeter( 333 AthenaEventTargeter* athena_event_targeter =
329 scoped_ptr<ui::EventTargeter>(new AthenaEventTargeter(container))); 334 new AthenaEventTargeter(container);
335 athena_event_targeter->SetPreviousEventTargeter(
336 root_window_->SetEventTargeter(
337 scoped_ptr<ui::EventTargeter>(athena_event_targeter)));
330 } 338 }
331 339
332 root_window_->AddChild(container); 340 root_window_->AddChild(container);
333 341
334 aura::Window::Windows::const_iterator iter = 342 aura::Window::Windows::const_iterator iter =
335 std::find_if(children.begin(), 343 std::find_if(children.begin(),
336 children.end(), 344 children.end(),
337 HigherPriorityFinder(params.z_order_priority)); 345 HigherPriorityFinder(params.z_order_priority));
338 if (iter != children.end()) 346 if (iter != children.end())
339 root_window_->StackChildBelow(container, *iter); 347 root_window_->StackChildBelow(container, *iter);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 393 }
386 394
387 // static 395 // static
388 void ScreenManager::Shutdown() { 396 void ScreenManager::Shutdown() {
389 DCHECK(instance); 397 DCHECK(instance);
390 delete instance; 398 delete instance;
391 DCHECK(!instance); 399 DCHECK(!instance);
392 } 400 }
393 401
394 } // namespace athena 402 } // namespace athena
OLDNEW
« no previous file with comments | « athena/main/athena_launcher.cc ('k') | athena/screen_lock/chrome/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698