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 #include "chrome/browser/chromeos/display/primary_display_switch_observer.h" | |
6 | |
7 #include "ash/shell.h" | |
8 #include "chrome/browser/chromeos/display/display_preferences.h" | |
9 #include "ui/aura/root_window.h" | |
10 | |
11 namespace chromeos { | |
12 | |
13 PrimaryDisplaySwitchObserver::PrimaryDisplaySwitchObserver() | |
14 : primary_root_(ash::Shell::GetInstance()->GetPrimaryRootWindow()) { | |
15 primary_root_->AddRootWindowObserver(this); | |
16 primary_root_->AddObserver(this); | |
17 } | |
18 | |
19 PrimaryDisplaySwitchObserver::~PrimaryDisplaySwitchObserver() { | |
20 primary_root_->RemoveRootWindowObserver(this); | |
21 primary_root_->RemoveObserver(this); | |
22 } | |
23 | |
24 void PrimaryDisplaySwitchObserver::OnRootWindowMoved( | |
25 const aura::RootWindow* root_window, const gfx::Point& new_origin) { | |
26 StoreDisplayPrefs(); | |
27 } | |
28 | |
29 void PrimaryDisplaySwitchObserver::OnWindowDestroying(aura::Window* window) { | |
30 if (primary_root_ == window) { | |
31 primary_root_->RemoveRootWindowObserver(this); | |
32 primary_root_->RemoveObserver(this); | |
33 primary_root_ = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | |
34 primary_root_->AddRootWindowObserver(this); | |
35 primary_root_->AddObserver(this); | |
36 } | |
37 } | |
38 | |
39 } // namespace chromeos | |
OLD | NEW |