OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/chromeos/options/ip_config_view.h" | 9 #include "chrome/browser/chromeos/options/ip_config_view.h" |
10 #include "chrome/browser/chromeos/options/wifi_config_view.h" | 10 #include "chrome/browser/chromeos/options/wifi_config_view.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return ASCIIToWide(wifi_.name()); | 108 return ASCIIToWide(wifi_.name()); |
109 if (flags_ & FLAG_CELLULAR) | 109 if (flags_ & FLAG_CELLULAR) |
110 return ASCIIToWide(cellular_.name()); | 110 return ASCIIToWide(cellular_.name()); |
111 return l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); | 111 return l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); |
112 } | 112 } |
113 | 113 |
114 void NetworkConfigView::TabSelectedAt(int index) { | 114 void NetworkConfigView::TabSelectedAt(int index) { |
115 } | 115 } |
116 | 116 |
117 void NetworkConfigView::SetLoginTextfieldFocus() { | 117 void NetworkConfigView::SetLoginTextfieldFocus() { |
118 wificonfig_view_->FocusFirstField(); | 118 if (wificonfig_view_) |
| 119 wificonfig_view_->FocusFirstField(); |
119 } | 120 } |
120 | 121 |
121 void NetworkConfigView::Layout() { | 122 void NetworkConfigView::Layout() { |
122 static const int kDialogBottomPadding = 7; | 123 static const int kDialogBottomPadding = 7; |
123 tabs_->SetBounds(0, 0, width(), height() - kDialogBottomPadding); | 124 tabs_->SetBounds(0, 0, width(), height() - kDialogBottomPadding); |
124 } | 125 } |
125 | 126 |
126 gfx::Size NetworkConfigView::GetPreferredSize() { | 127 gfx::Size NetworkConfigView::GetPreferredSize() { |
127 // TODO(chocobo): Once UI is finalized, create locale settings. | 128 // TODO(chocobo): Once UI is finalized, create locale settings. |
128 return gfx::Size(views::Window::GetLocalizedContentsSize( | 129 gfx::Size result(views::Window::GetLocalizedContentsSize( |
129 IDS_IMPORT_DIALOG_WIDTH_CHARS, | 130 IDS_IMPORT_DIALOG_WIDTH_CHARS, |
130 IDS_IMPORT_DIALOG_HEIGHT_LINES)); | 131 IDS_IMPORT_DIALOG_HEIGHT_LINES)); |
| 132 result.set_height(0); // IMPORT_DIALOG height is too large |
| 133 // Expand the default size to fit results if necessary |
| 134 if (wificonfig_view_) { |
| 135 gfx::Size s = wificonfig_view_->GetPreferredSize(); |
| 136 s.set_height(s.height() + kPanelVertMargin * 2); |
| 137 s.set_width(s.width() + kPanelHorizMargin * 2); |
| 138 result = gfx::Size(std::max(result.width(), s.width()), |
| 139 std::max(result.height(), s.height())); |
| 140 } |
| 141 if (ipconfig_view_) { |
| 142 gfx::Size s = ipconfig_view_->GetPreferredSize(); |
| 143 s.set_height(s.height() + kPanelVertMargin * 2); |
| 144 s.set_width(s.width() + kPanelHorizMargin * 2); |
| 145 result = gfx::Size(std::max(result.width(), s.width()), |
| 146 std::max(result.height(), s.height())); |
| 147 } |
| 148 return result; |
131 } | 149 } |
132 | 150 |
133 void NetworkConfigView::ViewHierarchyChanged( | 151 void NetworkConfigView::ViewHierarchyChanged( |
134 bool is_add, views::View* parent, views::View* child) { | 152 bool is_add, views::View* parent, views::View* child) { |
135 // Can't init before we're inserted into a Container, because we require | 153 // Can't init before we're inserted into a Container, because we require |
136 // a HWND to parent native child controls to. | 154 // a HWND to parent native child controls to. |
137 if (is_add && child == this) | 155 if (is_add && child == this) |
138 Init(); | 156 Init(); |
139 } | 157 } |
140 | 158 |
(...skipping 19 matching lines...) Expand all Loading... |
160 ipconfig_view_ = new IPConfigView(cellular_.device_path()); | 178 ipconfig_view_ = new IPConfigView(cellular_.device_path()); |
161 else | 179 else |
162 ipconfig_view_ = new IPConfigView(ethernet_.device_path()); | 180 ipconfig_view_ = new IPConfigView(ethernet_.device_path()); |
163 tabs_->AddTab( | 181 tabs_->AddTab( |
164 l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_IP_CONFIG), | 182 l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_IP_CONFIG), |
165 ipconfig_view_); | 183 ipconfig_view_); |
166 } | 184 } |
167 } | 185 } |
168 | 186 |
169 } // namespace chromeos | 187 } // namespace chromeos |
OLD | NEW |