Chromium Code Reviews| Index: chrome/browser/chromeos/options/network_config_view.cc |
| diff --git a/chrome/browser/chromeos/options/network_config_view.cc b/chrome/browser/chromeos/options/network_config_view.cc |
| index b52eccb2adc949be5c5f7eaee930bce9c6e620e1..97226af7e30770e25022b33fd5d39daa3233d6a1 100644 |
| --- a/chrome/browser/chromeos/options/network_config_view.cc |
| +++ b/chrome/browser/chromeos/options/network_config_view.cc |
| @@ -12,7 +12,6 @@ |
| #include "chrome/browser/chromeos/cros/network_property_ui_data.h" |
| #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| #include "chrome/browser/chromeos/login/user.h" |
| -#include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/chromeos/options/vpn_config_view.h" |
| #include "chrome/browser/chromeos/options/wifi_config_view.h" |
| #include "chrome/browser/chromeos/options/wimax_config_view.h" |
| @@ -21,7 +20,8 @@ |
| #include "chrome/browser/ui/browser_finder.h" |
| #include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/host_desktop.h" |
| -#include "chromeos/network/managed_network_configuration_handler.h" |
| +#include "chromeos/network/network_state.h" |
| +#include "chromeos/network/network_state_handler.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| #include "grit/locale_settings.h" |
| @@ -76,39 +76,37 @@ namespace chromeos { |
| // static |
| const int ChildNetworkConfigView::kInputFieldMinWidth = 270; |
| -NetworkConfigView::NetworkConfigView(Network* network) |
| +NetworkConfigView::NetworkConfigView() |
| : child_config_view_(NULL), |
| delegate_(NULL), |
| advanced_button_(NULL) { |
| DCHECK(GetActiveDialog() == NULL); |
| SetActiveDialog(this); |
| - if (network->type() == TYPE_WIFI) { |
| - child_config_view_ = |
| - new WifiConfigView(this, static_cast<WifiNetwork*>(network)); |
| - } else if (network->type() == TYPE_WIMAX) { |
| - child_config_view_ = |
| - new WimaxConfigView(this, static_cast<WimaxNetwork*>(network)); |
| - } else if (network->type() == TYPE_VPN) { |
| - child_config_view_ = |
| - new VPNConfigView(this, static_cast<VirtualNetwork*>(network)); |
| - } else { |
| +} |
| + |
| +void NetworkConfigView::InitWithPath(const std::string& service_path) { |
| + const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| + GetNetworkState(service_path); |
| + DCHECK(network); |
| + if (network->type() == flimflam::kTypeWifi) |
| + child_config_view_ = new WifiConfigView(this, service_path, false); |
| + else if (network->type() == flimflam::kTypeWimax) |
| + child_config_view_ = new WimaxConfigView(this, service_path); |
| + else if (network->type() == flimflam::kTypeVPN) |
| + child_config_view_ = new VPNConfigView(this, service_path); |
| + else |
| NOTREACHED(); |
| - } |
| } |
| -NetworkConfigView::NetworkConfigView(ConnectionType type) |
| - : child_config_view_(NULL), |
| - delegate_(NULL), |
| - advanced_button_(NULL) { |
| - DCHECK(GetActiveDialog() == NULL); |
| - SetActiveDialog(this); |
| - if (type == TYPE_WIFI) { |
| - child_config_view_ = new WifiConfigView(this, false /* show_8021x */); |
| +void NetworkConfigView::InitWithType(const std::string& type) { |
| + if (type == flimflam::kTypeWifi) { |
| + child_config_view_ = |
| + new WifiConfigView(this, "" /* service_path */, false /* show_8021x */); |
|
gauravsh
2013/08/03 01:15:54
NIT: This is more readable if the args on separate
stevenjb
2013/08/06 00:32:48
Done.
|
| advanced_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16( |
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ADVANCED_BUTTON)); |
| advanced_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| - } else if (type == TYPE_VPN) { |
| - child_config_view_ = new VPNConfigView(this); |
| + } else if (type == flimflam::kTypeVPN) { |
| + child_config_view_ = new VPNConfigView(this, "" /* service_path */); |
|
gauravsh
2013/08/03 01:15:54
NIT: args on separate lines.
stevenjb
2013/08/06 00:32:48
Done.
|
| } else { |
| NOTREACHED(); |
| } |
| @@ -120,19 +118,22 @@ NetworkConfigView::~NetworkConfigView() { |
| } |
| // static |
| -void NetworkConfigView::Show(Network* network, gfx::NativeWindow parent) { |
| +void NetworkConfigView::Show(const std::string& service_path, |
| + gfx::NativeWindow parent) { |
| if (GetActiveDialog() != NULL) |
| return; |
| - NetworkConfigView* view = new NetworkConfigView(network); |
| + NetworkConfigView* view = new NetworkConfigView(); |
| + view->InitWithPath(service_path); |
| view->ShowDialog(parent); |
| } |
| // static |
| -void NetworkConfigView::ShowForType(ConnectionType type, |
| +void NetworkConfigView::ShowForType(const std::string& type, |
| gfx::NativeWindow parent) { |
| if (GetActiveDialog() != NULL) |
| return; |
| - NetworkConfigView* view = new NetworkConfigView(type); |
| + NetworkConfigView* view = new NetworkConfigView(); |
| + view->InitWithType(type); |
| view->ShowDialog(parent); |
| } |
| @@ -207,7 +208,8 @@ void NetworkConfigView::ShowAdvancedView() { |
| RemoveChildView(child_config_view_); |
| delete child_config_view_; |
| // For now, there is only an advanced view for Wi-Fi 802.1X. |
| - child_config_view_ = new WifiConfigView(this, true /* show_8021x */); |
| + child_config_view_ = |
| + new WifiConfigView(this, "" /* service_path */, true /* show_8021x */); |
|
gauravsh
2013/08/03 01:15:54
NIT: separate lines if you please
stevenjb
2013/08/06 00:32:48
Done.
|
| AddChildView(child_config_view_); |
| // Resize the window to be able to hold the new widgets. |
| gfx::Size size = views::Widget::GetLocalizedContentsSize( |
| @@ -259,6 +261,20 @@ void NetworkConfigView::ShowDialog(gfx::NativeWindow parent) { |
| window->Show(); |
| } |
| +// ChildNetworkConfigView |
| + |
| +ChildNetworkConfigView::ChildNetworkConfigView( |
| + NetworkConfigView* parent, |
| + const std::string& service_path) |
| + : parent_(parent), |
| + service_path_(service_path) { |
| +} |
| + |
| +ChildNetworkConfigView::~ChildNetworkConfigView() { |
| +} |
| + |
| +// ControlledSettingIndicatorView |
| + |
| ControlledSettingIndicatorView::ControlledSettingIndicatorView() |
| : managed_(false), |
| image_view_(NULL) { |
| @@ -289,17 +305,6 @@ gfx::Size ControlledSettingIndicatorView::GetPreferredSize() { |
| : gfx::Size(); |
| } |
| -// static |
| -const base::DictionaryValue* NetworkConfigView::FindPolicyForActiveUser( |
| - const Network* network, |
| - onc::ONCSource* onc_source) { |
| - const User* user = UserManager::Get()->GetActiveUser(); |
| - std::string username_hash = user ? user->username_hash() : std::string(); |
| - std::string guid = network->unique_id(); |
| - return NetworkHandler::Get()->managed_network_configuration_handler() |
| - ->FindPolicyByGUID(username_hash, guid, onc_source); |
| -} |
| - |
| void ControlledSettingIndicatorView::Layout() { |
| image_view_->SetBounds(0, 0, width(), height()); |
| } |