Chromium Code Reviews| 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 "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 if (browser) | 62 if (browser) |
| 63 return browser->window()->GetNativeWindow(); | 63 return browser->window()->GetNativeWindow(); |
| 64 } | 64 } |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 // static | 70 // static |
| 71 const int ChildNetworkConfigView::kInputFieldMinWidth = 270; | 71 const int ChildNetworkConfigView::kInputFieldMinWidth = 270; |
| 72 const int ChildNetworkConfigView::kInputFieldHeight = 28; | |
| 72 | 73 |
| 73 NetworkConfigView::NetworkConfigView() | 74 NetworkConfigView::NetworkConfigView() |
| 74 : child_config_view_(nullptr), | 75 : child_config_view_(nullptr), |
| 75 delegate_(nullptr), | 76 delegate_(nullptr), |
| 76 advanced_button_(nullptr) { | 77 advanced_button_(nullptr) { |
| 77 DCHECK(!g_instance); | 78 DCHECK(!g_instance); |
| 78 g_instance = this; | 79 g_instance = this; |
| 79 } | 80 } |
| 80 | 81 |
| 81 bool NetworkConfigView::InitWithNetworkState(const NetworkState* network) { | 82 bool NetworkConfigView::InitWithNetworkState(const NetworkState* network) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 } | 193 } |
| 193 | 194 |
| 194 views::View* NetworkConfigView::CreateExtraView() { | 195 views::View* NetworkConfigView::CreateExtraView() { |
| 195 return advanced_button_; | 196 return advanced_button_; |
| 196 } | 197 } |
| 197 | 198 |
| 198 views::View* NetworkConfigView::GetInitiallyFocusedView() { | 199 views::View* NetworkConfigView::GetInitiallyFocusedView() { |
| 199 return child_config_view_->GetInitiallyFocusedView(); | 200 return child_config_view_->GetInitiallyFocusedView(); |
| 200 } | 201 } |
| 201 | 202 |
| 203 int NetworkConfigView::GetDefaultDialogButton() const { | |
| 204 return ui::DIALOG_BUTTON_CANCEL; | |
| 205 } | |
| 206 | |
| 202 base::string16 NetworkConfigView::GetWindowTitle() const { | 207 base::string16 NetworkConfigView::GetWindowTitle() const { |
| 203 DCHECK(!child_config_view_->GetTitle().empty()); | 208 DCHECK(!child_config_view_->GetTitle().empty()); |
| 204 return child_config_view_->GetTitle(); | 209 return child_config_view_->GetTitle(); |
| 205 } | 210 } |
| 206 | 211 |
| 207 ui::ModalType NetworkConfigView::GetModalType() const { | 212 ui::ModalType NetworkConfigView::GetModalType() const { |
| 208 return ui::MODAL_TYPE_SYSTEM; | 213 return ui::MODAL_TYPE_SYSTEM; |
| 209 } | 214 } |
| 210 | 215 |
| 211 void NetworkConfigView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 216 void NetworkConfigView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 225 void NetworkConfigView::ShowAdvancedView() { | 230 void NetworkConfigView::ShowAdvancedView() { |
| 226 // Clear out the old widgets and build new ones. | 231 // Clear out the old widgets and build new ones. |
| 227 RemoveChildView(child_config_view_); | 232 RemoveChildView(child_config_view_); |
| 228 delete child_config_view_; | 233 delete child_config_view_; |
| 229 // For now, there is only an advanced view for Wi-Fi 802.1X. | 234 // For now, there is only an advanced view for Wi-Fi 802.1X. |
| 230 child_config_view_ = new WifiConfigView(this, | 235 child_config_view_ = new WifiConfigView(this, |
| 231 "" /* service_path */, | 236 "" /* service_path */, |
| 232 true /* show_8021x */); | 237 true /* show_8021x */); |
| 233 AddChildView(child_config_view_); | 238 AddChildView(child_config_view_); |
| 234 // Resize the window to be able to hold the new widgets. | 239 // Resize the window to be able to hold the new widgets. |
| 235 gfx::Size size = views::Widget::GetLocalizedContentsSize( | 240 gfx::Size size = GetWidget()->client_view()->GetPreferredSize(); |
| 241 gfx::Size predefined_size = views::Widget::GetLocalizedContentsSize( | |
| 236 IDS_JOIN_WIFI_NETWORK_DIALOG_ADVANCED_WIDTH_CHARS, | 242 IDS_JOIN_WIFI_NETWORK_DIALOG_ADVANCED_WIDTH_CHARS, |
| 237 IDS_JOIN_WIFI_NETWORK_DIALOG_ADVANCED_MINIMUM_HEIGHT_LINES); | 243 IDS_JOIN_WIFI_NETWORK_DIALOG_ADVANCED_MINIMUM_HEIGHT_LINES); |
| 244 size.set_width(std::max(size.width(), predefined_size.width())); | |
| 245 size.set_height(std::max(size.height(), predefined_size.height())); | |
|
oshima
2017/01/27 22:09:18
size.SetToMax
xdai1
2017/01/27 22:25:17
Done.
| |
| 246 | |
| 238 // Get the new bounds with desired size at the same center point. | 247 // Get the new bounds with desired size at the same center point. |
| 239 gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen(); | 248 gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen(); |
| 240 int horiz_padding = bounds.width() - size.width(); | 249 int horiz_padding = bounds.width() - size.width(); |
| 241 int vert_padding = bounds.height() - size.height(); | 250 int vert_padding = bounds.height() - size.height(); |
| 242 bounds.Inset(horiz_padding / 2, vert_padding / 2, | 251 bounds.Inset(horiz_padding / 2, vert_padding / 2, |
| 243 horiz_padding / 2, vert_padding / 2); | 252 horiz_padding / 2, vert_padding / 2); |
|
oshima
2017/01/27 22:09:18
ClampToCenteredSize
xdai1
2017/01/27 22:25:17
This function only shrinks to the smaller size, th
oshima
2017/01/30 18:10:45
Acknowledged.
| |
| 244 GetWidget()->SetBoundsConstrained(bounds); | 253 GetWidget()->SetBoundsConstrained(bounds); |
| 245 Layout(); | 254 Layout(); |
| 246 child_config_view_->InitFocus(); | 255 child_config_view_->InitFocus(); |
| 247 } | 256 } |
| 248 | 257 |
| 249 void NetworkConfigView::Layout() { | 258 void NetworkConfigView::Layout() { |
| 250 child_config_view_->SetBounds(0, 0, width(), height()); | 259 child_config_view_->SetBounds(0, 0, width(), height()); |
| 251 } | 260 } |
| 252 | 261 |
| 253 gfx::Size NetworkConfigView::GetPreferredSize() const { | 262 gfx::Size NetworkConfigView::GetPreferredSize() const { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 } | 338 } |
| 330 | 339 |
| 331 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} | 340 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} |
| 332 | 341 |
| 333 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() const { | 342 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() const { |
| 334 return (managed_ && visible()) ? image_view_->GetPreferredSize() | 343 return (managed_ && visible()) ? image_view_->GetPreferredSize() |
| 335 : gfx::Size(); | 344 : gfx::Size(); |
| 336 } | 345 } |
| 337 | 346 |
| 338 } // namespace chromeos | 347 } // namespace chromeos |
| OLD | NEW |