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/common/system/chromeos/network/tray_network.h" | 5 #include "ash/common/system/chromeos/network/tray_network.h" |
6 | 6 |
7 #include "ash/common/shelf/wm_shelf_util.h" | 7 #include "ash/common/shelf/wm_shelf_util.h" |
8 #include "ash/common/system/chromeos/network/network_state_list_detailed_view.h" | 8 #include "ash/common/system/chromeos/network/network_state_list_detailed_view.h" |
9 #include "ash/common/system/chromeos/network/tray_network_state_observer.h" | 9 #include "ash/common/system/chromeos/network/tray_network_state_observer.h" |
10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
11 #include "ash/common/system/tray/system_tray_delegate.h" | 11 #include "ash/common/system/tray/system_tray_delegate.h" |
12 #include "ash/common/system/tray/system_tray_notifier.h" | 12 #include "ash/common/system/tray/system_tray_notifier.h" |
13 #include "ash/common/system/tray/tray_constants.h" | 13 #include "ash/common/system/tray/tray_constants.h" |
14 #include "ash/common/system/tray/tray_item_more.h" | 14 #include "ash/common/system/tray/tray_item_more.h" |
15 #include "ash/common/system/tray/tray_item_view.h" | 15 #include "ash/common/system/tray/tray_item_view.h" |
| 16 #include "ash/common/system/tray/tray_popup_item_style.h" |
16 #include "ash/common/system/tray/tray_utils.h" | 17 #include "ash/common/system/tray/tray_utils.h" |
17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "chromeos/network/network_state.h" | 21 #include "chromeos/network/network_state.h" |
21 #include "chromeos/network/network_state_handler.h" | 22 #include "chromeos/network/network_state_handler.h" |
22 #include "grit/ash_resources.h" | 23 #include "grit/ash_resources.h" |
23 #include "grit/ash_strings.h" | 24 #include "grit/ash_strings.h" |
24 #include "grit/ui_chromeos_strings.h" | 25 #include "grit/ui_chromeos_strings.h" |
25 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 91 } |
91 | 92 |
92 void UpdateAlignment(ShelfAlignment alignment) { | 93 void UpdateAlignment(ShelfAlignment alignment) { |
93 SetLayoutManager(new views::BoxLayout(IsHorizontalAlignment(alignment) | 94 SetLayoutManager(new views::BoxLayout(IsHorizontalAlignment(alignment) |
94 ? views::BoxLayout::kHorizontal | 95 ? views::BoxLayout::kHorizontal |
95 : views::BoxLayout::kVertical, | 96 : views::BoxLayout::kVertical, |
96 0, 0, 0)); | 97 0, 0, 0)); |
97 Layout(); | 98 Layout(); |
98 } | 99 } |
99 | 100 |
100 // views::View override. | 101 // views::View: |
101 void GetAccessibleState(ui::AXViewState* state) override { | 102 void GetAccessibleState(ui::AXViewState* state) override { |
102 state->name = connection_status_string_; | 103 state->name = connection_status_string_; |
103 state->role = ui::AX_ROLE_BUTTON; | 104 state->role = ui::AX_ROLE_BUTTON; |
104 } | 105 } |
105 | 106 |
106 // ui::network_icon::AnimationObserver | 107 // ui::network_icon::AnimationObserver: |
107 void NetworkIconChanged() override { UpdateNetworkStateHandlerIcon(); } | 108 void NetworkIconChanged() override { UpdateNetworkStateHandlerIcon(); } |
108 | 109 |
109 private: | 110 private: |
110 // Updates connection status and notifies accessibility event when necessary. | 111 // Updates connection status and notifies accessibility event when necessary. |
111 void UpdateConnectionStatus(const base::string16& network_name, | 112 void UpdateConnectionStatus(const base::string16& network_name, |
112 bool connected) { | 113 bool connected) { |
113 base::string16 new_connection_status_string; | 114 base::string16 new_connection_status_string; |
114 if (connected) { | 115 if (connected) { |
115 new_connection_status_string = l10n_util::GetStringFUTF16( | 116 new_connection_status_string = l10n_util::GetStringFUTF16( |
116 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, network_name); | 117 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, network_name); |
(...skipping 26 matching lines...) Expand all Loading... |
143 } | 144 } |
144 | 145 |
145 ~NetworkDefaultView() override { | 146 ~NetworkDefaultView() override { |
146 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 147 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
147 } | 148 } |
148 | 149 |
149 void Update() { | 150 void Update() { |
150 gfx::ImageSkia image; | 151 gfx::ImageSkia image; |
151 base::string16 label; | 152 base::string16 label; |
152 bool animating = false; | 153 bool animating = false; |
| 154 // TODO(bruthig): Update the image to use the proper color. See |
| 155 // https://crbug.com/632027. |
153 ui::network_icon::GetDefaultNetworkImageAndLabel( | 156 ui::network_icon::GetDefaultNetworkImageAndLabel( |
154 ui::network_icon::ICON_TYPE_DEFAULT_VIEW, &image, &label, &animating); | 157 ui::network_icon::ICON_TYPE_DEFAULT_VIEW, &image, &label, &animating); |
155 if (animating) | 158 if (animating) |
156 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 159 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
157 else | 160 else |
158 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver( | 161 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver( |
159 this); | 162 this); |
160 SetImage(image); | 163 SetImage(image); |
161 SetLabel(label); | 164 SetLabel(label); |
162 SetAccessibleName(label); | 165 SetAccessibleName(label); |
163 } | 166 } |
164 | 167 |
165 // ui::network_icon::AnimationObserver | 168 // ui::network_icon::AnimationObserver |
166 void NetworkIconChanged() override { Update(); } | 169 void NetworkIconChanged() override { Update(); } |
167 | 170 |
| 171 protected: |
| 172 // TrayItemMore: |
| 173 std::unique_ptr<TrayPopupItemStyle> CreateStyle() const override { |
| 174 // TODO(bruthig): Apply different ColorStyles based on network state. See |
| 175 // https://crbug.com/632027. |
| 176 return base::MakeUnique<TrayPopupItemStyle>( |
| 177 GetNativeTheme(), TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 178 } |
| 179 |
168 private: | 180 private: |
169 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); | 181 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); |
170 }; | 182 }; |
171 | 183 |
172 class NetworkWifiDetailedView : public NetworkDetailedView { | 184 class NetworkWifiDetailedView : public NetworkDetailedView { |
173 public: | 185 public: |
174 explicit NetworkWifiDetailedView(SystemTrayItem* owner) | 186 explicit NetworkWifiDetailedView(SystemTrayItem* owner) |
175 : NetworkDetailedView(owner) { | 187 : NetworkDetailedView(owner) { |
176 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 188 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
177 kTrayPopupPaddingHorizontal, 10, | 189 kTrayPopupPaddingHorizontal, 10, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 void TrayNetwork::NetworkStateChanged() { | 341 void TrayNetwork::NetworkStateChanged() { |
330 if (tray_) | 342 if (tray_) |
331 tray_->UpdateNetworkStateHandlerIcon(); | 343 tray_->UpdateNetworkStateHandlerIcon(); |
332 if (default_) | 344 if (default_) |
333 default_->Update(); | 345 default_->Update(); |
334 if (detailed_) | 346 if (detailed_) |
335 detailed_->Update(); | 347 detailed_->Update(); |
336 } | 348 } |
337 | 349 |
338 } // namespace ash | 350 } // namespace ash |
OLD | NEW |