| 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/chromeos/network/tray_vpn.h" | 5 #include "ash/system/chromeos/network/tray_vpn.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/tray/system_tray_delegate.h" | 8 #include "ash/common/system/tray/system_tray_delegate.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "ash/common/system/tray/tray_item_more.h" | 10 #include "ash/common/system/tray/tray_item_more.h" |
| 11 #include "ash/common/system/tray/tray_popup_label_button.h" | 11 #include "ash/common/system/tray/tray_popup_label_button.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/metrics/user_metrics_recorder.h" | |
| 14 #include "ash/shell.h" | |
| 15 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" | 13 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" |
| 16 #include "ash/system/chromeos/network/vpn_delegate.h" | 14 #include "ash/system/chromeos/network/vpn_delegate.h" |
| 17 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
| 18 #include "chromeos/network/network_state.h" | 16 #include "chromeos/network/network_state.h" |
| 19 #include "chromeos/network/network_state_handler.h" | 17 #include "chromeos/network/network_state_handler.h" |
| 20 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
| 21 #include "grit/ui_chromeos_strings.h" | 19 #include "grit/ui_chromeos_strings.h" |
| 22 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/chromeos/network/network_icon.h" | 22 #include "ui/chromeos/network/network_icon.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 125 |
| 128 views::View* TrayVPN::CreateDefaultView(LoginStatus status) { | 126 views::View* TrayVPN::CreateDefaultView(LoginStatus status) { |
| 129 CHECK(default_ == NULL); | 127 CHECK(default_ == NULL); |
| 130 if (!chromeos::NetworkHandler::IsInitialized()) | 128 if (!chromeos::NetworkHandler::IsInitialized()) |
| 131 return NULL; | 129 return NULL; |
| 132 if (status == LoginStatus::NOT_LOGGED_IN) | 130 if (status == LoginStatus::NOT_LOGGED_IN) |
| 133 return NULL; | 131 return NULL; |
| 134 if (!tray::VpnDefaultView::ShouldShow()) | 132 if (!tray::VpnDefaultView::ShouldShow()) |
| 135 return NULL; | 133 return NULL; |
| 136 | 134 |
| 137 bool userAddingRunning = ash::Shell::GetInstance() | 135 const bool is_in_secondary_login_screen = |
| 138 ->session_state_delegate() | 136 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 139 ->IsInSecondaryLoginScreen(); | |
| 140 | 137 |
| 141 default_ = new tray::VpnDefaultView( | 138 default_ = new tray::VpnDefaultView( |
| 142 this, status != LoginStatus::LOCKED && !userAddingRunning); | 139 this, status != LoginStatus::LOCKED && !is_in_secondary_login_screen); |
| 143 | 140 |
| 144 return default_; | 141 return default_; |
| 145 } | 142 } |
| 146 | 143 |
| 147 views::View* TrayVPN::CreateDetailedView(LoginStatus status) { | 144 views::View* TrayVPN::CreateDetailedView(LoginStatus status) { |
| 148 CHECK(detailed_ == NULL); | 145 CHECK(detailed_ == NULL); |
| 149 if (!chromeos::NetworkHandler::IsInitialized()) | 146 if (!chromeos::NetworkHandler::IsInitialized()) |
| 150 return NULL; | 147 return NULL; |
| 151 | 148 |
| 152 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 149 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_DETAILED_VPN_VIEW); |
| 153 ash::UMA_STATUS_AREA_DETAILED_VPN_VIEW); | |
| 154 detailed_ = new tray::NetworkStateListDetailedView( | 150 detailed_ = new tray::NetworkStateListDetailedView( |
| 155 this, tray::NetworkStateListDetailedView::LIST_TYPE_VPN, status); | 151 this, tray::NetworkStateListDetailedView::LIST_TYPE_VPN, status); |
| 156 detailed_->Init(); | 152 detailed_->Init(); |
| 157 return detailed_; | 153 return detailed_; |
| 158 } | 154 } |
| 159 | 155 |
| 160 void TrayVPN::DestroyTrayView() { | 156 void TrayVPN::DestroyTrayView() { |
| 161 } | 157 } |
| 162 | 158 |
| 163 void TrayVPN::DestroyDefaultView() { | 159 void TrayVPN::DestroyDefaultView() { |
| 164 default_ = NULL; | 160 default_ = NULL; |
| 165 } | 161 } |
| 166 | 162 |
| 167 void TrayVPN::DestroyDetailedView() { | 163 void TrayVPN::DestroyDetailedView() { |
| 168 detailed_ = NULL; | 164 detailed_ = NULL; |
| 169 } | 165 } |
| 170 | 166 |
| 171 void TrayVPN::UpdateAfterLoginStatusChange(LoginStatus status) {} | 167 void TrayVPN::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 172 | 168 |
| 173 void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {} | 169 void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {} |
| 174 | 170 |
| 175 void TrayVPN::NetworkStateChanged() { | 171 void TrayVPN::NetworkStateChanged() { |
| 176 if (default_) | 172 if (default_) |
| 177 default_->Update(); | 173 default_->Update(); |
| 178 if (detailed_) | 174 if (detailed_) |
| 179 detailed_->Update(); | 175 detailed_->Update(); |
| 180 } | 176 } |
| 181 | 177 |
| 182 } // namespace ash | 178 } // namespace ash |
| OLD | NEW |