| 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_network.h" | 5 #include "ash/system/chromeos/network/tray_network.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/metrics/user_metrics_recorder.h" | 8 #include "ash/metrics/user_metrics_recorder.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" | 10 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 image_view_ = new views::ImageView; | 55 image_view_ = new views::ImageView; |
| 56 AddChildView(image_view_); | 56 AddChildView(image_view_); |
| 57 | 57 |
| 58 UpdateNetworkStateHandlerIcon(); | 58 UpdateNetworkStateHandlerIcon(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual ~NetworkTrayView() { | 61 virtual ~NetworkTrayView() { |
| 62 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 62 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual const char* GetClassName() const OVERRIDE { | 65 virtual const char* GetClassName() const override { |
| 66 return "NetworkTrayView"; | 66 return "NetworkTrayView"; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void UpdateNetworkStateHandlerIcon() { | 69 void UpdateNetworkStateHandlerIcon() { |
| 70 NetworkStateHandler* handler = | 70 NetworkStateHandler* handler = |
| 71 NetworkHandler::Get()->network_state_handler(); | 71 NetworkHandler::Get()->network_state_handler(); |
| 72 gfx::ImageSkia image; | 72 gfx::ImageSkia image; |
| 73 base::string16 name; | 73 base::string16 name; |
| 74 bool animating = false; | 74 bool animating = false; |
| 75 ui::network_icon::GetDefaultNetworkImageAndLabel( | 75 ui::network_icon::GetDefaultNetworkImageAndLabel( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 94 | 94 |
| 95 void UpdateAlignment(ShelfAlignment alignment) { | 95 void UpdateAlignment(ShelfAlignment alignment) { |
| 96 SetLayoutManager(new views::BoxLayout( | 96 SetLayoutManager(new views::BoxLayout( |
| 97 alignment == SHELF_ALIGNMENT_BOTTOM ? | 97 alignment == SHELF_ALIGNMENT_BOTTOM ? |
| 98 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, | 98 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, |
| 99 0, 0, 0)); | 99 0, 0, 0)); |
| 100 Layout(); | 100 Layout(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // views::View override. | 103 // views::View override. |
| 104 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE { | 104 virtual void GetAccessibleState(ui::AXViewState* state) override { |
| 105 state->name = connection_status_string_; | 105 state->name = connection_status_string_; |
| 106 state->role = ui::AX_ROLE_BUTTON; | 106 state->role = ui::AX_ROLE_BUTTON; |
| 107 } | 107 } |
| 108 | 108 |
| 109 // ui::network_icon::AnimationObserver | 109 // ui::network_icon::AnimationObserver |
| 110 virtual void NetworkIconChanged() OVERRIDE { | 110 virtual void NetworkIconChanged() override { |
| 111 UpdateNetworkStateHandlerIcon(); | 111 UpdateNetworkStateHandlerIcon(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 // Updates connection status and notifies accessibility event when necessary. | 115 // Updates connection status and notifies accessibility event when necessary. |
| 116 void UpdateConnectionStatus(const base::string16& network_name, | 116 void UpdateConnectionStatus(const base::string16& network_name, |
| 117 bool connected) { | 117 bool connected) { |
| 118 base::string16 new_connection_status_string; | 118 base::string16 new_connection_status_string; |
| 119 if (connected) { | 119 if (connected) { |
| 120 new_connection_status_string = l10n_util::GetStringFUTF16( | 120 new_connection_status_string = l10n_util::GetStringFUTF16( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 163 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 164 else | 164 else |
| 165 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver( | 165 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver( |
| 166 this); | 166 this); |
| 167 SetImage(&image); | 167 SetImage(&image); |
| 168 SetLabel(label); | 168 SetLabel(label); |
| 169 SetAccessibleName(label); | 169 SetAccessibleName(label); |
| 170 } | 170 } |
| 171 | 171 |
| 172 // ui::network_icon::AnimationObserver | 172 // ui::network_icon::AnimationObserver |
| 173 virtual void NetworkIconChanged() OVERRIDE { | 173 virtual void NetworkIconChanged() override { |
| 174 Update(); | 174 Update(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 TrayNetwork* network_tray_; | 178 TrayNetwork* network_tray_; |
| 179 | 179 |
| 180 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); | 180 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 class NetworkWifiDetailedView : public NetworkDetailedView { | 183 class NetworkWifiDetailedView : public NetworkDetailedView { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 197 AddChildView(label_view_); | 197 AddChildView(label_view_); |
| 198 | 198 |
| 199 Update(); | 199 Update(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 virtual ~NetworkWifiDetailedView() { | 202 virtual ~NetworkWifiDetailedView() { |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Overridden from NetworkDetailedView: | 205 // Overridden from NetworkDetailedView: |
| 206 | 206 |
| 207 virtual void Init() OVERRIDE { | 207 virtual void Init() override { |
| 208 } | 208 } |
| 209 | 209 |
| 210 virtual NetworkDetailedView::DetailedViewType GetViewType() const OVERRIDE { | 210 virtual NetworkDetailedView::DetailedViewType GetViewType() const override { |
| 211 return NetworkDetailedView::WIFI_VIEW; | 211 return NetworkDetailedView::WIFI_VIEW; |
| 212 } | 212 } |
| 213 | 213 |
| 214 virtual void ManagerChanged() OVERRIDE { | 214 virtual void ManagerChanged() override { |
| 215 Update(); | 215 Update(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 virtual void NetworkListChanged() OVERRIDE { | 218 virtual void NetworkListChanged() override { |
| 219 Update(); | 219 Update(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 virtual void NetworkServiceChanged( | 222 virtual void NetworkServiceChanged( |
| 223 const chromeos::NetworkState* network) OVERRIDE { | 223 const chromeos::NetworkState* network) override { |
| 224 } | 224 } |
| 225 | 225 |
| 226 private: | 226 private: |
| 227 virtual void Layout() OVERRIDE { | 227 virtual void Layout() override { |
| 228 // Center both views vertically. | 228 // Center both views vertically. |
| 229 views::View::Layout(); | 229 views::View::Layout(); |
| 230 image_view_->SetY( | 230 image_view_->SetY( |
| 231 (height() - image_view_->GetPreferredSize().height()) / 2); | 231 (height() - image_view_->GetPreferredSize().height()) / 2); |
| 232 label_view_->SetY( | 232 label_view_->SetY( |
| 233 (height() - label_view_->GetPreferredSize().height()) / 2); | 233 (height() - label_view_->GetPreferredSize().height()) / 2); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void Update() { | 236 void Update() { |
| 237 bool wifi_enabled = | 237 bool wifi_enabled = |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 detailed_->ManagerChanged(); | 369 detailed_->ManagerChanged(); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 void TrayNetwork::NetworkServiceChanged(const chromeos::NetworkState* network) { | 373 void TrayNetwork::NetworkServiceChanged(const chromeos::NetworkState* network) { |
| 374 if (detailed_) | 374 if (detailed_) |
| 375 detailed_->NetworkServiceChanged(network); | 375 detailed_->NetworkServiceChanged(network); |
| 376 } | 376 } |
| 377 | 377 |
| 378 } // namespace ash | 378 } // namespace ash |
| OLD | NEW |