Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: ash/system/network/vpn_list_view.cc

Issue 2843163003: Remove NetworkListDelegate (Closed)
Patch Set: Addressed review comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/network/vpn_list_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/network/vpn_list_view.h" 5 #include "ash/system/network/vpn_list_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_view_ids.h" 11 #include "ash/ash_view_ids.h"
12 #include "ash/resources/vector_icons/vector_icons.h" 12 #include "ash/resources/vector_icons/vector_icons.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_port.h" 14 #include "ash/shell_port.h"
15 #include "ash/strings/grit/ash_strings.h" 15 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/network/network_icon.h" 16 #include "ash/system/network/network_icon.h"
17 #include "ash/system/network/network_icon_animation.h" 17 #include "ash/system/network/network_icon_animation.h"
18 #include "ash/system/network/network_icon_animation_observer.h" 18 #include "ash/system/network/network_icon_animation_observer.h"
19 #include "ash/system/network/network_list_delegate.h" 19 #include "ash/system/network/network_state_list_detailed_view.h"
20 #include "ash/system/network/vpn_list.h" 20 #include "ash/system/network/vpn_list.h"
21 #include "ash/system/tray/hover_highlight_view.h" 21 #include "ash/system/tray/hover_highlight_view.h"
22 #include "ash/system/tray/system_menu_button.h" 22 #include "ash/system/tray/system_menu_button.h"
23 #include "ash/system/tray/system_tray_controller.h" 23 #include "ash/system/tray/system_tray_controller.h"
24 #include "ash/system/tray/throbber_view.h" 24 #include "ash/system/tray/throbber_view.h"
25 #include "ash/system/tray/tray_constants.h" 25 #include "ash/system/tray/tray_constants.h"
26 #include "ash/system/tray/tray_popup_utils.h" 26 #include "ash/system/tray/tray_popup_utils.h"
27 #include "ash/system/tray/tri_view.h" 27 #include "ash/system/tray/tri_view.h"
28 #include "base/bind.h" 28 #include "base/bind.h"
29 #include "base/bind_helpers.h" 29 #include "base/bind_helpers.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 this, l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VPN_DISCONNECT)); 213 this, l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VPN_DISCONNECT));
214 tri_view()->AddView(TriView::Container::END, disconnect_button_); 214 tri_view()->AddView(TriView::Container::END, disconnect_button_);
215 tri_view()->SetContainerVisible(TriView::Container::END, true); 215 tri_view()->SetContainerVisible(TriView::Container::END, true);
216 tri_view()->SetContainerBorder( 216 tri_view()->SetContainerBorder(
217 TriView::Container::END, 217 TriView::Container::END,
218 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin)); 218 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin));
219 } 219 }
220 Layout(); 220 Layout();
221 } 221 }
222 222
223 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. 223 // TODO(varkha|mohsen): Consolidate with a similar method in
224 // BluetoothDetailedView. See https://crbug.com/686924.
224 void VPNListNetworkEntry::SetupConnectedItem(const base::string16& text, 225 void VPNListNetworkEntry::SetupConnectedItem(const base::string16& text,
225 const gfx::ImageSkia& image) { 226 const gfx::ImageSkia& image) {
226 AddIconAndLabels( 227 AddIconAndLabels(
227 image, text, 228 image, text,
228 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)); 229 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED));
229 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION); 230 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION);
230 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); 231 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED);
231 style.SetupLabel(sub_text_label()); 232 style.SetupLabel(sub_text_label());
232 } 233 }
233 234
234 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. 235 // TODO(varkha|mohsen): Consolidate with a similar method in
236 // BluetoothDetailedView. See https://crbug.com/686924.
235 void VPNListNetworkEntry::SetupConnectingItem(const base::string16& text, 237 void VPNListNetworkEntry::SetupConnectingItem(const base::string16& text,
236 const gfx::ImageSkia& image) { 238 const gfx::ImageSkia& image) {
237 AddIconAndLabels( 239 AddIconAndLabels(
238 image, text, 240 image, text,
239 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)); 241 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING));
240 ThrobberView* throbber = new ThrobberView; 242 ThrobberView* throbber = new ThrobberView;
241 throbber->Start(); 243 throbber->Start();
242 AddRightView(throbber); 244 AddRightView(throbber);
243 } 245 }
244 246
245 } // namespace 247 } // namespace
246 248
247 VPNListView::VPNListView(NetworkListDelegate* delegate) : delegate_(delegate) { 249 VPNListView::VPNListView(tray::NetworkStateListDetailedView* detailed_view)
250 : NetworkListViewBase(detailed_view) {
248 Shell::Get()->vpn_list()->AddObserver(this); 251 Shell::Get()->vpn_list()->AddObserver(this);
249 } 252 }
250 253
251 VPNListView::~VPNListView() { 254 VPNListView::~VPNListView() {
252 Shell::Get()->vpn_list()->RemoveObserver(this); 255 Shell::Get()->vpn_list()->RemoveObserver(this);
253 } 256 }
254 257
255 void VPNListView::Update() { 258 void VPNListView::Update() {
256 // Before updating the list, determine whether the user was hovering over one 259 // Before updating the list, determine whether the user was hovering over one
257 // of the VPN provider or network entries. 260 // of the VPN provider or network entries.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 network_view_guid_map_) { 310 network_view_guid_map_) {
308 if (entry.second == hovered_network_guid) { 311 if (entry.second == hovered_network_guid) {
309 scroll_to_show_view = entry.first; 312 scroll_to_show_view = entry.first;
310 break; 313 break;
311 } 314 }
312 } 315 }
313 } 316 }
314 317
315 // Layout the updated list. 318 // Layout the updated list.
316 container()->SizeToPreferredSize(); 319 container()->SizeToPreferredSize();
317 delegate_->RelayoutScrollList(); 320 detailed_view()->RelayoutScrollList();
318 321
319 if (scroll_to_show_view) { 322 if (scroll_to_show_view) {
320 // Scroll the list so that |scroll_to_show_view| is in view. 323 // Scroll the list so that |scroll_to_show_view| is in view.
321 container()->ScrollRectToVisible(scroll_to_show_view->bounds()); 324 container()->ScrollRectToVisible(scroll_to_show_view->bounds());
322 } 325 }
323 } 326 }
324 327
325 bool VPNListView::IsNetworkEntry(views::View* view, std::string* guid) const { 328 bool VPNListView::IsNetworkEntry(views::View* view, std::string* guid) const {
326 const auto& entry = network_view_guid_map_.find(view); 329 const auto& entry = network_view_guid_map_.find(view);
327 if (entry == network_view_guid_map_.end()) 330 if (entry == network_view_guid_map_.end())
(...skipping 22 matching lines...) Expand all
350 UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED); 353 UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED);
351 Shell::Get()->system_tray_controller()->ShowNetworkCreate( 354 Shell::Get()->system_tray_controller()->ShowNetworkCreate(
352 shill::kTypeVPN); 355 shill::kTypeVPN);
353 } 356 }
354 return; 357 return;
355 } 358 }
356 359
357 // If the user clicked on a network entry, let the |delegate_| trigger a 360 // If the user clicked on a network entry, let the |delegate_| trigger a
358 // connection attempt (if the network is currently disconnected) or show a 361 // connection attempt (if the network is currently disconnected) or show a
359 // configuration dialog (if the network is currently connected or connecting). 362 // configuration dialog (if the network is currently connected or connecting).
360 delegate_->OnNetworkEntryClicked(sender); 363 detailed_view()->OnNetworkEntryClicked(sender);
361 } 364 }
362 365
363 void VPNListView::AddNetwork(const chromeos::NetworkState* network) { 366 void VPNListView::AddNetwork(const chromeos::NetworkState* network) {
364 views::View* entry(new VPNListNetworkEntry(this, network)); 367 views::View* entry(new VPNListNetworkEntry(this, network));
365 container()->AddChildView(entry); 368 container()->AddChildView(entry);
366 network_view_guid_map_[entry] = network->guid(); 369 network_view_guid_map_[entry] = network->guid();
367 list_empty_ = false; 370 list_empty_ = false;
368 } 371 }
369 372
370 void VPNListView::AddProviderAndNetworks( 373 void VPNListView::AddProviderAndNetworks(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 416 }
414 } 417 }
415 418
416 // Add providers without any configured networks, in the order that the 419 // Add providers without any configured networks, in the order that the
417 // providers were returned by the extensions system. 420 // providers were returned by the extensions system.
418 for (const VPNProvider& provider : providers) 421 for (const VPNProvider& provider : providers)
419 AddProviderAndNetworks(provider, networks); 422 AddProviderAndNetworks(provider, networks);
420 } 423 }
421 424
422 } // namespace ash 425 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/network/vpn_list_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698