1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/options/ip_config_view.h"
#include "app/l10n_util.h"
#include "base/string_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "views/controls/label.h"
#include "views/controls/textfield/textfield.h"
#include "views/grid_layout.h"
#include "views/standard_layout.h"
#include "views/window/window.h"
namespace chromeos {
IPConfigView::IPConfigView(const std::string& device_path)
: device_path_(device_path),
ip_configs_(),
address_textfield_(NULL),
netmask_textfield_(NULL),
gateway_textfield_(NULL),
dnsserver_textfield_(NULL) {
Init();
RefreshData();
}
bool IPConfigView::Cancel() {
return true;
}
bool IPConfigView::Accept() {
return true;
}
std::wstring IPConfigView::GetWindowTitle() const {
return l10n_util::GetString(IDS_OPTIONS_SETTINGS_SECTION_TITLE_OPTIONS);
}
void IPConfigView::RefreshData() {
NetworkIPConfigVector ipconfigs =
NetworkLibrary::Get()->GetIPConfigs(device_path_);
for (NetworkIPConfigVector::const_iterator it = ipconfigs.begin();
it != ipconfigs.end(); ++it) {
const NetworkIPConfig& ipconfig = *it;
address_textfield_->SetText(ASCIIToUTF16(ipconfig.address));
netmask_textfield_->SetText(ASCIIToUTF16(ipconfig.netmask));
gateway_textfield_->SetText(ASCIIToUTF16(ipconfig.gateway));
dnsserver_textfield_->SetText(ASCIIToUTF16(ipconfig.name_servers));
}
}
void IPConfigView::Init() {
views::GridLayout* layout = CreatePanelGridLayout(this);
SetLayoutManager(layout);
int column_view_set_id = 0;
views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id);
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1,
views::GridLayout::USE_PREF, 0, 0);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
views::GridLayout::USE_PREF, 0, 200);
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(l10n_util::GetString(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ADDRESS)));
address_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
address_textfield_->SetEnabled(false);
layout->AddView(address_textfield_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(l10n_util::GetString(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SUBNETMASK)));
netmask_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
netmask_textfield_->SetEnabled(false);
layout->AddView(netmask_textfield_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(l10n_util::GetString(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_GATEWAY)));
gateway_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
gateway_textfield_->SetEnabled(false);
layout->AddView(gateway_textfield_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(l10n_util::GetString(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_DNSSERVER)));
dnsserver_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
dnsserver_textfield_->SetEnabled(false);
layout->AddView(dnsserver_textfield_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
}
} // namespace chromeos
|