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

Side by Side Diff: chrome/browser/chromeos/login/helper.cc

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test in Debug. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/chromeos/login/helper.h" 5 #include "chrome/browser/chromeos/login/helper.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chromeos/network/network_handler.h" 9 #include "chromeos/network/network_handler.h"
10 #include "chromeos/network/network_state.h" 10 #include "chromeos/network/network_state.h"
11 #include "chromeos/network/network_state_handler.h" 11 #include "chromeos/network/network_state_handler.h"
12 #include "chromeos/network/shill_property_util.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "grit/theme_resources.h" 14 #include "grit/theme_resources.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h" 15 #include "third_party/cros_system_api/dbus/service_constants.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/screen.h" 18 #include "ui/gfx/screen.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 gfx::Rect CalculateScreenBounds(const gfx::Size& size) { 22 gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
(...skipping 17 matching lines...) Expand all
39 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); 40 ui::GetScaleFactorScale(ui::GetMaxScaleFactor());
40 } 41 }
41 42
42 namespace login { 43 namespace login {
43 44
44 NetworkStateHelper::NetworkStateHelper() {} 45 NetworkStateHelper::NetworkStateHelper() {}
45 NetworkStateHelper::~NetworkStateHelper() {} 46 NetworkStateHelper::~NetworkStateHelper() {}
46 47
47 string16 NetworkStateHelper::GetCurrentNetworkName() const { 48 string16 NetworkStateHelper::GetCurrentNetworkName() const {
48 NetworkStateHandler* nsh = NetworkHandler::Get()->network_state_handler(); 49 NetworkStateHandler* nsh = NetworkHandler::Get()->network_state_handler();
49 const NetworkState* network = nsh->ConnectedNetworkByType( 50 const NetworkState* network =
50 NetworkStateHandler::kMatchTypeNonVirtual); 51 nsh->ConnectedNetworkByType(NetworkTypePattern::NonVirtual());
51 if (network) { 52 if (network) {
52 if (network->type() == flimflam::kTypeEthernet) 53 if (network->Matches(NetworkTypePattern::Ethernet()))
53 return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 54 return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
54 return UTF8ToUTF16(network->name()); 55 return UTF8ToUTF16(network->name());
55 } 56 }
56 57
57 network = nsh->ConnectingNetworkByType( 58 network = nsh->ConnectingNetworkByType(NetworkTypePattern::NonVirtual());
58 NetworkStateHandler::kMatchTypeNonVirtual);
59 if (network) { 59 if (network) {
60 if (network->type() == flimflam::kTypeEthernet) 60 if (network->Matches(NetworkTypePattern::Ethernet()))
61 return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 61 return l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
62 return UTF8ToUTF16(network->name()); 62 return UTF8ToUTF16(network->name());
63 } 63 }
64 return string16(); 64 return string16();
65 } 65 }
66 66
67 bool NetworkStateHelper::IsConnected() const { 67 bool NetworkStateHelper::IsConnected() const {
68 chromeos::NetworkStateHandler* nsh = 68 chromeos::NetworkStateHandler* nsh =
69 chromeos::NetworkHandler::Get()->network_state_handler(); 69 chromeos::NetworkHandler::Get()->network_state_handler();
70 return nsh->ConnectedNetworkByType( 70 return nsh->ConnectedNetworkByType(chromeos::NetworkTypePattern::Default()) !=
71 chromeos::NetworkStateHandler::kMatchTypeDefault) != NULL; 71 NULL;
72 } 72 }
73 73
74 bool NetworkStateHelper::IsConnecting() const { 74 bool NetworkStateHelper::IsConnecting() const {
75 chromeos::NetworkStateHandler* nsh = 75 chromeos::NetworkStateHandler* nsh =
76 chromeos::NetworkHandler::Get()->network_state_handler(); 76 chromeos::NetworkHandler::Get()->network_state_handler();
77 return nsh->ConnectingNetworkByType( 77 return nsh->ConnectingNetworkByType(
78 chromeos::NetworkStateHandler::kMatchTypeDefault) != NULL; 78 chromeos::NetworkTypePattern::Default()) != NULL;
79 } 79 }
80 80
81 } // namespace login 81 } // namespace login
82 82
83 } // namespace chromeos 83 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/auth_prewarmer.cc ('k') | chrome/browser/chromeos/login/proxy_settings_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698