| 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 "chrome/browser/chromeos/options/network_config_view.h" | 5 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 | 115 |
| 116 NetworkConfigView::~NetworkConfigView() { | 116 NetworkConfigView::~NetworkConfigView() { |
| 117 DCHECK(GetActiveDialog() == this); | 117 DCHECK(GetActiveDialog() == this); |
| 118 SetActiveDialog(nullptr); | 118 SetActiveDialog(nullptr); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // static | 121 // static |
| 122 void NetworkConfigView::Show(const std::string& service_path, | 122 void NetworkConfigView::Show(const std::string& service_path, |
| 123 gfx::NativeWindow parent) { | 123 gfx::NativeWindow parent) { |
| 124 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| 125 GetNetworkState(service_path); |
| 126 ShowByNetwork(network, parent); |
| 127 } |
| 128 |
| 129 // static |
| 130 void NetworkConfigView::ShowByNetworkId(const std::string& network_id, |
| 131 gfx::NativeWindow parent) { |
| 132 const NetworkState* network = |
| 133 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid( |
| 134 network_id); |
| 135 ShowByNetwork(network, parent); |
| 136 } |
| 137 |
| 138 // static |
| 139 void NetworkConfigView::ShowByNetwork(const NetworkState* network, |
| 140 gfx::NativeWindow parent) { |
| 124 if (GetActiveDialog() != nullptr) | 141 if (GetActiveDialog() != nullptr) |
| 125 return; | 142 return; |
| 126 NetworkConfigView* view = new NetworkConfigView(); | |
| 127 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | |
| 128 GetNetworkState(service_path); | |
| 129 if (!network) { | 143 if (!network) { |
| 130 LOG(ERROR) << "NetworkConfigView::Show called with invalid service_path"; | 144 LOG(ERROR) << "NetworkConfigView::Show called with invalid network"; |
| 131 return; | 145 return; |
| 132 } | 146 } |
| 147 NetworkConfigView* view = new NetworkConfigView(); |
| 133 if (!view->InitWithNetworkState(network)) { | 148 if (!view->InitWithNetworkState(network)) { |
| 134 LOG(ERROR) << "NetworkConfigView::Show called with invalid network type: " | 149 LOG(ERROR) << "NetworkConfigView::Show called with invalid network type: " |
| 135 << network->type(); | 150 << network->type(); |
| 136 delete view; | 151 delete view; |
| 137 return; | 152 return; |
| 138 } | 153 } |
| 139 NET_LOG(USER) << "NetworkConfigView::Show: " << service_path; | 154 NET_LOG(USER) << "NetworkConfigView::Show: " << network->path(); |
| 140 view->ShowDialog(parent); | 155 view->ShowDialog(parent); |
| 141 } | 156 } |
| 142 | 157 |
| 143 // static | 158 // static |
| 144 void NetworkConfigView::ShowForType(const std::string& type, | 159 void NetworkConfigView::ShowForType(const std::string& type, |
| 145 gfx::NativeWindow parent) { | 160 gfx::NativeWindow parent) { |
| 146 if (GetActiveDialog() != nullptr) | 161 if (GetActiveDialog() != nullptr) |
| 147 return; | 162 return; |
| 148 NetworkConfigView* view = new NetworkConfigView(); | 163 NetworkConfigView* view = new NetworkConfigView(); |
| 149 if (!view->InitWithType(type)) { | 164 if (!view->InitWithType(type)) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 343 } |
| 329 | 344 |
| 330 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} | 345 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} |
| 331 | 346 |
| 332 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() const { | 347 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() const { |
| 333 return (managed_ && visible()) ? image_view_->GetPreferredSize() | 348 return (managed_ && visible()) ? image_view_->GetPreferredSize() |
| 334 : gfx::Size(); | 349 : gfx::Size(); |
| 335 } | 350 } |
| 336 | 351 |
| 337 } // namespace chromeos | 352 } // namespace chromeos |
| OLD | NEW |