| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ash/system/tray_display.h" | 5 #include "ash/system/chromeos/tray_display.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
| 12 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_views.h" | 13 #include "ash/system/tray/tray_views.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 46 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY).ToImageSkia()); | 46 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY).ToImageSkia()); |
| 47 AddChildView(image); | 47 AddChildView(image); |
| 48 label_ = new views::Label(); | 48 label_ = new views::Label(); |
| 49 AddChildView(label_); | 49 AddChildView(label_); |
| 50 Update(); | 50 Update(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual ~DisplayView() {} | 53 virtual ~DisplayView() {} |
| 54 | 54 |
| 55 void Update() { | 55 void Update() { |
| 56 #if defined(OS_CHROMEOS) | |
| 57 switch (Shell::GetInstance()->output_configurator()->output_state()) { | 56 switch (Shell::GetInstance()->output_configurator()->output_state()) { |
| 58 case chromeos::STATE_INVALID: | 57 case chromeos::STATE_INVALID: |
| 59 case chromeos::STATE_HEADLESS: | 58 case chromeos::STATE_HEADLESS: |
| 60 case chromeos::STATE_SINGLE: | 59 case chromeos::STATE_SINGLE: |
| 61 SetVisible(false); | 60 SetVisible(false); |
| 62 return; | 61 return; |
| 63 case chromeos::STATE_DUAL_MIRROR: { | 62 case chromeos::STATE_DUAL_MIRROR: { |
| 64 // Simply assumes that the primary display appears first and the | 63 // Simply assumes that the primary display appears first and the |
| 65 // secondary display appears next in the list. | 64 // secondary display appears next in the list. |
| 66 std::vector<std::string> display_names; | 65 std::vector<std::string> display_names; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 90 ScreenAsh::GetSecondaryDisplay())))); | 89 ScreenAsh::GetSecondaryDisplay())))); |
| 91 SetVisible(true); | 90 SetVisible(true); |
| 92 } else { | 91 } else { |
| 93 SetVisible(false); | 92 SetVisible(false); |
| 94 } | 93 } |
| 95 return; | 94 return; |
| 96 } | 95 } |
| 97 default: | 96 default: |
| 98 NOTREACHED(); | 97 NOTREACHED(); |
| 99 } | 98 } |
| 100 #endif // OS_CHROMEOS | |
| 101 } | 99 } |
| 102 | 100 |
| 103 private: | 101 private: |
| 104 // Overridden from ActionableView. | 102 // Overridden from ActionableView. |
| 105 virtual bool PerformAction(const ui::Event& event) OVERRIDE { | 103 virtual bool PerformAction(const ui::Event& event) OVERRIDE { |
| 106 if (login_status_ == ash::user::LOGGED_IN_USER || | 104 if (login_status_ == ash::user::LOGGED_IN_USER || |
| 107 login_status_ == ash::user::LOGGED_IN_OWNER || | 105 login_status_ == ash::user::LOGGED_IN_OWNER || |
| 108 login_status_ == ash::user::LOGGED_IN_GUEST) { | 106 login_status_ == ash::user::LOGGED_IN_GUEST) { |
| 109 ash::Shell::GetInstance()->tray_delegate()->ShowDisplaySettings(); | 107 ash::Shell::GetInstance()->tray_delegate()->ShowDisplaySettings(); |
| 110 } | 108 } |
| 111 | 109 |
| 112 return true; | 110 return true; |
| 113 } | 111 } |
| 114 | 112 |
| 115 user::LoginStatus login_status_; | 113 user::LoginStatus login_status_; |
| 116 views::Label* label_; | 114 views::Label* label_; |
| 117 | 115 |
| 118 DISALLOW_COPY_AND_ASSIGN(DisplayView); | 116 DISALLOW_COPY_AND_ASSIGN(DisplayView); |
| 119 }; | 117 }; |
| 120 | 118 |
| 121 TrayDisplay::TrayDisplay() | 119 TrayDisplay::TrayDisplay() |
| 122 : default_(NULL) { | 120 : default_(NULL) { |
| 123 aura::Env::GetInstance()->display_manager()->AddObserver(this); | 121 aura::Env::GetInstance()->display_manager()->AddObserver(this); |
| 124 #if defined(OS_CHROMEOS) | |
| 125 ash::Shell::GetInstance()->output_configurator()->AddObserver(this); | 122 ash::Shell::GetInstance()->output_configurator()->AddObserver(this); |
| 126 #endif | |
| 127 } | 123 } |
| 128 | 124 |
| 129 TrayDisplay::~TrayDisplay() { | 125 TrayDisplay::~TrayDisplay() { |
| 130 aura::Env::GetInstance()->display_manager()->RemoveObserver(this); | 126 aura::Env::GetInstance()->display_manager()->RemoveObserver(this); |
| 131 #if defined(OS_CHROMEOS) | |
| 132 ash::Shell::GetInstance()->output_configurator()->RemoveObserver(this); | 127 ash::Shell::GetInstance()->output_configurator()->RemoveObserver(this); |
| 133 #endif | |
| 134 } | 128 } |
| 135 | 129 |
| 136 views::View* TrayDisplay::CreateDefaultView(user::LoginStatus status) { | 130 views::View* TrayDisplay::CreateDefaultView(user::LoginStatus status) { |
| 137 #if defined(OS_CHROMEOS) | |
| 138 default_ = new DisplayView(status); | 131 default_ = new DisplayView(status); |
| 139 #endif | |
| 140 return default_; | 132 return default_; |
| 141 } | 133 } |
| 142 | 134 |
| 143 void TrayDisplay::DestroyDefaultView() { | 135 void TrayDisplay::DestroyDefaultView() { |
| 144 default_ = NULL; | 136 default_ = NULL; |
| 145 } | 137 } |
| 146 | 138 |
| 147 void TrayDisplay::OnDisplayBoundsChanged(const gfx::Display& display) { | 139 void TrayDisplay::OnDisplayBoundsChanged(const gfx::Display& display) { |
| 148 if (default_) | 140 if (default_) |
| 149 default_->Update(); | 141 default_->Update(); |
| 150 } | 142 } |
| 151 | 143 |
| 152 void TrayDisplay::OnDisplayAdded(const gfx::Display& new_display) { | 144 void TrayDisplay::OnDisplayAdded(const gfx::Display& new_display) { |
| 153 if (default_) | 145 if (default_) |
| 154 default_->Update(); | 146 default_->Update(); |
| 155 } | 147 } |
| 156 | 148 |
| 157 void TrayDisplay::OnDisplayRemoved(const gfx::Display& old_display) { | 149 void TrayDisplay::OnDisplayRemoved(const gfx::Display& old_display) { |
| 158 if (default_) | 150 if (default_) |
| 159 default_->Update(); | 151 default_->Update(); |
| 160 } | 152 } |
| 161 | 153 |
| 162 #if defined(OS_CHROMEOS) | |
| 163 void TrayDisplay::OnDisplayModeChanged() { | 154 void TrayDisplay::OnDisplayModeChanged() { |
| 164 if (default_) | 155 if (default_) |
| 165 default_->Update(); | 156 default_->Update(); |
| 166 } | 157 } |
| 167 #endif | |
| 168 | |
| 169 | 158 |
| 170 } // namespace internal | 159 } // namespace internal |
| 171 } // namespace ash | 160 } // namespace ash |
| OLD | NEW |